Skip to content

Commit 348636d

Browse files
committed
Code cleanup: use Self
1 parent c67659c commit 348636d

File tree

1 file changed

+60
-60
lines changed

1 file changed

+60
-60
lines changed

crates/re_ui/src/command.rs

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -81,98 +81,98 @@ impl UICommand {
8181
pub fn text_and_tooltip(self) -> (&'static str, &'static str) {
8282
match self {
8383
#[cfg(not(target_arch = "wasm32"))]
84-
UICommand::Save => ("Save…", "Save all data to a Rerun data file (.rrd)"),
84+
Self::Save => ("Save…", "Save all data to a Rerun data file (.rrd)"),
8585

8686
#[cfg(not(target_arch = "wasm32"))]
87-
UICommand::SaveSelection => (
87+
Self::SaveSelection => (
8888
"Save loop selection…",
8989
"Save data for the current loop selection to a Rerun data file (.rrd)",
9090
),
9191

92-
UICommand::Open => ("Open…", "Open any supported files (.rrd, images, meshes, …)"),
92+
Self::Open => ("Open…", "Open any supported files (.rrd, images, meshes, …)"),
9393

94-
UICommand::CloseCurrentRecording => (
94+
Self::CloseCurrentRecording => (
9595
"Close current Recording",
9696
"Close the current Recording (unsaved data will be lost)",
9797
),
9898

9999
#[cfg(not(target_arch = "wasm32"))]
100-
UICommand::Quit => ("Quit", "Close the Rerun Viewer"),
100+
Self::Quit => ("Quit", "Close the Rerun Viewer"),
101101

102-
UICommand::OpenWebHelp => ("Help", "Visit the help page on our website, with troubleshooting tips and more"),
103-
UICommand::OpenRerunDiscord => ("Rerun Discord", "Visit the Rerun Discord server, where you can ask questions and get help"),
102+
Self::OpenWebHelp => ("Help", "Visit the help page on our website, with troubleshooting tips and more"),
103+
Self::OpenRerunDiscord => ("Rerun Discord", "Visit the Rerun Discord server, where you can ask questions and get help"),
104104

105-
UICommand::ResetViewer => (
105+
Self::ResetViewer => (
106106
"Reset Viewer",
107107
"Reset the Viewer to how it looked the first time you ran it",
108108
),
109109

110110
#[cfg(not(target_arch = "wasm32"))]
111-
UICommand::OpenProfiler => (
111+
Self::OpenProfiler => (
112112
"Open profiler",
113113
"Starts a profiler, showing what makes the viewer run slow",
114114
),
115115

116-
UICommand::ToggleMemoryPanel => (
116+
Self::ToggleMemoryPanel => (
117117
"Toggle Memory Panel",
118118
"View and track current RAM usage inside Rerun Viewer",
119119
),
120-
UICommand::ToggleBlueprintPanel => ("Toggle Blueprint Panel", "Toggle the left panel"),
121-
UICommand::ToggleSelectionPanel => ("Toggle Selection Panel", "Toggle the right panel"),
122-
UICommand::ToggleTimePanel => ("Toggle Time Panel", "Toggle the bottom panel"),
120+
Self::ToggleBlueprintPanel => ("Toggle Blueprint Panel", "Toggle the left panel"),
121+
Self::ToggleSelectionPanel => ("Toggle Selection Panel", "Toggle the right panel"),
122+
Self::ToggleTimePanel => ("Toggle Time Panel", "Toggle the bottom panel"),
123123

124124
#[cfg(debug_assertions)]
125-
UICommand::ToggleStylePanel => (
125+
Self::ToggleStylePanel => (
126126
"Toggle Style Panel",
127127
"View and change global egui style settings",
128128
),
129129

130130
#[cfg(not(target_arch = "wasm32"))]
131-
UICommand::ToggleFullscreen => (
131+
Self::ToggleFullscreen => (
132132
"Toggle fullscreen",
133133
"Toggle between windowed and fullscreen viewer",
134134
),
135135
#[cfg(not(target_arch = "wasm32"))]
136-
UICommand::ZoomIn => ("Zoom In", "Increases the UI zoom level"),
136+
Self::ZoomIn => ("Zoom In", "Increases the UI zoom level"),
137137
#[cfg(not(target_arch = "wasm32"))]
138-
UICommand::ZoomOut => ("Zoom Out", "Decreases the UI zoom level"),
138+
Self::ZoomOut => ("Zoom Out", "Decreases the UI zoom level"),
139139
#[cfg(not(target_arch = "wasm32"))]
140-
UICommand::ZoomReset => (
140+
Self::ZoomReset => (
141141
"Reset Zoom",
142142
"Resets the UI zoom level to the operating system's default value",
143143
),
144144

145-
UICommand::SelectionPrevious => ("Previous selection", "Go to previous selection"),
146-
UICommand::SelectionNext => ("Next selection", "Go to next selection"),
147-
UICommand::ToggleCommandPalette => ("Command Palette…", "Toggle the Command Palette"),
145+
Self::SelectionPrevious => ("Previous selection", "Go to previous selection"),
146+
Self::SelectionNext => ("Next selection", "Go to next selection"),
147+
Self::ToggleCommandPalette => ("Command Palette…", "Toggle the Command Palette"),
148148

149-
UICommand::PlaybackTogglePlayPause => {
149+
Self::PlaybackTogglePlayPause => {
150150
("Toggle play/pause", "Either play or pause the time")
151151
}
152-
UICommand::PlaybackFollow => ("Follow", "Follow on from end of timeline"),
153-
UICommand::PlaybackStepBack => (
152+
Self::PlaybackFollow => ("Follow", "Follow on from end of timeline"),
153+
Self::PlaybackStepBack => (
154154
"Step time back",
155155
"Move the time marker back to the previous point in time with any data",
156156
),
157-
UICommand::PlaybackStepForward => (
157+
Self::PlaybackStepForward => (
158158
"Step time forward",
159159
"Move the time marker to the next point in time with any data",
160160
),
161-
UICommand::PlaybackRestart => ("Restart", "Restart from beginning of timeline"),
161+
Self::PlaybackRestart => ("Restart", "Restart from beginning of timeline"),
162162

163163
#[cfg(not(target_arch = "wasm32"))]
164-
UICommand::ScreenshotWholeApp => (
164+
Self::ScreenshotWholeApp => (
165165
"Screenshot",
166166
"Copy screenshot of the whole app to clipboard",
167167
),
168168
#[cfg(not(target_arch = "wasm32"))]
169-
UICommand::PrintDatastore => (
169+
Self::PrintDatastore => (
170170
"Print datastore",
171171
"Prints the entire data store to the console. WARNING: this may be A LOT of text.",
172172
),
173173

174174
#[cfg(target_arch = "wasm32")]
175-
UICommand::CopyDirectLink => (
175+
Self::CopyDirectLink => (
176176
"Copy direct link",
177177
"Copy a link to the viewer with the URL parameter set to the current .rrd data source."
178178
)
@@ -200,58 +200,58 @@ impl UICommand {
200200

201201
match self {
202202
#[cfg(not(target_arch = "wasm32"))]
203-
UICommand::Save => Some(cmd(Key::S)),
203+
Self::Save => Some(cmd(Key::S)),
204204
#[cfg(not(target_arch = "wasm32"))]
205-
UICommand::SaveSelection => Some(cmd_alt(Key::S)),
206-
UICommand::Open => Some(cmd(Key::O)),
207-
UICommand::CloseCurrentRecording => None,
205+
Self::SaveSelection => Some(cmd_alt(Key::S)),
206+
Self::Open => Some(cmd(Key::O)),
207+
Self::CloseCurrentRecording => None,
208208

209209
#[cfg(all(not(target_arch = "wasm32"), target_os = "windows"))]
210-
UICommand::Quit => Some(KeyboardShortcut::new(Modifiers::ALT, Key::F4)),
210+
Self::Quit => Some(KeyboardShortcut::new(Modifiers::ALT, Key::F4)),
211211

212-
UICommand::OpenWebHelp => None,
213-
UICommand::OpenRerunDiscord => None,
212+
Self::OpenWebHelp => None,
213+
Self::OpenRerunDiscord => None,
214214

215215
#[cfg(all(not(target_arch = "wasm32"), not(target_os = "windows")))]
216-
UICommand::Quit => Some(cmd(Key::Q)),
216+
Self::Quit => Some(cmd(Key::Q)),
217217

218-
UICommand::ResetViewer => Some(ctrl_shift(Key::R)),
218+
Self::ResetViewer => Some(ctrl_shift(Key::R)),
219219
#[cfg(not(target_arch = "wasm32"))]
220-
UICommand::OpenProfiler => Some(ctrl_shift(Key::P)),
221-
UICommand::ToggleMemoryPanel => Some(ctrl_shift(Key::M)),
222-
UICommand::ToggleBlueprintPanel => Some(ctrl_shift(Key::B)),
223-
UICommand::ToggleSelectionPanel => Some(ctrl_shift(Key::S)),
224-
UICommand::ToggleTimePanel => Some(ctrl_shift(Key::T)),
220+
Self::OpenProfiler => Some(ctrl_shift(Key::P)),
221+
Self::ToggleMemoryPanel => Some(ctrl_shift(Key::M)),
222+
Self::ToggleBlueprintPanel => Some(ctrl_shift(Key::B)),
223+
Self::ToggleSelectionPanel => Some(ctrl_shift(Key::S)),
224+
Self::ToggleTimePanel => Some(ctrl_shift(Key::T)),
225225

226226
#[cfg(debug_assertions)]
227-
UICommand::ToggleStylePanel => Some(ctrl_shift(Key::U)),
227+
Self::ToggleStylePanel => Some(ctrl_shift(Key::U)),
228228

229229
#[cfg(not(target_arch = "wasm32"))]
230-
UICommand::ToggleFullscreen => Some(key(Key::F11)),
230+
Self::ToggleFullscreen => Some(key(Key::F11)),
231231
#[cfg(not(target_arch = "wasm32"))]
232-
UICommand::ZoomIn => Some(egui::gui_zoom::kb_shortcuts::ZOOM_IN),
232+
Self::ZoomIn => Some(egui::gui_zoom::kb_shortcuts::ZOOM_IN),
233233
#[cfg(not(target_arch = "wasm32"))]
234-
UICommand::ZoomOut => Some(egui::gui_zoom::kb_shortcuts::ZOOM_OUT),
234+
Self::ZoomOut => Some(egui::gui_zoom::kb_shortcuts::ZOOM_OUT),
235235
#[cfg(not(target_arch = "wasm32"))]
236-
UICommand::ZoomReset => Some(egui::gui_zoom::kb_shortcuts::ZOOM_RESET),
236+
Self::ZoomReset => Some(egui::gui_zoom::kb_shortcuts::ZOOM_RESET),
237237

238-
UICommand::SelectionPrevious => Some(ctrl_shift(Key::ArrowLeft)),
239-
UICommand::SelectionNext => Some(ctrl_shift(Key::ArrowRight)),
240-
UICommand::ToggleCommandPalette => Some(cmd(Key::P)),
238+
Self::SelectionPrevious => Some(ctrl_shift(Key::ArrowLeft)),
239+
Self::SelectionNext => Some(ctrl_shift(Key::ArrowRight)),
240+
Self::ToggleCommandPalette => Some(cmd(Key::P)),
241241

242-
UICommand::PlaybackTogglePlayPause => Some(key(Key::Space)),
243-
UICommand::PlaybackFollow => Some(cmd(Key::ArrowRight)),
244-
UICommand::PlaybackStepBack => Some(key(Key::ArrowLeft)),
245-
UICommand::PlaybackStepForward => Some(key(Key::ArrowRight)),
246-
UICommand::PlaybackRestart => Some(cmd(Key::ArrowLeft)),
242+
Self::PlaybackTogglePlayPause => Some(key(Key::Space)),
243+
Self::PlaybackFollow => Some(cmd(Key::ArrowRight)),
244+
Self::PlaybackStepBack => Some(key(Key::ArrowLeft)),
245+
Self::PlaybackStepForward => Some(key(Key::ArrowRight)),
246+
Self::PlaybackRestart => Some(cmd(Key::ArrowLeft)),
247247

248248
#[cfg(not(target_arch = "wasm32"))]
249-
UICommand::ScreenshotWholeApp => None,
249+
Self::ScreenshotWholeApp => None,
250250
#[cfg(not(target_arch = "wasm32"))]
251-
UICommand::PrintDatastore => None,
251+
Self::PrintDatastore => None,
252252

253253
#[cfg(target_arch = "wasm32")]
254-
UICommand::CopyDirectLink => None,
254+
Self::CopyDirectLink => None,
255255
}
256256
}
257257

@@ -277,7 +277,7 @@ impl UICommand {
277277
}
278278

279279
egui_ctx.input_mut(|input| {
280-
for command in UICommand::iter() {
280+
for command in Self::iter() {
281281
if let Some(kb_shortcut) = command.kb_shortcut() {
282282
if input.consume_shortcut(&kb_shortcut) {
283283
return Some(command);

0 commit comments

Comments
 (0)