From df16775103cd981612d363bd6937cd2d68801b5f Mon Sep 17 00:00:00 2001 From: Martin Owens Date: Mon, 30 Sep 2013 04:43:12 -0400 Subject: Reduce tools-switcher code, add description for node and select toos. (bzr r12630) --- src/tools-switch.cpp | 164 ++++++++++----------------------------------------- 1 file changed, 30 insertions(+), 134 deletions(-) (limited to 'src/tools-switch.cpp') diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp index fd160e518..32fab9f7e 100644 --- a/src/tools-switch.cpp +++ b/src/tools-switch.cpp @@ -86,6 +86,31 @@ static char const *const tool_names[] = { "/tools/lpetool", NULL }; +static char const *const tool_msg[] = { + NULL, + _("Click to Select and Tranform objects, Drag to select many objects."), + _("Modify selected path points (nodes) directly."), + _("To tweak a path by pushing, select it and drag over it."), + _("Drag, click or click and scroll to spray the selected objects."), + _("Drag to create a rectangle. Drag controls to round corners and resize. Click to select."), + _("Drag to create a 3D box. Drag controls to resize in perspective. Click to select (with Ctrl+Alt for single faces)."), + _("Drag to create an ellipse. Drag controls to make an arc or segment. Click to select."), + _("Drag to create a star. Drag controls to edit the star shape. Click to select."), + _("Drag to create a spiral. Drag controls to edit the spiral shape. Click to select."), + _("Drag to create a freehand line. Shift appends to selected path, Alt activates sketch mode."), + _("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)."), + _("Drag to draw a calligraphic stroke; with Ctrl to track a guide path. Arrow keys adjust width (left/right) and angle (up/down)."), + _("Click to select or create text, drag to create flowed text; then type."), + _("Drag or double click to create a gradient on selected objects, drag handles to adjust gradients."), + _("Drag or double click to create a mesh on selected objects, drag handles to adjust meshes."), + _("Click or drag around an area to zoom in, Shift+click to zoom out."), + _("Drag to measure the dimensions of objects."), + _("Click to set fill, Shift+click to set stroke; drag to average color in area; with Alt to pick inverse color; Ctrl+C to copy the color under mouse to clipboard"), + _("Click and drag between shapes to create a connector."), + _("Click to paint a bounded area, Shift+click to union the new fill with the current selection, Ctrl+click to change the clicked object's fill and stroke to the current setting."), + _("Drag to erase."), + _("Choose a subtool from the toolbar"), +}; static int tools_prefpath2num(char const *id) @@ -123,140 +148,11 @@ tools_switch(SPDesktop *dt, int num) } dt->set_event_context2(tool_names[num]); - - switch (num) { - case TOOLS_SELECT: - //dt->set_event_context(SP_TYPE_SELECT_CONTEXT, tool_names[num]); - /* fixme: This is really ugly hack. We should bind and unbind class methods */ - dt->activate_guides(true); - inkscape_eventcontext_set(dt->getEventContext()); - break; - case TOOLS_NODES: - //dt->set_event_context(INK_TYPE_NODE_TOOL, tool_names[num]); - dt->activate_guides(true); - inkscape_eventcontext_set(dt->getEventContext()); - break; - case TOOLS_TWEAK: - //dt->set_event_context(SP_TYPE_TWEAK_CONTEXT, tool_names[num]); - dt->activate_guides(true); - inkscape_eventcontext_set(dt->getEventContext()); - 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(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag, click or click and scroll to spray the selected objects.")); - break; - case TOOLS_SHAPES_RECT: - //dt->set_event_context(SP_TYPE_RECT_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a rectangle. Drag controls to round corners and resize. Click to select.")); - break; - case TOOLS_SHAPES_3DBOX: - //dt->set_event_context(SP_TYPE_BOX3D_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a 3D box. Drag controls to resize in perspective. Click to select (with Ctrl+Alt for single faces).")); - break; - case TOOLS_SHAPES_ARC: - //dt->set_event_context(SP_TYPE_ARC_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create an ellipse. Drag controls to make an arc or segment. Click to select.")); - break; - case TOOLS_SHAPES_STAR: - //dt->set_event_context(SP_TYPE_STAR_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a star. Drag controls to edit the star shape. Click to select.")); - break; - case TOOLS_SHAPES_SPIRAL: - //dt->set_event_context(SP_TYPE_SPIRAL_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to create a spiral. Drag controls to edit the spiral shape. Click to select.")); - break; - case TOOLS_FREEHAND_PENCIL: - //dt->set_event_context(SP_TYPE_PENCIL_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - 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(dt->getEventContext()); - 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(dt->getEventContext()); - 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]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click to select or create text, drag to create flowed text; then type.")); - break; - case TOOLS_GRADIENT: - //dt->set_event_context(SP_TYPE_GRADIENT_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag or double click to create a gradient on selected objects, drag handles to adjust gradients.")); - break; - case TOOLS_MESH: - //dt->set_event_context(SP_TYPE_MESH_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag or double click to create a mesh on selected objects, drag handles to adjust meshes.")); - break; - case TOOLS_ZOOM: - //dt->set_event_context(SP_TYPE_ZOOM_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click or drag around an area to zoom in, Shift+click to zoom out.")); - break; - case TOOLS_MEASURE: - //dt->set_event_context(SP_TYPE_MEASURE_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Drag to measure the dimensions of objects.")); - break; - case TOOLS_DROPPER: - //dt->set_event_context(SP_TYPE_DROPPER_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click to set fill, Shift+click to set stroke; drag to average color in area; with Alt to pick inverse color; Ctrl+C to copy the color under mouse to clipboard")); - break; - case TOOLS_CONNECTOR: - //dt->set_event_context(SP_TYPE_CONNECTOR_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click and drag between shapes to create a connector.")); - break; - case TOOLS_PAINTBUCKET: - //dt->set_event_context(SP_TYPE_FLOOD_CONTEXT, tool_names[num]); - dt->activate_guides(false); - inkscape_eventcontext_set(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Click to paint a bounded area, Shift+click to union the new fill with the current selection, Ctrl+click 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(dt->getEventContext()); - 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(dt->getEventContext()); - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, _("Choose a subtool from the toolbar")); - break; - } + /* fixme: This is really ugly hack. We should bind and unbind class methods */ + /* First 4 tools use guides, first is undefined but we don't care */ + dt->activate_guides(num < 5); + inkscape_eventcontext_set(dt->getEventContext()); + dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, tool_msg[num] ); } void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p) -- cgit v1.2.3