diff --git a/src/rubberband.cpp b/src/rubberband.cpp index 1ff4e11fa459a64ada6fa1731329c091b1f2415f..f52e416fa5ac7d4d8fe03df63c578efc0ff862dd 100644 --- a/src/rubberband.cpp +++ b/src/rubberband.cpp @@ -135,6 +135,11 @@ void Inkscape::Rubberband::move(Geom::Point const &p) auto const &css = Handles::Manager::get().getCss()->style_map; auto const &style = css.at(Handles::TypeState{.type = _handle}); + auto mode = _mode; + if (mode == Mode::EITHERRECT) { + mode = _start.x() > _end.x() ? Mode::TOUCHRECT : Mode::RECT; + } + switch (_mode) { case Inkscape::Rubberband::Mode::RECT: if (!_rect) { diff --git a/src/rubberband.h b/src/rubberband.h index 85029aa0aaeef4ebe3f4174bf0b9192ef97255aa..bbdcbc5d71902eb19a6c19f6bf1705ab5f6cb830 100644 --- a/src/rubberband.h +++ b/src/rubberband.h @@ -38,7 +38,8 @@ public: enum class Mode { RECT, TOUCHPATH, - TOUCHRECT + TOUCHRECT, + EITHERRECT // Right to Left }; void start(SPDesktop *desktop, Geom::Point const &p, bool tolerance = false); diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index b9093e958fd1f9577d82623cf2837b057b2b5537..a5ebce5883acf1935d4e1d90018344e66c0041cc 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -2567,12 +2567,15 @@ void InkscapePreferences::initPageBehavior() _sel_inlayer_same.init ( _("Select same behaves like select all"), "/options/selection/samelikeall", false); _sel_layer_deselects.init ( _("Deselect upon layer change"), "/options/selection/layerdeselect", true); + _sel_right_to_left.init ( _("Right to left touch selection"), "/options/selection/righttoleft", false); _sel_touch_topmost_only.init ( _("Select the topmost items only when in touch selection mode"), "/options/selection/touchsel_topmost_only", true); _sel_zero_opacity.init(_("Select transparent objects, strokes, and fills"), "/options/selection/zeroopacity", false); _page_select.add_line( false, "", _sel_layer_deselects, "", _("Uncheck this to be able to keep the current objects selected when the current layer changes")); + _page_select.add_line( false, "", _sel_right_to_left, "", + _("Check this if you want to use CAD based 'cross' selection where Right to Left selections use touch selection mode.")); _page_select.add_line( false, "", _sel_zero_opacity, "", _("Check to make objects, strokes, and fills which are completely transparent selectable even if not in outline mode")); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index f9364e994be94817700eb34ee57ae9880810f96a..c4a527b91aa55f875c968c58e9a09142177f8cb3 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -399,6 +399,7 @@ protected: UI::Widget::PrefCheckButton _sel_inlayer_same; UI::Widget::PrefCheckButton _sel_touch_topmost_only; UI::Widget::PrefCheckButton _sel_layer_deselects; + UI::Widget::PrefCheckButton _sel_right_to_left; UI::Widget::PrefCheckButton _sel_cycle; UI::Widget::PrefCheckButton _sel_zero_opacity; diff --git a/src/ui/toolbar/select-toolbar.cpp b/src/ui/toolbar/select-toolbar.cpp index 53fd5283b3d85c55e06456c6d9d88a345c0b498a..bc4e290f28702bfe9de963a9eb261af60060e31d 100644 --- a/src/ui/toolbar/select-toolbar.cpp +++ b/src/ui/toolbar/select-toolbar.cpp @@ -84,6 +84,12 @@ SelectToolbar::SelectToolbar(SPDesktop *desktop) _select_touch_btn.set_active(prefs->getBool("/tools/select/touch_box", false)); _select_touch_btn.signal_toggled().connect(sigc::mem_fun(*this, &SelectToolbar::toggle_touch)); + // Hide and show the touch rectangle option when in right to left mode + _select_touch_btn.set_visible(!prefs->getBool("/options/selection/righttoleft", false)); + _prefs_oberver = prefs->createObserver("/options/selection/righttoleft", [=](const Preferences::Entry& entry) { + _select_touch_btn.set_visible(!entry.getBool()); + }); + _tracker->addUnit(Util::UnitTable::get().getUnit("%")); _tracker->setActiveUnit(desktop->getNamedView()->display_units); diff --git a/src/ui/toolbar/select-toolbar.h b/src/ui/toolbar/select-toolbar.h index f8c750dda5e1cff7e07a00affb5e61559b9cdd5b..2785a7265fa73fe20fba98d6812f1f94e3a918c3 100644 --- a/src/ui/toolbar/select-toolbar.h +++ b/src/ui/toolbar/select-toolbar.h @@ -21,6 +21,7 @@ #include #include +#include "preferences.h" #include "toolbar.h" #include "helper/auto-connection.h" @@ -73,6 +74,8 @@ private: std::vector _context_items; std::vector _connections; + Inkscape::PrefObserver _prefs_oberver; + bool _update; std::string _action_key; std::string const _action_prefix; diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp index ddcf7e2260535507ef918c4d18553a7e58364d2c..cca5b0b26607908140b0d265a0c03a9a5e5883d7 100644 --- a/src/ui/tools/select-tool.cpp +++ b/src/ui/tools/select-tool.cpp @@ -1043,9 +1043,12 @@ void SelectTool::updateDescriber(Inkscape::Selection *selection) */ std::pair SelectTool::get_default_rubberband_state() { + auto prefs = Inkscape::Preferences::get(); auto mode = Rubberband::default_mode; auto handle = Rubberband::default_handle; - if (Inkscape::Preferences::get()->getBool("/tools/select/touch_box", false)) { + if (prefs->getBool("/options/selection/righttoleft", false)) { + mode = Rubberband::Mode::EITHERRECT; + } else if (prefs->getBool("/tools/select/touch_box", false)) { mode = Rubberband::Mode::TOUCHRECT; handle = CanvasItemCtrlType::RUBBERBAND_TOUCHRECT; }