Skip to main content

openlogi_core/binding/action_ring/
icon.rs

1use serde::{Deserialize, Serialize};
2
3use super::super::Action;
4
5/// Presentation icon for an Actions Ring slot.
6///
7/// Variant names are persisted in TOML and declaration order is part of the
8/// agent IPC wire format, so variants are append-only.
9#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
10pub enum ActionRingIcon {
11    /// Pointer click glyph.
12    Pointer,
13    /// Physical mouse glyph.
14    Mouse,
15    /// Copy glyph.
16    Copy,
17    /// Clipboard/paste glyph.
18    Paste,
19    /// Scissors/cut glyph.
20    Cut,
21    /// Search glyph.
22    Search,
23    /// Save glyph.
24    Save,
25    /// Keyboard glyph.
26    Keyboard,
27    /// Application grid glyph.
28    Applications,
29    /// Actions grid glyph.
30    Grid,
31    /// Layer stack glyph.
32    Layers,
33    /// Display glyph.
34    Monitor,
35    /// Lock glyph.
36    Lock,
37    /// Camera glyph.
38    Camera,
39    /// Playback glyph.
40    Play,
41    /// Audio glyph.
42    Volume,
43    /// Gauge glyph.
44    Gauge,
45    /// Refresh glyph.
46    Refresh,
47    /// Up arrow glyph.
48    ArrowUp,
49    /// Down arrow glyph.
50    ArrowDown,
51    /// Left arrow glyph.
52    ArrowLeft,
53    /// Right arrow glyph.
54    ArrowRight,
55    /// Undo glyph.
56    Undo,
57    /// Redo glyph.
58    Redo,
59    /// Selection checklist glyph.
60    SelectAll,
61    /// Circular back glyph.
62    MouseBack,
63    /// Circular forward glyph.
64    MouseForward,
65    /// New-tab glyph.
66    NewTab,
67    /// Close-tab glyph.
68    CloseTab,
69    /// Reopen-tab glyph.
70    ReopenTab,
71    /// Next-tab glyph.
72    NextTab,
73    /// Previous-tab glyph.
74    PreviousTab,
75    /// Reload glyph.
76    Reload,
77    /// Previous-desktop glyph.
78    PreviousDesktop,
79    /// Next-desktop glyph.
80    NextDesktop,
81    /// Previous-track glyph.
82    PreviousTrack,
83    /// Next-track glyph.
84    NextTrack,
85    /// Lower-volume glyph.
86    VolumeDown,
87    /// Muted-volume glyph.
88    Mute,
89    /// Horizontal scroll-left glyph.
90    ScrollLeft,
91    /// Horizontal scroll-right glyph.
92    ScrollRight,
93    /// Folder glyph.
94    Folder,
95    /// File glyph.
96    File,
97    /// Globe glyph.
98    Globe,
99    /// Terminal glyph.
100    Terminal,
101    /// Settings glyph.
102    Settings,
103    /// Star glyph.
104    Star,
105    /// Heart glyph.
106    Heart,
107    /// Calendar glyph.
108    Calendar,
109    /// Notification bell glyph.
110    Bell,
111    /// User glyph.
112    User,
113    /// Color palette glyph.
114    Palette,
115    /// Open book glyph.
116    Book,
117    /// Prohibited action glyph.
118    Ban,
119}
120
121impl ActionRingIcon {
122    /// Every icon offered by the Actions Ring editor.
123    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    /// Default icon for an executable action.
181    #[must_use]
182    pub fn for_action(action: &Action) -> Self {
183        match action {
184            Action::None => Self::Ban,
185            Action::LeftClick | Action::RightClick => Self::Pointer,
186            Action::MiddleClick => Self::Mouse,
187            Action::MouseBack => Self::MouseBack,
188            Action::MouseForward => Self::MouseForward,
189            Action::Copy => Self::Copy,
190            Action::Paste => Self::Paste,
191            Action::Cut => Self::Cut,
192            Action::Undo => Self::Undo,
193            Action::Redo => Self::Redo,
194            Action::SelectAll => Self::SelectAll,
195            Action::Find => Self::Search,
196            Action::Save => Self::Save,
197            Action::BrowserBack => Self::ArrowLeft,
198            Action::BrowserForward => Self::ArrowRight,
199            Action::NewTab => Self::NewTab,
200            Action::CloseTab => Self::CloseTab,
201            Action::ReopenTab => Self::ReopenTab,
202            Action::NextTab => Self::NextTab,
203            Action::PrevTab => Self::PreviousTab,
204            Action::ReloadPage => Self::Reload,
205            Action::MissionControl | Action::ShowActionsRing => Self::Grid,
206            Action::AppExpose => Self::Layers,
207            Action::PreviousDesktop => Self::PreviousDesktop,
208            Action::NextDesktop => Self::NextDesktop,
209            Action::ShowDesktop | Action::Sleep => Self::Monitor,
210            Action::LaunchpadShow | Action::OpenApplication(_) => Self::Applications,
211            Action::LockScreen => Self::Lock,
212            Action::Screenshot | Action::CaptureRegion => Self::Camera,
213            Action::PlayPause => Self::Play,
214            Action::NextTrack => Self::NextTrack,
215            Action::PrevTrack => Self::PreviousTrack,
216            Action::VolumeUp => Self::Volume,
217            Action::VolumeDown => Self::VolumeDown,
218            Action::MuteVolume => Self::Mute,
219            Action::CycleDpiPresets | Action::SetDpiPreset(_) => Self::Gauge,
220            Action::ToggleSmartShift => Self::Refresh,
221            Action::ScrollUp => Self::ArrowUp,
222            Action::ScrollDown => Self::ArrowDown,
223            Action::HorizontalScrollLeft => Self::ScrollLeft,
224            Action::HorizontalScrollRight => Self::ScrollRight,
225            Action::CustomShortcut(_) | Action::TypeText(_) | Action::Workflow(_) => Self::Keyboard,
226            Action::RunAppleScript(_) | Action::RunShellCommand(_) => Self::Terminal,
227        }
228    }
229
230    /// Existing localization key used as this icon's accessible label.
231    #[must_use]
232    pub fn label(self) -> &'static str {
233        match self {
234            Self::Pointer => "Left Click",
235            Self::Mouse => "Middle Click",
236            Self::Copy => "Copy",
237            Self::Paste => "Paste",
238            Self::Cut => "Cut",
239            Self::Search => "Find",
240            Self::Save => "Save",
241            Self::Keyboard => "Custom shortcut",
242            Self::Applications => "Open application or folder",
243            Self::Grid => "Actions Ring",
244            Self::Layers => "App Exposé",
245            Self::Monitor => "Show Desktop",
246            Self::Lock => "Lock Screen",
247            Self::Camera => "Screenshot",
248            Self::Play => "Play / Pause",
249            Self::Volume => "Volume Up",
250            Self::Gauge => "Cycle DPI Presets",
251            Self::Refresh => "Toggle SmartShift",
252            Self::ArrowUp => "Scroll Up",
253            Self::ArrowDown => "Scroll Down",
254            Self::ArrowLeft | Self::ScrollLeft => "Scroll Left",
255            Self::ArrowRight | Self::ScrollRight => "Scroll Right",
256            Self::Undo => "Undo",
257            Self::Redo => "Redo",
258            Self::SelectAll => "Select All",
259            Self::MouseBack => "Back (Button 4)",
260            Self::MouseForward => "Forward (Button 5)",
261            Self::NewTab => "New Tab",
262            Self::CloseTab => "Close Tab",
263            Self::ReopenTab => "Reopen Tab",
264            Self::NextTab => "Next Tab",
265            Self::PreviousTab => "Previous Tab",
266            Self::Reload => "Reload Page",
267            Self::PreviousDesktop => "Previous Desktop",
268            Self::NextDesktop => "Next Desktop",
269            Self::PreviousTrack => "Previous Track",
270            Self::NextTrack => "Next Track",
271            Self::VolumeDown => "Volume Down",
272            Self::Mute => "Mute",
273            Self::Folder => "Folder",
274            Self::File => "File",
275            Self::Globe => "Globe",
276            Self::Terminal => "Terminal",
277            Self::Settings => "Settings",
278            Self::Star => "Star",
279            Self::Heart => "Heart",
280            Self::Calendar => "Calendar",
281            Self::Bell => "Bell",
282            Self::User => "User",
283            Self::Palette => "Palette",
284            Self::Book => "Book",
285            Self::Ban => "Do Nothing",
286        }
287    }
288}