Skip to content

Commit e8ebcc2

Browse files
authored
Replace text-only tooltips with custom richly styled tooltips (#3436)
* Replace the title attribute with custom FloatingMenu tooltips * Separate tooltip labels and descriptions into two styled blocks * Move keyboard shortcut tooltips to a separate section at the bottom * Update shortcut key styling in tooltips and hints bar * Fix .to_string()
1 parent 94e5c8f commit e8ebcc2

File tree

94 files changed

+1324
-581
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+1324
-581
lines changed

editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,18 @@ impl PreferencesDialogMessageHandler {
4242

4343
let navigation_header = vec![TextLabel::new("Navigation").italic(true).widget_holder()];
4444

45-
let zoom_rate_tooltip = "Adjust how fast zooming occurs when using the scroll wheel or pinch gesture (relative to a default of 50)";
45+
let zoom_rate_description = "Adjust how fast zooming occurs when using the scroll wheel or pinch gesture (relative to a default of 50).";
4646
let zoom_rate_label = vec![
4747
Separator::new(SeparatorType::Unrelated).widget_holder(),
4848
Separator::new(SeparatorType::Unrelated).widget_holder(),
49-
TextLabel::new("Zoom Rate").tooltip(zoom_rate_tooltip).widget_holder(),
49+
TextLabel::new("Zoom Rate").tooltip_label("Zoom Rate").tooltip_description(zoom_rate_description).widget_holder(),
5050
];
5151
let zoom_rate = vec![
5252
Separator::new(SeparatorType::Unrelated).widget_holder(),
5353
Separator::new(SeparatorType::Unrelated).widget_holder(),
5454
NumberInput::new(Some(map_zoom_rate_to_display(preferences.viewport_zoom_wheel_rate)))
55-
.tooltip(zoom_rate_tooltip)
55+
.tooltip_label("Zoom Rate")
56+
.tooltip_description(zoom_rate_description)
5657
.mode_range()
5758
.int()
5859
.min(1.)
@@ -69,12 +70,13 @@ impl PreferencesDialogMessageHandler {
6970
];
7071

7172
let checkbox_id = CheckboxId::new();
72-
let zoom_with_scroll_tooltip = "Use the scroll wheel for zooming instead of vertically panning (not recommended for trackpads)";
73+
let zoom_with_scroll_description = "Use the scroll wheel for zooming instead of vertically panning (not recommended for trackpads).";
7374
let zoom_with_scroll = vec![
7475
Separator::new(SeparatorType::Unrelated).widget_holder(),
7576
Separator::new(SeparatorType::Unrelated).widget_holder(),
7677
CheckboxInput::new(preferences.zoom_with_scroll)
77-
.tooltip(zoom_with_scroll_tooltip)
78+
.tooltip_label("Zoom with Scroll")
79+
.tooltip_description(zoom_with_scroll_description)
7880
.on_update(|checkbox_input: &CheckboxInput| {
7981
PreferencesMessage::ModifyLayout {
8082
zoom_with_scroll: checkbox_input.checked,
@@ -84,9 +86,10 @@ impl PreferencesDialogMessageHandler {
8486
.for_label(checkbox_id)
8587
.widget_holder(),
8688
TextLabel::new("Zoom with Scroll")
87-
.table_align(true)
88-
.tooltip(zoom_with_scroll_tooltip)
89+
.tooltip_label("Zoom with Scroll")
90+
.tooltip_description(zoom_with_scroll_description)
8991
.for_checkbox(checkbox_id)
92+
.table_align(true)
9093
.widget_holder(),
9194
];
9295

@@ -105,7 +108,8 @@ impl PreferencesDialogMessageHandler {
105108
let selection_mode = RadioInput::new(vec![
106109
RadioEntryData::new(SelectionMode::Touched.to_string())
107110
.label(SelectionMode::Touched.to_string())
108-
.tooltip(SelectionMode::Touched.tooltip_description())
111+
.tooltip_label(SelectionMode::Touched.to_string())
112+
.tooltip_description(SelectionMode::Touched.tooltip_description())
109113
.on_update(move |_| {
110114
PreferencesMessage::SelectionMode {
111115
selection_mode: SelectionMode::Touched,
@@ -114,7 +118,8 @@ impl PreferencesDialogMessageHandler {
114118
}),
115119
RadioEntryData::new(SelectionMode::Enclosed.to_string())
116120
.label(SelectionMode::Enclosed.to_string())
117-
.tooltip(SelectionMode::Enclosed.tooltip_description())
121+
.tooltip_label(SelectionMode::Enclosed.to_string())
122+
.tooltip_description(SelectionMode::Enclosed.tooltip_description())
118123
.on_update(move |_| {
119124
PreferencesMessage::SelectionMode {
120125
selection_mode: SelectionMode::Enclosed,
@@ -123,7 +128,8 @@ impl PreferencesDialogMessageHandler {
123128
}),
124129
RadioEntryData::new(SelectionMode::Directional.to_string())
125130
.label(SelectionMode::Directional.to_string())
126-
.tooltip(SelectionMode::Directional.tooltip_description())
131+
.tooltip_label(SelectionMode::Directional.to_string())
132+
.tooltip_description(SelectionMode::Directional.tooltip_description())
127133
.on_update(move |_| {
128134
PreferencesMessage::SelectionMode {
129135
selection_mode: SelectionMode::Directional,
@@ -145,20 +151,25 @@ impl PreferencesDialogMessageHandler {
145151

146152
let experimental_header = vec![TextLabel::new("Experimental").italic(true).widget_holder()];
147153

148-
let node_graph_section_tooltip = "Appearance of the wires running between node connections in the graph";
154+
let node_graph_section_description = "Appearance of the wires running between node connections in the graph.";
149155
let node_graph_wires_label = vec![
150156
Separator::new(SeparatorType::Unrelated).widget_holder(),
151157
Separator::new(SeparatorType::Unrelated).widget_holder(),
152-
TextLabel::new("Node Graph Wires").tooltip(node_graph_section_tooltip).widget_holder(),
158+
TextLabel::new("Node Graph Wires")
159+
.tooltip_label("Node Graph Wires")
160+
.tooltip_description(node_graph_section_description)
161+
.widget_holder(),
153162
];
154163
let graph_wire_style = RadioInput::new(vec![
155164
RadioEntryData::new(GraphWireStyle::Direct.to_string())
156165
.label(GraphWireStyle::Direct.to_string())
157-
.tooltip(GraphWireStyle::Direct.tooltip_description())
166+
.tooltip_label(GraphWireStyle::Direct.to_string())
167+
.tooltip_description(GraphWireStyle::Direct.tooltip_description())
158168
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::Direct }.into()),
159169
RadioEntryData::new(GraphWireStyle::GridAligned.to_string())
160170
.label(GraphWireStyle::GridAligned.to_string())
161-
.tooltip(GraphWireStyle::GridAligned.tooltip_description())
171+
.tooltip_label(GraphWireStyle::GridAligned.to_string())
172+
.tooltip_description(GraphWireStyle::GridAligned.tooltip_description())
162173
.on_update(move |_| PreferencesMessage::GraphWireStyle { style: GraphWireStyle::GridAligned }.into()),
163174
])
164175
.selected_index(Some(preferences.graph_wire_style as u32))
@@ -170,36 +181,47 @@ impl PreferencesDialogMessageHandler {
170181
];
171182

172183
let checkbox_id = CheckboxId::new();
173-
let vello_tooltip = "Use the experimental Vello renderer (your browser must support WebGPU)";
184+
let vello_description = "Use the experimental Vello renderer. (Your browser must support WebGPU).";
174185
let use_vello = vec![
175186
Separator::new(SeparatorType::Unrelated).widget_holder(),
176187
Separator::new(SeparatorType::Unrelated).widget_holder(),
177188
CheckboxInput::new(preferences.use_vello && preferences.supports_wgpu())
178-
.tooltip(vello_tooltip)
189+
.tooltip_label("Vello Renderer")
190+
.tooltip_description(vello_description)
179191
.disabled(!preferences.supports_wgpu())
180192
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::UseVello { use_vello: checkbox_input.checked }.into())
181193
.for_label(checkbox_id)
182194
.widget_holder(),
183195
TextLabel::new("Vello Renderer")
184-
.table_align(true)
185-
.tooltip(vello_tooltip)
196+
.tooltip_label("Vello Renderer")
197+
.tooltip_description(vello_description)
186198
.disabled(!preferences.supports_wgpu())
187199
.for_checkbox(checkbox_id)
200+
.table_align(true)
188201
.widget_holder(),
189202
];
190203

191204
let checkbox_id = CheckboxId::new();
192-
let vector_mesh_tooltip =
193-
"Allow tools to produce vector meshes, where more than two segments can connect to an anchor point.\n\nCurrently this does not properly handle stroke joins and fills.";
205+
let vector_mesh_description = "
206+
Allow tools to produce vector meshes, where more than two segments can connect to an anchor point.\n\
207+
Currently this does not properly handle stroke joins and fills.
208+
"
209+
.trim();
194210
let vector_meshes = vec![
195211
Separator::new(SeparatorType::Unrelated).widget_holder(),
196212
Separator::new(SeparatorType::Unrelated).widget_holder(),
197213
CheckboxInput::new(preferences.vector_meshes)
198-
.tooltip(vector_mesh_tooltip)
214+
.tooltip_label("Vector Meshes")
215+
.tooltip_description(vector_mesh_description)
199216
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::VectorMeshes { enabled: checkbox_input.checked }.into())
200217
.for_label(checkbox_id)
201218
.widget_holder(),
202-
TextLabel::new("Vector Meshes").table_align(true).tooltip(vector_mesh_tooltip).for_checkbox(checkbox_id).widget_holder(),
219+
TextLabel::new("Vector Meshes")
220+
.tooltip_label("Vector Meshes")
221+
.tooltip_description(vector_mesh_description)
222+
.for_checkbox(checkbox_id)
223+
.table_align(true)
224+
.widget_holder(),
203225
];
204226

205227
Layout::WidgetLayout(WidgetLayout::new(vec![

editor/src/messages/dialog/simple_dialogs/licenses_dialog.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,19 @@ impl DialogLayoutHolder for LicensesDialog {
4949

5050
impl LayoutHolder for LicensesDialog {
5151
fn layout(&self) -> Layout {
52-
let description = concat!(
53-
"The Graphite logo and brand identity are copyright © [YEAR]\nGraphite Labs, LLC. See \"Graphite Logo\" for usage policy.",
54-
"\n\n",
55-
"The Graphite editor's icons and design assets are copyright\n© [YEAR] Graphite Labs, LLC. See \"Graphite Icons\" for details.",
56-
"\n\n",
57-
"Graphite code is copyright © [YEAR] Graphite contributors\nand is made available under the Apache 2.0 license. See\n\"Graphite License\" for details.",
58-
"\n\n",
59-
"Graphite is distributed with third-party open source code\ndependencies. See \"Other Licenses\" for details.",
60-
)
61-
.replace("[YEAR]", &self.localized_commit_year);
52+
let year = &self.localized_commit_year;
53+
let description = format!(
54+
"
55+
The Graphite logo and brand identity are copyright © {year}\nGraphite Labs, LLC. See \"Graphite Logo\" for usage policy.\n\
56+
\n\
57+
The Graphite editor's icons and design assets are copyright\n© {year} Graphite Labs, LLC. See \"Graphite Icons\" for details.\n\
58+
\n\
59+
Graphite code is copyright © {year} Graphite contributors\nand is made available under the Apache 2.0 license. See\n\"Graphite License\" for details.\n\
60+
\n\
61+
Graphite is distributed with third-party open source code\ndependencies. See \"Other Licenses\" for details.
62+
"
63+
);
64+
let description = description.trim();
6265

6366
Layout::WidgetLayout(WidgetLayout::new(vec![
6467
LayoutGroup::Row {

editor/src/messages/input_mapper/input_mappings.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,6 @@ pub fn input_mappings() -> Mapping {
410410
entry!(KeyDown(FakeKeyPlus); modifiers=[Accel], canonical, action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
411411
entry!(KeyDown(Equal); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
412412
entry!(KeyDown(Minus); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }),
413-
entry!(KeyDown(KeyF); modifiers=[Alt], action_dispatch=NavigationMessage::CanvasFlip),
414413
entry!(WheelScroll; modifiers=[Control], action_dispatch=NavigationMessage::CanvasZoomMouseWheel),
415414
entry!(WheelScroll; modifiers=[Shift], action_dispatch=NavigationMessage::CanvasPanMouseWheel { use_y_as_x: true }),
416415
entry!(WheelScroll; action_dispatch=NavigationMessage::CanvasPanMouseWheel { use_y_as_x: false }),

editor/src/messages/input_mapper/utility_types/input_keyboard.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,9 @@ impl fmt::Display for Key {
296296
KeyboardPlatformLayout::Standard => "Ctrl",
297297
KeyboardPlatformLayout::Mac => "⌘",
298298
},
299-
Self::MouseLeft => "LMB",
300-
Self::MouseRight => "RMB",
301-
Self::MouseMiddle => "MMB",
299+
Self::MouseLeft => "Click",
300+
Self::MouseRight => "R.Click",
301+
Self::MouseMiddle => "M.Click",
302302
Self::MouseBack => "Mouse Back",
303303
Self::MouseForward => "Mouse Fwd",
304304

@@ -321,7 +321,7 @@ impl From<Key> for LayoutKey {
321321

322322
#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
323323
pub struct LayoutKey {
324-
pub key: Key,
324+
key: Key,
325325
label: String,
326326
}
327327

0 commit comments

Comments
 (0)