Skip to content

Add space key to drag canvas #364

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions editor/src/document/movement_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub enum MovementMessage {
EnableSnapping,
DisableSnapping,
ZoomCanvasBegin,
TranslateCanvasEnd,
TransformCanvasEnd,
SetCanvasRotation(f64),
SetCanvasZoom(f64),
IncreaseCanvasZoom,
Expand Down Expand Up @@ -79,7 +79,7 @@ impl MessageHandler<MovementMessage, (&mut LayerData, &Document, &InputPreproces
self.zooming = true;
self.mouse_pos = ipp.mouse.position;
}
TranslateCanvasEnd => {
TransformCanvasEnd => {
layerdata.rotation = layerdata.snapped_angle();
layerdata.snap_rotate = false;
self.translating = false;
Expand Down Expand Up @@ -221,7 +221,6 @@ impl MessageHandler<MovementMessage, (&mut LayerData, &Document, &InputPreproces
fn actions(&self) -> ActionList {
let mut common = actions!(MovementMessageDiscriminant;
MouseMove,
TranslateCanvasEnd,
TranslateCanvasBegin,
RotateCanvasBegin,
ZoomCanvasBegin,
Expand All @@ -243,6 +242,12 @@ impl MessageHandler<MovementMessage, (&mut LayerData, &Document, &InputPreproces
);
common.extend(snapping);
}
if self.translating || self.rotating || self.zooming {
let transforming = actions!(MovementMessageDiscriminant;
TransformCanvasEnd,
);
common.extend(transforming);
}
common
}
}
4 changes: 3 additions & 1 deletion editor/src/input/input_mapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ impl Default for Mapping {
entry! {action=MovementMessage::ZoomCanvasBegin, key_down=Mmb, modifiers=[KeyShift]},
entry! {action=MovementMessage::ZoomCanvasToFitAll, key_down=Key0, modifiers=[KeyControl]},
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=KeyEquals, modifiers=[KeyControl]},
entry! {action=MovementMessage::DecreaseCanvasZoom, key_down=KeyMinus, modifiers=[KeyControl]},
Expand Down
1 change: 1 addition & 0 deletions editor/src/input/keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub enum Key {
KeyMinus,
KeyPlus,
KeyShift,
KeySpace,
KeyControl,
KeyDelete,
KeyBackspace,
Expand Down
1 change: 1 addition & 0 deletions frontend/wasm/src/wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ pub fn translate_key(name: &str) -> Key {
"shift" => KeyShift,
// When using linux + chrome + the neo keyboard layout, the shift key is recognized as caps
"capslock" => KeyShift,
" " => KeySpace,
"control" => KeyControl,
"delete" => KeyDelete,
"backspace" => KeyBackspace,
Expand Down