Code

Let LPEToolContext derive from PenContext so that we can use its LPE framework
authorcilix42 <cilix42@users.sourceforge.net>
Mon, 18 Aug 2008 00:34:50 +0000 (00:34 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Mon, 18 Aug 2008 00:34:50 +0000 (00:34 +0000)
src/lpe-tool-context.cpp
src/lpe-tool-context.h
src/preferences-skeleton.h
src/widgets/toolbox.cpp

index a93176067695e98c7208bb254e59463250685e0d..3df57027fcaa18309a2d088ea27df32f7c1df48a 100644 (file)
@@ -71,7 +71,7 @@ static void sp_lpetool_context_set(SPEventContext *ec, gchar const *key, gchar c
 static gint sp_lpetool_context_root_handler(SPEventContext *ec, GdkEvent *event);
 
 
-static SPEventContextClass *lpetool_parent_class = 0;
+static SPPenContextClass *lpetool_parent_class = 0;
 
 GType sp_lpetool_context_get_type(void)
 {
@@ -89,7 +89,7 @@ GType sp_lpetool_context_get_type(void)
             (GInstanceInitFunc)sp_lpetool_context_init,
             0 // value_table
         };
-        type = g_type_register_static(SP_TYPE_EVENT_CONTEXT, "SPLPEToolContext", &info, static_cast<GTypeFlags>(0));
+        type = g_type_register_static(SP_TYPE_PEN_CONTEXT, "SPLPEToolContext", &info, static_cast<GTypeFlags>(0));
     }
     return type;
 }
@@ -100,13 +100,13 @@ sp_lpetool_context_class_init(SPLPEToolContextClass *klass)
     GObjectClass *object_class = (GObjectClass *) klass;
     SPEventContextClass *event_context_class = (SPEventContextClass *) klass;
 
-    lpetool_parent_class = (SPEventContextClass*)g_type_class_peek_parent(klass);
+    lpetool_parent_class = (SPPenContextClass*)g_type_class_peek_parent(klass);
 
     object_class->dispose = sp_lpetool_context_dispose;
 
     event_context_class->setup = sp_lpetool_context_setup;
     event_context_class->set = sp_lpetool_context_set;
-    event_context_class->root_handler = sp_lpetool_context_root_handler;
+    //event_context_class->root_handler = sp_lpetool_context_root_handler;
 }
 
 static void
@@ -145,10 +145,16 @@ sp_lpetool_context_setup(SPEventContext *ec)
 static void
 sp_lpetool_context_set(SPEventContext *ec, gchar const *key, gchar const *val)
 {
+    // FIXME: how to set this correcly? the value from preferences-skeleton.h doesn't seem to get
+    // read (it wants to set drag = 1)
+    lpetool_parent_class->set(ec, key, "drag");
+
+    /**
     //pass on up to parent class to handle common attributes.
     if ( lpetool_parent_class->set ) {
         lpetool_parent_class->set(ec, key, val);
     }
+    **/
 }
 
 /**
index 73002143e42f1b8a899768293fcba60add13bb76..a5f849c7a2f33bbdcf232c3b8a464ede97869f5f 100644 (file)
@@ -16,7 +16,8 @@
  * Released under GNU GPL, read the file 'COPYING' for more information
  */
 
-#include "event-context.h"
+//#include "event-context.h"
+#include "pen-context.h"
 
 #define SP_TYPE_LPETOOL_CONTEXT (sp_lpetool_context_get_type())
 #define SP_LPETOOL_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContext))
@@ -27,7 +28,7 @@
 class SPLPEToolContext;
 class SPLPEToolContextClass;
 
-struct SPLPEToolContext : public SPEventContext {
+struct SPLPEToolContext : public SPPenContext {
 };
 
 struct SPLPEToolContextClass : public SPEventContextClass{};
index dfbbd61eeaa405eec8b43ef3cf7973c718d76e82..6a14b044aa66c177c9b62138675dd5d933929fc8 100644 (file)
@@ -85,7 +85,7 @@ static char const preferences_skeleton[] =
 "                       mass=\"0.02\" drag=\"1\" angle=\"30\" width=\"0.15\" thinning=\"0.1\" flatness=\"0.9\" cap_rounding=\"0.0\" usecurrent=\"0\"\n"
 "                       tracebackground=\"0\" usepressure=\"1\" usetilt=\"0\" selcue=\"1\">\n"
 "    </eventcontext>\n"
-"    <eventcontext id=\"lpetool\" mode=\"0\" style=\"fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;\">\n"
+"    <eventcontext id=\"lpetool\" mode=\"drag\" style=\"fill:#ff0000;fill-opacity:1;fill-rule:nonzero;stroke:none;\">\n"
 "    </eventcontext>\n"
 "    <eventcontext id=\"text\"  usecurrent=\"0\" gradientdrag=\"1\"\n"
 "                       font_sample=\"AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()\"\n"
index 18becfdb66b32b13ece1cdc44b105ee39ec9c62a..2a8f14a78f0200120ae61a6b11fd27b6980f4c80 100644 (file)
@@ -4802,7 +4802,9 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
             case 1:
                 // circle through 3 points
                 g_print ("circle through 3 points\n");
-                sp_pen_context_put_into_waiting_mode(desktop, Inkscape::LivePathEffect::CIRCLE_3PTS, 3);
+                //sp_pen_context_put_into_waiting_mode(desktop, Inkscape::LivePathEffect::CIRCLE_3PTS, 3);
+                sp_pen_context_wait_for_LPE_mouse_clicks(SP_PEN_CONTEXT(desktop->event_context), Inkscape::LivePathEffect::CIRCLE_3PTS, 3);
+                //sp_pen_context_put_into_waiting_mode(desktop, Inkscape::LivePathEffect::CIRCLE_3PTS, 3);
                 break;
             default:
                 // don't do anything