summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7f8b4ee)
raw | patch | inline | side by side (parent: 7f8b4ee)
author | joncruz <joncruz@users.sourceforge.net> | |
Mon, 2 Jun 2008 07:01:30 +0000 (07:01 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Mon, 2 Jun 2008 07:01:30 +0000 (07:01 +0000) |
Fixes bug #236667 and issues with middle-drag and ctrl-arrow.
src/common-context.cpp | patch | blob | history | |
src/dyna-draw-context.cpp | patch | blob | history | |
src/eraser-context.cpp | patch | blob | history |
diff --git a/src/common-context.cpp b/src/common-context.cpp
index a52e83c22fce6bbfa730ce64fd7c64e5e53bae8e..c28e704ee789f7ee3ede1b0b90db17684137dcd3 100644 (file)
--- a/src/common-context.cpp
+++ b/src/common-context.cpp
#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
+#define DRAG_MIN 0.0
+#define DRAG_DEFAULT 1.0
+#define DRAG_MAX 1.0
+
static void sp_common_context_class_init(SPCommonContextClass *klass);
static void sp_common_context_init(SPCommonContext *erc);
}
-static void sp_common_context_setup(SPEventContext */*ec*/)
+static void sp_common_context_setup(SPEventContext *ec)
{
+ if ( common_parent_class->setup ) {
+ common_parent_class->setup(ec);
+ }
}
-static void sp_common_context_set(SPEventContext */*ec*/, gchar const */*key*/, gchar const */*value*/)
+static void sp_common_context_set(SPEventContext *ec, gchar const *key, gchar const *value)
{
+ SPCommonContext *ctx = SP_COMMON_CONTEXT(ec);
+
+ if (!strcmp(key, "mass")) {
+ double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.2 );
+ ctx->mass = CLAMP(dval, -1000.0, 1000.0);
+ } else if (!strcmp(key, "wiggle")) {
+ double const dval = ( value ? g_ascii_strtod (value, NULL) : (1 - DRAG_DEFAULT));
+ ctx->drag = CLAMP((1 - dval), DRAG_MIN, DRAG_MAX); // drag is inverse to wiggle
+ } else if (!strcmp(key, "angle")) {
+ double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.0);
+ ctx->angle = CLAMP (dval, -90, 90);
+ } else if (!strcmp(key, "width")) {
+ double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.1 );
+ ctx->width = CLAMP(dval, -1000.0, 1000.0);
+ } else if (!strcmp(key, "thinning")) {
+ double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.1 );
+ ctx->vel_thin = CLAMP(dval, -1.0, 1.0);
+ } else if (!strcmp(key, "tremor")) {
+ double const dval = ( value ? g_ascii_strtod (value, NULL) : 0.0 );
+ ctx->tremor = CLAMP(dval, 0.0, 1.0);
+ } else if (!strcmp(key, "flatness")) {
+ double const dval = ( value ? g_ascii_strtod (value, NULL) : 1.0 );
+ ctx->flatness = CLAMP(dval, 0, 1.0);
+ } else if (!strcmp(key, "usepressure")) {
+ ctx->usepressure = ( value && strcmp(value, "0"));
+ } else if (!strcmp(key, "usetilt")) {
+ ctx->usetilt = ( value && strcmp(value, "0"));
+ } else if (!strcmp(key, "abs_width")) {
+ ctx->abs_width = ( value && strcmp(value, "0"));
+ } else if (!strcmp(key, "cap_rounding")) {
+ ctx->cap_rounding = ( value ? g_ascii_strtod (value, NULL) : 0.0 );
+ }
}
-static gint sp_common_context_root_handler(SPEventContext */*event_context*/, GdkEvent */*event*/)
+static gint sp_common_context_root_handler(SPEventContext *event_context, GdkEvent *event)
{
- return 0;
+ gint ret = FALSE;
+
+ // TODO add common hanlding
+
+
+ if ( !ret ) {
+ if ( common_parent_class->root_handler ) {
+ ret = common_parent_class->root_handler(event_context, event);
+ }
+ }
+
+ return ret;
}
/*
index 9f759558c603cf49b8c3d7365d6ae1ab9d1bf283..7f3c41c2ec94ebc0939b3a249d1ba2bdcb772ad2 100644 (file)
#define DYNA_MIN_WIDTH 1.0e-6
-#define DRAG_MIN 0.0
-#define DRAG_DEFAULT 1.0
-#define DRAG_MAX 1.0
// FIXME: move it to some shared file to be reused by both calligraphy and dropper
#define C1 0.552
@@ -258,39 +255,15 @@ sp_dyna_draw_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
{
SPDynaDrawContext *ddc = SP_DYNA_DRAW_CONTEXT(ec);
- if (!strcmp(key, "mass")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.2 );
- ddc->mass = CLAMP(dval, -1000.0, 1000.0);
- } else if (!strcmp(key, "wiggle")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : (1 - DRAG_DEFAULT));
- ddc->drag = CLAMP((1 - dval), DRAG_MIN, DRAG_MAX); // drag is inverse to wiggle
- } else if (!strcmp(key, "angle")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.0);
- ddc->angle = CLAMP (dval, -90, 90);
- } else if (!strcmp(key, "width")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.1 );
- ddc->width = CLAMP(dval, -1000.0, 1000.0);
- } else if (!strcmp(key, "thinning")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.1 );
- ddc->vel_thin = CLAMP(dval, -1.0, 1.0);
- } else if (!strcmp(key, "tremor")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.0 );
- ddc->tremor = CLAMP(dval, 0.0, 1.0);
- } else if (!strcmp(key, "flatness")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 1.0 );
- ddc->flatness = CLAMP(dval, 0, 1.0);
- } else if (!strcmp(key, "tracebackground")) {
+ if (!strcmp(key, "tracebackground")) {
ddc->trace_bg = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "usepressure")) {
- ddc->usepressure = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "usetilt")) {
- ddc->usetilt = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "abs_width")) {
- ddc->abs_width = (val && strcmp(val, "0"));
} else if (!strcmp(key, "keep_selected")) {
ddc->keep_selected = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "cap_rounding")) {
- ddc->cap_rounding = ( val ? g_ascii_strtod (val, NULL) : 0.0 );
+ } else {
+ //pass on up to parent class to handle common attributes.
+ if ( dd_parent_class->set ) {
+ dd_parent_class->set(ec, key, val);
+ }
}
//g_print("DDC: %g %g %g %g\n", ddc->mass, ddc->drag, ddc->angle, ddc->width);
diff --git a/src/eraser-context.cpp b/src/eraser-context.cpp
index 1920baed5be3bd11dbca846afb3548d2039e51a4..88496b06554c157517467a9da66f607b869c206b 100644 (file)
--- a/src/eraser-context.cpp
+++ b/src/eraser-context.cpp
static void
sp_eraser_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
{
- SPEraserContext *erc = SP_ERASER_CONTEXT(ec);
-
- if (!strcmp(key, "mass")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.2 );
- erc->mass = CLAMP(dval, -1000.0, 1000.0);
- } else if (!strcmp(key, "wiggle")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : (1 - DRAG_DEFAULT));
- erc->drag = CLAMP((1 - dval), DRAG_MIN, DRAG_MAX); // drag is inverse to wiggle
- } else if (!strcmp(key, "angle")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.0);
- erc->angle = CLAMP (dval, -90, 90);
- } else if (!strcmp(key, "width")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.1 );
- erc->width = CLAMP(dval, -1000.0, 1000.0);
- } else if (!strcmp(key, "thinning")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.1 );
- erc->vel_thin = CLAMP(dval, -1.0, 1.0);
- } else if (!strcmp(key, "tremor")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 0.0 );
- erc->tremor = CLAMP(dval, 0.0, 1.0);
- } else if (!strcmp(key, "flatness")) {
- double const dval = ( val ? g_ascii_strtod (val, NULL) : 1.0 );
- erc->flatness = CLAMP(dval, 0, 1.0);
- } else if (!strcmp(key, "usepressure")) {
- erc->usepressure = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "usetilt")) {
- erc->usetilt = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "abs_width")) {
- erc->abs_width = (val && strcmp(val, "0"));
- } else if (!strcmp(key, "cap_rounding")) {
- erc->cap_rounding = ( val ? g_ascii_strtod (val, NULL) : 0.0 );
+ //pass on up to parent class to handle common attributes.
+ if ( eraser_parent_class->set ) {
+ eraser_parent_class->set(ec, key, val);
}
-
- //g_print("ERC: %g %g %g %g\n", erc->mass, erc->drag, erc->angle, erc->width);
}
static double