mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 03:38:12 +08:00
Add space key & drag to pan the canvas (#364)
This commit is contained in:
committed by
Keavon Chambers
parent
6b274b3f1c
commit
4f871919f5
@@ -24,7 +24,7 @@ pub enum MovementMessage {
|
|||||||
EnableSnapping,
|
EnableSnapping,
|
||||||
DisableSnapping,
|
DisableSnapping,
|
||||||
ZoomCanvasBegin,
|
ZoomCanvasBegin,
|
||||||
TranslateCanvasEnd,
|
TransformCanvasEnd,
|
||||||
SetCanvasRotation(f64),
|
SetCanvasRotation(f64),
|
||||||
SetCanvasZoom(f64),
|
SetCanvasZoom(f64),
|
||||||
IncreaseCanvasZoom,
|
IncreaseCanvasZoom,
|
||||||
@@ -79,7 +79,7 @@ impl MessageHandler<MovementMessage, (&mut LayerData, &Document, &InputPreproces
|
|||||||
self.zooming = true;
|
self.zooming = true;
|
||||||
self.mouse_pos = ipp.mouse.position;
|
self.mouse_pos = ipp.mouse.position;
|
||||||
}
|
}
|
||||||
TranslateCanvasEnd => {
|
TransformCanvasEnd => {
|
||||||
layerdata.rotation = layerdata.snapped_angle();
|
layerdata.rotation = layerdata.snapped_angle();
|
||||||
layerdata.snap_rotate = false;
|
layerdata.snap_rotate = false;
|
||||||
self.translating = false;
|
self.translating = false;
|
||||||
@@ -221,7 +221,6 @@ impl MessageHandler<MovementMessage, (&mut LayerData, &Document, &InputPreproces
|
|||||||
fn actions(&self) -> ActionList {
|
fn actions(&self) -> ActionList {
|
||||||
let mut common = actions!(MovementMessageDiscriminant;
|
let mut common = actions!(MovementMessageDiscriminant;
|
||||||
MouseMove,
|
MouseMove,
|
||||||
TranslateCanvasEnd,
|
|
||||||
TranslateCanvasBegin,
|
TranslateCanvasBegin,
|
||||||
RotateCanvasBegin,
|
RotateCanvasBegin,
|
||||||
ZoomCanvasBegin,
|
ZoomCanvasBegin,
|
||||||
@@ -243,6 +242,12 @@ impl MessageHandler<MovementMessage, (&mut LayerData, &Document, &InputPreproces
|
|||||||
);
|
);
|
||||||
common.extend(snapping);
|
common.extend(snapping);
|
||||||
}
|
}
|
||||||
|
if self.translating || self.rotating || self.zooming {
|
||||||
|
let transforming = actions!(MovementMessageDiscriminant;
|
||||||
|
TransformCanvasEnd,
|
||||||
|
);
|
||||||
|
common.extend(transforming);
|
||||||
|
}
|
||||||
common
|
common
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -208,7 +208,9 @@ impl Default for Mapping {
|
|||||||
entry! {action=MovementMessage::ZoomCanvasBegin, key_down=Mmb, modifiers=[KeyShift]},
|
entry! {action=MovementMessage::ZoomCanvasBegin, key_down=Mmb, modifiers=[KeyShift]},
|
||||||
entry! {action=MovementMessage::ZoomCanvasToFitAll, key_down=Key0, modifiers=[KeyControl]},
|
entry! {action=MovementMessage::ZoomCanvasToFitAll, key_down=Key0, modifiers=[KeyControl]},
|
||||||
entry! {action=MovementMessage::TranslateCanvasBegin, key_down=Mmb},
|
entry! {action=MovementMessage::TranslateCanvasBegin, key_down=Mmb},
|
||||||
entry! {action=MovementMessage::TranslateCanvasEnd, key_up=Mmb},
|
entry! {action=MovementMessage::TransformCanvasEnd, key_up=Mmb},
|
||||||
|
entry! {action=MovementMessage::TranslateCanvasBegin, key_down=Lmb, modifiers=[KeySpace]},
|
||||||
|
entry! {action=MovementMessage::TransformCanvasEnd, key_up=Lmb, modifiers=[KeySpace]},
|
||||||
entry! {action=MovementMessage::IncreaseCanvasZoom, key_down=KeyPlus, modifiers=[KeyControl]},
|
entry! {action=MovementMessage::IncreaseCanvasZoom, key_down=KeyPlus, modifiers=[KeyControl]},
|
||||||
entry! {action=MovementMessage::IncreaseCanvasZoom, key_down=KeyEquals, modifiers=[KeyControl]},
|
entry! {action=MovementMessage::IncreaseCanvasZoom, key_down=KeyEquals, modifiers=[KeyControl]},
|
||||||
entry! {action=MovementMessage::DecreaseCanvasZoom, key_down=KeyMinus, modifiers=[KeyControl]},
|
entry! {action=MovementMessage::DecreaseCanvasZoom, key_down=KeyMinus, modifiers=[KeyControl]},
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ pub enum Key {
|
|||||||
KeyMinus,
|
KeyMinus,
|
||||||
KeyPlus,
|
KeyPlus,
|
||||||
KeyShift,
|
KeyShift,
|
||||||
|
KeySpace,
|
||||||
KeyControl,
|
KeyControl,
|
||||||
KeyDelete,
|
KeyDelete,
|
||||||
KeyBackspace,
|
KeyBackspace,
|
||||||
|
|||||||
@@ -137,6 +137,7 @@ pub fn translate_key(name: &str) -> Key {
|
|||||||
"shift" => KeyShift,
|
"shift" => KeyShift,
|
||||||
// When using linux + chrome + the neo keyboard layout, the shift key is recognized as caps
|
// When using linux + chrome + the neo keyboard layout, the shift key is recognized as caps
|
||||||
"capslock" => KeyShift,
|
"capslock" => KeyShift,
|
||||||
|
" " => KeySpace,
|
||||||
"control" => KeyControl,
|
"control" => KeyControl,
|
||||||
"delete" => KeyDelete,
|
"delete" => KeyDelete,
|
||||||
"backspace" => KeyBackspace,
|
"backspace" => KeyBackspace,
|
||||||
|
|||||||
Reference in New Issue
Block a user