From 156cf3323a936c7dfccd9e09458cd8b5d174b7fe Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Sun, 5 Oct 2014 19:24:27 -0400 Subject: Move more UI code into ui/ (bzr r13341.1.253) --- src/tools-switch.cpp | 195 --------------------------------------------------- 1 file changed, 195 deletions(-) delete mode 100644 src/tools-switch.cpp (limited to 'src/tools-switch.cpp') diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp deleted file mode 100644 index fe9d32f43..000000000 --- a/src/tools-switch.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Utility functions for switching tools (= contexts) - * - * Authors: - * bulia byak - * Josh Andler - * - * Copyright (C) 2003-2007 authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include - -#include "inkscape-private.h" -#include "desktop.h" -#include "desktop-handles.h" -#include - -#include - -#include "ui/tools/select-tool.h" -#include "ui/tools/node-tool.h" -#include "ui/tools/tweak-tool.h" -#include "ui/tools/spray-tool.h" -#include "sp-path.h" -#include "ui/tools/rect-tool.h" -#include "sp-rect.h" -#include "ui/tools/box3d-tool.h" -#include "box3d.h" -#include "ui/tools/arc-tool.h" -#include "sp-ellipse.h" -#include "ui/tools/tweak-tool.h" -#include "sp-star.h" -#include "ui/tools/spiral-tool.h" -#include "sp-spiral.h" -#include "ui/tools/calligraphic-tool.h" -#include "ui/tools/eraser-tool.h" -#include "ui/tools/pen-tool.h" -#include "ui/tools/pencil-tool.h" -#include "ui/tools/lpe-tool.h" -#include "ui/tools/text-tool.h" -#include "sp-text.h" -#include "sp-flowtext.h" -#include "ui/tools/gradient-tool.h" -#include "ui/tools/mesh-tool.h" -#include "ui/tools/zoom-tool.h" -#include "ui/tools/measure-tool.h" -#include "ui/tools/dropper-tool.h" -#include "ui/tools/connector-tool.h" -#include "ui/tools/flood-tool.h" -#include "sp-offset.h" -#include "message-context.h" - -#include "tools-switch.h" - -static char const *const tool_names[] = { - NULL, - "/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/mesh", - "/tools/zoom", - "/tools/measure", - "/tools/dropper", - "/tools/connector", - "/tools/paintbucket", - "/tools/eraser", - "/tools/lpetool", - NULL -}; -static char const *const tool_msg[] = { - NULL, - N_("Click to Select and Transform objects, Drag to select many objects."), - N_("Modify selected path points (nodes) directly."), - N_("To tweak a path by pushing, select it and drag over it."), - N_("Drag, click or click and scroll to spray the selected objects."), - N_("Drag to create a rectangle. Drag controls to round corners and resize. Click to select."), - N_("Drag to create a 3D box. Drag controls to resize in perspective. Click to select (with Ctrl+Alt for single faces)."), - N_("Drag to create an ellipse. Drag controls to make an arc or segment. Click to select."), - N_("Drag to create a star. Drag controls to edit the star shape. Click to select."), - N_("Drag to create a spiral. Drag controls to edit the spiral shape. Click to select."), - N_("Drag to create a freehand line. Shift appends to selected path, Alt activates sketch mode."), - N_("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)."), - N_("Drag to draw a calligraphic stroke; with Ctrl to track a guide path. Arrow keys adjust width (left/right) and angle (up/down)."), - N_("Click to select or create text, drag to create flowed text; then type."), - N_("Drag or double click to create a gradient on selected objects, drag handles to adjust gradients."), - N_("Drag or double click to create a mesh on selected objects, drag handles to adjust meshes."), - N_("Click or drag around an area to zoom in, Shift+click to zoom out."), - N_("Drag to measure the dimensions of objects."), - N_("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"), - N_("Click and drag between shapes to create a connector."), - N_("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."), - N_("Drag to erase."), - N_("Choose a subtool from the toolbar"), -}; - -static int -tools_prefpath2num(char const *id) -{ - int i = 1; - while (tool_names[i]) { - if (strcmp(tool_names[i], id) == 0) - return i; - else i++; - } - g_assert( 0 == TOOLS_INVALID ); - return 0; //nothing found -} - -int -tools_isactive(SPDesktop *dt, unsigned num) -{ - g_assert( num < G_N_ELEMENTS(tool_names) ); - if (SP_IS_EVENT_CONTEXT(dt->event_context)) - return dt->event_context->pref_observer->observed_path == tool_names[num]; - else return FALSE; -} - -int -tools_active(SPDesktop *dt) -{ - return tools_prefpath2num(dt->event_context->pref_observer->observed_path.data()); -} - -void -tools_switch(SPDesktop *dt, int num) -{ - dt->tipsMessageContext()->set(Inkscape::NORMAL_MESSAGE, gettext( tool_msg[num] ) ); - if (dt) { - // This event may change the above message - dt->_tool_changed.emit(num); - } - - dt->set_event_context2(tool_names[num]); - /* 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()); -} - -void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p) -{ - 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)) { - tools_switch(dt, TOOLS_SHAPES_STAR); - } else if (SP_IS_SPIRAL(item)) { - tools_switch(dt, TOOLS_SHAPES_SPIRAL); - } else if (SP_IS_PATH(item)) { - if (Inkscape::UI::Tools::cc_item_is_connector(item)) { - tools_switch(dt, TOOLS_CONNECTOR); - } - else { - tools_switch(dt, TOOLS_NODES); - } - } 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); - } -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : -- cgit v1.2.3