Code

Add ctrl+click to paint bucket to change clicked object's fill and stroke to current...
authorjohncoswell <johncoswell@users.sourceforge.net>
Sun, 11 Mar 2007 15:02:41 +0000 (15:02 +0000)
committerjohncoswell <johncoswell@users.sourceforge.net>
Sun, 11 Mar 2007 15:02:41 +0000 (15:02 +0000)
src/flood-context.cpp
src/tools-switch.cpp

index 24c948241f36f6bc0b0d9e26dc7b55e490af738c..aa6eab7b36cb7390b76ac8cd697a73a5f333378f 100644 (file)
@@ -737,10 +737,22 @@ static gint sp_flood_context_item_handler(SPEventContext *event_context, SPItem
 {
     gint ret = FALSE;
 
+    SPDesktop *desktop = event_context->desktop;
+
     switch (event->type) {
     case GDK_BUTTON_PRESS:
+        if (event->button.state & GDK_CONTROL_MASK) {
+            NR::Point const button_w(event->button.x,
+                                     event->button.y);
+            
+            SPItem *item = sp_event_context_find_item (desktop, button_w, TRUE, TRUE);
+            
+            Inkscape::XML::Node *pathRepr = SP_OBJECT_REPR(item);
+            /* Set style */
+            sp_desktop_apply_style_tool (desktop, pathRepr, "tools.paintbucket", false);
+            ret = TRUE;
+        }
         break;
-        // motion and release are always on root (why?)
     default:
         break;
     }
@@ -760,18 +772,19 @@ static gint sp_flood_context_root_handler(SPEventContext *event_context, GdkEven
     switch (event->type) {
     case GDK_BUTTON_PRESS:
         if ( event->button.button == 1 ) {
-
-            // set "busy" cursor
-            GdkCursor *waiting = gdk_cursor_new(GDK_WATCH);
-            gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, waiting);
-
-            sp_flood_do_flood_fill(event_context, event);
-
-            // restore cursor when done
-            gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, event_context->cursor);
-            gdk_cursor_unref(waiting);
-
-            ret = TRUE;
+            if (!(event->button.state & GDK_CONTROL_MASK)) {
+                // set "busy" cursor
+                GdkCursor *waiting = gdk_cursor_new(GDK_WATCH);
+                gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, waiting);
+    
+                sp_flood_do_flood_fill(event_context, event);
+    
+                // restore cursor when done
+                gdk_window_set_cursor(GTK_WIDGET(sp_desktop_canvas(desktop))->window, event_context->cursor);
+                gdk_cursor_unref(waiting);
+    
+                ret = TRUE;
+            }
         }
         break;
     case GDK_KEY_PRESS:
index 1d92d74d13e2e9f27ffe74010b1382e11a2cff50..1dbb0f29f7391ee6dbb84ccdd84c4b9c17cd5284 100644 (file)
@@ -213,7 +213,7 @@ tools_switch(SPDesktop *dt, int num)
             dt->set_event_context(SP_TYPE_FLOOD_CONTEXT, tool_names[num]);
             dt->activate_guides(false);
             inkscape_eventcontext_set(sp_desktop_event_context(dt));
-            dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to paint a bounded area."));
+            dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to paint a bounded area, <b>Ctrl+click</b> to change the clicked object's fill and stroke to the current setting."));
             break;
     }
 }