-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathmessages.rs
More file actions
158 lines (149 loc) · 3.87 KB
/
messages.rs
File metadata and controls
158 lines (149 loc) · 3.87 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
use graphite_editor::messages::prelude::FrontendMessage;
use std::path::PathBuf;
pub(crate) use graphite_editor::messages::prelude::Message as EditorMessage;
pub use graphite_editor::messages::frontend::utility_types::{DocumentInfo, PersistedState};
pub use graphite_editor::messages::input_mapper::utility_types::input_keyboard::{Key, ModifierKeys};
pub use graphite_editor::messages::input_mapper::utility_types::input_mouse::{EditorMouseState as MouseState, EditorPosition as Position, MouseKeys};
pub use graphite_editor::messages::prelude::DocumentId;
pub use graphite_editor::messages::prelude::InputPreprocessorMessage as InputMessage;
pub use graphite_editor::messages::prelude::PreferencesMessageHandler as Preferences;
pub enum DesktopFrontendMessage {
ToWeb(Vec<FrontendMessage>),
OpenLaunchDocuments,
OpenFileDialog {
title: String,
filters: Vec<FileFilter>,
multiple: bool,
context: OpenFileDialogContext,
},
SaveFileDialog {
title: String,
default_filename: String,
default_folder: Option<PathBuf>,
filters: Vec<FileFilter>,
context: SaveFileDialogContext,
},
WriteFile {
path: PathBuf,
content: Vec<u8>,
},
OpenUrl(String),
UpdateViewportPhysicalBounds {
x: f64,
y: f64,
width: f64,
height: f64,
},
UpdateUIScale {
scale: f64,
},
UpdateOverlays(vello::Scene),
PersistenceWriteDocument {
id: DocumentId,
document_serialized_content: String,
},
PersistenceDeleteDocument {
id: DocumentId,
},
PersistenceWritePreferences {
preferences: Preferences,
},
PersistenceLoadPreferences,
PersistenceWriteState {
state: PersistedState,
},
PersistenceReadState,
PersistenceReadDocument {
id: DocumentId,
},
UpdateMenu {
entries: Vec<MenuItem>,
},
ClipboardRead,
ClipboardWrite {
content: String,
},
PointerLock,
WindowClose,
WindowMinimize,
WindowMaximize,
WindowFullscreen,
WindowDrag,
WindowFocus,
WindowHide,
WindowHideOthers,
WindowShowAll,
Restart,
LoadThirdPartyLicenses,
}
pub enum DesktopWrapperMessage {
FromWeb(Box<EditorMessage>),
Input(InputMessage),
FileDialogResult { path: PathBuf, content: Vec<u8>, context: OpenFileDialogContext },
SaveFileDialogResult { path: PathBuf, context: SaveFileDialogContext },
OpenFile { path: PathBuf, content: Vec<u8> },
ImportFile { path: PathBuf, content: Vec<u8> },
PollNodeGraphEvaluation,
UpdateMaximized { maximized: bool },
UpdateFullscreen { fullscreen: bool },
LoadDocumentContent { id: DocumentId, document: String },
LoadPersistedState { state: PersistedState },
LoadPreferences { preferences: Preferences },
MenuEvent { id: String },
ClipboardReadResult { content: Option<String> },
PointerLockMove { x: f64, y: f64 },
LoadThirdPartyLicenses { text: String },
}
pub struct FileFilter {
pub name: String,
pub extensions: Vec<String>,
}
#[derive(Clone, Copy)]
pub enum OpenFileDialogContext {
Open,
Import,
}
pub enum SaveFileDialogContext {
Document {
document_id: DocumentId,
content: Vec<u8>,
},
File {
content: Vec<u8>,
},
/// Multiple files written into a folder whose path is the user-chosen path with the matching `expected_extension`
/// stripped (e.g. for a PNG animation export, picking `MyAnim.png` yields a `MyAnim/` folder, while picking `v1.0`
/// is preserved as `v1.0/` because `.0` isn't the expected extension). Each `(filename, content)` entry is written
/// inside that folder, which is created if it doesn't exist.
MultipleFiles {
files: Vec<(String, Vec<u8>)>,
expected_extension: String,
},
}
pub enum MenuItem {
Action {
id: String,
text: String,
enabled: bool,
shortcut: Option<Shortcut>,
},
Checkbox {
id: String,
text: String,
enabled: bool,
shortcut: Option<Shortcut>,
checked: bool,
},
SubMenu {
id: String,
text: String,
enabled: bool,
items: Vec<MenuItem>,
},
Separator,
}
pub use keyboard_types::{Code as KeyCode, Modifiers};
pub struct Shortcut {
pub key: KeyCode,
pub modifiers: Modifiers,
}