Skip to content

Commit ca5785b

Browse files
authored
Show a "Ctrl +" label instead of "Ctrl =" for View > Zoom In (#3377)
1 parent 2835fbc commit ca5785b

File tree

4 files changed

+38
-25
lines changed

4 files changed

+38
-25
lines changed

editor/src/messages/input_mapper/input_mappings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ pub fn input_mappings() -> Mapping {
406406
entry!(KeyDown(MouseMiddle); action_dispatch=NavigationMessage::BeginCanvasPan),
407407
entry!(KeyDown(MouseLeft); modifiers=[Space], action_dispatch=NavigationMessage::BeginCanvasPan),
408408
entry!(KeyDown(NumpadAdd); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
409+
// `FakeKeyPlus` is a nonfunctional key mapping that must be accompanied by its real `Equal` key counterpart. This is used only to set the canonical key label so it shows "+" instead of "=" in the UI.
410+
entry!(KeyDown(FakeKeyPlus); modifiers=[Accel], canonical, action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
409411
entry!(KeyDown(Equal); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
410412
entry!(KeyDown(Minus); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }),
411413
entry!(KeyDown(KeyF); modifiers=[Alt], action_dispatch=NavigationMessage::CanvasFlip),

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

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub enum Key {
6161
Digit7,
6262
Digit8,
6363
Digit9,
64-
//
64+
6565
KeyA,
6666
KeyB,
6767
KeyC,
@@ -88,7 +88,7 @@ pub enum Key {
8888
KeyX,
8989
KeyY,
9090
KeyZ,
91-
//
91+
9292
Backquote,
9393
Backslash,
9494
BracketLeft,
@@ -197,6 +197,8 @@ pub enum Key {
197197
Unidentified,
198198

199199
// Other keys that aren't part of the W3C spec
200+
//
201+
/// "Cmd" on Mac (not present on other platforms)
200202
Command,
201203
/// "Ctrl" on Windows/Linux, "Cmd" on Mac
202204
Accel,
@@ -206,8 +208,14 @@ pub enum Key {
206208
MouseBack,
207209
MouseForward,
208210

209-
// This has to be the last element in the enum
210-
NumKeys,
211+
// Fake keys for displaying special labels in the UI
212+
//
213+
/// Not a physical key that can be pressed. May be used so that an actual shortcut bound to `Equal` can separately map this fake "key" as an additional binding to display the "+" shortcut label in the UI.
214+
FakeKeyPlus,
215+
/// Not a physical key that can be pressed. May be used so that an actual shortcut bound to all ten number keys (0, ..., 9) can separately map this fake "key" as an additional binding to display the "0–9" shortcut label in the UI.
216+
FakeKeyNumbers,
217+
218+
_KeysVariantCount, // This has to be the last element in the enum
211219
}
212220

213221
impl fmt::Display for Key {
@@ -293,7 +301,10 @@ impl fmt::Display for Key {
293301
Self::MouseMiddle => "MMB",
294302
Self::MouseBack => "Mouse Back",
295303
Self::MouseForward => "Mouse Fwd",
296-
Self::NumKeys => "0–9",
304+
305+
// Fake keys for displaying special labels in the UI
306+
Self::FakeKeyPlus => "+",
307+
Self::FakeKeyNumbers => "0–9",
297308

298309
_ => key_name.as_str(),
299310
};
@@ -314,7 +325,7 @@ pub struct LayoutKey {
314325
label: String,
315326
}
316327

317-
pub const NUMBER_OF_KEYS: usize = Key::NumKeys as usize;
328+
pub const NUMBER_OF_KEYS: usize = Key::_KeysVariantCount as usize - 1;
318329

319330
/// Only `Key`s that exist on a physical keyboard should be used.
320331
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]

editor/src/messages/portfolio/document/utility_types/transformation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ impl TransformOperation {
456456
}
457457
let mut typing_hints = vec![HintInfo::keys([Key::Minus], "Negate Direction")];
458458
if self.can_begin_typing() {
459-
typing_hints.push(HintInfo::keys([Key::NumKeys], "Enter Number"));
459+
typing_hints.push(HintInfo::keys([Key::FakeKeyNumbers], "Enter Number"));
460460
if self.is_typing() {
461461
typing_hints.push(HintInfo::keys([Key::Backspace], "Delete Digit"));
462462
}

node-graph/gcore/src/vector/vector_nodes.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,11 +1141,11 @@ async fn sample_polyline(
11411141
.collect()
11421142
}
11431143

1144-
/// Cuts a path at a given progress from 0 to 1 along the path, creating two new subpaths from the original one (if the path is initially open) or one open subpath (if the path is initially closed).
1144+
/// Cuts a path at a given progression from 0 to 1 along the path, creating two new subpaths from the original one (if the path is initially open) or one open subpath (if the path is initially closed).
11451145
///
1146-
/// If multiple subpaths make up the path, the whole number part of the progress value selects the subpath and the decimal part determines the position along it.
1146+
/// If multiple subpaths make up the path, the whole number part of the progression value selects the subpath and the decimal part determines the position along it.
11471147
#[node_macro::node(category("Vector: Modifier"), path(graphene_core::vector))]
1148-
async fn cut_path(_: impl Ctx, mut content: Table<Vector>, progress: Fraction, parameterized_distance: bool, reverse: bool) -> Table<Vector> {
1148+
async fn cut_path(_: impl Ctx, mut content: Table<Vector>, progression: Fraction, parameterized_distance: bool, reverse: bool) -> Table<Vector> {
11491149
let euclidian = !parameterized_distance;
11501150

11511151
let bezpaths = content
@@ -1155,7 +1155,7 @@ async fn cut_path(_: impl Ctx, mut content: Table<Vector>, progress: Fraction, p
11551155
.collect::<Vec<_>>();
11561156

11571157
let bezpath_count = bezpaths.len() as f64;
1158-
let t_value = progress.clamp(0., bezpath_count);
1158+
let t_value = progression.clamp(0., bezpath_count);
11591159
let t_value = if reverse { bezpath_count - t_value } else { t_value };
11601160
let index = if t_value >= bezpath_count { (bezpath_count - 1.) as usize } else { t_value as usize };
11611161

@@ -1241,16 +1241,16 @@ async fn cut_segments(_: impl Ctx, mut content: Table<Vector>) -> Table<Vector>
12411241
content
12421242
}
12431243

1244-
/// Determines the position of a point on the path, given by its progress from 0 to 1 along the path.
1244+
/// Determines the position of a point on the path, given by its progression from 0 to 1 along the path.
12451245
///
1246-
/// If multiple subpaths make up the path, the whole number part of the progress value selects the subpath and the decimal part determines the position along it.
1246+
/// If multiple subpaths make up the path, the whole number part of the progression value selects the subpath and the decimal part determines the position along it.
12471247
#[node_macro::node(name("Position on Path"), category("Vector: Measure"), path(graphene_core::vector))]
12481248
async fn position_on_path(
12491249
_: impl Ctx,
12501250
/// The path to traverse.
12511251
content: Table<Vector>,
12521252
/// The factor from the start to the end of the path, 0–1 for one subpath, 1–2 for a second subpath, and so on.
1253-
progress: Fraction,
1253+
progression: Fraction,
12541254
/// Swap the direction of the path.
12551255
reverse: bool,
12561256
/// Traverse the path using each segment's Bézier curve parameterization instead of the Euclidean distance. Faster to compute but doesn't respect actual distances.
@@ -1266,12 +1266,12 @@ async fn position_on_path(
12661266
})
12671267
.collect::<Vec<_>>();
12681268
let bezpath_count = bezpaths.len() as f64;
1269-
let progress = progress.clamp(0., bezpath_count);
1270-
let progress = if reverse { bezpath_count - progress } else { progress };
1271-
let index = if progress >= bezpath_count { (bezpath_count - 1.) as usize } else { progress as usize };
1269+
let progression = progression.clamp(0., bezpath_count);
1270+
let progression = if reverse { bezpath_count - progression } else { progression };
1271+
let index = if progression >= bezpath_count { (bezpath_count - 1.) as usize } else { progression as usize };
12721272

12731273
bezpaths.get_mut(index).map_or(DVec2::ZERO, |(bezpath, transform)| {
1274-
let t = if progress == bezpath_count { 1. } else { progress.fract() };
1274+
let t = if progression == bezpath_count { 1. } else { progression.fract() };
12751275
let t = if euclidian { TValue::Euclidean(t) } else { TValue::Parametric(t) };
12761276

12771277
bezpath.apply_affine(Affine::new(transform.to_cols_array()));
@@ -1280,16 +1280,16 @@ async fn position_on_path(
12801280
})
12811281
}
12821282

1283-
/// Determines the angle of the tangent at a point on the path, given by its progress from 0 to 1 along the path.
1283+
/// Determines the angle of the tangent at a point on the path, given by its progression from 0 to 1 along the path.
12841284
///
1285-
/// If multiple subpaths make up the path, the whole number part of the progress value selects the subpath and the decimal part determines the position along it.
1285+
/// If multiple subpaths make up the path, the whole number part of the progression value selects the subpath and the decimal part determines the position along it.
12861286
#[node_macro::node(name("Tangent on Path"), category("Vector: Measure"), path(graphene_core::vector))]
12871287
async fn tangent_on_path(
12881288
_: impl Ctx,
12891289
/// The path to traverse.
12901290
content: Table<Vector>,
12911291
/// The factor from the start to the end of the path, 0–1 for one subpath, 1–2 for a second subpath, and so on.
1292-
progress: Fraction,
1292+
progression: Fraction,
12931293
/// Swap the direction of the path.
12941294
reverse: bool,
12951295
/// Traverse the path using each segment's Bézier curve parameterization instead of the Euclidean distance. Faster to compute but doesn't respect actual distances.
@@ -1307,12 +1307,12 @@ async fn tangent_on_path(
13071307
})
13081308
.collect::<Vec<_>>();
13091309
let bezpath_count = bezpaths.len() as f64;
1310-
let progress = progress.clamp(0., bezpath_count);
1311-
let progress = if reverse { bezpath_count - progress } else { progress };
1312-
let index = if progress >= bezpath_count { (bezpath_count - 1.) as usize } else { progress as usize };
1310+
let progression = progression.clamp(0., bezpath_count);
1311+
let progression = if reverse { bezpath_count - progression } else { progression };
1312+
let index = if progression >= bezpath_count { (bezpath_count - 1.) as usize } else { progression as usize };
13131313

13141314
let angle = bezpaths.get_mut(index).map_or(0., |(bezpath, transform)| {
1315-
let t = if progress == bezpath_count { 1. } else { progress.fract() };
1315+
let t = if progression == bezpath_count { 1. } else { progression.fract() };
13161316
let t_value = |t: f64| if euclidian { TValue::Euclidean(t) } else { TValue::Parametric(t) };
13171317

13181318
bezpath.apply_affine(Affine::new(transform.to_cols_array()));

0 commit comments

Comments
 (0)