diff --git a/crates/rnote-compose/src/penevent.rs b/crates/rnote-compose/src/penevent.rs index 9683e44566..83f5aedc89 100644 --- a/crates/rnote-compose/src/penevent.rs +++ b/crates/rnote-compose/src/penevent.rs @@ -130,6 +130,12 @@ pub enum ShortcutKey { /// Secondary mouse button. #[serde(rename = "mouse_secondary_button")] MouseSecondaryButton, + /// Backward mouse button. + #[serde(rename = "mouse_backward_button")] + MouseBackwardButton, + /// Forward mouse button. + #[serde(rename = "mouse_forward_button")] + MouseForwardButton, /// Touch two finger long press gesture. #[serde(rename = "touch_two_finger_long_press")] TouchTwoFingerLongPress, diff --git a/crates/rnote-engine/src/pens/shortcuts.rs b/crates/rnote-engine/src/pens/shortcuts.rs index ab17304439..5a736a35bd 100644 --- a/crates/rnote-engine/src/pens/shortcuts.rs +++ b/crates/rnote-engine/src/pens/shortcuts.rs @@ -80,6 +80,20 @@ impl Default for Shortcuts { mode: ShortcutMode::Temporary, }, ); + map.insert( + ShortcutKey::MouseBackwardButton, + ShortcutAction::ChangePenStyle { + style: PenStyle::Selector, + mode: ShortcutMode::Toggle, + }, + ); + map.insert( + ShortcutKey::MouseForwardButton, + ShortcutAction::ChangePenStyle { + style: PenStyle::Typewriter, + mode: ShortcutMode::Toggle, + }, + ); map.insert( ShortcutKey::TouchTwoFingerLongPress, ShortcutAction::ChangePenStyle { diff --git a/crates/rnote-ui/data/icons/scalable/actions/mouse-button-backward-symbolic.svg b/crates/rnote-ui/data/icons/scalable/actions/mouse-button-backward-symbolic.svg new file mode 100644 index 0000000000..26bee3c303 --- /dev/null +++ b/crates/rnote-ui/data/icons/scalable/actions/mouse-button-backward-symbolic.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/crates/rnote-ui/data/icons/scalable/actions/mouse-button-forward-symbolic.svg b/crates/rnote-ui/data/icons/scalable/actions/mouse-button-forward-symbolic.svg new file mode 100644 index 0000000000..6f5de1c419 --- /dev/null +++ b/crates/rnote-ui/data/icons/scalable/actions/mouse-button-forward-symbolic.svg @@ -0,0 +1,8 @@ + + + + + diff --git a/crates/rnote-ui/data/meson.build b/crates/rnote-ui/data/meson.build index b1ae9b76b9..73fadc5c6b 100644 --- a/crates/rnote-ui/data/meson.build +++ b/crates/rnote-ui/data/meson.build @@ -215,6 +215,8 @@ rnote_ui_gresources_icons_files = files( 'icons/scalable/actions/misc-menu-symbolic.svg', 'icons/scalable/actions/mouse-button-primary-symbolic.svg', 'icons/scalable/actions/mouse-button-secondary-symbolic.svg', + 'icons/scalable/actions/mouse-button-backward-symbolic.svg', + 'icons/scalable/actions/mouse-button-forward-symbolic.svg', 'icons/scalable/actions/pen-brush-style-marker-symbolic.svg', 'icons/scalable/actions/pen-brush-style-solid-symbolic.svg', 'icons/scalable/actions/pen-brush-style-textured-symbolic.svg', diff --git a/crates/rnote-ui/data/resources.gresource.xml b/crates/rnote-ui/data/resources.gresource.xml index a1deb7af1f..078545ddc4 100644 --- a/crates/rnote-ui/data/resources.gresource.xml +++ b/crates/rnote-ui/data/resources.gresource.xml @@ -84,6 +84,8 @@ icons/scalable/actions/misc-menu-symbolic.svg icons/scalable/actions/mouse-button-primary-symbolic.svg icons/scalable/actions/mouse-button-secondary-symbolic.svg + icons/scalable/actions/mouse-button-backward-symbolic.svg + icons/scalable/actions/mouse-button-forward-symbolic.svg icons/scalable/actions/pen-brush-style-marker-symbolic.svg icons/scalable/actions/pen-brush-style-solid-symbolic.svg icons/scalable/actions/pen-brush-style-symbolic.svg diff --git a/crates/rnote-ui/data/ui/settingspanel.ui b/crates/rnote-ui/data/ui/settingspanel.ui index e1c205a8e7..8935cc31a3 100644 --- a/crates/rnote-ui/data/ui/settingspanel.ui +++ b/crates/rnote-ui/data/ui/settingspanel.ui @@ -439,6 +439,32 @@ secondary mouse button + + + Mouse Backward Button Action + Set the action for the +backward mouse button + + + mouse-button-backward-symbolic + large + + + + + + + Mouse Forward Button Action + Set the action for the +forward mouse button + + + mouse-button-forward-symbolic + large + + + + Touch Two-Finger Long-Press Action diff --git a/crates/rnote-ui/src/canvas/input.rs b/crates/rnote-ui/src/canvas/input.rs index e0f0967d80..1a90fc4b95 100644 --- a/crates/rnote-ui/src/canvas/input.rs +++ b/crates/rnote-ui/src/canvas/input.rs @@ -71,7 +71,13 @@ pub(crate) fn handle_pointer_controller_event( } } else { #[allow(clippy::collapsible_else_if)] - if gdk_button == gdk::BUTTON_PRIMARY || gdk_button == gdk::BUTTON_SECONDARY { + if gdk_button == gdk::BUTTON_PRIMARY + || gdk_button == gdk::BUTTON_SECONDARY + // Backward Button + || gdk_button == 8 + // Forward Button + || gdk_button == 9 + { handle_pen_event = true; handle_shortcut_key = true; pen_state = PenState::Down; @@ -121,7 +127,13 @@ pub(crate) fn handle_pointer_controller_event( } } else { #[allow(clippy::collapsible_else_if)] - if gdk_button == gdk::BUTTON_PRIMARY || gdk_button == gdk::BUTTON_SECONDARY { + if gdk_button == gdk::BUTTON_PRIMARY + || gdk_button == gdk::BUTTON_SECONDARY + // Backward Button + || gdk_button == 8 + // Forward Button + || gdk_button == 9 + { pen_state = PenState::Up; handle_pen_event = true; } @@ -423,6 +435,8 @@ pub(crate) fn retrieve_button_shortcut_key( match (is_stylus, gdk_button) { (_, gdk::BUTTON_PRIMARY) => None, (false, gdk::BUTTON_SECONDARY) => Some(ShortcutKey::MouseSecondaryButton), + (false, 8) => Some(ShortcutKey::MouseBackwardButton), + (false, 9) => Some(ShortcutKey::MouseForwardButton), (true, gdk::BUTTON_SECONDARY) => Some(ShortcutKey::StylusPrimaryButton), (true, gdk::BUTTON_MIDDLE) => Some(ShortcutKey::StylusSecondaryButton), (_, _) => None, diff --git a/crates/rnote-ui/src/settingspanel/mod.rs b/crates/rnote-ui/src/settingspanel/mod.rs index f2a3a0923c..f87d08e47f 100644 --- a/crates/rnote-ui/src/settingspanel/mod.rs +++ b/crates/rnote-ui/src/settingspanel/mod.rs @@ -102,6 +102,10 @@ mod imp { #[template_child] pub(crate) penshortcut_mouse_button_secondary_row: TemplateChild, #[template_child] + pub(crate) penshortcut_mouse_button_backward_row: TemplateChild, + #[template_child] + pub(crate) penshortcut_mouse_button_forward_row: TemplateChild, + #[template_child] pub(crate) penshortcut_touch_two_finger_long_press_row: TemplateChild, #[template_child] pub(crate) penshortcut_keyboard_ctrl_space_row: TemplateChild, @@ -431,6 +435,12 @@ impl RnSettingsPanel { imp.penshortcut_mouse_button_secondary_row .set_action(action); } + ShortcutKey::MouseBackwardButton => { + imp.penshortcut_mouse_button_backward_row.set_action(action); + } + ShortcutKey::MouseForwardButton => { + imp.penshortcut_mouse_button_forward_row.set_action(action); + } ShortcutKey::TouchTwoFingerLongPress => { imp.penshortcut_touch_two_finger_long_press_row .set_action(action); @@ -765,6 +775,8 @@ impl RnSettingsPanel { imp.penshortcut_stylus_button_secondary_row.get(); let penshortcut_mouse_button_secondary_row = imp.penshortcut_mouse_button_secondary_row.get(); + let penshortcut_mouse_button_backward_row = imp.penshortcut_mouse_button_backward_row.get(); + let penshortcut_mouse_button_forward_row = imp.penshortcut_mouse_button_forward_row.get(); let penshortcut_touch_two_finger_long_press_row = imp.penshortcut_touch_two_finger_long_press_row.get(); let penshortcut_keyboard_ctrl_space_row = imp.penshortcut_keyboard_ctrl_space_row.get(); @@ -791,6 +803,18 @@ impl RnSettingsPanel { None })); + imp.penshortcut_mouse_button_backward_row.connect_local("action-changed", false, clone!(@weak penshortcut_mouse_button_backward_row, @weak appwindow => @default-return None, move |_values| { + let action = penshortcut_mouse_button_backward_row.action(); + appwindow.active_tab_wrapper().canvas().engine_mut().penholder.register_shortcut(ShortcutKey::MouseBackwardButton, action); + None + })); + + imp.penshortcut_mouse_button_forward_row.connect_local("action-changed", false, clone!(@weak penshortcut_mouse_button_forward_row, @weak appwindow => @default-return None, move |_values| { + let action = penshortcut_mouse_button_forward_row.action(); + appwindow.active_tab_wrapper().canvas().engine_mut().penholder.register_shortcut(ShortcutKey::MouseForwardButton, action); + None + })); + imp.penshortcut_touch_two_finger_long_press_row.connect_local("action-changed", false, clone!(@weak penshortcut_touch_two_finger_long_press_row, @weak appwindow => @default-return None, move |_values| { let action = penshortcut_touch_two_finger_long_press_row.action(); appwindow.active_tab_wrapper().canvas().engine_mut().penholder.register_shortcut(ShortcutKey::TouchTwoFingerLongPress, action);