Code

Initial cut of eraser tool
[inkscape.git] / src / tools-switch.cpp
index 1bc83d7a2bc09cdfde14eedc6ffbcd5b6ba80892..e32d8d13d27610869513e3455b97b084443a8a2a 100644 (file)
@@ -15,6 +15,9 @@
 # include "config.h"
 #endif
 
+#include <cstring>
+#include <string>
+
 #include "inkscape-private.h"
 #include "desktop.h"
 #include "desktop-handles.h"
@@ -37,6 +40,7 @@
 #include "spiral-context.h"
 #include "sp-spiral.h"
 #include "dyna-draw-context.h"
+#include "eraser-context.h"
 #include "pen-context.h"
 #include "pencil-context.h"
 #include "text-context.h"
@@ -71,6 +75,7 @@ static char const *const tool_names[] = {
     "tools.dropper",
     "tools.connector",
     "tools.paintbucket",
+    "tools.eraser",
     NULL
 };
 
@@ -93,6 +98,7 @@ static char const *const tool_ids[] = {
     "dropper",
     "connector",
     "paintbucket",
+    "eraser",
     NULL
 };
 
@@ -157,7 +163,7 @@ tools_switch(SPDesktop *dt, int num)
             dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a rectangle. <b>Drag controls</b> to round corners and resize. <b>Click</b> to select."));
             break;
         case TOOLS_SHAPES_3DBOX:
-            dt->set_event_context(SP_TYPE_3DBOX_CONTEXT, tool_names[num]);
+            dt->set_event_context(SP_TYPE_BOX3D_CONTEXT, tool_names[num]);
             dt->activate_guides(false);
             inkscape_eventcontext_set(sp_desktop_event_context(dt));
             dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a 3D box. <b>Drag controls</b> to resize in perspective. <b>Click</b> to select (with <b>Ctrl+Alt</b> for single faces)."));
@@ -184,13 +190,13 @@ tools_switch(SPDesktop *dt, int num)
             dt->set_event_context(SP_TYPE_PENCIL_CONTEXT, tool_names[num]);
             dt->activate_guides(false);
             inkscape_eventcontext_set(sp_desktop_event_context(dt));
-            dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a freehand line. Start drawing with <b>Shift</b> to append to selected path."));
+            dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to create a freehand line. Start drawing with <b>Shift</b> to append to selected path. <b>Ctrl+click</b> to create single dots."));
             break;
         case TOOLS_FREEHAND_PEN:
             dt->set_event_context(SP_TYPE_PEN_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> or <b>click and drag</b> to start a path; with <b>Shift</b> to append to selected path."));
+            dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to start a path; with <b>Shift</b> to append to selected path. <b>Ctrl+click</b> to create single dots."));
             break;
         case TOOLS_CALLIGRAPHIC:
             dt->set_event_context(SP_TYPE_DYNA_DRAW_CONTEXT, tool_names[num]);
@@ -234,6 +240,12 @@ tools_switch(SPDesktop *dt, int num)
             inkscape_eventcontext_set(sp_desktop_event_context(dt));
             dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> to paint a bounded area, <b>Shift+click</b> to union the new fill with the current selection, <b>Ctrl+click</b> to change the clicked object's fill and stroke to the current setting."));
             break;
+        case TOOLS_ERASER:
+            dt->set_event_context(SP_TYPE_ERASER_CONTEXT, tool_names[num]);
+            dt->activate_guides(false);
+            inkscape_eventcontext_set(sp_desktop_event_context(dt));
+            dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to erase."));
+            break;
     }
 }
 
@@ -248,6 +260,8 @@ void tools_switch_by_item(SPDesktop *dt, SPItem *item)
 {
     if (SP_IS_RECT(item)) {
         tools_switch(dt, TOOLS_SHAPES_RECT);
+    } else if (SP_IS_BOX3D(item)) {
+        tools_switch(dt, TOOLS_SHAPES_3DBOX);
     } else if (SP_IS_GENERICELLIPSE(item)) {
         tools_switch(dt, TOOLS_SHAPES_ARC);
     } else if (SP_IS_STAR(item)) {