feat: add a window drag resize task
This commit is contained in:
parent
a00f564dee
commit
e3f149d932
5 changed files with 77 additions and 2 deletions
|
|
@ -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;
|
||||
|
|
@ -35,6 +36,13 @@ pub enum Action {
|
|||
/// 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)))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue