diff options
| author | 2025-02-03 17:24:05 +0100 | |
|---|---|---|
| committer | 2025-02-03 17:24:05 +0100 | |
| commit | 50eaef28447f453bc90133de19cff8b2bfee27de (patch) | |
| tree | eaa85242780846f22198dd02909a69815385f589 /core | |
| parent | 141290c7402a4e087ce18d60b210f4feeafcebee (diff) | |
| parent | 0c0651de5b1722194d48c19cd645e747fb72ccb6 (diff) | |
| download | iced-50eaef28447f453bc90133de19cff8b2bfee27de.tar.gz iced-50eaef28447f453bc90133de19cff8b2bfee27de.tar.bz2 iced-50eaef28447f453bc90133de19cff8b2bfee27de.zip | |
Merge branch 'master' into explore-input-method2
Diffstat (limited to '')
| -rw-r--r-- | core/src/mouse/cursor.rs | 39 | ||||
| -rw-r--r-- | core/src/shell.rs | 12 | 
2 files changed, 44 insertions, 7 deletions
| diff --git a/core/src/mouse/cursor.rs b/core/src/mouse/cursor.rs index 616cd315..9388a578 100644 --- a/core/src/mouse/cursor.rs +++ b/core/src/mouse/cursor.rs @@ -1,13 +1,14 @@  use crate::{Point, Rectangle, Transformation, Vector}; -use std::ops::Mul; -  /// The mouse cursor state.  #[derive(Debug, Clone, Copy, PartialEq, Default)]  pub enum Cursor {      /// The cursor has a defined position.      Available(Point), +    /// The cursor has a defined position, but it's levitating over a layer above. +    Levitating(Point), +      /// The cursor is currently unavailable (i.e. out of bounds or busy).      #[default]      Unavailable, @@ -18,7 +19,7 @@ impl Cursor {      pub fn position(self) -> Option<Point> {          match self {              Cursor::Available(position) => Some(position), -            Cursor::Unavailable => None, +            Cursor::Levitating(_) | Cursor::Unavailable => None,          }      } @@ -51,17 +52,41 @@ impl Cursor {      pub fn is_over(self, bounds: Rectangle) -> bool {          self.position_over(bounds).is_some()      } + +    /// Returns true if the [`Cursor`] is levitating over a layer above. +    pub fn is_levitating(self) -> bool { +        matches!(self, Self::Levitating(_)) +    } + +    /// Makes the [`Cursor`] levitate over a layer above. +    pub fn levitate(self) -> Self { +        match self { +            Self::Available(position) => Self::Levitating(position), +            _ => self, +        } +    } + +    /// Brings the [`Cursor`] back to the current layer. +    pub fn land(self) -> Self { +        match self { +            Cursor::Levitating(position) => Cursor::Available(position), +            _ => self, +        } +    }  } -impl Mul<Transformation> for Cursor { +impl std::ops::Mul<Transformation> for Cursor {      type Output = Self;      fn mul(self, transformation: Transformation) -> Self {          match self { -            Cursor::Unavailable => Cursor::Unavailable, -            Cursor::Available(point) => { -                Cursor::Available(point * transformation) +            Self::Available(position) => { +                Self::Available(position * transformation) +            } +            Self::Levitating(position) => { +                Self::Levitating(position * transformation)              } +            Self::Unavailable => Self::Unavailable,          }      }  } diff --git a/core/src/shell.rs b/core/src/shell.rs index a13492d5..509e3822 100644 --- a/core/src/shell.rs +++ b/core/src/shell.rs @@ -77,6 +77,18 @@ impl<'a, Message> Shell<'a, Message> {          self.redraw_request      } +    /// Replaces the redraw request of the [`Shell`]; without conflict resolution. +    /// +    /// This is useful if you want to overwrite the redraw request to a previous value. +    /// Since it's a fairly advanced use case and should rarely be used, it is a static +    /// method. +    pub fn replace_redraw_request( +        shell: &mut Self, +        redraw_request: window::RedrawRequest, +    ) { +        shell.redraw_request = redraw_request; +    } +      /// Requests the current [`InputMethod`] strategy.      ///      /// __Important__: This request will only be honored by the | 
