Skip to main content

DragState

Struct DragState 

Source
pub struct DragState { /* private fields */ }
Expand description

State for tracking a popup drag operation.

Encapsulates the begin/drag/end lifecycle and clamps the new position so the popup keeps at least MIN_VISIBLE_W columns and MIN_VISIBLE_H rows on-screen (the widget’s resolve_rect further shrinks the popup to fit fully within the area).

Also tracks whether the user has ever dragged from the border. Once a border drag is detected, the header area becomes draggable too (progressive disclosure).

Implementations§

Source§

impl DragState

Source

pub fn new() -> Self

Source

pub fn begin( &mut self, popup: Rect, col: u16, row: u16, on_border: bool, in_drag_area: bool, )

Start a drag if in_drag_area is true.

  • on_border — whether the click was on the border (not the header). Only border clicks enable header drag for later interactions.
  • in_drag_area — whether the click is inside any drag zone (border or header, depending on header_drag_enabled()).
Source

pub fn header_drag_enabled(&self) -> bool

Whether the header area is draggable.

Returns true once the user has dragged from the border at least once during this session.

Source

pub fn update(&self, area: Rect, col: u16, row: u16) -> Option<(u16, u16)>

Update the drag and return the new popup origin (x, y). Returns None if no drag is in progress.

The origin is clamped so at least MIN_VISIBLE_W columns and MIN_VISIBLE_H rows of the popup always remain on-screen.

Source

pub fn end(&mut self)

End the drag (called on mouse up).

Source

pub fn is_dragging(&self) -> bool

Whether a drag is in progress.

Trait Implementations§

Source§

impl Default for DragState

Source§

fn default() -> DragState

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.