1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! **File** drag & drop management
//!
//! Manages hovered files (drag-and-drop).
use azul_css::AzString;
/// Manager for cursor state and hovered file tracking
#[derive(Debug, Clone, PartialEq)]
pub struct FileDropManager {
/// File being hovered during drag-and-drop operation
pub hovered_file: Option<AzString>,
/// File that was dropped (cleared after one frame)
pub dropped_file: Option<AzString>,
}
impl Default for FileDropManager {
fn default() -> Self {
Self::new()
}
}
impl FileDropManager {
/// Create a new cursor manager
pub fn new() -> Self {
Self {
hovered_file: None,
dropped_file: None,
}
}
/// Set the currently hovered file during drag operation
pub fn set_hovered_file(&mut self, file: Option<AzString>) {
self.hovered_file = file;
}
/// Get the currently hovered file
pub fn get_hovered_file(&self) -> Option<&AzString> {
self.hovered_file.as_ref()
}
/// Set the dropped file (should be cleared after one frame)
pub fn set_dropped_file(&mut self, file: Option<AzString>) {
self.dropped_file = file;
}
/// Get and clear the dropped file (one-shot event)
pub fn take_dropped_file(&mut self) -> Option<AzString> {
self.dropped_file.take()
}
/// Clear all state
pub fn clear(&mut self) {
self.hovered_file = None;
self.dropped_file = None;
}
}