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') 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 7ea7dbef578ddbe2a9a50da6aab253ba016f1362 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Thu, 6 Oct 2022 20:38:21 +0200 Subject: feat: Add window drag support from winit Exposes access to the winit window's window_drag method as an action. --- native/src/window/action.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'native/src') diff --git a/native/src/window/action.rs b/native/src/window/action.rs index 73338e22..ce125144 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -5,6 +5,12 @@ use std::fmt; /// An operation to be performed on some window. pub enum Action { + /// Moves the window with the left mouse button until the button is + /// released. + /// + /// There’s no guarantee that this will work unless the left mouse + /// button was pressed immediately before this function is called. + Drag, /// Resize the window. Resize { /// The new logical width of the window @@ -37,6 +43,7 @@ impl Action { T: 'static, { match self { + Self::Drag => Action::Drag, Self::Resize { width, height } => Action::Resize { width, height }, Self::Move { x, y } => Action::Move { x, y }, Self::SetMode(mode) => Action::SetMode(mode), @@ -48,6 +55,7 @@ impl Action { impl fmt::Debug for Action { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { + Self::Drag => write!(f, "Action::Drag"), Self::Resize { width, height } => write!( f, "Action::Resize {{ widget: {}, height: {} }}", -- cgit From 8a50836ffc32a6d9157eb18740b3947c4dbd7d1f Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Sun, 9 Oct 2022 16:35:28 +0200 Subject: feat: Add window maximize support --- native/src/window/action.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'native/src') diff --git a/native/src/window/action.rs b/native/src/window/action.rs index ce125144..c49fdf9d 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -18,6 +18,8 @@ pub enum Action { /// The new logical height of the window height: u32, }, + /// Sets the window to maximized or back + Maximize(bool), /// Move the window. /// /// Unsupported on Wayland. @@ -29,6 +31,8 @@ pub enum Action { }, /// Set the [`Mode`] of the window. SetMode(Mode), + /// Sets the window to maximized or back + ToggleMaximize, /// Fetch the current [`Mode`] of the window. FetchMode(Box T + 'static>), } @@ -45,8 +49,10 @@ impl Action { match self { Self::Drag => Action::Drag, Self::Resize { width, height } => Action::Resize { width, height }, + Self::Maximize(bool) => Action::Maximize(bool), Self::Move { x, y } => Action::Move { x, y }, Self::SetMode(mode) => Action::SetMode(mode), + Self::ToggleMaximize => Action::ToggleMaximize, Self::FetchMode(o) => Action::FetchMode(Box::new(move |s| f(o(s)))), } } @@ -61,10 +67,12 @@ impl fmt::Debug for Action { "Action::Resize {{ widget: {}, height: {} }}", width, height ), + Self::Maximize(value) => write!(f, "Action::Maximize({})", value), Self::Move { x, y } => { write!(f, "Action::Move {{ x: {}, y: {} }}", x, y) } Self::SetMode(mode) => write!(f, "Action::SetMode({:?})", mode), + Self::ToggleMaximize => write!(f, "Action::ToggleMaximize"), Self::FetchMode(_) => write!(f, "Action::FetchMode"), } } -- cgit From ac6e137be3e9d2d2a1d8c1284880096a0e2c2a47 Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Tue, 11 Oct 2022 15:24:26 +0200 Subject: feat: Add window minimize support --- native/src/window/action.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'native/src') diff --git a/native/src/window/action.rs b/native/src/window/action.rs index c49fdf9d..009dcc27 100644 --- a/native/src/window/action.rs +++ b/native/src/window/action.rs @@ -20,6 +20,8 @@ pub enum Action { }, /// Sets the window to maximized or back Maximize(bool), + /// Set the window to minimized or back + Minimize(bool), /// Move the window. /// /// Unsupported on Wayland. @@ -50,6 +52,7 @@ impl Action { Self::Drag => Action::Drag, Self::Resize { width, height } => Action::Resize { width, height }, Self::Maximize(bool) => Action::Maximize(bool), + Self::Minimize(bool) => Action::Minimize(bool), Self::Move { x, y } => Action::Move { x, y }, Self::SetMode(mode) => Action::SetMode(mode), Self::ToggleMaximize => Action::ToggleMaximize, @@ -68,6 +71,7 @@ impl fmt::Debug for Action { width, height ), Self::Maximize(value) => write!(f, "Action::Maximize({})", value), + Self::Minimize(value) => write!(f, "Action::Minimize({}", value), Self::Move { x, y } => { write!(f, "Action::Move {{ x: {}, y: {} }}", x, y) } -- 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') 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') 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') 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') 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') 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') 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') 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') 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