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
impl DragState
pub fn new() -> Self
Sourcepub fn begin(
&mut self,
popup: Rect,
col: u16,
row: u16,
on_border: bool,
in_drag_area: bool,
)
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 onheader_drag_enabled()).
Sourcepub fn header_drag_enabled(&self) -> bool
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.
Sourcepub fn update(&self, area: Rect, col: u16, row: u16) -> Option<(u16, u16)>
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.
Sourcepub fn is_dragging(&self) -> bool
pub fn is_dragging(&self) -> bool
Whether a drag is in progress.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for DragState
impl RefUnwindSafe for DragState
impl Send for DragState
impl Sync for DragState
impl Unpin for DragState
impl UnsafeUnpin for DragState
impl UnwindSafe for DragState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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