mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Show a "Ctrl +" label instead of "Ctrl =" for View > Zoom In (#3377)
This commit is contained in:
@@ -406,6 +406,8 @@ pub fn input_mappings() -> Mapping {
|
||||
entry!(KeyDown(MouseMiddle); action_dispatch=NavigationMessage::BeginCanvasPan),
|
||||
entry!(KeyDown(MouseLeft); modifiers=[Space], action_dispatch=NavigationMessage::BeginCanvasPan),
|
||||
entry!(KeyDown(NumpadAdd); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
|
||||
// `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.
|
||||
entry!(KeyDown(FakeKeyPlus); modifiers=[Accel], canonical, action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
|
||||
entry!(KeyDown(Equal); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
|
||||
entry!(KeyDown(Minus); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }),
|
||||
entry!(KeyDown(KeyF); modifiers=[Alt], action_dispatch=NavigationMessage::CanvasFlip),
|
||||
|
||||
@@ -61,7 +61,7 @@ pub enum Key {
|
||||
Digit7,
|
||||
Digit8,
|
||||
Digit9,
|
||||
//
|
||||
|
||||
KeyA,
|
||||
KeyB,
|
||||
KeyC,
|
||||
@@ -88,7 +88,7 @@ pub enum Key {
|
||||
KeyX,
|
||||
KeyY,
|
||||
KeyZ,
|
||||
//
|
||||
|
||||
Backquote,
|
||||
Backslash,
|
||||
BracketLeft,
|
||||
@@ -197,6 +197,8 @@ pub enum Key {
|
||||
Unidentified,
|
||||
|
||||
// Other keys that aren't part of the W3C spec
|
||||
//
|
||||
/// "Cmd" on Mac (not present on other platforms)
|
||||
Command,
|
||||
/// "Ctrl" on Windows/Linux, "Cmd" on Mac
|
||||
Accel,
|
||||
@@ -206,8 +208,14 @@ pub enum Key {
|
||||
MouseBack,
|
||||
MouseForward,
|
||||
|
||||
// This has to be the last element in the enum
|
||||
NumKeys,
|
||||
// Fake keys for displaying special labels in the UI
|
||||
//
|
||||
/// 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.
|
||||
FakeKeyPlus,
|
||||
/// 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.
|
||||
FakeKeyNumbers,
|
||||
|
||||
_KeysVariantCount, // This has to be the last element in the enum
|
||||
}
|
||||
|
||||
impl fmt::Display for Key {
|
||||
@@ -293,7 +301,10 @@ impl fmt::Display for Key {
|
||||
Self::MouseMiddle => "MMB",
|
||||
Self::MouseBack => "Mouse Back",
|
||||
Self::MouseForward => "Mouse Fwd",
|
||||
Self::NumKeys => "0–9",
|
||||
|
||||
// Fake keys for displaying special labels in the UI
|
||||
Self::FakeKeyPlus => "+",
|
||||
Self::FakeKeyNumbers => "0–9",
|
||||
|
||||
_ => key_name.as_str(),
|
||||
};
|
||||
@@ -314,7 +325,7 @@ pub struct LayoutKey {
|
||||
label: String,
|
||||
}
|
||||
|
||||
pub const NUMBER_OF_KEYS: usize = Key::NumKeys as usize;
|
||||
pub const NUMBER_OF_KEYS: usize = Key::_KeysVariantCount as usize - 1;
|
||||
|
||||
/// Only `Key`s that exist on a physical keyboard should be used.
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
|
||||
@@ -456,7 +456,7 @@ impl TransformOperation {
|
||||
}
|
||||
let mut typing_hints = vec![HintInfo::keys([Key::Minus], "Negate Direction")];
|
||||
if self.can_begin_typing() {
|
||||
typing_hints.push(HintInfo::keys([Key::NumKeys], "Enter Number"));
|
||||
typing_hints.push(HintInfo::keys([Key::FakeKeyNumbers], "Enter Number"));
|
||||
if self.is_typing() {
|
||||
typing_hints.push(HintInfo::keys([Key::Backspace], "Delete Digit"));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user