summaryrefslogtreecommitdiffstats
path: root/runtime/src
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2025-01-16 11:44:15 +0000
committerLibravatar GitHub <noreply@github.com>2025-01-16 11:44:15 +0000
commit24297c549be022ee1e848c0c090df986e825f10c (patch)
tree10d10bf65d41de0d04ea7ae8037dd49681f3916b /runtime/src
parenta00f564deed291765a35311784096193dc3988b3 (diff)
parent8a453903b99dd2855e556f5f8baab502441eb16b (diff)
downloadiced-24297c549be022ee1e848c0c090df986e825f10c.tar.gz
iced-24297c549be022ee1e848c0c090df986e825f10c.tar.bz2
iced-24297c549be022ee1e848c0c090df986e825f10c.zip
Merge pull request #2642 from tsuza/master
feat: add a window drag resize task
Diffstat (limited to 'runtime/src')
-rw-r--r--runtime/src/window.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/runtime/src/window.rs b/runtime/src/window.rs
index 94ee0ae5..183fab97 100644
--- a/runtime/src/window.rs
+++ b/runtime/src/window.rs
@@ -1,7 +1,8 @@
//! Build window-based GUI applications.
use crate::core::time::Instant;
use crate::core::window::{
- Event, Icon, Id, Level, Mode, Screenshot, Settings, UserAttention,
+ Direction, Event, Icon, Id, Level, Mode, Screenshot, Settings,
+ UserAttention,
};
use crate::core::{Point, Size};
use crate::futures::event;
@@ -31,10 +32,17 @@ pub enum Action {
/// Move the window with the left mouse button until the button is
/// released.
///
- /// There’s no guarantee that this will work unless the left mouse
+ /// There's no guarantee that this will work unless the left mouse
/// button was pressed immediately before this function is called.
Drag(Id),
+ /// Resize 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.
+ DragResize(Id, Direction),
+
/// Resize the window to the given logical dimensions.
Resize(Id, Size),
@@ -272,6 +280,11 @@ pub fn drag<T>(id: Id) -> Task<T> {
task::effect(crate::Action::Window(Action::Drag(id)))
}
+/// Begins resizing the window while the left mouse button is held.
+pub fn drag_resize<T>(id: Id, direction: Direction) -> Task<T> {
+ task::effect(crate::Action::Window(Action::DragResize(id, direction)))
+}
+
/// Resizes the window to the given logical dimensions.
pub fn resize<T>(id: Id, new_size: Size) -> Task<T> {
task::effect(crate::Action::Window(Action::Resize(id, new_size)))