summaryrefslogtreecommitdiffstats
path: root/src/display/canvas-grid.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2007-12-12 18:50:47 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2007-12-12 18:50:47 +0000
commita26a6461f2fd95fb81baed3d2949a432b4799fdf (patch)
treeb38c1b811ccf41a142ed9320836dec73ed1d829b /src/display/canvas-grid.cpp
parentDo NOT use frames in the snapping tab in the document properties dialog ;-) (diff)
downloadinkscape-a26a6461f2fd95fb81baed3d2949a432b4799fdf.tar.gz
inkscape-a26a6461f2fd95fb81baed3d2949a432b4799fdf.zip
Toggle snapping for each grid individually
(bzr r4219)
Diffstat (limited to 'src/display/canvas-grid.cpp')
-rw-r--r--src/display/canvas-grid.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index 183b299d1..d4a78f265 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -159,7 +159,7 @@ grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
};
CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type)
- : namelabel("", Gtk::ALIGN_CENTER), visible(true), snap_enabled(true), gridtype(type)
+ : namelabel("", Gtk::ALIGN_CENTER), visible(true), gridtype(type)
{
repr = in_repr;
doc = in_doc;
@@ -336,6 +336,14 @@ CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gc
((CanvasGrid*) data)->onReprAttrChanged(repr, key, oldval, newval, is_interactive);
}
+bool CanvasGrid::isSnapEnabled()
+{
+ if (snapper == NULL) {
+ return false;
+ }
+
+ return snapper->getEnabled();
+}
// ##########################################################
// CanvasXYGrid
@@ -644,6 +652,11 @@ CanvasXYGrid::readRepr()
if ( (value = repr->attribute("visible")) ) {
visible = (strcmp(value,"true") == 0);
}
+
+ if ( (value = repr->attribute("snap_enabled")) ) {
+ g_assert(snapper != NULL);
+ snapper->setEnabled(strcmp(value,"true") == 0);
+ }
for (GSList *l = canvasitems; l != NULL; l = l->next) {
sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
@@ -685,7 +698,9 @@ CanvasXYGrid::updateWidgets()
_wr.setUpdating (true);
_rcb_visible.setActive(visible);
- _rcb_snap_enabled.setActive(snap_enabled);
+ if (snapper != NULL) {
+ _rcb_snap_enabled.setActive(snapper->getEnabled());
+ }
_rumg.setUnit (gridunit);
@@ -906,6 +921,15 @@ void CanvasXYGridSnapper::_addSnappedLine(SnappedConstraints &sc, NR::Point cons
sc.grid_lines.push_back(dummy);
}
+/**
+ * \return true if this Snapper will snap at least one kind of point.
+ */
+bool CanvasXYGridSnapper::ThisSnapperMightSnap() const
+{
+ return _named_view == NULL ? false : (_snap_enabled && _snap_from != 0);
+}
+
+