pub struct DragContext {
pub drag_type: ActiveDragType,
pub session_id: u64,
pub cancelled: bool,
}Expand description
The unified drag context.
This struct wraps ActiveDragType and provides common metadata
that applies to all drag operations.
Note: this type is Rust-only and not exposed through the C API.
Fields§
§drag_type: ActiveDragTypeThe specific type of drag operation
session_id: u64Session ID from gesture detection (links back to GestureManager)
cancelled: boolWhether the drag has been cancelled (e.g., Escape pressed)
Implementations§
Source§impl DragContext
impl DragContext
Sourcepub const fn new(drag_type: ActiveDragType, session_id: u64) -> Self
pub const fn new(drag_type: ActiveDragType, session_id: u64) -> Self
Create a new drag context
Sourcepub const fn text_selection(
dom_id: DomId,
anchor_ifc_node: NodeId,
start_mouse_position: LogicalPosition,
session_id: u64,
) -> Self
pub const fn text_selection( dom_id: DomId, anchor_ifc_node: NodeId, start_mouse_position: LogicalPosition, session_id: u64, ) -> Self
Create a text selection drag
Sourcepub const fn scrollbar_thumb(
dom_id: DomId,
scroll_container_node: NodeId,
axis: ScrollbarAxis,
start_mouse_position: LogicalPosition,
start_scroll_offset: f32,
track_length_px: f32,
content_length_px: f32,
viewport_length_px: f32,
session_id: u64,
) -> Self
pub const fn scrollbar_thumb( dom_id: DomId, scroll_container_node: NodeId, axis: ScrollbarAxis, start_mouse_position: LogicalPosition, start_scroll_offset: f32, track_length_px: f32, content_length_px: f32, viewport_length_px: f32, session_id: u64, ) -> Self
Create a scrollbar thumb drag
Sourcepub const fn node_drag(
dom_id: DomId,
node_id: NodeId,
start_position: LogicalPosition,
drag_data: DragData,
session_id: u64,
) -> Self
pub const fn node_drag( dom_id: DomId, node_id: NodeId, start_position: LogicalPosition, drag_data: DragData, session_id: u64, ) -> Self
Create a node drag
Sourcepub const fn window_move(
start_position: LogicalPosition,
initial_window_position: WindowPosition,
session_id: u64,
) -> Self
pub const fn window_move( start_position: LogicalPosition, initial_window_position: WindowPosition, session_id: u64, ) -> Self
Create a window move drag
Sourcepub fn file_drop(
files: Vec<AzString>,
position: LogicalPosition,
session_id: u64,
) -> Self
pub fn file_drop( files: Vec<AzString>, position: LogicalPosition, session_id: u64, ) -> Self
Create a file drop drag
Sourcepub const fn update_position(&mut self, position: LogicalPosition)
pub const fn update_position(&mut self, position: LogicalPosition)
Update the current mouse position for all drag types
Sourcepub const fn current_position(&self) -> LogicalPosition
pub const fn current_position(&self) -> LogicalPosition
Get the current mouse position
Sourcepub const fn start_position(&self) -> LogicalPosition
pub const fn start_position(&self) -> LogicalPosition
Get the start position
Sourcepub const fn is_text_selection(&self) -> bool
pub const fn is_text_selection(&self) -> bool
Check if this is a text selection drag
Sourcepub const fn is_scrollbar_thumb(&self) -> bool
pub const fn is_scrollbar_thumb(&self) -> bool
Check if this is a scrollbar thumb drag
Sourcepub const fn is_node_drag(&self) -> bool
pub const fn is_node_drag(&self) -> bool
Check if this is a node drag
Sourcepub const fn is_window_move(&self) -> bool
pub const fn is_window_move(&self) -> bool
Check if this is a window move drag
Sourcepub const fn is_file_drop(&self) -> bool
pub const fn is_file_drop(&self) -> bool
Check if this is a file drop
Sourcepub const fn as_text_selection(&self) -> Option<&TextSelectionDrag>
pub const fn as_text_selection(&self) -> Option<&TextSelectionDrag>
Get as text selection drag (if applicable)
Sourcepub const fn as_text_selection_mut(&mut self) -> Option<&mut TextSelectionDrag>
pub const fn as_text_selection_mut(&mut self) -> Option<&mut TextSelectionDrag>
Get as mutable text selection drag (if applicable)
Sourcepub const fn as_scrollbar_thumb(&self) -> Option<&ScrollbarThumbDrag>
pub const fn as_scrollbar_thumb(&self) -> Option<&ScrollbarThumbDrag>
Get as scrollbar thumb drag (if applicable)
Sourcepub const fn as_scrollbar_thumb_mut(
&mut self,
) -> Option<&mut ScrollbarThumbDrag>
pub const fn as_scrollbar_thumb_mut( &mut self, ) -> Option<&mut ScrollbarThumbDrag>
Get as mutable scrollbar thumb drag (if applicable)
Sourcepub const fn as_node_drag(&self) -> Option<&NodeDrag>
pub const fn as_node_drag(&self) -> Option<&NodeDrag>
Get as node drag (if applicable)
Sourcepub const fn as_node_drag_mut(&mut self) -> Option<&mut NodeDrag>
pub const fn as_node_drag_mut(&mut self) -> Option<&mut NodeDrag>
Get as mutable node drag (if applicable)
Sourcepub const fn as_window_move(&self) -> Option<&WindowMoveDrag>
pub const fn as_window_move(&self) -> Option<&WindowMoveDrag>
Get as window move drag (if applicable)
Sourcepub const fn as_file_drop(&self) -> Option<&FileDropDrag>
pub const fn as_file_drop(&self) -> Option<&FileDropDrag>
Get as file drop (if applicable)
Sourcepub const fn as_file_drop_mut(&mut self) -> Option<&mut FileDropDrag>
pub const fn as_file_drop_mut(&mut self) -> Option<&mut FileDropDrag>
Get as mutable file drop (if applicable)
Sourcepub fn calculate_scrollbar_scroll_offset(&self) -> Option<f32>
pub fn calculate_scrollbar_scroll_offset(&self) -> Option<f32>
Calculate scroll delta for scrollbar thumb drag
Returns the new scroll offset based on current mouse position.
Sourcepub fn remap_node_ids(
&mut self,
dom_id: DomId,
node_id_map: &BTreeMap<NodeId, NodeId>,
) -> bool
pub fn remap_node_ids( &mut self, dom_id: DomId, node_id_map: &BTreeMap<NodeId, NodeId>, ) -> bool
Remap NodeIds stored in this drag context after DOM reconciliation.
When the DOM is regenerated during an active drag, NodeIds can change.
This updates all stored NodeIds using the old→new mapping.
Returns false if a critical NodeId was removed (drag should be cancelled).
Trait Implementations§
Source§impl Clone for DragContext
impl Clone for DragContext
Source§fn clone(&self) -> DragContext
fn clone(&self) -> DragContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more