summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8d3072a)
raw | patch | inline | side by side (parent: 8d3072a)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 26 Oct 2006 22:13:06 +0000 (22:13 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 26 Oct 2006 22:13:06 +0000 (22:13 +0000) |
index 4d8f089712719b6e9cb3f8df01c18b949aa749d3..17f5e7e8cf654f145376382c9a56c481b873ce84 100644 (file)
-#define SP_CANVAS_GRID_C
+#define INKSCAPE_CANVAS_GRID_C
/*
- * SPCGrid
+ * CXYGrid
*
+ * Copyright (C) Johan Engelen 2006 <johan@shouraizou.nl>
* Copyright (C) Lauris Kaplinski 2000
*
*/
#include "display-forward.h"
#include <libnr/nr-pixops.h>
+namespace Inkscape {
+
enum {
ARG_0,
ARG_ORIGINX,
};
-static void sp_cgrid_class_init (SPCGridClass *klass);
-static void sp_cgrid_init (SPCGrid *grid);
-static void sp_cgrid_destroy (GtkObject *object);
-static void sp_cgrid_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
+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 sp_cgrid_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
-static void sp_cgrid_render (SPCanvasItem *item, SPCanvasBuf *buf);
+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
-sp_cgrid_get_type (void)
+cxygrid_get_type (void)
{
- static GtkType cgrid_type = 0;
-
- if (!cgrid_type) {
- GtkTypeInfo cgrid_info = {
- "SPCGrid",
- sizeof (SPCGrid),
- sizeof (SPCGridClass),
- (GtkClassInitFunc) sp_cgrid_class_init,
- (GtkObjectInitFunc) sp_cgrid_init,
+ 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
};
- cgrid_type = gtk_type_unique (sp_canvas_item_get_type (), &cgrid_info);
+ cxygrid_type = gtk_type_unique (sp_canvas_item_get_type (), &cxygrid_info);
}
- return cgrid_type;
+ return cxygrid_type;
}
static void
-sp_cgrid_class_init (SPCGridClass *klass)
+cxygrid_class_init (CXYGridClass *klass)
{
GtkObjectClass *object_class;
SPCanvasItemClass *item_class;
parent_class = (SPCanvasItemClass*)gtk_type_class (sp_canvas_item_get_type ());
- gtk_object_add_arg_type ("SPCGrid::originx", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_ORIGINX);
- gtk_object_add_arg_type ("SPCGrid::originy", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_ORIGINY);
- gtk_object_add_arg_type ("SPCGrid::spacingx", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_SPACINGX);
- gtk_object_add_arg_type ("SPCGrid::spacingy", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_SPACINGY);
- gtk_object_add_arg_type ("SPCGrid::color", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_COLOR);
- gtk_object_add_arg_type ("SPCGrid::empcolor", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_EMPCOLOR);
- gtk_object_add_arg_type ("SPCGrid::empspacing", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_EMPSPACING);
+ 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 = sp_cgrid_destroy;
- object_class->set_arg = sp_cgrid_set_arg;
+ object_class->destroy = cxygrid_destroy;
+ object_class->set_arg = cxygrid_set_arg;
- item_class->update = sp_cgrid_update;
- item_class->render = sp_cgrid_render;
+ item_class->update = cxygrid_update;
+ item_class->render = cxygrid_render;
}
static void
-sp_cgrid_init (SPCGrid *grid)
+cxygrid_init (CXYGrid *grid)
{
grid->origin[NR::X] = grid->origin[NR::Y] = 0.0;
grid->spacing[NR::X] = grid->spacing[NR::Y] = 8.0;
}
static void
-sp_cgrid_destroy (GtkObject *object)
+cxygrid_destroy (GtkObject *object)
{
g_return_if_fail (object != NULL);
- g_return_if_fail (SP_IS_CGRID (object));
+ g_return_if_fail (INKSCAPE_IS_CXYGRID (object));
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
-sp_cgrid_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+cxygrid_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
{
SPCanvasItem *item = SP_CANVAS_ITEM (object);
- SPCGrid *grid = SP_CGRID (object);
+ CXYGrid *grid = INKSCAPE_CXYGRID (object);
switch (arg_id) {
case ARG_ORIGINX:
}
static void
-sp_grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba)
+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;
}
static void
-sp_grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba)
+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;
lines, then that line is drawn in the emphisis color.
*/
static void
-sp_cgrid_render (SPCanvasItem * item, SPCanvasBuf * buf)
+cxygrid_render (SPCanvasItem * item, SPCanvasBuf * buf)
{
- SPCGrid *grid = SP_CGRID (item);
+ CXYGrid *grid = INKSCAPE_CXYGRID (item);
sp_canvas_prepare_buffer (buf);
const gint y0 = (gint) Inkscape::round(y);
if (!grid->scaled[NR::Y] && (ylinenum % grid->empspacing) == 0) {
- sp_grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, grid->empcolor);
+ grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, grid->empcolor);
} else {
- sp_grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, grid->color);
+ grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, grid->color);
}
}
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) {
- sp_grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, grid->empcolor);
+ grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, grid->empcolor);
} else {
- sp_grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, grid->color);
+ grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, grid->color);
}
}
}
static void
-sp_cgrid_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
+cxygrid_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
{
- SPCGrid *grid = SP_CGRID (item);
+ CXYGrid *grid = INKSCAPE_CXYGRID (item);
if (parent_class->update)
(* parent_class->update) (item, affine, flags);
@@ -291,7 +294,10 @@ sp_cgrid_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flag
item->x1 = item->y1 = -1000000;
item->x2 = item->y2 = 1000000;
-}
+}
+
+
+}; /* namespace Inkscape */
/*
Local Variables:
index 0f3791773b721552987e890b1e7b5f23903d0d88..7645d30f643a5b88b61dda84bbd7a3869423b653 100644 (file)
-#ifndef SP_CANVAS_GRID_H
-#define SP_CANVAS_GRID_H
+#ifndef INKSCAPE_CANVAS_GRID_H
+#define INKSCAPE_CANVAS_GRID_H
/*
- * SPCGrid
+ * Inkscape::CXYGrid
*
* Generic (and quite unintelligent) grid item for gnome canvas
*
+ * Copyright (C) Johan Engelen 2006 <johan@shouraizou.nl>
* Copyright (C) Lauris Kaplinski 2000
*
*/
#include <display/sp-canvas.h>
+namespace Inkscape {
-
-#define SP_TYPE_CGRID (sp_cgrid_get_type ())
-#define SP_CGRID(obj) (GTK_CHECK_CAST ((obj), SP_TYPE_CGRID, SPCGrid))
-#define SP_CGRID_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), SP_TYPE_CGRID, SPCGridClass))
-#define SP_IS_CGRID(obj) (GTK_CHECK_TYPE ((obj), SP_TYPE_CGRID))
-#define SP_IS_CGRID_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), SP_TYPE_CGRID))
+#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 SPCGrid : public SPCanvasItem{
+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 */
NR::Point sw; /**< Transformed spacing by the affine for the zoom */
};
-struct SPCGridClass {
+struct CXYGridClass {
SPCanvasItemClass parent_class;
};
-
/* Standard Gtk function */
-GtkType sp_cgrid_get_type (void);
+GtkType cxygrid_get_type (void);
+
+}; /* namespace Inkscape */
+
diff --git a/src/grid-snapper.cpp b/src/grid-snapper.cpp
index 2d6e8e2e30d80926f908c6b981a424a80ed324b6..c6a802a54aecae1f9b055b7bfc078c021617497d 100644 (file)
--- a/src/grid-snapper.cpp
+++ b/src/grid-snapper.cpp
return s;
}
- SPCGrid *griditem = NULL;
+ 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 SPCGrid in _named_view->gridviews will be used.
- if ( SP_IS_CGRID(GTK_OBJECT(l->data)) ) {
- griditem = SP_CGRID(l->data);
+ // 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);
}
}
diff --git a/src/grid-snapper.h b/src/grid-snapper.h
index c664c5f9b880a89d6282b1eadce52f68a9710278..1a3e6d3a8619203dfaffd6eb8ef2176daf08dc61 100644 (file)
--- a/src/grid-snapper.h
+++ b/src/grid-snapper.h
namespace Inkscape
{
-/// Snap to grid
+/// Normal 2D grid
class GridSnapper : public LineSnapper
{
public:
diff --git a/src/snap.h b/src/snap.h
index ff3da3adbcdc4f2f868ee9da7ab15465b664eca5..dc2d0c7883c25d980479a20e4fffa19c87380740 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
typedef std::list<const Inkscape::Snapper*> SnapperList;
SnapperList getSnappers() const;
+ SnapperList gridSnappers; ///< List of grid snappers to enable multiple grids
protected:
SPNamedView const *_named_view;
diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp
index 6ab3c5235442f3c231cbb5006efbcf41592bb780..97640c87a1af6c53a54674c7aaa9fa0950ebb153 100644 (file)
--- a/src/sp-namedview.cpp
+++ b/src/sp-namedview.cpp
views = g_slist_prepend(views, desktop);
- SPCanvasItem * item = sp_canvas_item_new(sp_desktop_grid(desktop), SP_TYPE_CGRID, NULL);
+ SPCanvasItem * item = sp_canvas_item_new(sp_desktop_grid(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);
"empspacing", nv->gridempspacing,
NULL);
if (!btype){
- // CGRID
+ // CXYGRID
sp_canvas_item_set((GtkObject *) item,
"spacingx", nv->gridspacing[NR::X],
NULL);