From 20fd1f2047b2c425398d0b237c6d3031deaaa0c9 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Fri, 7 Oct 2022 09:03:44 -0700 Subject: Render pane grid titlebar after body --- native/src/widget/pane_grid/content.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/pane_grid/content.rs b/native/src/widget/pane_grid/content.rs index 98ce2c4b..8d26c3d8 100644 --- a/native/src/widget/pane_grid/content.rs +++ b/native/src/widget/pane_grid/content.rs @@ -115,25 +115,25 @@ where let show_controls = bounds.contains(cursor_position); - title_bar.draw( - &tree.children[1], + self.body.as_widget().draw( + &tree.children[0], renderer, theme, style, - title_bar_layout, + body_layout, cursor_position, viewport, - show_controls, ); - self.body.as_widget().draw( - &tree.children[0], + title_bar.draw( + &tree.children[1], renderer, theme, style, - body_layout, + title_bar_layout, cursor_position, viewport, + show_controls, ); } else { self.body.as_widget().draw( -- cgit From dca99f35e938bebdfdad16eaabd220b5d52c2375 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Mon, 17 Oct 2022 14:38:24 -0700 Subject: Fix pane grid mouse interactions - Use `grabbing` interaction while dragging - Ignore grab interaction when dragging is disabled --- native/src/widget/pane_grid.rs | 3 ++- native/src/widget/pane_grid/content.rs | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index d84fb7a0..8eadac48 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -341,6 +341,7 @@ where cursor_position, viewport, renderer, + self.on_drag.is_some(), ) }) .max() @@ -648,7 +649,7 @@ pub fn mouse_interaction( resize_leeway: Option, ) -> Option { if action.picked_pane().is_some() { - return Some(mouse::Interaction::Grab); + return Some(mouse::Interaction::Grabbing); } let resize_axis = diff --git a/native/src/widget/pane_grid/content.rs b/native/src/widget/pane_grid/content.rs index 8d26c3d8..c236d820 100644 --- a/native/src/widget/pane_grid/content.rs +++ b/native/src/widget/pane_grid/content.rs @@ -238,6 +238,7 @@ where cursor_position: Point, viewport: &Rectangle, renderer: &Renderer, + drag_enabled: bool, ) -> mouse::Interaction { let (body_layout, title_bar_interaction) = if let Some(title_bar) = &self.title_bar { @@ -247,7 +248,7 @@ where let is_over_pick_area = title_bar .is_over_pick_area(title_bar_layout, cursor_position); - if is_over_pick_area { + if is_over_pick_area && drag_enabled { return mouse::Interaction::Grab; } -- cgit From fb036529a222126da3f119da4d94d17776460421 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Mon, 17 Oct 2022 14:56:06 -0700 Subject: Render picked pane last --- native/src/widget/pane_grid.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'native/src/widget') diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index 8eadac48..3ef578bf 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -757,7 +757,12 @@ pub fn draw( cursor_position }; - for ((id, pane), layout) in elements.zip(layout.children()) { + // Render picked pane last + let mut elements = elements.zip(layout.children()).collect::>(); + elements + .sort_by_key(|((id, _), _)| picked_pane.map(|(id, _)| id) == Some(*id)); + + for ((id, pane), layout) in elements { match picked_pane { Some((dragging, origin)) if id == dragging => { let bounds = layout.bounds(); -- cgit From 470723c232493282c513af47d19b3877066ceb2e Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Wed, 19 Oct 2022 13:05:56 -0700 Subject: Eliminate unnecessary allocation --- native/src/widget/pane_grid.rs | 46 +++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index 3ef578bf..12ccbb41 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -757,32 +757,12 @@ pub fn draw( cursor_position }; - // Render picked pane last - let mut elements = elements.zip(layout.children()).collect::>(); - elements - .sort_by_key(|((id, _), _)| picked_pane.map(|(id, _)| id) == Some(*id)); + let mut render_picked_pane = None; - for ((id, pane), layout) in elements { + for ((id, pane), layout) in elements.zip(layout.children()) { match picked_pane { Some((dragging, origin)) if id == dragging => { - let bounds = layout.bounds(); - - renderer.with_translation( - cursor_position - - Point::new(bounds.x + origin.x, bounds.y + origin.y), - |renderer| { - renderer.with_layer(bounds, |renderer| { - draw_pane( - pane, - renderer, - default_style, - layout, - pane_cursor_position, - viewport, - ); - }); - }, - ); + render_picked_pane = Some((pane, origin, layout.bounds())); } _ => { draw_pane( @@ -797,6 +777,26 @@ pub fn draw( } } + // Render picked pane last + if let Some((pane, origin, bounds)) = render_picked_pane { + renderer.with_translation( + cursor_position + - Point::new(bounds.x + origin.x, bounds.y + origin.y), + |renderer| { + renderer.with_layer(bounds, |renderer| { + draw_pane( + pane, + renderer, + default_style, + layout, + pane_cursor_position, + viewport, + ); + }); + }, + ); + }; + if let Some((axis, split_region, is_picked)) = picked_split { let highlight = if is_picked { theme.picked_split(style) -- cgit From 069371c86b2eef62277462810fb5ac1852623bd9 Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Wed, 19 Oct 2022 13:21:46 -0700 Subject: Use child layout --- native/src/widget/pane_grid.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/pane_grid.rs b/native/src/widget/pane_grid.rs index 12ccbb41..96cf78ef 100644 --- a/native/src/widget/pane_grid.rs +++ b/native/src/widget/pane_grid.rs @@ -762,7 +762,7 @@ pub fn draw( for ((id, pane), layout) in elements.zip(layout.children()) { match picked_pane { Some((dragging, origin)) if id == dragging => { - render_picked_pane = Some((pane, origin, layout.bounds())); + render_picked_pane = Some((pane, origin, layout)); } _ => { draw_pane( @@ -778,7 +778,9 @@ pub fn draw( } // Render picked pane last - if let Some((pane, origin, bounds)) = render_picked_pane { + if let Some((pane, origin, layout)) = render_picked_pane { + let bounds = layout.bounds(); + renderer.with_translation( cursor_position - Point::new(bounds.x + origin.x, bounds.y + origin.y), -- cgit From f8c363eeacc6c0875834ea1b241de4540f55ba0c Mon Sep 17 00:00:00 2001 From: Cory Forsstrom Date: Thu, 27 Oct 2022 17:40:18 -0700 Subject: Fix drop down not closing when inside scrollable and user clicks outside the scrollable. This is because the scrollable sets -1.0 on cursor.y for any events where cursor is outside it's bounds. I'm not sure why picklist had this logic to stay open on -1.0 / -1.0, any click outside the overlay should close it. --- native/src/widget/pick_list.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/pick_list.rs b/native/src/widget/pick_list.rs index c334804e..896f5b35 100644 --- a/native/src/widget/pick_list.rs +++ b/native/src/widget/pick_list.rs @@ -348,9 +348,9 @@ where let state = state(); let event_status = if state.is_open { - // TODO: Encode cursor availability in the type system - state.is_open = - cursor_position.x < 0.0 || cursor_position.y < 0.0; + // Event wasn't processed by overlay, so cursor was clicked either outside it's + // bounds or on the drop-down, either way we close the overlay. + state.is_open = false; event::Status::Captured } else if layout.bounds().contains(cursor_position) { -- cgit From 58d3374229dc500635a608b91b7761dd776ff79e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 29 Oct 2022 04:36:18 +0200 Subject: Keep keyboard modifiers always in sync in `TextInput` --- native/src/widget/text_input.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'native/src/widget') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index c2d25520..a6de90a5 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -717,9 +717,7 @@ where Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { let state = state(); - if state.is_focused { - state.keyboard_modifiers = modifiers; - } + state.keyboard_modifiers = modifiers; } _ => {} } -- cgit From ac6a3cf8eb77df69cbb6538900786faca778cf05 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 29 Oct 2022 04:50:45 +0200 Subject: Reset `is_pasting` for `TextInput` even when unfocused --- native/src/widget/text_input.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'native/src/widget') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index a6de90a5..e5213cbe 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -712,6 +712,8 @@ where } return event::Status::Captured; + } else { + state.is_pasting = None; } } Event::Keyboard(keyboard::Event::ModifiersChanged(modifiers)) => { -- cgit From 1687d11389fa8ddfb8d2d7cda64cc6b5c4aa7f9c Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 3 Nov 2022 02:35:17 +0100 Subject: Increase default `padding` of `TextInput` --- native/src/widget/text_input.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'native/src/widget') diff --git a/native/src/widget/text_input.rs b/native/src/widget/text_input.rs index e5213cbe..54a6aaf8 100644 --- a/native/src/widget/text_input.rs +++ b/native/src/widget/text_input.rs @@ -92,7 +92,7 @@ where is_secure: false, font: Default::default(), width: Length::Fill, - padding: Padding::ZERO, + padding: Padding::new(5), size: None, on_change: Box::new(on_change), on_paste: None, -- cgit