Skip to main content

glory_render/
drag.rs

1//! Logical drag phases. Coordinates use viewport CSS pixels in every host.
2/// Primary-pointer capture on a boxed View. Applications provide
3/// separate semantic keyboard controls; capture does not invent a control role.
4#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5pub enum DragCapture {
6    /// Preserve the current actual focus, such as an adjacent text editor.
7    Press,
8    /// Focus the View, which must declare Programmatic or TabStop focus.
9    PressFocus,
10    /// Wry preserves clicks until the pointer moves six CSS pixels, then captures
11    /// it and routes Drop to the nearest live Drag observer under the pointer.
12    Threshold,
13    /// Like Threshold, with a Wry preview of the source View's accessible name.
14    ThresholdPreview,
15}
16impl DragCapture {
17    pub fn as_str(self) -> &'static str {
18        match self {
19            Self::Press => "press",
20            Self::PressFocus => "press-focus",
21            Self::Threshold => "threshold",
22            Self::ThresholdPreview => "threshold-preview",
23        }
24    }
25
26    pub fn is_threshold(self) -> bool {
27        matches!(self, Self::Threshold | Self::ThresholdPreview)
28    }
29}
30#[derive(Clone, Copy, Debug, PartialEq, Eq)]
31pub enum DragPhase {
32    Start,
33    Move,
34    Drop,
35    Cancel,
36}