From 4e47450c336a235fe26090665aca1cc7b4d23384 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 29 Oct 2024 15:55:47 +0100 Subject: Implement `reactive-rendering` for `pane_grid` --- widget/src/pane_grid/content.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'widget/src/pane_grid/content.rs') diff --git a/widget/src/pane_grid/content.rs b/widget/src/pane_grid/content.rs index e0199f0a..f1f67023 100644 --- a/widget/src/pane_grid/content.rs +++ b/widget/src/pane_grid/content.rs @@ -284,6 +284,31 @@ where } } + pub(crate) fn grid_interaction( + &self, + layout: Layout<'_>, + cursor: mouse::Cursor, + drag_enabled: bool, + ) -> Option { + let title_bar = self.title_bar.as_ref()?; + + let mut children = layout.children(); + let title_bar_layout = children.next().unwrap(); + + let is_over_pick_area = cursor + .position() + .map(|cursor_position| { + title_bar.is_over_pick_area(title_bar_layout, cursor_position) + }) + .unwrap_or_default(); + + if is_over_pick_area && drag_enabled { + return Some(mouse::Interaction::Grab); + } + + None + } + pub(crate) fn mouse_interaction( &self, tree: &Tree, -- cgit