1use crate::{KeyModifiers, Length};
2use std::sync::Arc;
3
4#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
5pub enum DragAction {
6 #[default]
7 None,
8 Copy,
9 Move,
10 Link,
11}
12
13impl KeyModifiers {
14 #[doc(hidden)]
15 pub fn drag_action(self) -> Option<DragAction> {
16 match (self.control, self.shift) {
17 (false, false) => None,
18 (true, false) => Some(DragAction::Copy),
19 (false, true) => Some(DragAction::Move),
20 (true, true) => Some(DragAction::Link),
21 }
22 }
23}
24
25#[derive(Clone, Debug, PartialEq)]
26pub enum DragEvent {
27 Started,
28 Finished(DragAction),
29 Entered { data: String, action: DragAction },
30 FilesEntered(Arc<[String]>),
31 Moved { x: Length, y: Length },
32 Exited,
33 Dropped { data: String, action: DragAction },
34 FilesDropped(Arc<[String]>),
35}
36
37impl DragEvent {
38 #[doc(hidden)]
39 pub fn target_kind(&self) -> &'static str {
40 match self {
41 Self::Started | Self::Finished(_) => "DragArea",
42 _ => "DropArea",
43 }
44 }
45
46 #[doc(hidden)]
47 pub fn is_terminal(&self) -> bool {
48 matches!(self, Self::Exited | Self::Finished(_))
49 }
50}
51
52pub fn is_drag_area(kind: &str) -> bool {
53 matches!(kind, "DragArea" | "DropArea")
54}