From ca8aaf9b8daa3d8b925165fb912af425438d4e79 Mon Sep 17 00:00:00 2001 From: JL710 <76447362+JL710@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:51:44 +0200 Subject: add Task and Action for changing a window title --- runtime/src/window.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 0ebdba2f..b5c6ee50 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -73,6 +73,9 @@ pub enum Action { /// Get the current [`Mode`] of the window. GetMode(Id, oneshot::Sender), + /// Change the title of the window. + ChangeTitle(Id, String), + /// Toggle the window to maximized or back ToggleMaximize(Id), @@ -368,6 +371,11 @@ pub fn change_level(id: Id, level: Level) -> Task { task::effect(crate::Action::Window(Action::ChangeLevel(id, level))) } +/// Changes the title of the window. +pub fn change_title(id: Id, title: String) -> Task { + task::effect(crate::Action::Window(Action::ChangeTitle(id, title))) +} + /// Show the [system menu] at cursor position. /// /// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu -- cgit From 8ebbfa9767bcb8f8efd43cc1c7d40e9c61f6c461 Mon Sep 17 00:00:00 2001 From: JL710 <76447362+JL710@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:10:30 +0200 Subject: window tasks for setting min and max size --- runtime/src/window.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index b5c6ee50..598ee491 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -158,6 +158,12 @@ pub enum Action { /// This enables mouse events for the window and stops mouse events /// from being passed to whatever is underneath. DisableMousePassthrough(Id), + + /// Set the minimum inner window size. + SetMinSize(Id, Option), + + /// Set the maximum inner window size. + SetMaxSize(Id, Option), } /// Subscribes to the frames of the window of the running application. @@ -376,6 +382,16 @@ pub fn change_title(id: Id, title: String) -> Task { task::effect(crate::Action::Window(Action::ChangeTitle(id, title))) } +/// Set the inner maximum size of the window. +pub fn set_max_size(id: Id, size: Option) -> Task { + task::effect(crate::Action::Window(Action::SetMaxSize(id, size))) +} + +/// Set the inner minimum size of the window. +pub fn set_min_size(id: Id, size: Option) -> Task { + task::effect(crate::Action::Window(Action::SetMinSize(id, size))) +} + /// Show the [system menu] at cursor position. /// /// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu -- cgit From f5f075e5cdff84a58c181c498653b7ab66c9531a Mon Sep 17 00:00:00 2001 From: JL710 <76447362+JL710@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:16:52 +0200 Subject: window resizable task --- runtime/src/window.rs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 598ee491..cdef70e3 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -164,6 +164,9 @@ pub enum Action { /// Set the maximum inner window size. SetMaxSize(Id, Option), + + /// Set the window to be resizable or not. + SetResizable(Id, bool), } /// Subscribes to the frames of the window of the running application. @@ -274,6 +277,11 @@ pub fn resize(id: Id, new_size: Size) -> Task { task::effect(crate::Action::Window(Action::Resize(id, new_size))) } +/// Set the window to be resizable or not. +pub fn resizable(id: Id, resizable: bool) -> Task { + task::effect(crate::Action::Window(Action::SetResizable(id, resizable))) +} + /// Get the window's size in logical dimensions. pub fn get_size(id: Id) -> Task { task::oneshot(move |channel| { -- cgit From 00b60d819b25abe14790a26fe0eb5818c3c6bc4f Mon Sep 17 00:00:00 2001 From: JL710 <76447362+JL710@users.noreply.github.com> Date: Fri, 11 Oct 2024 12:24:05 +0200 Subject: window task for setting resize increments --- runtime/src/window.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index cdef70e3..e82d4505 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -167,6 +167,9 @@ pub enum Action { /// Set the window to be resizable or not. SetResizable(Id, bool), + + /// Set the window size increment. + SetResizeIncrements(Id, Option), } /// Subscribes to the frames of the window of the running application. @@ -400,6 +403,15 @@ pub fn set_min_size(id: Id, size: Option) -> Task { task::effect(crate::Action::Window(Action::SetMinSize(id, size))) } +/// Set the window size increment. +/// +/// This is usually used by apps such as terminal emulators that need "blocky" resizing. +pub fn set_resize_increments(id: Id, increments: Option) -> Task { + task::effect(crate::Action::Window(Action::SetResizeIncrements( + id, increments, + ))) +} + /// Show the [system menu] at cursor position. /// /// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu -- cgit From 91fd6d395fad08bcf5d068be95575865ccb305cb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 6 Jan 2025 23:20:12 +0100 Subject: Remove `window::change_title` since it's redundant Applications can change title declaratively. --- runtime/src/window.rs | 8 -------- 1 file changed, 8 deletions(-) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index e82d4505..9be61315 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -73,9 +73,6 @@ pub enum Action { /// Get the current [`Mode`] of the window. GetMode(Id, oneshot::Sender), - /// Change the title of the window. - ChangeTitle(Id, String), - /// Toggle the window to maximized or back ToggleMaximize(Id), @@ -388,11 +385,6 @@ pub fn change_level(id: Id, level: Level) -> Task { task::effect(crate::Action::Window(Action::ChangeLevel(id, level))) } -/// Changes the title of the window. -pub fn change_title(id: Id, title: String) -> Task { - task::effect(crate::Action::Window(Action::ChangeTitle(id, title))) -} - /// Set the inner maximum size of the window. pub fn set_max_size(id: Id, size: Option) -> Task { task::effect(crate::Action::Window(Action::SetMaxSize(id, size))) -- cgit From 82ac0e7bf96d7c130108159a8b933ddfb39233fd Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 6 Jan 2025 23:24:01 +0100 Subject: Rename `window::resizable` to `window::set_resizable` --- runtime/src/window.rs | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index 9be61315..ab805e52 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -278,10 +278,29 @@ pub fn resize(id: Id, new_size: Size) -> Task { } /// Set the window to be resizable or not. -pub fn resizable(id: Id, resizable: bool) -> Task { +pub fn set_resizable(id: Id, resizable: bool) -> Task { task::effect(crate::Action::Window(Action::SetResizable(id, resizable))) } +/// Set the inner maximum size of the window. +pub fn set_max_size(id: Id, size: Option) -> Task { + task::effect(crate::Action::Window(Action::SetMaxSize(id, size))) +} + +/// Set the inner minimum size of the window. +pub fn set_min_size(id: Id, size: Option) -> Task { + task::effect(crate::Action::Window(Action::SetMinSize(id, size))) +} + +/// Set the window size increment. +/// +/// This is usually used by apps such as terminal emulators that need "blocky" resizing. +pub fn set_resize_increments(id: Id, increments: Option) -> Task { + task::effect(crate::Action::Window(Action::SetResizeIncrements( + id, increments, + ))) +} + /// Get the window's size in logical dimensions. pub fn get_size(id: Id) -> Task { task::oneshot(move |channel| { @@ -385,25 +404,6 @@ pub fn change_level(id: Id, level: Level) -> Task { task::effect(crate::Action::Window(Action::ChangeLevel(id, level))) } -/// Set the inner maximum size of the window. -pub fn set_max_size(id: Id, size: Option) -> Task { - task::effect(crate::Action::Window(Action::SetMaxSize(id, size))) -} - -/// Set the inner minimum size of the window. -pub fn set_min_size(id: Id, size: Option) -> Task { - task::effect(crate::Action::Window(Action::SetMinSize(id, size))) -} - -/// Set the window size increment. -/// -/// This is usually used by apps such as terminal emulators that need "blocky" resizing. -pub fn set_resize_increments(id: Id, increments: Option) -> Task { - task::effect(crate::Action::Window(Action::SetResizeIncrements( - id, increments, - ))) -} - /// Show the [system menu] at cursor position. /// /// [system menu]: https://en.wikipedia.org/wiki/Common_menus_in_Microsoft_Windows#System_menu -- cgit From 5b70754809df9d9f4f3a2f7d4d348dd58bd86aa3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 6 Jan 2025 23:25:57 +0100 Subject: Rename `window::change_*` tasks to `set_*` --- runtime/src/window.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'runtime/src/window.rs') diff --git a/runtime/src/window.rs b/runtime/src/window.rs index ab805e52..94ee0ae5 100644 --- a/runtime/src/window.rs +++ b/runtime/src/window.rs @@ -68,7 +68,7 @@ pub enum Action { Move(Id, Point), /// Change the [`Mode`] of the window. - ChangeMode(Id, Mode), + SetMode(Id, Mode), /// Get the current [`Mode`] of the window. GetMode(Id, oneshot::Sender), @@ -111,7 +111,7 @@ pub enum Action { GainFocus(Id), /// Change the window [`Level`]. - ChangeLevel(Id, Level), + SetLevel(Id, Level), /// Show the system menu at cursor position. /// @@ -136,7 +136,7 @@ pub enum Action { /// /// - **X11:** Has no universal guidelines for icon sizes, so you're at the whims of the WM. That /// said, it's usually in the same ballpark as on Windows. - ChangeIcon(Id, Icon), + SetIcon(Id, Icon), /// Runs the closure with the native window handle of the window with the given [`Id`]. RunWithHandle(Id, Box) + Send>), @@ -351,11 +351,6 @@ pub fn move_to(id: Id, position: Point) -> Task { task::effect(crate::Action::Window(Action::Move(id, position))) } -/// Changes the [`Mode`] of the window. -pub fn change_mode(id: Id, mode: Mode) -> Task { - task::effect(crate::Action::Window(Action::ChangeMode(id, mode))) -} - /// Gets the current [`Mode`] of the window. pub fn get_mode(id: Id) -> Task { task::oneshot(move |channel| { @@ -363,6 +358,11 @@ pub fn get_mode(id: Id) -> Task { }) } +/// Changes the [`Mode`] of the window. +pub fn set_mode(id: Id, mode: Mode) -> Task { + task::effect(crate::Action::Window(Action::SetMode(id, mode))) +} + /// Toggles the window to maximized or back. pub fn toggle_maximize(id: Id) -> Task { task::effect(crate::Action::Window(Action::ToggleMaximize(id))) @@ -400,8 +400,8 @@ pub fn gain_focus(id: Id) -> Task { } /// Changes the window [`Level`]. -pub fn change_level(id: Id, level: Level) -> Task { - task::effect(crate::Action::Window(Action::ChangeLevel(id, level))) +pub fn set_level(id: Id, level: Level) -> Task { + task::effect(crate::Action::Window(Action::SetLevel(id, level))) } /// Show the [system menu] at cursor position. @@ -420,8 +420,8 @@ pub fn get_raw_id(id: Id) -> Task { } /// Changes the [`Icon`] of the window. -pub fn change_icon(id: Id, icon: Icon) -> Task { - task::effect(crate::Action::Window(Action::ChangeIcon(id, icon))) +pub fn set_icon(id: Id, icon: Icon) -> Task { + task::effect(crate::Action::Window(Action::SetIcon(id, icon))) } /// Runs the given callback with the native window handle for the window with the given id. -- cgit