diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2009-04-25 16:57:08 +0000 |
|---|---|---|
| committer | dvlierop2 <dvlierop2@users.sourceforge.net> | 2009-04-25 16:57:08 +0000 |
| commit | 5606958cb81a4abb20aa5379d3c66184da470784 (patch) | |
| tree | 99cd4ebfa780c2e8b89de86533dad523177ead31 /src/display/canvas-grid.cpp | |
| parent | Fix missing dock icons (bug #364075) (diff) | |
| download | inkscape-5606958cb81a4abb20aa5379d3c66184da470784.tar.gz inkscape-5606958cb81a4abb20aa5379d3c66184da470784.zip | |
Optionaly snap to invisible grid lines too (when zoomed out). See the grids tab in the document properties dialog. This closes bug #172115
(bzr r7773)
Diffstat (limited to 'src/display/canvas-grid.cpp')
| -rw-r--r-- | src/display/canvas-grid.cpp | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index c971382b4..5037c0375 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -324,6 +324,12 @@ CanvasGrid::newWidget() new Inkscape::UI::Widget::RegisteredCheckButton( _("_Enabled"), _("Determines whether to snap to this grid or not. Can be 'on' for invisible grids."), "enabled", _wr, false, repr, doc) ); + + Inkscape::UI::Widget::RegisteredCheckButton * _rcb_snap_visible_only = Gtk::manage( + new Inkscape::UI::Widget::RegisteredCheckButton( _("Snap to visible _grid lines only"), + _("When zoomed out, not all grid lines will be displayed. Only the visible ones will be snapped to"), + "snapvisiblegridlinesonly", _wr, true, repr, doc) ); + Inkscape::UI::Widget::RegisteredCheckButton * _rcb_visible = Gtk::manage( new Inkscape::UI::Widget::RegisteredCheckButton( _("_Visible"), _("Determines whether the grid is displayed or not. Objects are still snapped to invisible grids."), @@ -331,11 +337,13 @@ CanvasGrid::newWidget() vbox->pack_start(*_rcb_enabled, true, true); vbox->pack_start(*_rcb_visible, true, true); + vbox->pack_start(*_rcb_snap_visible_only, true, true); Gtk::Widget * gridwdg = newSpecificWidget(); vbox->pack_start(*gridwdg, true, true); std::list<Gtk::Widget*> slaves; slaves.push_back(_rcb_visible); + slaves.push_back(_rcb_snap_visible_only); slaves.push_back(gridwdg); _rcb_enabled->setSlaveWidgets(slaves); @@ -343,6 +351,7 @@ CanvasGrid::newWidget() _rcb_visible->setActive(visible); if (snapper != NULL) { _rcb_enabled->setActive(snapper->getEnabled()); + _rcb_snap_visible_only->setActive(snapper->getSnapVisibleOnly()); } return dynamic_cast<Gtk::Widget *> (vbox); @@ -625,6 +634,11 @@ CanvasXYGrid::readRepr() snapper->setEnabled(strcmp(value,"false") != 0 && strcmp(value, "0") != 0); } + if ( (value = repr->attribute("snapvisiblegridlinesonly")) ) { + g_assert(snapper != NULL); + snapper->setSnapVisibleOnly(strcmp(value,"false") != 0 && strcmp(value, "0") != 0); + } + for (GSList *l = canvasitems; l != NULL; l = l->next) { sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) ); } @@ -979,23 +993,30 @@ CanvasXYGridSnapper::_getSnapLines(Geom::Point const &p) const for (unsigned int i = 0; i < 2; ++i) { - /* This is to make sure we snap to only visible grid lines */ - double scaled_spacing = grid->sw[i]; // this is spacing of visible lines in screen pixels - - // convert screen pixels to px - // FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary - if (SP_ACTIVE_DESKTOP) { - scaled_spacing /= SP_ACTIVE_DESKTOP->current_zoom(); + double spacing; + + if (getSnapVisibleOnly()) { + // Only snapping to visible grid lines + spacing = grid->sw[i]; // this is the spacing of the visible grid lines measured in screen pixels + // convert screen pixels to px + // FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary + SPDesktop const *dt = _snapmanager->getDesktop(); + if (dt) { + spacing /= dt->current_zoom(); + } + } else { + // Snapping to any grid line, whether it's visible or not + spacing = grid->spacing[i]; } Geom::Coord rounded; Geom::Point point_on_line; - rounded = Inkscape::Util::round_to_upper_multiple_plus(p[i], scaled_spacing, grid->origin[i]); + rounded = Inkscape::Util::round_to_upper_multiple_plus(p[i], spacing, grid->origin[i]); point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0); s.push_back(std::make_pair(component_vectors[i], point_on_line)); - rounded = Inkscape::Util::round_to_lower_multiple_plus(p[i], scaled_spacing, grid->origin[i]); + rounded = Inkscape::Util::round_to_lower_multiple_plus(p[i], spacing, grid->origin[i]); point_on_line = i ? Geom::Point(0, rounded) : Geom::Point(rounded, 0); s.push_back(std::make_pair(component_vectors[i], point_on_line)); } |
