summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a205581)
raw | patch | inline | side by side (parent: a205581)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 15 Apr 2007 17:05:40 +0000 (17:05 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Sun, 15 Apr 2007 17:05:40 +0000 (17:05 +0000) |
19 files changed:
src/Makefile_insert | patch | blob | history | |
src/attributes.cpp | patch | blob | history | |
src/attributes.h | patch | blob | history | |
src/desktop.cpp | patch | blob | history | |
src/display/canvas-grid.cpp | patch | blob | history | |
src/display/canvas-grid.h | patch | blob | history | |
src/grid-snapper.cpp | [deleted file] | patch | blob | history |
src/grid-snapper.h | [deleted file] | patch | blob | history |
src/guide-snapper.h | patch | blob | history | |
src/selection-chemistry.cpp | patch | blob | history | |
src/snap.cpp | patch | blob | history | |
src/snap.h | patch | blob | history | |
src/sp-namedview.cpp | patch | blob | history | |
src/sp-namedview.h | patch | blob | history | |
src/ui/dialog/document-properties.cpp | patch | blob | history | |
src/ui/dialog/document-properties.h | patch | blob | history | |
src/ui/view/edit-widget.cpp | patch | blob | history | |
src/verbs.cpp | patch | blob | history | |
src/widgets/desktop-widget.cpp | patch | blob | history |
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 77bd4e7e5bfc5384031c5d4d4306fd76bf9162c4..9ded1945f600ad9ae59eeac9e436159c5cda502a 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
snapped-point.cpp snapped-point.h \
snapper.cpp snapper.h \
line-snapper.cpp line-snapper.h \
- grid-snapper.cpp grid-snapper.h \
guide-snapper.cpp guide-snapper.h \
object-snapper.cpp object-snapper.h \
sp-anchor.cpp sp-anchor.h \
diff --git a/src/attributes.cpp b/src/attributes.cpp
index e7465a0377a1724270309848c7f3fcb3042a216c..39f6a04f95491f0810beb8e0797944cfc7d861d3 100644 (file)
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
{SP_ATTR_INKSCAPE_VERSION, "inkscape:version"},
/* SPNamedView */
{SP_ATTR_VIEWONLY, "viewonly"},
- {SP_ATTR_SHOWGRID, "showgrid"},
{SP_ATTR_SHOWGUIDES, "showguides"},
{SP_ATTR_GRIDTOLERANCE, "gridtolerance"},
{SP_ATTR_GUIDETOLERANCE, "guidetolerance"},
{SP_ATTR_OBJECTTOLERANCE, "objecttolerance"},
- {SP_ATTR_GRIDORIGINX, "gridoriginx"},
- {SP_ATTR_GRIDORIGINY, "gridoriginy"},
- {SP_ATTR_GRIDSPACINGX, "gridspacingx"},
- {SP_ATTR_GRIDSPACINGY, "gridspacingy"},
- {SP_ATTR_GRIDCOLOR, "gridcolor"},
- {SP_ATTR_GRIDOPACITY, "gridopacity"},
- {SP_ATTR_GRIDEMPCOLOR, "gridempcolor"},
- {SP_ATTR_GRIDEMPOPACITY, "gridempopacity"},
- {SP_ATTR_GRIDEMPSPACING, "gridempspacing"},
{SP_ATTR_GUIDECOLOR, "guidecolor"},
{SP_ATTR_GUIDEOPACITY, "guideopacity"},
{SP_ATTR_GUIDEHICOLOR, "guidehicolor"},
diff --git a/src/attributes.h b/src/attributes.h
index bff5d2aefbb85926f2d3c4215745f49f3bb505ef..85eb00e38f1644f9511c780a66e04c48581c9c51 100644 (file)
--- a/src/attributes.h
+++ b/src/attributes.h
SP_ATTR_INKSCAPE_VERSION,
/* SPNamedView */
SP_ATTR_VIEWONLY,
- SP_ATTR_SHOWGRID,
SP_ATTR_SHOWGUIDES,
SP_ATTR_GRIDTOLERANCE,
SP_ATTR_GUIDETOLERANCE,
SP_ATTR_OBJECTTOLERANCE,
- SP_ATTR_GRIDORIGINX,
- SP_ATTR_GRIDORIGINY,
- SP_ATTR_GRIDSPACINGX,
- SP_ATTR_GRIDSPACINGY,
- SP_ATTR_GRIDCOLOR,
- SP_ATTR_GRIDOPACITY,
- SP_ATTR_GRIDEMPCOLOR,
- SP_ATTR_GRIDEMPOPACITY,
- SP_ATTR_GRIDEMPSPACING,
SP_ATTR_GUIDECOLOR,
SP_ATTR_GUIDEOPACITY,
SP_ATTR_GUIDEHICOLOR,
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 4236fd7d8ee97af8bd76e5550176c6d6989337b9..a9c4e5d7f7d244c82bba42fbda1121e9bfdcff89 100644 (file)
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
SPNamedView &nv = *desktop->namedview;
-
- // FIXME GRID: make one gridsnapper object that snaps to all enabled grids by calling their snappers.
- nv.snap_manager.grid.setDistance(sp_convert_distance_full(nv.gridtolerance,
- *nv.gridtoleranceunit,
- px));
- //new grid snappers
+ //tell all grid snappers
for ( GSList const *l = nv.grids; l != NULL; l = l->next) {
Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
grid->snapper->setDistance(sp_convert_distance_full(nv.gridtolerance,
index 6ca6b7f8335b732d1243d1997fb7479a94d1a884..7db2d4020dfd46642ee1557c680e1426df08d358 100644 (file)
@@ -240,8 +240,52 @@ CanvasGrid::on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key,
// ##########################################################
// CanvasXYGrid
-static void grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba);
-static void grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba);
+static void
+grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba)
+{
+ if ((y >= buf->rect.y0) && (y < buf->rect.y1)) {
+ guint r, g, b, a;
+ gint x0, x1, x;
+ guchar *p;
+ r = NR_RGBA32_R (rgba);
+ g = NR_RGBA32_G (rgba);
+ b = NR_RGBA32_B (rgba);
+ a = NR_RGBA32_A (rgba);
+ x0 = MAX (buf->rect.x0, xs);
+ x1 = MIN (buf->rect.x1, xe + 1);
+ p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3;
+ for (x = x0; x < x1; x++) {
+ p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
+ p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
+ p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
+ p += 3;
+ }
+ }
+}
+
+static void
+grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba)
+{
+ if ((x >= buf->rect.x0) && (x < buf->rect.x1)) {
+ guint r, g, b, a;
+ gint y0, y1, y;
+ guchar *p;
+ r = NR_RGBA32_R(rgba);
+ g = NR_RGBA32_G (rgba);
+ b = NR_RGBA32_B (rgba);
+ a = NR_RGBA32_A (rgba);
+ y0 = MAX (buf->rect.y0, ys);
+ y1 = MIN (buf->rect.y1, ye + 1);
+ p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3;
+ for (y = y0; y < y1; y++) {
+ p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
+ p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
+ p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
+ p += buf->buf_rowstride;
+ }
+ }
+}
+
/**
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-enum {
- ARG_0,
- ARG_ORIGINX,
- ARG_ORIGINY,
- ARG_SPACINGX,
- ARG_SPACINGY,
- ARG_COLOR,
- ARG_EMPCOLOR,
- ARG_EMPSPACING
-};
-
-
-static void cxygrid_class_init (CXYGridClass *klass);
-static void cxygrid_init (CXYGrid *grid);
-static void cxygrid_destroy (GtkObject *object);
-static void cxygrid_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-
-static void cxygrid_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
-static void cxygrid_render (SPCanvasItem *item, SPCanvasBuf *buf);
-
-//static SPCanvasItemClass * parent_class;
-
-GtkType
-cxygrid_get_type (void)
-{
- static GtkType cxygrid_type = 0;
-
- if (!cxygrid_type) {
- GtkTypeInfo cxygrid_info = {
- "CXYGrid",
- sizeof (CXYGrid),
- sizeof (CXYGridClass),
- (GtkClassInitFunc) cxygrid_class_init,
- (GtkObjectInitFunc) cxygrid_init,
- NULL, NULL,
- (GtkClassInitFunc) NULL
- };
- cxygrid_type = gtk_type_unique (sp_canvas_item_get_type (), &cxygrid_info);
- }
- return cxygrid_type;
-}
-
-static void
-cxygrid_class_init (CXYGridClass *klass)
-{
- GtkObjectClass *object_class;
- SPCanvasItemClass *item_class;
-
- object_class = (GtkObjectClass *) klass;
- item_class = (SPCanvasItemClass *) klass;
-
- parent_class = (SPCanvasItemClass*)gtk_type_class (sp_canvas_item_get_type ());
-
- gtk_object_add_arg_type ("CXYGrid::originx", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_ORIGINX);
- gtk_object_add_arg_type ("CXYGrid::originy", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_ORIGINY);
- gtk_object_add_arg_type ("CXYGrid::spacingx", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_SPACINGX);
- gtk_object_add_arg_type ("CXYGrid::spacingy", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_SPACINGY);
- gtk_object_add_arg_type ("CXYGrid::color", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_COLOR);
- gtk_object_add_arg_type ("CXYGrid::empcolor", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_EMPCOLOR);
- gtk_object_add_arg_type ("CXYGrid::empspacing", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_EMPSPACING);
-
- object_class->destroy = cxygrid_destroy;
- object_class->set_arg = cxygrid_set_arg;
-
- item_class->update = cxygrid_update;
- item_class->render = cxygrid_render;
-}
-
-static void
-cxygrid_init (CXYGrid *grid)
-{
- grid->origin[NR::X] = grid->origin[NR::Y] = 0.0;
- grid->spacing[NR::X] = grid->spacing[NR::Y] = 8.0;
- grid->color = 0x0000ff7f;
- grid->empcolor = 0x3F3FFF40;
- grid->empspacing = 5;
-}
-
-static void
-cxygrid_destroy (GtkObject *object)
-{
- g_return_if_fail (object != NULL);
- g_return_if_fail (INKSCAPE_IS_CXYGRID (object));
-
- if (GTK_OBJECT_CLASS (parent_class)->destroy)
- (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
-}
-
-static void
-cxygrid_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- SPCanvasItem *item = SP_CANVAS_ITEM (object);
- CXYGrid *grid = INKSCAPE_CXYGRID (object);
-
- switch (arg_id) {
- case ARG_ORIGINX:
- grid->origin[NR::X] = GTK_VALUE_DOUBLE (* arg);
- sp_canvas_item_request_update (item);
- break;
- case ARG_ORIGINY:
- grid->origin[NR::Y] = GTK_VALUE_DOUBLE (* arg);
- sp_canvas_item_request_update (item);
- break;
- case ARG_SPACINGX:
- grid->spacing[NR::X] = GTK_VALUE_DOUBLE (* arg);
- if (grid->spacing[NR::X] < 0.01) grid->spacing[NR::X] = 0.01;
- sp_canvas_item_request_update (item);
- break;
- case ARG_SPACINGY:
- grid->spacing[NR::Y] = GTK_VALUE_DOUBLE (* arg);
- if (grid->spacing[NR::Y] < 0.01) grid->spacing[NR::Y] = 0.01;
- sp_canvas_item_request_update (item);
- break;
- case ARG_COLOR:
- grid->color = GTK_VALUE_INT (* arg);
- sp_canvas_item_request_update (item);
- break;
- case ARG_EMPCOLOR:
- grid->empcolor = GTK_VALUE_INT (* arg);
- sp_canvas_item_request_update (item);
- break;
- case ARG_EMPSPACING:
- grid->empspacing = GTK_VALUE_INT (* arg);
- // std::cout << "Emphasis Spacing: " << grid->empspacing << std::endl;
- sp_canvas_item_request_update (item);
- break;
- default:
- break;
- }
-}
-
-static void
-grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba)
-{
- if ((y >= buf->rect.y0) && (y < buf->rect.y1)) {
- guint r, g, b, a;
- gint x0, x1, x;
- guchar *p;
- r = NR_RGBA32_R (rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
- x0 = MAX (buf->rect.x0, xs);
- x1 = MIN (buf->rect.x1, xe + 1);
- p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3;
- for (x = x0; x < x1; x++) {
- p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
- p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
- p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
- p += 3;
- }
- }
-}
-
-static void
-grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba)
-{
- if ((x >= buf->rect.x0) && (x < buf->rect.x1)) {
- guint r, g, b, a;
- gint y0, y1, y;
- guchar *p;
- r = NR_RGBA32_R(rgba);
- g = NR_RGBA32_G (rgba);
- b = NR_RGBA32_B (rgba);
- a = NR_RGBA32_A (rgba);
- y0 = MAX (buf->rect.y0, ys);
- y1 = MIN (buf->rect.y1, ye + 1);
- p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3;
- for (y = y0; y < y1; y++) {
- p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
- p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
- p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
- p += buf->buf_rowstride;
- }
- }
-}
-
-/**
- \brief This function renders the grid on a particular canvas buffer
- \param item The grid to render on the buffer
- \param buf The buffer to render the grid on
-
- This function gets called a touch more than you might believe,
- about once per tile. This means that it could probably be optimized
- and help things out.
-
- Basically this function has to determine where in the canvas it is,
- and how that associates with the grid. It does this first by looking
- at the bounding box of the buffer, and then calculates where the grid
- starts in that buffer. It will then step through grid lines until
- it is outside of the buffer.
-
- For each grid line it is drawn using the function \c sp_grid_hline
- or \c sp_grid_vline. These are convience functions for the sake
- of making the function easier to read.
-
- Also, there are emphisized lines on the grid. While the \c syg and
- \c sxg variable track grid positioning, the \c xlinestart and \c
- ylinestart variables track the 'count' of what lines they are. If
- that count is a multiple of the line seperation between emphisis
- lines, then that line is drawn in the emphisis color.
-*/
-static void
-cxygrid_render (SPCanvasItem * item, SPCanvasBuf * buf)
-{
- CXYGrid *grid = INKSCAPE_CXYGRID (item);
-
- sp_canvas_prepare_buffer (buf);
-
- const gdouble sxg = floor ((buf->rect.x0 - grid->ow[NR::X]) / grid->sw[NR::X]) * grid->sw[NR::X] + grid->ow[NR::X];
- const gint xlinestart = (gint) Inkscape::round((sxg - grid->ow[NR::X]) / grid->sw[NR::X]);
- const gdouble syg = floor ((buf->rect.y0 - grid->ow[NR::Y]) / grid->sw[NR::Y]) * grid->sw[NR::Y] + grid->ow[NR::Y];
- const gint ylinestart = (gint) Inkscape::round((syg - grid->ow[NR::Y]) / grid->sw[NR::Y]);
-
- gint ylinenum;
- gdouble y;
- for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += grid->sw[NR::Y], ylinenum++) {
- const gint y0 = (gint) Inkscape::round(y);
-
- if (!grid->scaled[NR::Y] && (ylinenum % grid->empspacing) == 0) {
- grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, grid->empcolor);
- } else {
- grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, grid->color);
- }
- }
-
- gint xlinenum;
- gdouble x;
- for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += grid->sw[NR::X], xlinenum++) {
- const gint ix = (gint) Inkscape::round(x);
- if (!grid->scaled[NR::X] && (xlinenum % grid->empspacing) == 0) {
- grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, grid->empcolor);
- } else {
- grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, grid->color);
- }
- }
-}
-
-static void
-cxygrid_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
-{
- CXYGrid *grid = INKSCAPE_CXYGRID (item);
-
- if (parent_class->update)
- (* parent_class->update) (item, affine, flags);
-
- grid->ow = grid->origin * affine;
- grid->sw = grid->spacing * affine;
- grid->sw -= NR::Point(affine[4], affine[5]);
-
- for(int dim = 0; dim < 2; dim++) {
- gint scaling_factor = grid->empspacing;
-
- if (scaling_factor <= 1)
- scaling_factor = 5;
-
- grid->scaled[dim] = FALSE;
- grid->sw[dim] = fabs (grid->sw[dim]);
- while (grid->sw[dim] < 8.0) {
- grid->scaled[dim] = TRUE;
- grid->sw[dim] *= scaling_factor;
- /* First pass, go up to the major line spacing, then
- keep increasing by two. */
- scaling_factor = 2;
- }
- }
-
- if (grid->empspacing == 0) {
- grid->scaled[NR::Y] = TRUE;
- grid->scaled[NR::X] = TRUE;
- }
-
- sp_canvas_request_redraw (item->canvas,
- -1000000, -1000000,
- 1000000, 1000000);
-
- item->x1 = item->y1 = -1000000;
- item->x2 = item->y2 = 1000000;
-}
-
-
}; /* namespace Inkscape */
/*
index 984ddad7983053e7cec67c3dc125bc4d0a939438..a4d36e3613ca7db337216f2e09bea9056dc0708a 100644 (file)
CanvasXYGrid *grid;
};
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-#define INKSCAPE_TYPE_CXYGRID (Inkscape::cxygrid_get_type ())
-#define INKSCAPE_CXYGRID(obj) (GTK_CHECK_CAST ((obj), INKSCAPE_TYPE_CXYGRID, CXYGrid))
-#define INKSCAPE_CXYGRID_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), INKSCAPE_TYPE_CXYGRID, CXYGridClass))
-#define INKSCAPE_IS_CXYGRID(obj) (GTK_CHECK_TYPE ((obj), INKSCAPE_TYPE_CXYGRID))
-#define INKSCAPE_IS_CXYGRID_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), INKSCAPE_TYPE_CXYGRID))
-
-
-/** \brief All the variables that are tracked for a grid specific
- canvas item. */
-struct CXYGrid : public SPCanvasItem{
- NR::Point origin; /**< Origin of the grid */
- NR::Point spacing; /**< Spacing between elements of the grid */
- guint32 color; /**< Color for normal lines */
- guint32 empcolor; /**< Color for emphisis lines */
- gint empspacing; /**< Spacing between emphisis lines */
- bool scaled[2]; /**< Whether the grid is in scaled mode, which can
- be different in the X or Y direction, hense two
- variables */
- NR::Point ow; /**< Transformed origin by the affine for the zoom */
- NR::Point sw; /**< Transformed spacing by the affine for the zoom */
-};
-
-struct CXYGridClass {
- SPCanvasItemClass parent_class;
-};
-
-/* Standard Gtk function */
-GtkType cxygrid_get_type (void);
-
}; /* namespace Inkscape */
diff --git a/src/grid-snapper.cpp b/src/grid-snapper.cpp
--- a/src/grid-snapper.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * \file grid-snapper.cpp
- * \brief Snapping things to grids.
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Frank Felfe <innerspace@iname.com>
- * Carl Hetherington <inkscape@carlh.net>
- *
- * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
- * Copyright (C) 1999-2002 Authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "sp-namedview.h"
-#include "inkscape.h"
-#include "desktop.h"
-#include "display/canvas-grid.h"
-#include "display/canvas-axonomgrid.h"
-
-/**
- * \return x rounded to the nearest multiple of c1 plus c0.
- *
- * \note
- * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero
- * mean "ignore the grid in this dimention". We're currently discussing "good" semantics
- * for guide/grid snapping.
- */
-
-/* FIXME: move this somewhere else, perhaps */
-static double round_to_nearest_multiple_plus(double x, double const c1, double const c0)
-{
- return floor((x - c0) / c1 + .5) * c1 + c0;
-}
-
-Inkscape::GridSnapper::GridSnapper(SPNamedView const *nv, NR::Coord const d) : LineSnapper(nv, d)
-{
-
-}
-
-Inkscape::LineSnapper::LineList
-Inkscape::GridSnapper::_getSnapLines(NR::Point const &p) const
-{
- LineList s;
-
- if ( NULL == _named_view ) {
- return s;
- }
-
- CXYGrid *griditem = NULL;
- for (GSList *l = _named_view->gridviews; l != NULL; l = l->next) {
- // FIXME : this is a hack since there is only one view for now
- // but when we'll handle multiple views, snapping should
- // must be rethought and maybe only the current view
- // should give back it's SHOWN lines to snap to
- // For now, the last CXYGrid in _named_view->gridviews will be used.
- if ( INKSCAPE_IS_CXYGRID(GTK_OBJECT(l->data)) ) {
- griditem = INKSCAPE_CXYGRID(l->data);
- }
- }
-
- g_assert(griditem != NULL);
-
- for (unsigned int i = 0; i < 2; ++i) {
-
- /* This is to make sure we snap to only visible grid lines */
- double scaled_spacing = griditem->sw[i]; // this is spacing of visible lines if 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();
- }
-
- NR::Coord const rounded = round_to_nearest_multiple_plus(p[i],
- scaled_spacing,
- _named_view->gridorigin[i]);
-
- s.push_back(std::make_pair(NR::Dim2(i), rounded));
- }
-
- return s;
-}
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/grid-snapper.h b/src/grid-snapper.h
--- a/src/grid-snapper.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#ifndef SEEN_GRID_SNAPPER_H
-#define SEEN_GRID_SNAPPER_H
-
-/**
- * \file grid-snapper.h
- * \brief Snapping things to grids.
- *
- * Authors:
- * Lauris Kaplinski <lauris@kaplinski.com>
- * Frank Felfe <innerspace@iname.com>
- * Carl Hetherington <inkscape@carlh.net>
- *
- * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
- * Copyright (C) 1999-2002 Authors
- *
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include "line-snapper.h"
-
-namespace Inkscape
-{
-
-/// Normal 2D grid
-class GridSnapper : public LineSnapper
-{
-public:
- GridSnapper(SPNamedView const *nv, NR::Coord const d);
-
-private:
- LineList _getSnapLines(NR::Point const &p) const;
-};
-
-}
-
-#endif
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/guide-snapper.h b/src/guide-snapper.h
index f4c7b2de711de71723b4749fb4585d2beeb234a7..37e3e3006d66c51c2c733fbefed5119b8026b595 100644 (file)
--- a/src/guide-snapper.h
+++ b/src/guide-snapper.h
#include "libnr/nr-forward.h"
#include "libnr/nr-coord.h"
-#include "snapper.h"
+#include "line-snapper.h"
struct SPNamedView;
index f8548cdc4eda0fb199276a687c923b59de6597b8..2b13021a227801bfea94dbf1d4780ac1c63ff50b 100644 (file)
}
/* Snap the offset of the new item(s) to the grid */
- /* FIXME: this gridsnap fiddling is a hack. */
- Inkscape::GridSnapper &s = desktop->namedview->snap_manager.grid;
- gdouble const curr_gridsnap = s.getDistance();
- s.setDistance(NR_HUGE);
- m = s.freeSnap(Inkscape::Snapper::SNAP_POINT, m, NULL).getPoint();
- s.setDistance(curr_gridsnap);
+ SnapManager &sm = desktop->namedview->snap_manager;
+ SnapManager::SnapperList gs = sm.getGridSnappers();
+ m = sm.freeSnapAlways(Inkscape::Snapper::SNAP_POINT, m, NULL, gs).getPoint();
sp_selection_move_relative(selection, m);
}
diff --git a/src/snap.cpp b/src/snap.cpp
index 4f871e73670873e14b288795545130262f7a0588..1714b6b67b75b9010efacd5f0361fdfa457e7ef6 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
*/
SnapManager::SnapManager(SPNamedView const *v) :
- grid(v, 0),
guide(v, 0),
object(v, 0),
_named_view(v)
/**
* \return List of snappers that we use.
*/
-
-SnapManager::SnapperList SnapManager::getSnappers() const
+SnapManager::SnapperList
+SnapManager::getSnappers() const
{
SnapManager::SnapperList s;
- s.push_back(&grid);
s.push_back(&guide);
s.push_back(&object);
- //FIXME: this code should do this: add new grid snappers that are active for this desktop
+ SnapManager::SnapperList gs = getGridSnappers();
+ s.splice(s.begin(), gs);
+
+ return s;
+}
+
+/**
+ * \return List of gridsnappers that we use.
+ */
+SnapManager::SnapperList
+SnapManager::getGridSnappers() const
+{
+ SnapperList s;
+
+ //FIXME: this code should actually do this: add new grid snappers that are active for this desktop. now it just adds all gridsnappers
SPDesktop* desktop = SP_ACTIVE_DESKTOP;
if (desktop && desktop->gridsEnabled()) {
for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) {
Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t,
NR::Point const &p,
std::list<SPItem const *> const &it) const
+{
+ SnapperList const snappers = getSnappers();
+
+ return freeSnap(t, p, it, snappers);
+}
+
+/**
+ * Try to snap a point to any of the specified snappers.
+ *
+ * \param t Type of point.
+ * \param p Point.
+ * \param it List of items to ignore when snapping.
+ * \param snappers List of snappers to try to snap to
+ * \return Snapped point.
+ */
+
+Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t,
+ NR::Point const &p,
+ std::list<SPItem const *> const &it,
+ SnapperList const &snappers) const
{
Inkscape::SnappedPoint r(p, NR_HUGE);
- SnapperList const snappers = getSnappers();
for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) {
Inkscape::SnappedPoint const s = (*i)->freeSnap(t, p, it);
if (s.getDistance() < r.getDistance()) {
return r;
}
+/**
+ * Try to snap a point to any of the specified snappers. Snap always, ignoring the snap-distance
+ *
+ * \param t Type of point.
+ * \param p Point.
+ * \param it Item to ignore when snapping.
+ * \param snappers List of snappers to try to snap to
+ * \return Snapped point.
+ */
+
+Inkscape::SnappedPoint
+SnapManager::freeSnapAlways( Inkscape::Snapper::PointType t,
+ NR::Point const &p,
+ SPItem const *it,
+ SnapperList &snappers )
+{
+ std::list<SPItem const *> lit;
+ lit.push_back(it);
+ return freeSnapAlways(t, p, lit, snappers);
+}
+
+/**
+ * Try to snap a point to any of the specified snappers. Snap always, ignoring the snap-distance
+ *
+ * \param t Type of point.
+ * \param p Point.
+ * \param it List of items to ignore when snapping.
+ * \param snappers List of snappers to try to snap to
+ * \return Snapped point.
+ */
+
+Inkscape::SnappedPoint
+SnapManager::freeSnapAlways( Inkscape::Snapper::PointType t,
+ NR::Point const &p,
+ std::list<SPItem const *> const &it,
+ SnapperList &snappers )
+{
+ Inkscape::SnappedPoint r(p, NR_HUGE);
+
+ for (SnapperList::iterator i = snappers.begin(); i != snappers.end(); i++) {
+ gdouble const curr_gridsnap = (*i)->getDistance();
+ const_cast<Inkscape::Snapper*> (*i)->setDistance(NR_HUGE);
+ Inkscape::SnappedPoint const s = (*i)->freeSnap(t, p, it);
+ const_cast<Inkscape::Snapper*> (*i)->setDistance(curr_gridsnap);
+
+ if (s.getDistance() < r.getDistance()) {
+ r = s;
+ }
+ }
+
+ return r;
+}
+
+
/**
* Try to snap a point to any interested snappers. A snap will only occur along
diff --git a/src/snap.h b/src/snap.h
index 2f8e83b1364e28265e882ccdc56d5fa09dfb2bdf..4185b051ab3a985f030de7884855fd0d4a44db26 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
#include <libnr/nr-dim2.h>
#include <libnr/nr-forward.h>
#include <libnr/nr-scale.h>
-#include "grid-snapper.h"
#include "guide-snapper.h"
#include "object-snapper.h"
{
public:
SnapManager(SPNamedView const *v);
-
+
+ typedef std::list<const Inkscape::Snapper*> SnapperList;
+
bool willSnapSomething() const;
Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t,
Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t,
NR::Point const &p,
std::list<SPItem const *> const &it) const;
-
+
+ Inkscape::SnappedPoint freeSnap( Inkscape::Snapper::PointType t,
+ NR::Point const &p,
+ std::list<SPItem const *> const &it,
+ SnapperList const &snappers ) const;
+
+ Inkscape::SnappedPoint freeSnapAlways( Inkscape::Snapper::PointType t,
+ NR::Point const &p,
+ SPItem const *it,
+ SnapperList &snappers );
+
+ Inkscape::SnappedPoint freeSnapAlways( Inkscape::Snapper::PointType t,
+ NR::Point const &p,
+ std::list<SPItem const *> const &it,
+ SnapperList &snappers );
+
Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType t,
NR::Point const &p,
Inkscape::Snapper::ConstraintLine const &c,
NR::Point const &o,
NR::Dim2 d) const;
- Inkscape::GridSnapper grid; ///< grid snapper
Inkscape::GuideSnapper guide; ///< guide snapper
Inkscape::ObjectSnapper object; ///< snapper to other objects
- typedef std::list<const Inkscape::Snapper*> SnapperList;
SnapperList getSnappers() const;
+ SnapperList getGridSnappers() const;
protected:
SPNamedView const *_named_view;
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index a11904570dd626b2e08d61f231460900685f0a6b..d831a50eb4f2dd969094cd31aa92345d8d7aef9d 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
static void sp_namedview_setup_guides(SPNamedView * nv);
-static void sp_namedview_setup_grid(SPNamedView * nv);
-static void sp_namedview_setup_grid_item(SPNamedView * nv, SPCanvasItem * item);
-
static gboolean sp_str_to_bool(const gchar *str);
static gboolean sp_nv_read_length(const gchar *str, guint base, gdouble *val, const SPUnit **unit);
static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color);
static void sp_namedview_init(SPNamedView *nv)
{
nv->editable = TRUE;
- nv->showgrid = FALSE;
nv->showguides = TRUE;
nv->showborder = TRUE;
nv->showpageshadow = TRUE;
@@ -134,20 +130,10 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape:
sp_object_read_attr(object, "inkscape:document-units");
sp_object_read_attr(object, "viewonly");
- sp_object_read_attr(object, "showgrid");
sp_object_read_attr(object, "showguides");
sp_object_read_attr(object, "gridtolerance");
sp_object_read_attr(object, "guidetolerance");
sp_object_read_attr(object, "objecttolerance");
- sp_object_read_attr(object, "gridoriginx");
- sp_object_read_attr(object, "gridoriginy");
- sp_object_read_attr(object, "gridspacingx");
- sp_object_read_attr(object, "gridspacingy");
- sp_object_read_attr(object, "gridempspacing");
- sp_object_read_attr(object, "gridcolor");
- sp_object_read_attr(object, "gridempcolor");
- sp_object_read_attr(object, "gridopacity");
- sp_object_read_attr(object, "gridempopacity");
sp_object_read_attr(object, "guidecolor");
sp_object_read_attr(object, "guideopacity");
sp_object_read_attr(object, "guidehicolor");
namedview->guides = NULL;
}
- while (namedview->gridviews) {
- gtk_object_unref(GTK_OBJECT(namedview->gridviews->data));
- namedview->gridviews = g_slist_remove(namedview->gridviews, namedview->gridviews->data);
- }
-
// delete grids:
while ( namedview->grids ) {
Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data;
@@ -227,13 +208,6 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
nv->editable = (!value);
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
- case SP_ATTR_SHOWGRID:
- nv->showgrid = sp_str_to_bool(value);
- sp_namedview_setup_grid(nv);
- /* Disable grid snaps if the grid is turned off */
- nv->snap_manager.grid.setEnabled(nv->showgrid);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
case SP_ATTR_SHOWGUIDES:
if (!value) { // show guides if not specified, for backwards compatibility
nv->showguides = TRUE;
@@ -267,69 +241,6 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va
}
object->requestModified(SP_OBJECT_MODIFIED_FLAG);
break;
- case SP_ATTR_GRIDORIGINX:
- case SP_ATTR_GRIDORIGINY:
- {
- unsigned const d = (key == SP_ATTR_GRIDORIGINY);
- nv->gridunit = nv->doc_units;
- nv->gridorigin[d] = 0.0;
- if (value) {
- sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->gridorigin[d], &nv->gridunit);
- }
- nv->gridorigin[d] = sp_units_get_pixels(nv->gridorigin[d], *(nv->gridunit));
- sp_namedview_setup_grid(nv);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
- }
- case SP_ATTR_GRIDSPACINGX:
- case SP_ATTR_GRIDSPACINGY:
- {
- unsigned const d = (key == SP_ATTR_GRIDSPACINGY);
- nv->gridunit = nv->doc_units;
- nv->gridspacing[d] = 1.0;
- if (value) {
- sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->gridspacing[d], &nv->gridunit);
- }
- nv->gridspacing[d] = sp_units_get_pixels(nv->gridspacing[d], *(nv->gridunit));
- sp_namedview_setup_grid(nv);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
- }
- case SP_ATTR_GRIDCOLOR:
- nv->gridcolor = (nv->gridcolor & 0xff) | (DEFAULTGRIDCOLOR & 0xffffff00);
- if (value) {
- nv->gridcolor = (nv->gridcolor & 0xff) | sp_svg_read_color(value, nv->gridcolor);
- }
- sp_namedview_setup_grid(nv);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
- case SP_ATTR_GRIDEMPCOLOR:
- nv->gridempcolor = (nv->gridempcolor & 0xff) | (DEFAULTGRIDEMPCOLOR & 0xffffff00);
- if (value) {
- nv->gridempcolor = (nv->gridempcolor & 0xff) | sp_svg_read_color(value, nv->gridempcolor);
- }
- sp_namedview_setup_grid(nv);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
- case SP_ATTR_GRIDOPACITY:
- nv->gridcolor = (nv->gridcolor & 0xffffff00) | (DEFAULTGRIDCOLOR & 0xff);
- sp_nv_read_opacity(value, &nv->gridcolor);
- sp_namedview_setup_grid(nv);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
- case SP_ATTR_GRIDEMPOPACITY:
- nv->gridempcolor = (nv->gridempcolor & 0xffffff00) | (DEFAULTGRIDEMPCOLOR & 0xff);
- sp_nv_read_opacity(value, &nv->gridempcolor);
- sp_namedview_setup_grid(nv);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
- case SP_ATTR_GRIDEMPSPACING:
- nv->gridempspacing = DEFAULTGRIDEMPSPACING;
- if (value != NULL)
- nv->gridempspacing = atoi(value);
- sp_namedview_setup_grid(nv);
- object->requestModified(SP_OBJECT_MODIFIED_FLAG);
- break;
case SP_ATTR_GUIDECOLOR:
nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00);
if (value) {
views = g_slist_prepend(views, desktop);
- SPCanvasItem * item = sp_canvas_item_new(sp_desktop_gridgroup(desktop), INKSCAPE_TYPE_CXYGRID, NULL);
- // since we're keeping a copy, we need to bump up the ref count
- gtk_object_ref(GTK_OBJECT(item));
- gridviews = g_slist_prepend(gridviews, item);
-
// generate grids specified in SVG:
Inkscape::XML::Node *repr = SP_OBJECT_REPR(this);
if (repr) {
}
}
}
-
- sp_namedview_setup_grid(this);
}
#define MIN_ONSCREEN_DISTANCE 50
views = g_slist_remove(views, desktop);
- GSList *l;
- for (l = gridviews; l != NULL; l = l->next) {
- if (! l->data) {
- continue;
- }
- SPCanvasItem *item = static_cast<SPCanvasItem*>(l->data);
-
- if (item->canvas == sp_desktop_canvas(desktop)) {
- sp_canvas_item_hide(SP_CANVAS_ITEM(l->data));
- gtk_object_unref(GTK_OBJECT(l->data));
- gridviews = g_slist_remove(gridviews, l->data);
- }
- }
-
// delete grids:
while ( grids ) {
Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)grids->data;
sp_document_set_undo_sensitive(doc, saved);
}
-void sp_namedview_toggle_grid(SPDocument *doc, Inkscape::XML::Node *repr)
-{
- unsigned int v;
- sp_repr_get_boolean(repr, "showgrid", &v);
- v = !v;
-
- bool saved = sp_document_get_undo_sensitive(doc);
- sp_document_set_undo_sensitive(doc, false);
-
- sp_repr_set_boolean(repr, "showgrid", v);
-
- doc->rroot->setAttribute("sodipodi:modified", "true");
- sp_document_set_undo_sensitive(doc, saved);
-}
-
-static void sp_namedview_setup_grid(SPNamedView *nv)
-{
- for (GSList *l = nv->gridviews; l != NULL; l = l->next) {
- sp_namedview_setup_grid_item(nv, SP_CANVAS_ITEM(l->data));
- }
-}
-
-static void sp_namedview_setup_grid_item(SPNamedView *nv, SPCanvasItem *item)
-{
- if ( nv->showgrid ) {
- sp_canvas_item_show(item);
- } else {
- sp_canvas_item_hide(item);
- }
-
- sp_canvas_item_set((GtkObject *) item,
- "color", nv->gridcolor,
- "originx", nv->gridorigin[NR::X],
- "originy", nv->gridorigin[NR::Y],
- "spacingx", nv->gridspacing[NR::X],
- "spacingy", nv->gridspacing[NR::Y],
- "empcolor", nv->gridempcolor,
- "empspacing", nv->gridempspacing,
- NULL);
-}
-
-
gchar const *SPNamedView::getName() const
{
SPException ex;
diff --git a/src/sp-namedview.h b/src/sp-namedview.h
index 64b78d29c5527d558078ab5153742e331e4e18bf..7eefdfae53cf345fd6d65281c2273cf3e69b6510 100644 (file)
--- a/src/sp-namedview.h
+++ b/src/sp-namedview.h
struct SPNamedView : public SPObjectGroup {
unsigned int editable : 1;
- unsigned int showgrid : 1;
unsigned int showguides : 1;
unsigned int showborder : 1;
unsigned int showpageshadow : 1;
gint window_y;
SnapManager snap_manager;
- //GridManager grid_manager;
GSList * grids;
- SPUnit const *gridunit;
- /* Grid data is in points regardless of unit */
- NR::Point gridorigin;
- gdouble gridspacing[2];
- gint gridempspacing;
-
SPUnit const *doc_units;
SPUnit const *gridtoleranceunit;
double connector_spacing;
- guint32 gridcolor;
- guint32 gridempcolor;
guint32 guidecolor;
guint32 guidehicolor;
guint32 bordercolor;
GSList *guides;
GSList *views;
- GSList *gridviews;
gint viewcount;
void sp_namedview_update_layers_from_document (SPDesktop *desktop);
void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr);
-void sp_namedview_toggle_grid(SPDocument *doc, Inkscape::XML::Node *repr);
-void sp_namedview_set_gridtype(unsigned int type, SPDocument *doc, Inkscape::XML::Node *repr);
#endif /* !INKSCAPE_SP_NAMEDVIEW_H */
index 39b3e36b40b3d8ff71d6fa0c92ae97701eb1cd61..324b638723d918b0093240a4bb24b77a97c5b1c8 100644 (file)
DocumentProperties::DocumentProperties()
: Dialog ("dialogs.documentoptions", SP_VERB_DIALOG_NAMEDVIEW),
- _page_page(1, 1), _page_grid(1, 1), _page_guides(1, 1),
+ _page_page(1, 1), _page_guides(1, 1),
_page_snap(1, 1), _page_grids(1, 1),
_grids_button_new(_("_New"), _("Create new grid.")),
_grids_button_remove(_("_Remove"), _("Remove selected grid.")),
get_vbox()->pack_start (_notebook, true, true);
_notebook.append_page(_page_page, _("Page"));
- _notebook.append_page(_page_grid, _("Grid/Guides"));
+ _notebook.append_page(_page_guides, _("Guides"));
_notebook.append_page(_page_snap, _("Snap"));
- _notebook.append_page(_page_grids, _("Grids setup"));
+ _notebook.append_page(_page_grids, _("Grids"));
build_page();
- build_grid();
+ build_guides();
build_snap();
build_gridspage();
}
void
-DocumentProperties::build_grid()
+DocumentProperties::build_guides()
{
- _page_grid.show();
+ _page_guides.show();
- /// \todo FIXME: gray out snapping when grid is off.
- /// Dissenting view: you want snapping without grid.
-
- _rcbgrid.init (_("_Show grid"), _("Show or hide grid"), "showgrid", _wr);
-
- _rumg.init (_("Grid _units:"), "grid_units", _wr);
- _rsu_ox.init (_("_Origin X:"), _("X coordinate of grid origin"),
- "gridoriginx", _rumg, _wr);
- _rsu_oy.init (_("O_rigin Y:"), _("Y coordinate of grid origin"),
- "gridoriginy", _rumg, _wr);
- _rsu_sx.init (_("Spacing _X:"), _("Distance between vertical grid lines"),
- "gridspacingx", _rumg, _wr);
- _rsu_sy.init (_("Spacing _Y:"), _("Distance between horizontal grid lines"),
- "gridspacingy", _rumg, _wr);
- _rcp_gcol.init (_("Grid line _color:"), _("Grid line color"),
- _("Color of grid lines"), "gridcolor", "gridopacity", _wr);
- _rcp_gmcol.init (_("Ma_jor grid line color:"), _("Major grid line color"),
- _("Color of the major (highlighted) grid lines"),
- "gridempcolor", "gridempopacity", _wr);
- _rsi.init (_("_Major grid line every:"), _("lines"), "gridempspacing", _wr);
_rcb_sgui.init (_("Show _guides"), _("Show or hide guides"), "showguides", _wr);
_rcp_gui.init (_("Guide co_lor:"), _("Guideline color"),
_("Color of guidelines"), "guidecolor", "guideopacity", _wr);
_rcp_hgui.init (_("_Highlight color:"), _("Highlighted guideline color"),
_("Color of a guideline when it is under mouse"),
"guidehicolor", "guidehiopacity", _wr);
- Gtk::Label *label_grid = manage (new Gtk::Label);
- label_grid->set_markup (_("<b>Grid</b>"));
Gtk::Label *label_gui = manage (new Gtk::Label);
label_gui->set_markup (_("<b>Guides</b>"));
const Gtk::Widget* widget_array[] =
{
- label_grid, 0,
- 0, _rcbgrid._button,
- _rumg._label, _rumg._sel,
- 0, _rsu_ox.getSU(),
- 0, _rsu_oy.getSU(),
- 0, _rsu_sx.getSU(),
- 0, _rsu_sy.getSU(),
- _rcp_gcol._label, _rcp_gcol._cp,
- 0, 0,
- _rcp_gmcol._label, _rcp_gmcol._cp,
- _rsi._label, &_rsi._hbox,
- 0, 0,
label_gui, 0,
0, _rcb_sgui._button,
_rcp_gui._label, _rcp_gui._cp,
_rcp_hgui._label, _rcp_hgui._cp,
};
- attach_all (_page_grid.table(), widget_array, sizeof(widget_array));
+ attach_all (_page_guides.table(), widget_array, sizeof(widget_array));
}
void
{
_page_grids.show();
+ /// \todo FIXME: gray out snapping when grid is off.
+ /// Dissenting view: you want snapping without grid.
+
SPDesktop *dt = SP_ACTIVE_DESKTOP;
SPNamedView *nv = sp_desktop_namedview(dt);
double const doc_h_px = sp_document_height(sp_desktop_document(dt));
_page_sizer.setDim (doc_w_px, doc_h_px);
- //-----------------------------------------------------------grid page
- _rcbgrid.setActive (nv->showgrid);
- _rumg.setUnit (nv->gridunit);
-
- gdouble val;
- val = nv->gridorigin[NR::X];
- val = sp_pixels_get_units (val, *(nv->gridunit));
- _rsu_ox.setValue (val);
- val = nv->gridorigin[NR::Y];
- val = sp_pixels_get_units (val, *(nv->gridunit));
- _rsu_oy.setValue (val);
- val = nv->gridspacing[NR::X];
- double gridx = sp_pixels_get_units (val, *(nv->gridunit));
- _rsu_sx.setValue (gridx);
- val = nv->gridspacing[NR::Y];
- double gridy = sp_pixels_get_units (val, *(nv->gridunit));
- _rsu_sy.setValue (gridy);
-
- _rcp_gcol.setRgba32 (nv->gridcolor);
- _rcp_gmcol.setRgba32 (nv->gridempcolor);
- _rsi.setValue (nv->gridempspacing);
-
//-----------------------------------------------------------guide
_rcb_sgui.setActive (nv->showguides);
_rcp_gui.setRgba32 (nv->guidecolor);
{
_rcp_bg.closeWindow();
_rcp_bord.closeWindow();
- _rcp_gcol.closeWindow();
- _rcp_gmcol.closeWindow();
_rcp_gui.closeWindow();
_rcp_hgui.closeWindow();
}
index 439ad570111a1853301fb5b78102a470d5985bcc..294bbab4328ac120bf66425877072a86cbc57949 100644 (file)
Gtk::Tooltips _tt;
Gtk::Notebook _notebook;
- NotebookPage _page_page, _page_grid, _page_guides;
+ NotebookPage _page_page, _page_guides;
NotebookPage _page_snap;
NotebookPage _page_grids;
PageSizer _page_sizer;
//---------------------------------------------------------------
RegisteredCheckButton _rcbgrid; //_rcbsnbb, _rcbsnnod
- RegisteredUnitMenu _rumg, _rums;
- RegisteredScalarUnit _rsu_ox, _rsu_oy, _rsu_sx, _rsu_sy;
- RegisteredColorPicker _rcp_gcol, _rcp_gmcol;
- RegisteredSuffixedInteger _rsi;
+ RegisteredUnitMenu _rums;
//---------------------------------------------------------------
RegisteredCheckButton _rcb_sgui; //_rcb_snpgui, _rcb_snbgui
RegisteredUnitMenu _rum_gusn;
- ToleranceSlider _rsu_sn, _rsu_gusn;
RegisteredColorPicker _rcp_gui, _rcp_hgui;
//---------------------------------------------------------------
RegisteredCheckButton _rcbsnop, _rcbsnon; //_rcbsnbo, _rcbsnnob
RegisteredUnitMenu _rumso;
- ToleranceSlider _rsu_sno;
+ ToleranceSlider _rsu_sno, _rsu_sn, _rsu_gusn;
RegisteredRadioButtonPair _rrb_pix;
//---------------------------------------------------------------
Gtk::Notebook _grids_notebook;
index 79258283d176410516b3dd9ac0328c829c19bb67..bac6854a13e873d874e65526fc3a0bee10c7788c 100644 (file)
void
EditWidget::viewSetPosition (NR::Point p)
{
- p -= _namedview->gridorigin;
+ // p -= _namedview->gridorigin;
+ /// \todo Why was the origin corrected for the grid origin? (johan)
+
double lo, up, pos, max;
_top_ruler.get_range (lo, up, pos, max);
_top_ruler.set_range (lo, up, p[NR::X], max);
void
EditWidget::updateRulers()
{
- NR::Point origin = _namedview->gridorigin;
-
+ //NR::Point gridorigin = _namedview->gridorigin;
+ /// \todo Why was the origin corrected for the grid origin? (johan)
+
NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox();
double lo, up, pos, max;
double const scale = _desktop->current_zoom();
- double s = viewbox.min()[NR::X] / scale - origin[NR::X];
- double e = viewbox.max()[NR::X] / scale - origin[NR::X];
+ double s = viewbox.min()[NR::X] / scale; //- gridorigin[NR::X];
+ double e = viewbox.max()[NR::X] / scale; //- gridorigin[NR::X];
_top_ruler.get_range(lo, up, pos, max);
_top_ruler.set_range(s, e, pos, e);
- s = viewbox.min()[NR::Y] / -scale - origin[NR::Y];
- e = viewbox.max()[NR::Y] / -scale - origin[NR::Y];
- _left_ruler.set_range(s, e, origin[NR::Y], e);
+ s = viewbox.min()[NR::Y] / -scale; //- gridorigin[NR::Y];
+ e = viewbox.max()[NR::Y] / -scale; //- gridorigin[NR::Y];
+ _left_ruler.set_range(s, e, 0 /*gridorigin[NR::Y]*/, e);
/// \todo is that correct?
}
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 172b5220c321fd070d76a2827129e26e04ede083..977c22cf8a1de84bd5b987f6ec152e7226c34172 100644 (file)
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
sp_namedview_toggle_guides(doc, repr);
break;
case SP_VERB_TOGGLE_GRID:
- sp_namedview_toggle_grid(doc, repr);
dt->toggleGrid();
break;
#ifdef HAVE_GTK_WINDOW_FULLSCREEN
index cc723a532dacdbb9f5e34d78fff40f39ccf70229..47694518c912019bf0f2a8c664c7db3db6c7f538 100644 (file)
SPDesktopWidget *dtw = (SPDesktopWidget*)gtk_type_new (SP_TYPE_DESKTOP_WIDGET);
dtw->dt2r = 1.0 / namedview->doc_units->unittobase;
- dtw->ruler_origin = namedview->gridorigin;
+
+ dtw->ruler_origin = NR::Point(0,0); //namedview->gridorigin; Why was the grid origin used here?
dtw->desktop = new SPDesktop();
dtw->stub = new SPDesktopWidget::WidgetStub (dtw);
@@ -1032,7 +1033,7 @@ sp_desktop_widget_namedview_modified (SPObject *obj, guint flags, SPDesktopWidge
SPNamedView *nv=SP_NAMEDVIEW(obj);
if (flags & SP_OBJECT_MODIFIED_FLAG) {
dtw->dt2r = 1.0 / nv->doc_units->unittobase;
- dtw->ruler_origin = nv->gridorigin;
+ dtw->ruler_origin = NR::Point(0,0); //nv->gridorigin; Why was the grid origin used here?
sp_ruler_set_metric (GTK_RULER (dtw->vruler), nv->getDefaultMetric());
sp_ruler_set_metric (GTK_RULER (dtw->hruler), nv->getDefaultMetric());