diff options
| author | 2023-07-12 12:23:18 -0700 | |
|---|---|---|
| committer | 2023-07-12 12:23:18 -0700 | |
| commit | 633f405f3f78bc7f82d2b2061491b0e011137451 (patch) | |
| tree | 5ebfc1f45d216a5c14a90492563599e6969eab4d /graphics/src/widget/canvas/cursor.rs | |
| parent | 41836dd80d0534608e7aedfbf2319c540a23de1a (diff) | |
| parent | 21bd51426d900e271206f314e0c915dd41065521 (diff) | |
| download | iced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.gz iced-633f405f3f78bc7f82d2b2061491b0e011137451.tar.bz2 iced-633f405f3f78bc7f82d2b2061491b0e011137451.zip | |
Merge remote-tracking branch 'origin/master' into feat/multi-window-support
# Conflicts:
#	Cargo.toml
#	core/src/window/icon.rs
#	core/src/window/id.rs
#	core/src/window/position.rs
#	core/src/window/settings.rs
#	examples/integration/src/main.rs
#	examples/integration_opengl/src/main.rs
#	glutin/src/application.rs
#	native/src/subscription.rs
#	native/src/window.rs
#	runtime/src/window/action.rs
#	src/lib.rs
#	src/window.rs
#	winit/Cargo.toml
#	winit/src/application.rs
#	winit/src/icon.rs
#	winit/src/settings.rs
#	winit/src/window.rs
Diffstat (limited to 'graphics/src/widget/canvas/cursor.rs')
| -rw-r--r-- | graphics/src/widget/canvas/cursor.rs | 64 | 
1 files changed, 0 insertions, 64 deletions
| diff --git a/graphics/src/widget/canvas/cursor.rs b/graphics/src/widget/canvas/cursor.rs deleted file mode 100644 index 9588d129..00000000 --- a/graphics/src/widget/canvas/cursor.rs +++ /dev/null @@ -1,64 +0,0 @@ -use iced_native::{Point, Rectangle}; - -/// The mouse cursor state. -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum Cursor { -    /// The cursor has a defined position. -    Available(Point), - -    /// The cursor is currently unavailable (i.e. out of bounds or busy). -    Unavailable, -} - -impl Cursor { -    // TODO: Remove this once this type is used in `iced_native` to encode -    // proper cursor availability -    pub(crate) fn from_window_position(position: Point) -> Self { -        if position.x < 0.0 || position.y < 0.0 { -            Cursor::Unavailable -        } else { -            Cursor::Available(position) -        } -    } - -    /// Returns the absolute position of the [`Cursor`], if available. -    pub fn position(&self) -> Option<Point> { -        match self { -            Cursor::Available(position) => Some(*position), -            Cursor::Unavailable => None, -        } -    } - -    /// Returns the relative position of the [`Cursor`] inside the given bounds, -    /// if available. -    /// -    /// If the [`Cursor`] is not over the provided bounds, this method will -    /// return `None`. -    pub fn position_in(&self, bounds: &Rectangle) -> Option<Point> { -        if self.is_over(bounds) { -            self.position_from(bounds.position()) -        } else { -            None -        } -    } - -    /// Returns the relative position of the [`Cursor`] from the given origin, -    /// if available. -    pub fn position_from(&self, origin: Point) -> Option<Point> { -        match self { -            Cursor::Available(position) => { -                Some(Point::new(position.x - origin.x, position.y - origin.y)) -            } -            Cursor::Unavailable => None, -        } -    } - -    /// Returns whether the [`Cursor`] is currently over the provided bounds -    /// or not. -    pub fn is_over(&self, bounds: &Rectangle) -> bool { -        match self { -            Cursor::Available(position) => bounds.contains(*position), -            Cursor::Unavailable => false, -        } -    } -} | 
