diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2011-12-18 12:45:52 +0000 |
|---|---|---|
| committer | Diederik van Lierop <mail@diedenrezi.nl> | 2011-12-18 12:45:52 +0000 |
| commit | 8f1c271f1e1d226061e9fe63faa40cefdd1dcd81 (patch) | |
| tree | 815228eb578c6dcb90a999eba02cfb169ce5b261 /src | |
| parent | some static code analysis stuff (cppcheck warnings) (diff) | |
| download | inkscape-8f1c271f1e1d226061e9fe63faa40cefdd1dcd81.tar.gz inkscape-8f1c271f1e1d226061e9fe63faa40cefdd1dcd81.zip | |
Refactor snap-preferences a bit more
(bzr r10780)
Diffstat (limited to 'src')
| -rw-r--r-- | src/line-snapper.cpp | 4 | ||||
| -rw-r--r-- | src/object-snapper.cpp | 8 | ||||
| -rw-r--r-- | src/seltrans.cpp | 8 | ||||
| -rw-r--r-- | src/snap-enums.h | 2 | ||||
| -rw-r--r-- | src/snap-preferences.cpp | 160 | ||||
| -rw-r--r-- | src/snap-preferences.h | 28 | ||||
| -rw-r--r-- | src/snap.cpp | 2 | ||||
| -rw-r--r-- | src/sp-namedview.cpp | 6 | ||||
| -rw-r--r-- | src/widgets/toolbox.cpp | 12 |
9 files changed, 108 insertions, 122 deletions
diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index 6a50e8485..3fb503354 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -26,7 +26,7 @@ void Inkscape::LineSnapper::freeSnap(IntermSnapResults &isr, std::vector<SPItem const *> const */*it*/, std::vector<Inkscape::SnapCandidatePoint> */*unselected_nodes*/) const { - if (!(_snap_enabled && _snapmanager->snapprefs.getSnapFrom(p.getSourceType())) ) { + if (!(_snap_enabled && _snapmanager->snapprefs.isSourceSnappable(p.getSourceType())) ) { return; } @@ -67,7 +67,7 @@ void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr, std::vector<SnapCandidatePoint> */*unselected_nodes*/) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false) { + if (_snap_enabled == false || _snapmanager->snapprefs.isSourceSnappable(p.getSourceType()) == false) { return; } diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index e7d9b774d..b1c118e92 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -130,7 +130,7 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent, // We'll only need to obtain the visual bounding box if the user preferences tell // us to, AND if we are snapping to the bounding box itself. If we're snapping to // paths only, then we can just as well use the geometric bounding box (which is faster) - SPItem::BBoxType bbox_type = (!prefs_bbox && _snapmanager->snapprefs.getSnapModeBBox()) ? + SPItem::BBoxType bbox_type = (!prefs_bbox && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY)) ? SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX; if (clip_or_mask) { // Oh oh, this will get ugly. We cannot use sp_item_i2d_affine directly because we need to @@ -368,7 +368,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, } // Consider the page border for snapping - if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_BORDER) && _snapmanager->snapprefs.getSnapModeAny()) { + if (_snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PAGE_BORDER) && _snapmanager->snapprefs.isAnyCategorySnappable()) { Geom::PathVector *border_path = _getBorderPathv(); if (border_path != NULL) { _paths_to_snap_to->push_back(SnapCandidatePath(border_path, SNAPTARGET_PAGE_BORDER, Geom::OptRect())); @@ -687,7 +687,7 @@ void Inkscape::ObjectSnapper::freeSnap(IntermSnapResults &isr, std::vector<SPItem const *> const *it, std::vector<SnapCandidatePoint> *unselected_nodes) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { + if (_snap_enabled == false || _snapmanager->snapprefs.isSourceSnappable(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { return; } @@ -728,7 +728,7 @@ void Inkscape::ObjectSnapper::constrainedSnap( IntermSnapResults &isr, std::vector<SPItem const *> const *it, std::vector<SnapCandidatePoint> *unselected_nodes) const { - if (_snap_enabled == false || _snapmanager->snapprefs.getSnapFrom(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { + if (_snap_enabled == false || _snapmanager->snapprefs.isSourceSnappable(p.getSourceType()) == false || ThisSnapperMightSnap() == false) { return; } diff --git a/src/seltrans.cpp b/src/seltrans.cpp index cb8270bf2..9439ed0ac 100644 --- a/src/seltrans.cpp +++ b/src/seltrans.cpp @@ -321,7 +321,7 @@ void Inkscape::SelTrans::grab(Geom::Point const &p, gdouble x, gdouble y, bool s _bbox_points.clear(); // Collect the bounding box's corners and midpoints for each selected item - if (m.snapprefs.getSnapModeBBox()) { + if (m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY)) { bool c = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CORNER); bool mp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_MIDPOINT); bool emp = m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_EDGE_MIDPOINT); @@ -1603,11 +1603,13 @@ void Inkscape::SelTrans::_keepClosestPointOnly(Geom::Point const &p) { SnapManager const &m = _desktop->namedview->snap_manager; - if (!(m.snapprefs.getSnapModeNode() || m.snapprefs.getSnapModeOthers() || m.snapprefs.getSnapModeDatums())) { + // If we're not going to snap nodes, then we might just as well get rid of their snappoints right away + if (!(m.snapprefs.isTargetSnappable(SNAPTARGET_NODE_CATEGORY, SNAPTARGET_OTHERS_CATEGORY) || m.snapprefs.isAnyDatumSnappable())) { _snap_points.clear(); } - if (!m.snapprefs.getSnapModeBBox()) { + // If we're not going to snap bounding boxes, then we might just as well get rid of their snappoints right away + if (!m.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY)) { _bbox_points.clear(); } diff --git a/src/snap-enums.h b/src/snap-enums.h index 15d35092c..df1324001 100644 --- a/src/snap-enums.h +++ b/src/snap-enums.h @@ -4,7 +4,7 @@ * Authors: * Diederik van Lierop <mail@diedenrezi.nl> * - * Copyright (C) 2010 Authors + * Copyright (C) 2010 - 2011 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ diff --git a/src/snap-preferences.cpp b/src/snap-preferences.cpp index 50bb8ef2c..f3df788c9 100644 --- a/src/snap-preferences.cpp +++ b/src/snap-preferences.cpp @@ -24,100 +24,39 @@ Inkscape::SnapPreferences::SnapPreferences() : g_assert((SNAPTARGET_DATUMS_CATEGORY != 0) && !(SNAPTARGET_DATUMS_CATEGORY & (SNAPTARGET_DATUMS_CATEGORY - 1))); g_assert((SNAPTARGET_OTHERS_CATEGORY != 0) && !(SNAPTARGET_OTHERS_CATEGORY & (SNAPTARGET_OTHERS_CATEGORY - 1))); - setSnapFrom(SnapSourceType(SNAPSOURCE_BBOX_CATEGORY | SNAPSOURCE_NODE_CATEGORY | SNAPSOURCE_DATUMS_CATEGORY | SNAPSOURCE_OTHERS_CATEGORY), true); //Snap any point. In v0.45 and earlier, this was controlled in the preferences tab - for (int n = 0; n < Inkscape::SNAPTARGET_MAX_ENUM_VALUE; n++) { + for (int n = 0; n < SNAPTARGET_MAX_ENUM_VALUE; n++) { _active_snap_targets[n] = -1; } } -/* - * The snappers have too many parameters to adjust individually. Therefore only - * three snapping modes are presented to the user: snapping bounding box corners (to - * other bounding boxes, grids or guides), and/or snapping nodes (to other nodes, - * paths, grids or guides), and or snapping to/from others (e.g. grids, guide, text, etc) - * To select either of these three modes (or all), use the - * methods defined below: setSnapModeBBox(), setSnapModeNode(), or setSnapModeOthers() - * - * */ - - -void Inkscape::SnapPreferences::setSnapModeBBox(bool enabled) -{ - if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_BBOX_CATEGORY); - } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_BBOX_CATEGORY); - } - setTargetSnappable(SNAPTARGET_BBOX_CATEGORY, enabled); -} - -bool Inkscape::SnapPreferences::getSnapModeBBox() const -{ - return (_snap_from & Inkscape::SNAPSOURCE_BBOX_CATEGORY); -} - -void Inkscape::SnapPreferences::setSnapModeNode(bool enabled) -{ - if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_NODE_CATEGORY); - } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_NODE_CATEGORY); - } - setTargetSnappable(SNAPTARGET_NODE_CATEGORY, enabled); -} - -bool Inkscape::SnapPreferences::getSnapModeNode() const -{ - return (_snap_from & Inkscape::SNAPSOURCE_NODE_CATEGORY); -} - -void Inkscape::SnapPreferences::setSnapModeOthers(bool enabled) -{ - if (enabled) { - _snap_from = SnapSourceType(_snap_from | Inkscape::SNAPSOURCE_OTHERS_CATEGORY); - } else { - _snap_from = SnapSourceType(_snap_from & ~Inkscape::SNAPSOURCE_OTHERS_CATEGORY); - } - setTargetSnappable(SNAPTARGET_OTHERS_CATEGORY, enabled); -} - -bool Inkscape::SnapPreferences::getSnapModeOthers() const -{ - return (_snap_from & Inkscape::SNAPSOURCE_OTHERS_CATEGORY); -} - -bool Inkscape::SnapPreferences::getSnapModeDatums() const +bool Inkscape::SnapPreferences::isAnyDatumSnappable() const { - return isTargetSnappable(Inkscape::SNAPTARGET_GUIDE); + return isTargetSnappable(SNAPTARGET_GUIDE, SNAPTARGET_GRID, SNAPTARGET_PAGE_BORDER); } -bool Inkscape::SnapPreferences::getSnapModeAny() const +bool Inkscape::SnapPreferences::isAnyCategorySnappable() const { - return (_snap_from != 0); + return isTargetSnappable(SNAPTARGET_NODE_CATEGORY, SNAPTARGET_BBOX_CATEGORY, SNAPTARGET_OTHERS_CATEGORY) || isTargetSnappable(SNAPTARGET_GUIDE, SNAPTARGET_GRID, SNAPTARGET_PAGE_BORDER); } -void Inkscape::SnapPreferences::setSnapFrom(Inkscape::SnapSourceType t, bool s) +void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const { - if (s) { - _snap_from = SnapSourceType(_snap_from | t); - } else { - _snap_from = SnapSourceType(_snap_from & ~t); + if (target == SNAPTARGET_BBOX_CATEGORY || + target == SNAPTARGET_NODE_CATEGORY || + target == SNAPTARGET_OTHERS_CATEGORY || + target == SNAPTARGET_DATUMS_CATEGORY) { + // These main targets should be handled separately, because otherwise we might call isTargetSnappable() + // for them (to check whether the corresponding group is on) which would lead to an infinite recursive loop + always_on = (target == SNAPTARGET_DATUMS_CATEGORY); + group_on = true; + return; } -} - -bool Inkscape::SnapPreferences::getSnapFrom(Inkscape::SnapSourceType t) const -{ - return (_snap_from & t); -} -void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType &target, bool &always_on, bool &group_on) const -{ if (target & SNAPTARGET_BBOX_CATEGORY) { - group_on = getSnapModeBBox(); // Only if the group with bbox sources/targets has been enabled, then we might snap to any of the bbox targets - + group_on = isTargetSnappable(SNAPTARGET_BBOX_CATEGORY); // Only if the group with bbox sources/targets has been enabled, then we might snap to any of the bbox targets } else if (target & SNAPTARGET_NODE_CATEGORY) { - group_on = getSnapModeNode(); // Only if the group with path/node sources/targets has been enabled, then we might snap to any of the nodes/paths + group_on = isTargetSnappable(SNAPTARGET_NODE_CATEGORY); // Only if the group with path/node sources/targets has been enabled, then we might snap to any of the nodes/paths if (target == SNAPTARGET_RECT_CORNER) { target = SNAPTARGET_NODE_CUSP; } else if (target == SNAPTARGET_ELLIPSE_QUADRANT_POINT) { @@ -162,7 +101,7 @@ void Inkscape::SnapPreferences::_mapTargetToArrayIndex(Inkscape::SnapTargetType } else if (target & SNAPTARGET_OTHERS_CATEGORY) { // Only if the group with "other" snap sources/targets has been enabled, then we might snap to any of those targets // ... but this doesn't hold for the page border, grids, and guides - group_on = getSnapModeOthers(); + group_on = isTargetSnappable(SNAPTARGET_OTHERS_CATEGORY); switch (target) { // Some snap targets don't have their own toggle. These targets are called "secondary targets". We will re-map // them to their cousin which does have a toggle, and which is called a "primary target" @@ -281,6 +220,69 @@ bool Inkscape::SnapPreferences::isSnapButtonEnabled(Inkscape::SnapTargetType con return false; } +Inkscape::SnapTargetType Inkscape::SnapPreferences::source2target(Inkscape::SnapSourceType source) const +{ + switch (source) + { + case SNAPSOURCE_UNDEFINED: + return SNAPTARGET_UNDEFINED; + case SNAPSOURCE_BBOX_CATEGORY: + return SNAPTARGET_BBOX_CATEGORY; + case SNAPSOURCE_BBOX_CORNER: + return SNAPTARGET_BBOX_CORNER; + case SNAPSOURCE_BBOX_MIDPOINT: + return SNAPTARGET_BBOX_MIDPOINT; + case SNAPSOURCE_BBOX_EDGE_MIDPOINT: + return SNAPTARGET_BBOX_EDGE_MIDPOINT; + case SNAPSOURCE_NODE_CATEGORY: + return SNAPTARGET_NODE_CATEGORY; + case SNAPSOURCE_NODE_SMOOTH: + return SNAPTARGET_NODE_SMOOTH; + case SNAPSOURCE_NODE_CUSP: + return SNAPTARGET_NODE_CUSP; + case SNAPSOURCE_LINE_MIDPOINT: + return SNAPTARGET_LINE_MIDPOINT; + case SNAPSOURCE_PATH_INTERSECTION: + return SNAPTARGET_PATH_INTERSECTION; + case SNAPSOURCE_RECT_CORNER: + return SNAPTARGET_RECT_CORNER; + case SNAPSOURCE_ELLIPSE_QUADRANT_POINT: + return SNAPTARGET_ELLIPSE_QUADRANT_POINT; + case SNAPSOURCE_DATUMS_CATEGORY: + return SNAPTARGET_DATUMS_CATEGORY; + case SNAPSOURCE_GUIDE: + return SNAPTARGET_GUIDE; + case SNAPSOURCE_GUIDE_ORIGIN: + return SNAPTARGET_GUIDE_ORIGIN; + case SNAPSOURCE_OTHERS_CATEGORY: + return SNAPTARGET_OTHERS_CATEGORY; + case SNAPSOURCE_ROTATION_CENTER: + return SNAPTARGET_ROTATION_CENTER; + case SNAPSOURCE_OBJECT_MIDPOINT: + return SNAPTARGET_OBJECT_MIDPOINT; + case SNAPSOURCE_IMG_CORNER: + return SNAPTARGET_IMG_CORNER; + case SNAPSOURCE_TEXT_ANCHOR: + return SNAPTARGET_TEXT_ANCHOR; + + case SNAPSOURCE_NODE_HANDLE: + case SNAPSOURCE_OTHER_HANDLE: + case SNAPSOURCE_CONVEX_HULL_CORNER: + // For these snapsources there doesn't exist an equivalent snap target + return SNAPTARGET_NODE_CATEGORY; + case SNAPSOURCE_GRID_PITCH: + return SNAPTARGET_GRID; + default: + g_warning("Mapping of snap source to snap target undefined"); + return SNAPTARGET_UNDEFINED; + } +} + +bool Inkscape::SnapPreferences::isSourceSnappable(Inkscape::SnapSourceType const source) const +{ + return isTargetSnappable(source2target(source)); +} + /* Local Variables: diff --git a/src/snap-preferences.h b/src/snap-preferences.h index 0db135f5d..71f6c1247 100644 --- a/src/snap-preferences.h +++ b/src/snap-preferences.h @@ -31,14 +31,11 @@ public: bool isTargetSnappable(Inkscape::SnapTargetType const target1, Inkscape::SnapTargetType const target2, Inkscape::SnapTargetType const target3, Inkscape::SnapTargetType const target4, Inkscape::SnapTargetType const target5) const; bool isSnapButtonEnabled(Inkscape::SnapTargetType const target) const; - void setSnapModeBBox(bool enabled); - void setSnapModeNode(bool enabled); - void setSnapModeOthers(bool enabled); - bool getSnapModeBBox() const; - bool getSnapModeNode() const; - bool getSnapModeDatums() const; - bool getSnapModeOthers() const; - bool getSnapModeAny() const; + SnapTargetType source2target(SnapSourceType source) const; + bool isSourceSnappable(Inkscape::SnapSourceType const source) const; + + bool isAnyDatumSnappable() const; // Needed because we cannot toggle the datum snap targets as a group + bool isAnyCategorySnappable() const; void setSnapEnabledGlobally(bool enabled) {_snap_enabled_globally = enabled;} bool getSnapEnabledGlobally() const {return _snap_enabled_globally;} @@ -46,19 +43,6 @@ public: void setSnapPostponedGlobally(bool postponed) {_snap_postponed_globally = postponed;} bool getSnapPostponedGlobally() const {return _snap_postponed_globally;} - /** - * Turn on/off snapping of specific point types. - * @param t Point type. - * @param s true to snap to this point type, otherwise false. - */ - void setSnapFrom(Inkscape::SnapSourceType t, bool s); - - /** - * @param t Point type. - * @return true if snapper will snap this type of point, otherwise false. - */ - bool getSnapFrom(Inkscape::SnapSourceType t) const; - bool getStrictSnapping() const {return _strict_snapping;} gdouble getGridTolerance() const {return _grid_tolerance;} @@ -94,8 +78,6 @@ private: bool _snap_enabled_globally; // Toggles ALL snapping bool _snap_postponed_globally; // Hold all snapping temporarily when the mouse is moving fast - SnapSourceType _snap_from; ///< bitmap of point types that we will snap from - //If enabled, then bbox corners will only snap to bboxes, //and nodes will only snap to nodes and paths. We will not //snap bbox corners to nodes, or nodes to bboxes. diff --git a/src/snap.cpp b/src/snap.cpp index 853268b4b..36d17102d 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -1124,7 +1124,7 @@ void SnapManager::displaySnapsource(Inkscape::SnapCandidatePoint const &p) const bool p_is_other = (t & Inkscape::SNAPSOURCE_OTHERS_CATEGORY) || (t & Inkscape::SNAPSOURCE_DATUMS_CATEGORY); g_assert(_desktop != NULL); - if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.getSnapModeNode()) || (p_is_a_bbox && snapprefs.getSnapModeBBox()))) { + if (snapprefs.getSnapEnabledGlobally() && (p_is_other || (p_is_a_node && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY)) || (p_is_a_bbox && snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY)))) { _desktop->snapindicator->set_new_snapsource(p); } else { _desktop->snapindicator->remove_snapsource(); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index c7d212d23..ca30ccae2 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -462,15 +462,15 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_BBOX: - nv->snap_manager.snapprefs.setSnapModeBBox(value ? sp_str_to_bool(value) : FALSE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY, value ? sp_str_to_bool(value) : FALSE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_NODE: - nv->snap_manager.snapprefs.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_OTHERS: - nv->snap_manager.snapprefs.setSnapModeOthers(value ? sp_str_to_bool(value) : TRUE); + nv->snap_manager.snapprefs.setTargetSnappable(Inkscape::SNAPTARGET_OTHERS_CATEGORY, value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp index a5d05a1e4..0638e9ca7 100644 --- a/src/widgets/toolbox.cpp +++ b/src/widgets/toolbox.cpp @@ -2134,7 +2134,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi dt->toggleSnapGlobal(); break; case SP_ATTR_INKSCAPE_SNAP_BBOX: - v = nv->snap_manager.snapprefs.getSnapModeBBox(); + v = nv->snap_manager.snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_BBOX_CATEGORY); sp_repr_set_boolean(repr, "inkscape:snap-bbox", !v); break; case SP_ATTR_INKSCAPE_SNAP_BBOX_EDGE: @@ -2146,7 +2146,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:bbox-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_NODE: - v = nv->snap_manager.snapprefs.getSnapModeNode(); + v = nv->snap_manager.snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_NODE_CATEGORY); sp_repr_set_boolean(repr, "inkscape:snap-nodes", !v); break; case SP_ATTR_INKSCAPE_SNAP_PATH: @@ -2174,7 +2174,7 @@ static void toggle_snap_callback(GtkToggleAction *act, gpointer data) //data poi sp_repr_set_boolean(repr, "inkscape:snap-intersection-paths", !v); break; case SP_ATTR_INKSCAPE_SNAP_OTHERS: - v = nv->snap_manager.snapprefs.getSnapModeOthers(); + v = nv->snap_manager.snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_OTHERS_CATEGORY); sp_repr_set_boolean(repr, "inkscape:snap-others", !v); break; case SP_ATTR_INKSCAPE_SNAP_ROTATION_CENTER: @@ -2509,7 +2509,7 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev bool const c1 = nv->snap_manager.snapprefs.getSnapEnabledGlobally(); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act1->gobj()), c1); - bool const c2 = nv->snap_manager.snapprefs.getSnapModeBBox(); + bool const c2 = nv->snap_manager.snapprefs.isTargetSnappable(SNAPTARGET_BBOX_CATEGORY); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act2->gobj()), c2); gtk_action_set_sensitive(GTK_ACTION(act2->gobj()), c1); @@ -2522,7 +2522,7 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act4c->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(SNAPTARGET_BBOX_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act4c->gobj()), c1 && c2); - bool const c3 = nv->snap_manager.snapprefs.getSnapModeNode(); + bool const c3 = nv->snap_manager.snapprefs.isTargetSnappable(SNAPTARGET_NODE_CATEGORY); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act5->gobj()), c3); gtk_action_set_sensitive(GTK_ACTION(act5->gobj()), c1); @@ -2537,7 +2537,7 @@ void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*ev gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act9->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_LINE_MIDPOINT)); gtk_action_set_sensitive(GTK_ACTION(act9->gobj()), c1 && c3); - bool const c5 = nv->snap_manager.snapprefs.getSnapModeOthers(); + bool const c5 = nv->snap_manager.snapprefs.isTargetSnappable(SNAPTARGET_OTHERS_CATEGORY); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10->gobj()), c5); gtk_action_set_sensitive(GTK_ACTION(act10->gobj()), c1); gtk_toggle_action_set_active(GTK_TOGGLE_ACTION(act10b->gobj()), nv->snap_manager.snapprefs.isSnapButtonEnabled(Inkscape::SNAPTARGET_OBJECT_MIDPOINT)); |
