1use serde::{Deserialize, Serialize};
2
3use super::super::Action;
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
10pub enum ActionRingIcon {
11 Pointer,
13 Mouse,
15 Copy,
17 Paste,
19 Cut,
21 Search,
23 Save,
25 Keyboard,
27 Applications,
29 Grid,
31 Layers,
33 Monitor,
35 Lock,
37 Camera,
39 Play,
41 Volume,
43 Gauge,
45 Refresh,
47 ArrowUp,
49 ArrowDown,
51 ArrowLeft,
53 ArrowRight,
55 Undo,
57 Redo,
59 SelectAll,
61 MouseBack,
63 MouseForward,
65 NewTab,
67 CloseTab,
69 ReopenTab,
71 NextTab,
73 PreviousTab,
75 Reload,
77 PreviousDesktop,
79 NextDesktop,
81 PreviousTrack,
83 NextTrack,
85 VolumeDown,
87 Mute,
89 ScrollLeft,
91 ScrollRight,
93 Folder,
95 File,
97 Globe,
99 Terminal,
101 Settings,
103 Star,
105 Heart,
107 Calendar,
109 Bell,
111 User,
113 Palette,
115 Book,
117 Ban,
119}
120
121impl ActionRingIcon {
122 pub const ALL: [Self; 54] = [
124 Self::Pointer,
125 Self::Mouse,
126 Self::Copy,
127 Self::Paste,
128 Self::Cut,
129 Self::Search,
130 Self::Save,
131 Self::Keyboard,
132 Self::Applications,
133 Self::Grid,
134 Self::Layers,
135 Self::Monitor,
136 Self::Lock,
137 Self::Camera,
138 Self::Play,
139 Self::Volume,
140 Self::Gauge,
141 Self::Refresh,
142 Self::ArrowUp,
143 Self::ArrowDown,
144 Self::ArrowLeft,
145 Self::ArrowRight,
146 Self::Undo,
147 Self::Redo,
148 Self::SelectAll,
149 Self::MouseBack,
150 Self::MouseForward,
151 Self::NewTab,
152 Self::CloseTab,
153 Self::ReopenTab,
154 Self::NextTab,
155 Self::PreviousTab,
156 Self::Reload,
157 Self::PreviousDesktop,
158 Self::NextDesktop,
159 Self::PreviousTrack,
160 Self::NextTrack,
161 Self::VolumeDown,
162 Self::Mute,
163 Self::ScrollLeft,
164 Self::ScrollRight,
165 Self::Folder,
166 Self::File,
167 Self::Globe,
168 Self::Terminal,
169 Self::Settings,
170 Self::Star,
171 Self::Heart,
172 Self::Calendar,
173 Self::Bell,
174 Self::User,
175 Self::Palette,
176 Self::Book,
177 Self::Ban,
178 ];
179
180 #[must_use]
182 pub fn label(self) -> &'static str {
183 match self {
184 Self::Pointer => "Left Click",
185 Self::Mouse => "Middle Click",
186 Self::Copy => "Copy",
187 Self::Paste => "Paste",
188 Self::Cut => "Cut",
189 Self::Search => "Find",
190 Self::Save => "Save",
191 Self::Keyboard => "Custom shortcut",
192 Self::Applications => "Open application or folder",
193 Self::Grid => "Actions Ring",
194 Self::Layers => "App Exposé",
195 Self::Monitor => "Show Desktop",
196 Self::Lock => "Lock Screen",
197 Self::Camera => "Screenshot",
198 Self::Play => "Play / Pause",
199 Self::Volume => "Volume Up",
200 Self::Gauge => "Cycle DPI Presets",
201 Self::Refresh => "Toggle SmartShift",
202 Self::ArrowUp => "Scroll Up",
203 Self::ArrowDown => "Scroll Down",
204 Self::ArrowLeft | Self::ScrollLeft => "Scroll Left",
205 Self::ArrowRight | Self::ScrollRight => "Scroll Right",
206 Self::Undo => "Undo",
207 Self::Redo => "Redo",
208 Self::SelectAll => "Select All",
209 Self::MouseBack => "Back (Button 4)",
210 Self::MouseForward => "Forward (Button 5)",
211 Self::NewTab => "New Tab",
212 Self::CloseTab => "Close Tab",
213 Self::ReopenTab => "Reopen Tab",
214 Self::NextTab => "Next Tab",
215 Self::PreviousTab => "Previous Tab",
216 Self::Reload => "Reload Page",
217 Self::PreviousDesktop => "Previous Desktop",
218 Self::NextDesktop => "Next Desktop",
219 Self::PreviousTrack => "Previous Track",
220 Self::NextTrack => "Next Track",
221 Self::VolumeDown => "Volume Down",
222 Self::Mute => "Mute",
223 Self::Folder => "Folder",
224 Self::File => "File",
225 Self::Globe => "Globe",
226 Self::Terminal => "Terminal",
227 Self::Settings => "Settings",
228 Self::Star => "Star",
229 Self::Heart => "Heart",
230 Self::Calendar => "Calendar",
231 Self::Bell => "Bell",
232 Self::User => "User",
233 Self::Palette => "Palette",
234 Self::Book => "Book",
235 Self::Ban => "Do Nothing",
236 }
237 }
238}
239
240macro_rules! derive_action_icon {
245 ( $( $variant:ident $label:literal $category:ident $icon:ident $( $tag:ident )? ),* $(,)? ) => {
246 impl ActionRingIcon {
247 #[must_use]
249 pub fn for_action(action: &Action) -> Self {
250 match action {
251 $( Action::$variant => Self::$icon, )*
252 Action::SetDpiPreset(_) => Self::Gauge,
253 Action::CustomShortcut(_) | Action::TypeText(_) | Action::Workflow(_) => {
254 Self::Keyboard
255 }
256 Action::RunAppleScript(_) | Action::RunShellCommand(_) => Self::Terminal,
257 Action::OpenApplication(_) => Self::Applications,
258 }
259 }
260 }
261 };
262}
263
264super::super::action::for_each_unit_action!(derive_action_icon);