X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Ftools-switch.cpp;h=e9fca952eb93c65ba2c4671169091b1135295710;hb=c7cf14ac71346f76ae219ce67fb88c1bd34832e2;hp=e32d8d13d27610869513e3455b97b084443a8a2a;hpb=b26cc655b98659f4a33794ee9169b67d908b824b;p=inkscape.git diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index e32d8d13d..e9fca952e 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -26,8 +26,9 @@ #include #include "select-context.h" -#include "node-context.h" +#include "ui/tool/node-tool.h" #include "tweak-context.h" +#include "spray-context.h" #include "sp-path.h" #include "rect-context.h" #include "sp-rect.h" @@ -43,6 +44,7 @@ #include "eraser-context.h" #include "pen-context.h" #include "pencil-context.h" +#include "lpe-tool-context.h" #include "text-context.h" #include "sp-text.h" #include "sp-flowtext.h" @@ -58,56 +60,35 @@ static char const *const tool_names[] = { NULL, - "tools.select", - "tools.nodes", - "tools.tweak", - "tools.shapes.rect", - "tools.shapes.3dbox", - "tools.shapes.arc", - "tools.shapes.star", - "tools.shapes.spiral", - "tools.freehand.pencil", - "tools.freehand.pen", - "tools.calligraphic", - "tools.text", - "tools.gradient", - "tools.zoom", - "tools.dropper", - "tools.connector", - "tools.paintbucket", - "tools.eraser", - NULL -}; - -static char const *const tool_ids[] = { - NULL, - "select", - "nodes", - "tweak", - "rect", - "3dbox", - "arc", - "star", - "spiral", - "pencil", - "pen", - "calligraphic", - "text", - "gradient", - "zoom", - "dropper", - "connector", - "paintbucket", - "eraser", + "/tools/select", + "/tools/nodes", + "/tools/tweak", + "/tools/spray", + "/tools/shapes/rect", + "/tools/shapes/3dbox", + "/tools/shapes/arc", + "/tools/shapes/star", + "/tools/shapes/spiral", + "/tools/freehand/pencil", + "/tools/freehand/pen", + "/tools/calligraphic", + "/tools/text", + "/tools/gradient", + "/tools/zoom", + "/tools/dropper", + "/tools/connector", + "/tools/paintbucket", + "/tools/eraser", + "/tools/lpetool", NULL }; static int -tools_id2num(char const *id) +tools_prefpath2num(char const *id) { int i = 1; - while (tool_ids[i]) { - if (strcmp(tool_ids[i], id) == 0) + while (tool_names[i]) { + if (strcmp(tool_names[i], id) == 0) return i; else i++; } @@ -118,16 +99,16 @@ tools_id2num(char const *id) int tools_isactive(SPDesktop *dt, unsigned num) { - g_assert( num < G_N_ELEMENTS(tool_ids) ); + g_assert( num < G_N_ELEMENTS(tool_names) ); if (SP_IS_EVENT_CONTEXT(dt->event_context)) - return (!strcmp(dt->event_context->prefs_repr->attribute("id"), tool_ids[num])); + return dt->event_context->pref_observer->observed_path == tool_names[num]; else return FALSE; } int tools_active(SPDesktop *dt) { - return (tools_id2num(dt->event_context->prefs_repr->attribute("id"))); + return tools_prefpath2num(dt->event_context->pref_observer->observed_path.data()); } void @@ -145,10 +126,9 @@ tools_switch(SPDesktop *dt, int num) inkscape_eventcontext_set(sp_desktop_event_context(dt)); break; case TOOLS_NODES: - dt->set_event_context(SP_TYPE_NODE_CONTEXT, tool_names[num]); + dt->set_event_context(INK_TYPE_NODE_TOOL, tool_names[num]); dt->activate_guides(true); inkscape_eventcontext_set(sp_desktop_event_context(dt)); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("To edit a path, click, Shift+click, or drag around nodes to select them, then drag nodes and handles. Click on an object to select.")); break; case TOOLS_TWEAK: dt->set_event_context(SP_TYPE_TWEAK_CONTEXT, tool_names[num]); @@ -156,6 +136,12 @@ tools_switch(SPDesktop *dt, int num) inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("To tweak a path by pushing, select it and drag over it.")); break; + case TOOLS_SPRAY: + dt->set_event_context(SP_TYPE_SPRAY_CONTEXT, tool_names[num]); + dt->activate_guides(true); + inkscape_eventcontext_set(sp_desktop_event_context(dt)); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("To spray a path by pushing, select it and drag over it.")); + break; case TOOLS_SHAPES_RECT: dt->set_event_context(SP_TYPE_RECT_CONTEXT, tool_names[num]); dt->activate_guides(false); @@ -190,19 +176,19 @@ 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, _("Drag to create a freehand line. Start drawing with Shift to append to selected path. Ctrl+click to create single dots.")); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a freehand line. Shift appends to selected path, Alt activates sketch mode.")); 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, _("Click or click and drag to start a path; with Shift to append to selected path. Ctrl+click to create single dots.")); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click or click and drag to start a path; with Shift to append to selected path. Ctrl+click to create single dots (straight line modes only).")); break; case TOOLS_CALLIGRAPHIC: dt->set_event_context(SP_TYPE_DYNA_DRAW_CONTEXT, tool_names[num]); dt->activate_guides(false); inkscape_eventcontext_set(sp_desktop_event_context(dt)); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to draw a calligraphic stroke; with Ctrl to track a guide, with Alt to thin/thicken. Arrow keys adjust width (left/right) and angle (up/down).")); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to draw a calligraphic stroke; with Ctrl to track a guide path. Arrow keys adjust width (left/right) and angle (up/down).")); break; case TOOLS_TEXT: dt->set_event_context(SP_TYPE_TEXT_CONTEXT, tool_names[num]); @@ -246,17 +232,16 @@ tools_switch(SPDesktop *dt, int num) inkscape_eventcontext_set(sp_desktop_event_context(dt)); dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to erase.")); break; + case TOOLS_LPETOOL: + dt->set_event_context(SP_TYPE_LPETOOL_CONTEXT, tool_names[num]); + dt->activate_guides(false); + inkscape_eventcontext_set(sp_desktop_event_context(dt)); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Choose a subtool from the toolbar")); + break; } } -void -tools_switch_current(int num) -{ - SPDesktop *dt = SP_ACTIVE_DESKTOP; - if (dt) tools_switch(dt, num); -} - -void tools_switch_by_item(SPDesktop *dt, SPItem *item) +void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p) { if (SP_IS_RECT(item)) { tools_switch(dt, TOOLS_SHAPES_RECT); @@ -277,6 +262,7 @@ void tools_switch_by_item(SPDesktop *dt, SPItem *item) } } else if (SP_IS_TEXT(item) || SP_IS_FLOWTEXT(item)) { tools_switch(dt, TOOLS_TEXT); + sp_text_context_place_cursor_at (SP_TEXT_CONTEXT(dt->event_context), SP_OBJECT(item), p); } else if (SP_IS_OFFSET(item)) { tools_switch(dt, TOOLS_NODES); } @@ -291,4 +277,4 @@ void tools_switch_by_item(SPDesktop *dt, SPItem *item) fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :