summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 972378c)
raw | patch | inline | side by side (parent: 972378c)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Fri, 3 Aug 2007 19:59:25 +0000 (19:59 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Fri, 3 Aug 2007 19:59:25 +0000 (19:59 +0000) |
diff --git a/src/attributes.cpp b/src/attributes.cpp
index 245529e61e05f17f54c44b5336bb53d2e2e2cbec..ee7ebff69fb23108a22f4266e2642daae577cdde 100644 (file)
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
{SP_ATTR_INKSCAPE_WINDOW_Y, "inkscape:window-y"},
{SP_ATTR_INKSCAPE_SNAP_BBOX, "inkscape:snap-bbox"},
{SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"},
+ {SP_ATTR_INKSCAPE_OBJECT_PATHS, "inkscape:object-paths"},
+ {SP_ATTR_INKSCAPE_OBJECT_NODES, "inkscape:object-nodes"},
{SP_ATTR_INKSCAPE_CURRENT_LAYER, "inkscape:current-layer"},
{SP_ATTR_INKSCAPE_DOCUMENT_UNITS, "inkscape:document-units"},
{SP_ATTR_INKSCAPE_CONNECTOR_SPACING, "inkscape:connector-spacing"},
diff --git a/src/attributes.h b/src/attributes.h
index bb6962304a50c4876a460b8d741fa4ef1f45b104..5eb906320bec59993dc42259c0e3abc19f458c92 100644 (file)
--- a/src/attributes.h
+++ b/src/attributes.h
SP_ATTR_INKSCAPE_WINDOW_Y,
SP_ATTR_INKSCAPE_SNAP_BBOX,
SP_ATTR_INKSCAPE_SNAP_NODES,
+ SP_ATTR_INKSCAPE_OBJECT_PATHS,
+ SP_ATTR_INKSCAPE_OBJECT_NODES,
SP_ATTR_INKSCAPE_CURRENT_LAYER,
SP_ATTR_INKSCAPE_DOCUMENT_UNITS,
SP_ATTR_INKSCAPE_CONNECTOR_SPACING,
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 1a50841c47e4bba3513e2d1c2fc97b38dfb3a022..427b7c50790d0459f351855deecc9a87e44b9df2 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
Inkscape::ObjectSnapper::ObjectSnapper(SPNamedView const *nv, NR::Coord const d)
- : Snapper(nv, d), _snap_to_itemnodes(true), _snap_to_itempaths(true),
- _snap_to_bboxnodes(true), _snap_to_bboxpaths(true), _strict_snapping(true)
+ : Snapper(nv, d), _snap_to_itemnode(true), _snap_to_itempath(true),
+ _snap_to_bboxnode(true), _snap_to_bboxpath(true), _strict_snapping(true)
{
}
// Determine the type of bounding box we should snap to
SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX;
- if (_snap_to_bboxnodes) {
+ if (_snap_to_bboxnode) {
gchar const *prefs_bbox = prefs_get_string_attribute("tools.select", "bounding_box");
bbox_type = (prefs_bbox != NULL && strcmp(prefs_bbox, "geometric")==0)? SPItem::GEOMETRIC_BBOX : SPItem::APPROXIMATE_BBOX;
}
std::list<NR::Point> points_to_snap_to;
//Collect all nodes so we can snap to them
- if (_snap_to_itemnodes) {
+ if (_snap_to_itemnode) {
if (!(_strict_snapping && !p_is_a_node)) {
if (curve) {
int j = 0;
}
//Collect the bounding box's corners so we can snap to them
- if (_snap_to_bboxnodes) {
+ if (_snap_to_bboxnode) {
if (!(_strict_snapping && p_is_a_node)) {
NR::Maybe<NR::Rect> b = sp_item_bbox_desktop(root_item, bbox_type);
if (b) {
// Determine the type of bounding box we should snap to
SPItem::BBoxType bbox_type = SPItem::GEOMETRIC_BBOX;
- if (_snap_to_bboxpaths) {
+ if (_snap_to_bboxpath) {
gchar const *prefs_bbox = prefs_get_string_attribute("tools.select", "bounding_box");
bbox_type = (prefs_bbox != NULL && strcmp(prefs_bbox, "geometric")==0)? SPItem::GEOMETRIC_BBOX : SPItem::APPROXIMATE_BBOX;
}
@@ -193,14 +193,14 @@ void Inkscape::ObjectSnapper::_snapPaths(Inkscape::Snapper::PointType const &t,
std::list<Path*> paths_to_snap_to;
//Add the item's path to snap to
- if (_snap_to_itempaths) {
+ if (_snap_to_itempath) {
if (!(_strict_snapping && !p_is_a_node)) {
paths_to_snap_to.push_back(Path_for_item(root_item, true, true));
}
}
//Add the item's bounding box to snap to
- if (_snap_to_bboxpaths) {
+ if (_snap_to_bboxpath) {
if (!(_strict_snapping && p_is_a_node)) {
//This will get ugly... rect -> curve -> bpath
NRRect rect;
@@ -255,10 +255,10 @@ Inkscape::SnappedPoint Inkscape::ObjectSnapper::_doFreeSnap(Inkscape::Snapper::P
SnappedPoint s(p, NR_HUGE);
- if (_snap_to_itemnodes || _snap_to_bboxnodes) {
+ if (_snap_to_itemnode || _snap_to_bboxnode) {
_snapNodes(t, s, p, cand);
}
- if (_snap_to_itempaths || _snap_to_bboxpaths) {
+ if (_snap_to_itempath || _snap_to_bboxpath) {
_snapPaths(t, s, p, cand);
}
@@ -283,7 +283,7 @@ Inkscape::SnappedPoint Inkscape::ObjectSnapper::_doConstrainedSnap(Inkscape::Sna
*/
bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const
{
- bool snap_to_something = _snap_to_itempaths || _snap_to_itemnodes || _snap_to_bboxpaths || _snap_to_bboxnodes;
+ bool snap_to_something = _snap_to_itempath || _snap_to_itemnode || _snap_to_bboxpath || _snap_to_bboxnode;
return (_enabled && _snap_from != 0 && snap_to_something);
}
diff --git a/src/object-snapper.h b/src/object-snapper.h
index 6556b0a243af612fefa860a35f7c120a627e91a8..a0d5f0b65d8cc7b0b801d7e00b1e91e59daeae64 100644 (file)
--- a/src/object-snapper.h
+++ b/src/object-snapper.h
public:
ObjectSnapper(SPNamedView const *nv, NR::Coord const d);
- void setSnapToItemNodes(bool s) {
- _snap_to_itemnodes = s;
+ void setSnapToItemNode(bool s) {
+ _snap_to_itemnode = s;
}
- bool getSnapToItemNodes() const {
- return _snap_to_itemnodes;
+ bool getSnapToItemNode() const {
+ return _snap_to_itemnode;
}
- void setSnapToItemPaths(bool s) {
- _snap_to_itempaths = s;
+ void setSnapToItemPath(bool s) {
+ _snap_to_itempath = s;
}
- bool getSnapToItemPaths() const {
- return _snap_to_itempaths;
+ bool getSnapToItemPath() const {
+ return _snap_to_itempath;
}
- void setSnapToBBoxNodes(bool s) {
- _snap_to_bboxnodes = s;
+ void setSnapToBBoxNode(bool s) {
+ _snap_to_bboxnode = s;
}
- bool getSnapToBBoxNodes() const {
- return _snap_to_bboxnodes;
+ bool getSnapToBBoxNode() const {
+ return _snap_to_bboxnode;
}
- void setSnapToBBoxPaths(bool s) {
- _snap_to_bboxpaths = s;
+ void setSnapToBBoxPath(bool s) {
+ _snap_to_bboxpath = s;
}
- bool getSnapToBBoxPaths() const {
- return _snap_to_bboxpaths;
+ bool getSnapToBBoxPath() const {
+ return _snap_to_bboxpath;
}
- bool setStrictSnapping(bool enabled) {
+ void setStrictSnapping(bool enabled) {
_strict_snapping = enabled;
}
NR::Point const &p,
std::list<SPItem*> const &cand) const;
- bool _snap_to_itemnodes;
- bool _snap_to_itempaths;
- bool _snap_to_bboxnodes;
- bool _snap_to_bboxpaths;
+ bool _snap_to_itemnode;
+ bool _snap_to_itempath;
+ bool _snap_to_bboxnode;
+ bool _snap_to_bboxpath;
- //if enabled, then bbox corners will only snap to bboxes,
- //and nodes will only snap to nodes and paths
+ //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.
+ //(snapping to grids and guides is not affected by this)
bool _strict_snapping;
};
diff --git a/src/snap.cpp b/src/snap.cpp
index 218cbb0293de6f42c082f78fbacd57f3e8d3e0bc..3ef246447f3a317b4d5e9b5c45cbd10b85537dbe 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
object(v, 0),
_named_view(v)
{
-
+
}
while (i != s.end() && (*i)->ThisSnapperMightSnap() == false) {
i++;
}
-
return (i != s.end());
}
+/*
+ * The snappers have too many parameters to adjust individually. Therefore only
+ * two 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). To select either of these modes (or both), use the
+ * methods defined below: setSnapModeBBox() and setSnapModeNode().
+ *
+ * */
+
+
void SnapManager::setSnapModeBBox(bool enabled)
{
+ //The default values are being set in sp_namedview_set() (in sp-namedview.cpp)
guide.setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled);
+
+ for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) {
+ Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
+ grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled);
+ }
+
object.setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled);
- object.setSnapToBBoxNodes(enabled);
- object.setSnapToBBoxPaths(enabled);
- object.setStrictSnapping(true);
+ object.setSnapToBBoxNode(enabled);
+ object.setSnapToBBoxPath(enabled);
+ object.setStrictSnapping(true); //don't snap bboxes to nodes/paths and vice versa
}
bool SnapManager::getSnapModeBBox() const
return guide.getSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX);
}
-
-void SnapManager::setSnapModeNodes(bool enabled)
+void SnapManager::setSnapModeNode(bool enabled)
{
guide.setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled);
+
+ for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) {
+ Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
+ grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled);
+ }
+
object.setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled);
- object.setSnapToItemNodes(enabled);
- object.setSnapToItemPaths(enabled);
- object.setStrictSnapping(true);
+ //object.setSnapToItemNode(enabled); // On second thought, these should be controlled
+ //object.setSnapToItemPath(enabled); // separately by the snapping prefs dialog
+ object.setStrictSnapping(true);
}
-bool SnapManager::getSnapModeNodes() const
+bool SnapManager::getSnapModeNode() const
{
return guide.getSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE);
}
diff --git a/src/snap.h b/src/snap.h
index 527947e104bf17d8973bea76b4454503e81498ac..401fd60bad1eeafa2ebd0484348b75bdae054821 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
SnapperList getGridSnappers() const;
void setSnapModeBBox(bool enabled);
- void setSnapModeNodes(bool enabled);
+ void setSnapModeNode(bool enabled);
bool getSnapModeBBox() const;
- bool getSnapModeNodes() const;
+ bool getSnapModeNode() const;
protected:
SPNamedView const *_named_view;
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 7667d07f111d22130247945a528b7327f3b77deb..af30b3ed170e8c328be361da9c36a006a560fe67 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
@@ -155,6 +155,8 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
sp_object_read_attr(object, "inkscape:window-y");
sp_object_read_attr(object, "inkscape:snap-bbox");
sp_object_read_attr(object, "inkscape:snap-nodes");
+ sp_object_read_attr(object, "inkscape:object-paths");
+ sp_object_read_attr(object, "inkscape:object-nodes");
sp_object_read_attr(object, "inkscape:current-layer");
sp_object_read_attr(object, "inkscape:connector-spacing");
@@ -345,7 +347,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_NODES:
- nv->snap_manager.setSnapModeNodes(value ? sp_str_to_bool(value) : FALSE);
+ nv->snap_manager.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ break;
+ case SP_ATTR_INKSCAPE_OBJECT_PATHS:
+ nv->snap_manager.object.setSnapToItemPath(value ? sp_str_to_bool(value) : TRUE);
+ object->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ break;
+ case SP_ATTR_INKSCAPE_OBJECT_NODES:
+ nv->snap_manager.object.setSnapToItemNode(value ? sp_str_to_bool(value) : TRUE);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_INKSCAPE_CURRENT_LAYER:
@@ -432,6 +442,11 @@ sp_namedview_add_grid(SPNamedView *nv, Inkscape::XML::Node *repr, SPDesktop *des
doc = sp_desktop_document(static_cast<SPDesktop*>(nv->views->data));
grid = Inkscape::CanvasGrid::NewGrid(nv, repr, doc, gridtype);
nv->grids = g_slist_append(nv->grids, grid);
+ //Initialize the snapping parameters for the new grid
+ bool enabled_node = nv->snap_manager.getSnapModeNode();
+ bool enabled_bbox = nv->snap_manager.getSnapModeBBox();
+ grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled_node);
+ grid->snapper->setSnapFrom(Inkscape::Snapper::SNAPPOINT_BBOX, enabled_bbox);
}
if (!desktop) {
index 3a86238526e9901b7d33b4f48cce27356e9648c2..807d4129f869309b4d24bd31540a754620a0d156 100644 (file)
DocumentProperties::build_snap()
{
_page_snap.show();
- _rcbsnbb.init (_("Snap bounding _boxes"),
+ //General options
+ _rcbsnbb.init (_("Snap bounding _box corners"),
_("Snap bounding box corners to grid lines, to guides, and to other bounding boxes"),
"inkscape:snap-bbox", _wr);
_rcbsnn.init (_("Snap _nodes"),
_("Snap nodes to grid lines, to guides, to paths, and to other nodes"),
"inkscape:snap-nodes", _wr);
- _rsu_sno.init (_("Snap s_ensitivity:"), _("Always snap"),
+
+ //Options for snapping to objects
+ _rcbsnop.init (_("Snap to _paths"),
+ _("Snap nodes to object paths"),
+ "inkscape:object-paths", _wr);
+ _rcbsnon.init (_("Snap to n_odes"),
+ _("Snap nodes to object nodes"),
+ "inkscape:object-nodes", _wr);
+ _rsu_sno.init (_(" Snap _distance"), _("Snap at any dist_ance"),
_("Snapping distance, in screen pixels, for snapping to objects"),
_("If set, objects snap to the nearest object, regardless of distance"),
"objecttolerance", _wr);
- _rsu_sn.init (_("Snap sens_itivity:"), _("Always snap"),
+
+ //Options for snapping to grids
+ _rsu_sn.init (_(" Snap d_istance"), _("Snap at any distan_ce"),
_("Snapping distance, in screen pixels, for snapping to grid"),
_("If set, objects snap to the nearest grid line, regardless of distance"),
"gridtolerance", _wr);
- _rsu_gusn.init (_("Snap sensiti_vity:"), _("Always snap"),
+
+ //Options for snapping to guides
+ _rsu_gusn.init (_(" Snap di_stance"), _("Snap at any distanc_e"),
_("Snapping distance, in screen pixels, for snapping to guides"),
_("If set, objects snap to the nearest guide, regardless of distance"),
"guidetolerance", _wr);
+
Gtk::Label *label_g = manage (new Gtk::Label);
label_g->set_markup (_("<b>General</b>"));
Gtk::Label *label_o = manage (new Gtk::Label);
Gtk::Widget *const array[] =
{
label_g, 0,
+ 0, _rcbsnn._button,
0, _rcbsnbb._button,
- 0, _rcbsnn._button,
+ 0, 0,
label_o, 0,
+ 0, _rcbsnop._button,
+ 0, _rcbsnon._button,
0, _rsu_sno._vbox,
0, 0,
label_gr, 0,
//-----------------------------------------------------------snap
_rcbsnbb.setActive (nv->snap_manager.getSnapModeBBox());
- _rcbsnn.setActive (nv->snap_manager.getSnapModeNodes());
+ _rcbsnn.setActive (nv->snap_manager.getSnapModeNode());
+ _rcbsnop.setActive(nv->snap_manager.object.getSnapToItemPath());
+ _rcbsnon.setActive(nv->snap_manager.object.getSnapToItemNode());
_rsu_sno.setValue (nv->objecttolerance);
_rsu_sn.setValue (nv->gridtolerance);
index f405e71a3642ee4a3439926b3a9caf050bb6ddb6..d2f8776e4a3154ab5d6cdb92e1e5114fbbe5a219 100644 (file)
RegisteredUnitMenu _rum_gusn;
RegisteredColorPicker _rcp_gui, _rcp_hgui;
//---------------------------------------------------------------
- RegisteredCheckButton _rcbsnbb, _rcbsnn;
+ RegisteredCheckButton _rcbsnbb, _rcbsnn, _rcbsnop, _rcbsnon;
RegisteredUnitMenu _rumso;
ToleranceSlider _rsu_sno, _rsu_sn, _rsu_gusn;
RegisteredRadioButtonPair _rrb_pix;
index f9a991c245694657771ccda5463a59611cb26684..92a6f76bb2400a9224f552098209dfeb622840da 100644 (file)
void
ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& key, Registry& wr)
{
+ // hbox = label + slider
+ //
+ // e.g.
+ //
+ // snap distance |-------X---| 37
+
+ // vbox = checkbutton
+ // +
+ // hbox
+
_vbox = new Gtk::VBox;
_hbox = manage (new Gtk::HBox);
+
Gtk::Label *theLabel1 = manage (new Gtk::Label (label1));
theLabel1->set_use_underline();
+ theLabel1->set_alignment(0, 0.5);
_hbox->add (*theLabel1);
_hscale = manage (new Gtk::HScale (1.0, 51, 1.0));
theLabel1->set_mnemonic_widget (*_hscale);
@@ -69,15 +81,17 @@ ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2,
_old_val = 10;
_hscale->set_value (_old_val);
_tt.set_tip (*_hscale, tip1);
- _hbox->add (*_hscale);
- _vbox->add (*_hbox);
+ _hbox->add (*_hscale);
+
Gtk::Label *theLabel2 = manage (new Gtk::Label (label2));
theLabel2->set_use_underline();
_button = manage (new Gtk::CheckButton);
_tt.set_tip (*_button, tip2);
_button->add (*theLabel2);
_button->set_alignment (0.0, 0.5);
+
_vbox->add (*_button);
+ _vbox->add (*_hbox);
_key = key;
_scale_changed_connection = _hscale->signal_value_changed().connect (sigc::mem_fun (*this, &ToleranceSlider::on_scale_changed));
_btn_toggled_connection = _button->signal_toggled().connect (sigc::mem_fun (*this, &ToleranceSlider::on_toggled));