summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 29961fe)
raw | patch | inline | side by side (parent: 29961fe)
author | joncruz <joncruz@users.sourceforge.net> | |
Thu, 29 May 2008 01:19:24 +0000 (01:19 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Thu, 29 May 2008 01:19:24 +0000 (01:19 +0000) |
src/Makefile_insert | patch | blob | history | |
src/common-context.cpp | [new file with mode: 0644] | patch | blob |
src/common-context.h | [new file with mode: 0644] | patch | blob |
src/dyna-draw-context.cpp | patch | blob | history | |
src/dyna-draw-context.h | patch | blob | history | |
src/eraser-context.cpp | patch | blob | history | |
src/eraser-context.h | patch | blob | history |
diff --git a/src/Makefile_insert b/src/Makefile_insert
index f39ad098fd17258f1ad4b63db9d556b454c74ae8..a81b7a2f55f490ac8678e5dc1f93ccd6dd3c13e9 100644 (file)
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
color-rgba.h \
color-profile.cpp color-profile.h \
color-profile-fns.h \
+ common-context.cpp common-context.h\
conditions.cpp conditions.h\
conn-avoid-ref.cpp conn-avoid-ref.h \
connector-context.cpp connector-context.h \
diff --git a/src/common-context.cpp b/src/common-context.cpp
--- /dev/null
+++ b/src/common-context.cpp
@@ -0,0 +1,169 @@
+
+#include "common-context.h"
+
+#include <gtk/gtk.h>
+
+#include "config.h"
+
+#include "forward.h"
+#include "message-context.h"
+
+#define DRAG_DEFAULT 1.0
+#define MIN_PRESSURE 0.0
+#define MAX_PRESSURE 1.0
+#define DEFAULT_PRESSURE 1.0
+
+
+static void sp_common_context_class_init(SPCommonContextClass *klass);
+static void sp_common_context_init(SPCommonContext *erc);
+static void sp_common_context_dispose(GObject *object);
+
+static void sp_common_context_setup(SPEventContext *ec);
+static void sp_common_context_set(SPEventContext *ec, gchar const *key, gchar const *value);
+
+static gint sp_common_context_root_handler(SPEventContext *event_context, GdkEvent *event);
+
+
+static SPEventContextClass *common_parent_class = 0;
+
+GType sp_common_context_get_type(void)
+{
+ static GType type = 0;
+ if (!type) {
+ GTypeInfo info = {
+ sizeof(SPCommonContextClass),
+ 0, // base_init
+ 0, // base_finalize
+ (GClassInitFunc)sp_common_context_class_init,
+ 0, // class_finalize
+ 0, // class_data
+ sizeof(SPCommonContext),
+ 0, // n_preallocs
+ (GInstanceInitFunc)sp_common_context_init,
+ 0 // value_table
+ };
+ type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPCommonContext", &info, static_cast<GTypeFlags>(0));
+ }
+ return type;
+}
+
+
+static void sp_common_context_class_init(SPCommonContextClass *klass)
+{
+ GObjectClass *object_class = (GObjectClass *) klass;
+ SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
+
+ common_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass);
+
+ object_class->dispose = sp_common_context_dispose;
+
+ event_context_class->setup = sp_common_context_setup;
+ event_context_class->set = sp_common_context_set;
+ event_context_class->root_handler = sp_common_context_root_handler;
+}
+
+static void sp_common_context_init(SPCommonContext *ctx)
+{
+// ctx->cursor_shape = cursor_eraser_xpm;
+// ctx->hot_x = 4;
+// ctx->hot_y = 4;
+
+ ctx->accumulated = 0;
+ ctx->segments = 0;
+ ctx->currentcurve = 0;
+ ctx->currentshape = 0;
+ ctx->npoints = 0;
+ ctx->cal1 = 0;
+ ctx->cal2 = 0;
+ ctx->repr = 0;
+
+ /* Common values */
+ ctx->cur = NR::Point(0,0);
+ ctx->last = NR::Point(0,0);
+ ctx->vel = NR::Point(0,0);
+ ctx->vel_max = 0;
+ ctx->acc = NR::Point(0,0);
+ ctx->ang = NR::Point(0,0);
+ ctx->del = NR::Point(0,0);
+
+ /* attributes */
+ ctx->dragging = FALSE;
+
+ ctx->mass = 0.3;
+ ctx->drag = DRAG_DEFAULT;
+ ctx->angle = 30.0;
+ ctx->width = 0.2;
+ ctx->pressure = DEFAULT_PRESSURE;
+
+ ctx->vel_thin = 0.1;
+ ctx->flatness = 0.9;
+ ctx->cap_rounding = 0.0;
+
+ ctx->abs_width = false;
+}
+
+static void sp_common_context_dispose(GObject *object)
+{
+ SPCommonContext *ctx = SP_COMMON_CONTEXT(object);
+
+ if (ctx->accumulated) {
+ ctx->accumulated = ctx->accumulated->unref();
+ ctx->accumulated = 0;
+ }
+
+ while (ctx->segments) {
+ gtk_object_destroy(GTK_OBJECT(ctx->segments->data));
+ ctx->segments = g_slist_remove(ctx->segments, ctx->segments->data);
+ }
+
+ if (ctx->currentcurve) {
+ ctx->currentcurve = ctx->currentcurve->unref();
+ ctx->currentcurve = 0;
+ }
+ if (ctx->cal1) {
+ ctx->cal1 = ctx->cal1->unref();
+ ctx->cal1 = 0;
+ }
+ if (ctx->cal2) {
+ ctx->cal2 = ctx->cal2->unref();
+ ctx->cal2 = 0;
+ }
+
+ if (ctx->currentshape) {
+ gtk_object_destroy(GTK_OBJECT(ctx->currentshape));
+ ctx->currentshape = 0;
+ }
+
+ if (ctx->_message_context) {
+ delete ctx->_message_context;
+ ctx->_message_context = 0;
+ }
+
+ G_OBJECT_CLASS(common_parent_class)->dispose(object);
+}
+
+
+static void sp_common_context_setup(SPEventContext */*ec*/)
+{
+}
+
+
+static void sp_common_context_set(SPEventContext */*ec*/, gchar const */*key*/, gchar const */*value*/)
+{
+}
+
+static gint sp_common_context_root_handler(SPEventContext */*event_context*/, GdkEvent */*event*/)
+{
+ return 0;
+}
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
diff --git a/src/common-context.h b/src/common-context.h
--- /dev/null
+++ b/src/common-context.h
@@ -0,0 +1,119 @@
+#ifndef COMMON_CONTEXT_H_SEEN
+#define COMMON_CONTEXT_H_SEEN
+
+/*
+ * Common drawing mode
+ *
+ * Authors:
+ * Mitsuru Oka <oka326@parkcity.ne.jp>
+ * Lauris Kaplinski <lauris@kaplinski.com>
+ *
+ * The original dynadraw code:
+ * Paul Haeberli <paul@sgi.com>
+ *
+ * Copyright (C) 1998 The Free Software Foundation
+ * Copyright (C) 1999-2002 authors
+ * Copyright (C) 2001-2002 Ximian, Inc.
+ * Copyright (C) 2008 Jon A. Cruz
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "event-context.h"
+#include "display/curve.h"
+#include "display/display-forward.h"
+
+#define SP_TYPE_COMMON_CONTEXT (sp_common_context_get_type())
+#define SP_COMMON_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_COMMON_CONTEXT, SPCommonContext))
+#define SP_COMMON_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_COMMON_CONTEXT, SPCommonContextClass))
+#define SP_IS_COMMON_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_COMMON_CONTEXT))
+#define SP_IS_COMMON_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_COMMON_CONTEXT))
+
+class SPCommonContext;
+class SPCommonContextClass;
+
+#define SAMPLING_SIZE 8 /* fixme: ?? */
+
+
+struct SPCommonContext : public SPEventContext {
+ /** accumulated shape which ultimately goes in svg:path */
+ SPCurve *accumulated;
+
+ /** canvas items for "comitted" segments */
+ GSList *segments;
+
+ /** canvas item for red "leading" segment */
+ SPCanvasItem *currentshape;
+ /** shape of red "leading" segment */
+ SPCurve *currentcurve;
+
+ /** left edge of the stroke; combined to get accumulated */
+ SPCurve *cal1;
+
+ /** right edge of the stroke; combined to get accumulated */
+ SPCurve *cal2;
+
+ /** left edge points for this segment */
+ NR::Point point1[SAMPLING_SIZE];
+
+ /** right edge points for this segment */
+ NR::Point point2[SAMPLING_SIZE];
+
+ /** number of edge points for this segment */
+ gint npoints;
+
+ /* repr */
+ Inkscape::XML::Node *repr;
+
+ /* common */
+ NR::Point cur;
+ NR::Point vel;
+ double vel_max;
+ NR::Point acc;
+ NR::Point ang;
+ NR::Point last;
+ NR::Point del;
+
+ /* extended input data */
+ gdouble pressure;
+ gdouble xtilt;
+ gdouble ytilt;
+
+ /* attributes */
+ guint dragging : 1; /* mouse state: mouse is dragging */
+ guint usepressure : 1;
+ guint usetilt : 1;
+ double mass, drag;
+ double angle;
+ double width;
+
+ double vel_thin;
+ double flatness;
+ double tremor;
+ double cap_rounding;
+
+ Inkscape::MessageContext *_message_context;
+
+ bool is_drawing;
+
+ /** uses absolute width independent of zoom */
+ bool abs_width;
+};
+
+struct SPCommonContextClass : public SPEventContextClass{};
+
+GType sp_common_context_get_type(void);
+
+#endif // COMMON_CONTEXT_H_SEEN
+
+/*
+ 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:encoding=utf-8:textwidth=99 :
+
index 9574d2cad0daf3db717fd2b936925dd18923855d..9f759558c603cf49b8c3d7365d6ae1ab9d1bf283 100644 (file)
@@ -117,7 +117,7 @@ static NR::Point sp_dyna_draw_get_vpoint(SPDynaDrawContext const *ddc, NR::Point
static void draw_temporary_box(SPDynaDrawContext *dc);
-static SPEventContextClass *parent_class;
+static SPEventContextClass *dd_parent_class = 0;
GType sp_dyna_draw_context_get_type(void)
{
(GInstanceInitFunc)sp_dyna_draw_context_init,
0 // value_table
};
- type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPDynaDrawContext", &info, static_cast<GTypeFlags>(0));
+ type = g_type_register_static(SP_TYPE_COMMON_CONTEXT, "SPDynaDrawContext", &info, static_cast<GTypeFlags>(0));
}
return type;
}
GObjectClass *object_class = (GObjectClass *) klass;
SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
- parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass);
+ dd_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass);
object_class->dispose = sp_dyna_draw_context_dispose;
static void
sp_dyna_draw_context_init(SPDynaDrawContext *ddc)
{
- SPEventContext *event_context = SP_EVENT_CONTEXT(ddc);
-
- event_context->cursor_shape = cursor_calligraphy_xpm;
- event_context->hot_x = 4;
- event_context->hot_y = 4;
-
- ddc->accumulated = NULL;
- ddc->segments = NULL;
- ddc->currentcurve = NULL;
- ddc->currentshape = NULL;
- ddc->npoints = 0;
- ddc->cal1 = NULL;
- ddc->cal2 = NULL;
- ddc->repr = NULL;
-
- /* DynaDraw values */
- ddc->cur = NR::Point(0,0);
- ddc->last = NR::Point(0,0);
- ddc->vel = NR::Point(0,0);
- ddc->vel_max = 0;
- ddc->acc = NR::Point(0,0);
- ddc->ang = NR::Point(0,0);
- ddc->del = NR::Point(0,0);
-
- /* attributes */
- ddc->dragging = FALSE;
-
- ddc->mass = 0.3;
- ddc->drag = DRAG_DEFAULT;
- ddc->angle = 30.0;
- ddc->width = 0.2;
- ddc->pressure = DDC_DEFAULT_PRESSURE;
+ ddc->cursor_shape = cursor_calligraphy_xpm;
+ ddc->hot_x = 4;
+ ddc->hot_y = 4;
ddc->vel_thin = 0.1;
ddc->flatness = 0.9;
ddc->hatch_area = NULL;
}
- if (ddc->accumulated) {
- ddc->accumulated = ddc->accumulated->unref();
- }
-
- while (ddc->segments) {
- gtk_object_destroy(GTK_OBJECT(ddc->segments->data));
- ddc->segments = g_slist_remove(ddc->segments, ddc->segments->data);
- }
-
- if (ddc->currentcurve) ddc->currentcurve = ddc->currentcurve->unref();
- if (ddc->cal1) ddc->cal1 = ddc->cal1->unref();
- if (ddc->cal2) ddc->cal2 = ddc->cal2->unref();
-
- if (ddc->currentshape) {
- gtk_object_destroy(GTK_OBJECT(ddc->currentshape));
- ddc->currentshape = NULL;
- }
-
- if (ddc->_message_context) {
- delete ddc->_message_context;
- }
- G_OBJECT_CLASS(parent_class)->dispose(object);
+ G_OBJECT_CLASS(dd_parent_class)->dispose(object);
ddc->hatch_pointer_past.~list();
ddc->hatch_nearest_past.~list();
{
SPDynaDrawContext *ddc = SP_DYNA_DRAW_CONTEXT(ec);
- if (((SPEventContextClass *) parent_class)->setup)
- ((SPEventContextClass *) parent_class)->setup(ec);
+ if (((SPEventContextClass *) dd_parent_class)->setup)
+ ((SPEventContextClass *) dd_parent_class)->setup(ec);
ddc->accumulated = new SPCurve(32);
ddc->currentcurve = new SPCurve(4);
}
if (!ret) {
- if (((SPEventContextClass *) parent_class)->root_handler) {
- ret = ((SPEventContextClass *) parent_class)->root_handler(event_context, event);
+ if (((SPEventContextClass *) dd_parent_class)->root_handler) {
+ ret = ((SPEventContextClass *) dd_parent_class)->root_handler(event_context, event);
}
}
index 0e83f6b506e85c08a7d8e72220815715c6e602ce..9232dd04b7cbca10b459c517378266586b920e43 100644 (file)
--- a/src/dyna-draw-context.h
+++ b/src/dyna-draw-context.h
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "event-context.h"
-#include <display/display-forward.h>
-#include <libnr/nr-point.h>
+#include "common-context.h"
#define SP_TYPE_DYNA_DRAW_CONTEXT (sp_dyna_draw_context_get_type())
#define SP_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContext))
class SPDynaDrawContext;
class SPDynaDrawContextClass;
-#define SAMPLING_SIZE 8 /* fixme: ?? */
-
#define DDC_MIN_PRESSURE 0.0
#define DDC_MAX_PRESSURE 1.0
#define DDC_DEFAULT_PRESSURE 1.0
#define DDC_MAX_TILT 1.0
#define DDC_DEFAULT_TILT 0.0
-struct SPDynaDrawContext
-{
- SPEventContext event_context;
-
- /** accumulated shape which ultimately goes in svg:path */
- SPCurve *accumulated;
-
- /** canvas items for "comitted" segments */
- GSList *segments;
-
- /** canvas item for red "leading" segment */
- SPCanvasItem *currentshape;
- /** shape of red "leading" segment */
- SPCurve *currentcurve;
-
- /** left edge of the stroke; combined to get accumulated */
- SPCurve *cal1;
- /** right edge of the stroke; combined to get accumulated */
- SPCurve *cal2;
-
- /** left edge points for this segment */
- NR::Point point1[SAMPLING_SIZE];
- /** right edge points for this segment */
- NR::Point point2[SAMPLING_SIZE];
- /** number of edge points for this segment */
- gint npoints;
-
- /* repr */
- Inkscape::XML::Node *repr;
-
- /* DynaDraw */
- NR::Point cur;
- NR::Point vel;
- double vel_max;
- NR::Point acc;
- NR::Point ang;
- NR::Point last;
- NR::Point del;
- /* extended input data */
- gdouble pressure;
- gdouble xtilt;
- gdouble ytilt;
- /* attributes */
- guint dragging : 1; /* mouse state: mouse is dragging */
- guint usepressure : 1;
- guint usetilt : 1;
- double mass, drag;
- double angle;
- double width;
-
- double vel_thin;
- double flatness;
- double tremor;
- double cap_rounding;
-
- Inkscape::MessageContext *_message_context;
-
- bool is_drawing;
-
- /** uses absolute width independent of zoom */
- bool abs_width;
-
+struct SPDynaDrawContext : public SPCommonContext {
/** newly created object remain selected */
bool keep_selected;
bool trace_bg;
};
-struct SPDynaDrawContextClass
-{
- SPEventContextClass parent_class;
-};
+struct SPDynaDrawContextClass : public SPEventContextClass{};
GType sp_dyna_draw_context_get_type(void);
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index f30b004eae24d172b589ce85706e4d2185c6cbe2..1920baed5be3bd11dbca846afb3548d2039e51a4 100644 (file)
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
(GInstanceInitFunc)sp_eraser_context_init,
0 // value_table
};
- type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPEraserContext", &info, static_cast<GTypeFlags>(0));
+ type = g_type_register_static(SP_TYPE_COMMON_CONTEXT, "SPEraserContext", &info, static_cast<GTypeFlags>(0));
}
return type;
}
static void
sp_eraser_context_init(SPEraserContext *erc)
{
- SPEventContext *event_context = SP_EVENT_CONTEXT(erc);
-
- event_context->cursor_shape = cursor_eraser_xpm;
- event_context->hot_x = 4;
- event_context->hot_y = 4;
-
- erc->accumulated = NULL;
- erc->segments = NULL;
- erc->currentcurve = NULL;
- erc->currentshape = NULL;
- erc->npoints = 0;
- erc->cal1 = NULL;
- erc->cal2 = NULL;
- erc->repr = NULL;
-
- /* Eraser values */
- erc->cur = NR::Point(0,0);
- erc->last = NR::Point(0,0);
- erc->vel = NR::Point(0,0);
- erc->vel_max = 0;
- erc->acc = NR::Point(0,0);
- erc->ang = NR::Point(0,0);
- erc->del = NR::Point(0,0);
-
- /* attributes */
- erc->dragging = FALSE;
-
- erc->mass = 0.3;
- erc->drag = DRAG_DEFAULT;
- erc->angle = 30.0;
- erc->width = 0.2;
- erc->pressure = ERC_DEFAULT_PRESSURE;
-
- erc->vel_thin = 0.1;
- erc->flatness = 0.9;
- erc->cap_rounding = 0.0;
-
- erc->abs_width = false;
+ erc->cursor_shape = cursor_eraser_xpm;
+ erc->hot_x = 4;
+ erc->hot_y = 4;
}
static void
sp_eraser_context_dispose(GObject *object)
{
- SPEraserContext *erc = SP_ERASER_CONTEXT(object);
-
- if (erc->accumulated) {
- erc->accumulated = erc->accumulated->unref();
- }
-
- while (erc->segments) {
- gtk_object_destroy(GTK_OBJECT(erc->segments->data));
- erc->segments = g_slist_remove(erc->segments, erc->segments->data);
- }
-
- if (erc->currentcurve) erc->currentcurve = erc->currentcurve->unref();
- if (erc->cal1) erc->cal1 = erc->cal1->unref();
- if (erc->cal2) erc->cal2 = erc->cal2->unref();
-
- if (erc->currentshape) {
- gtk_object_destroy(GTK_OBJECT(erc->currentshape));
- erc->currentshape = 0;
- }
-
- if (erc->_message_context) {
- delete erc->_message_context;
- erc->_message_context = 0;
- }
+ //SPEraserContext *erc = SP_ERASER_CONTEXT(object);
G_OBJECT_CLASS(eraser_parent_class)->dispose(object);
}
diff --git a/src/eraser-context.h b/src/eraser-context.h
index b47c21b577cab1b48f04d3a85a79320d6e8cbdae..0e3f5c625f8598c8dcebb7a8fad8207ca95c5828 100644 (file)
--- a/src/eraser-context.h
+++ b/src/eraser-context.h
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "display/curve.h"
-#include "event-context.h"
-#include <display/display-forward.h>
-#include <libnr/nr-point.h>
+#include "common-context.h"
#define SP_TYPE_ERASER_CONTEXT (sp_eraser_context_get_type())
#define SP_ERASER_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_ERASER_CONTEXT, SPEraserContext))
class SPEraserContext;
class SPEraserContextClass;
-#define SAMPLING_SIZE 8 /* fixme: ?? */
-
#define ERC_MIN_PRESSURE 0.0
#define ERC_MAX_PRESSURE 1.0
#define ERC_DEFAULT_PRESSURE 1.0
#define ERC_MAX_TILT 1.0
#define ERC_DEFAULT_TILT 0.0
-struct SPEraserContext : public SPEventContext {
- /** accumulated shape which ultimately goes in svg:path */
- SPCurve *accumulated;
-
- /** canvas items for "comitted" segments */
- GSList *segments;
-
- /** canvas item for red "leading" segment */
- SPCanvasItem *currentshape;
- /** shape of red "leading" segment */
- SPCurve *currentcurve;
-
- /** left edge of the stroke; combined to get accumulated */
- SPCurve *cal1;
-
- /** right edge of the stroke; combined to get accumulated */
- SPCurve *cal2;
-
- /** left edge points for this segment */
- NR::Point point1[SAMPLING_SIZE];
-
- /** right edge points for this segment */
- NR::Point point2[SAMPLING_SIZE];
-
- /** number of edge points for this segment */
- gint npoints;
-
- /* repr */
- Inkscape::XML::Node *repr;
-
- /* Eraser */
- NR::Point cur;
- NR::Point vel;
- double vel_max;
- NR::Point acc;
- NR::Point ang;
- NR::Point last;
- NR::Point del;
-
- /* extended input data */
- gdouble pressure;
- gdouble xtilt;
- gdouble ytilt;
-
- /* attributes */
- guint dragging : 1; /* mouse state: mouse is dragging */
- guint usepressure : 1;
- guint usetilt : 1;
- double mass, drag;
- double angle;
- double width;
-
- double vel_thin;
- double flatness;
- double tremor;
- double cap_rounding;
-
- Inkscape::MessageContext *_message_context;
-
- bool is_drawing;
-
- /** uses absolute width independent of zoom */
- bool abs_width;
+struct SPEraserContext : public SPCommonContext {
};
struct SPEraserContextClass : public SPEventContextClass{};