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