Code

Adding the Interpolate tutorial in Help>Tutorials
[inkscape.git] / src / verbs.cpp
index f03be681a631d68ae11ffb88df3ae7f27a3a2bbc..421736b7f8dc0a9dcf758c3e3752d8f54e912e18 100644 (file)
@@ -16,6 +16,7 @@
  *   MenTaLguY <mental@rydia.net>
  *   David Turner <novalis@gnu.org>
  *   bulia byak <buliabyak@users.sf.net>
+ *   Jon A. Cruz <jon@joncruz.org>
  *
  * Copyright (C) 2006 Johan Engelen <johan@shouraizou.nl>
  * Copyright (C) (date unspecified) Authors
@@ -49,7 +50,6 @@
 #include "draw-context.h"
 #include "extension/effect.h"
 #include "file.h"
-#include "gradient-context.h"
 #include "gradient-drag.h"
 #include "helper/action.h"
 #include "help.h"
@@ -79,8 +79,6 @@
 #include "ui/dialog/layers.h"
 #include "ui/dialog/swatches.h"
 #include "ui/icon-names.h"
-#include "ui/tool/control-point-selection.h"
-#include "ui/tool/multi-path-manipulator.h"
 #include "ui/tool/node-tool.h"
 
 //#ifdef WITH_INKBOARD
@@ -835,7 +833,6 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
     SPDesktop *dt = static_cast<SPDesktop*>(sp_action_get_view(action));
     if (!dt)
         return;
-    SPEventContext *ec = dt->event_context;
 
     switch (reinterpret_cast<std::size_t>(data)) {
         case SP_VERB_EDIT_UNDO:
@@ -920,70 +917,26 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
             sp_edit_clear_all(dt);
             break;
         case SP_VERB_EDIT_SELECT_ALL:
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
-                nt->_multipath->selectSubpaths();
-            } else {
-                sp_edit_select_all(dt);
-            }
+            SelectionHelper::selectAll(dt);
             break;
         case SP_VERB_EDIT_INVERT:
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
-                nt->_multipath->invertSelectionInSubpaths();
-            } else {
-                sp_edit_invert(dt);
-            }
+            SelectionHelper::invert(dt);
             break;
         case SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS:
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
-                nt->_selected_nodes->selectAll();
-            } else {
-                sp_edit_select_all_in_all_layers(dt);
-            }
+            SelectionHelper::selectAllInAll(dt);
             break;
         case SP_VERB_EDIT_INVERT_IN_ALL_LAYERS:
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
-                nt->_selected_nodes->invertSelection();
-            } else {
-                sp_edit_invert_in_all_layers(dt);
-            }
+            SelectionHelper::invertAllInAll(dt);
             break;
-
         case SP_VERB_EDIT_SELECT_NEXT:
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
-                nt->_multipath->shiftSelection(1);
-            } else if (tools_isactive(dt, TOOLS_GRADIENT)
-                       && ec->_grdrag->isNonEmpty()) {
-                sp_gradient_context_select_next (ec);
-            } else {
-                sp_selection_item_next(dt);
-            }
+            SelectionHelper::selectNext(dt);
             break;
         case SP_VERB_EDIT_SELECT_PREV:
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
-                nt->_multipath->shiftSelection(-1);
-            } else if (tools_isactive(dt, TOOLS_GRADIENT)
-                       && ec->_grdrag->isNonEmpty()) {
-                sp_gradient_context_select_prev (ec);
-            } else {
-                sp_selection_item_prev(dt);
-            }
+            SelectionHelper::selectPrev(dt);
             break;
-
         case SP_VERB_EDIT_DESELECT:
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
-                nt->_selected_nodes->clear();
-            } else {
-                sp_desktop_selection(dt)->clear();
-            }
+            SelectionHelper::selectNone(dt);
             break;
-
         case SP_VERB_EDIT_GUIDES_AROUND_PAGE:
             sp_guide_create_guides_around_page(dt);
             break;
@@ -1095,13 +1048,7 @@ SelectionVerb::perform(SPAction *action, void *data, void */*pdata*/)
             sp_selected_path_simplify(dt);
             break;
         case SP_VERB_SELECTION_REVERSE:
-            // TODO make this a virtual method of event context!
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
-                nt->_multipath->reverseSubpaths();
-            } else {
-                sp_selected_path_reverse(dt);
-            }
+            SelectionHelper::reverse(dt);
             break;
         case SP_VERB_SELECTION_TRACE:
             inkscape_dialogs_unhide();
@@ -1450,6 +1397,9 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/)
         case SP_VERB_CONTEXT_TWEAK:
             tools_switch(dt, TOOLS_TWEAK);
             break;
+        case SP_VERB_CONTEXT_SPRAY:
+            tools_switch(dt, TOOLS_SPRAY);
+            break;
         case SP_VERB_CONTEXT_RECT:
             tools_switch(dt, TOOLS_SHAPES_RECT);
             break;
@@ -1511,6 +1461,10 @@ ContextVerb::perform(SPAction *action, void *data, void */*pdata*/)
             prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_TWEAK);
             dt->_dlg_mgr->showDialog("InkscapePreferences");
             break;
+        case SP_VERB_CONTEXT_SPRAY_PREFS:
+            prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_SPRAY);
+            dt->_dlg_mgr->showDialog("InkscapePreferences");
+            break;
         case SP_VERB_CONTEXT_RECT_PREFS:
             prefs->setInt("/dialogs/preferences/page", PREFS_PAGE_TOOLS_SHAPES_RECT);
             dt->_dlg_mgr->showDialog("InkscapePreferences");
@@ -1728,6 +1682,9 @@ ZoomVerb::perform(SPAction *action, void *data, void */*pdata*/)
         case SP_VERB_VIEW_MODE_OUTLINE:
             dt->setDisplayModeOutline();
             break;
+        case SP_VERB_VIEW_MODE_PRINT_COLORS_PREVIEW:
+            dt->setDisplayModePrintColorsPreview();
+            break;
         case SP_VERB_VIEW_MODE_TOGGLE:
             dt->displayModeToggle();
             break;
@@ -1783,6 +1740,9 @@ DialogVerb::perform(SPAction *action, void *data, void */*pdata*/)
         case SP_VERB_DIALOG_ALIGN_DISTRIBUTE:
             dt->_dlg_mgr->showDialog("AlignAndDistribute");
             break;
+        case SP_VERB_DIALOG_SPRAY_OPTION:
+            dt->_dlg_mgr->showDialog("SprayOptionClass");
+            break;
         case SP_VERB_DIALOG_TEXT:
             sp_text_edit_dialog();
             break;
@@ -1847,6 +1807,9 @@ DialogVerb::perform(SPAction *action, void *data, void */*pdata*/)
         case SP_VERB_DIALOG_SVG_FONTS:
             dt->_dlg_mgr->showDialog("SvgFontsDialog");
             break;
+        case SP_VERB_DIALOG_PRINT_COLORS_PREVIEW:
+            dt->_dlg_mgr->showDialog("PrintColorsPreviewDialog");
+            break;
         default:
             break;
     }
@@ -1892,8 +1855,8 @@ TutorialVerb::perform(SPAction */*action*/, void *data, void */*pdata*/)
 {
     switch (reinterpret_cast<std::size_t>(data)) {
         case SP_VERB_TUTORIAL_BASIC:
-            /* TRANSLATORS: If you have translated the tutorial-basic.svg file to your language,
-               then translate this string as "tutorial-basic.LANG.svg" (where LANG is your language
+            /* TRANSLATORS: If you have translated the tutorial-basic.en.svgz file to your language,
+               then translate this string as "tutorial-basic.LANG.svgz" (where LANG is your language
                code); otherwise leave as "tutorial-basic.svg". */
             sp_help_open_tutorial(NULL, (gpointer)_("tutorial-basic.svg"));
             break;
@@ -1913,6 +1876,10 @@ TutorialVerb::perform(SPAction */*action*/, void *data, void */*pdata*/)
             // TRANSLATORS: See "tutorial-basic.svg" comment.
             sp_help_open_tutorial(NULL, (gpointer)_("tutorial-calligraphy.svg"));
             break;
+        case SP_VERB_TUTORIAL_INTERPOLATE:
+            // TRANSLATORS: See "tutorial-basic.svg" comment.
+            sp_help_open_tutorial(NULL, (gpointer)_("tutorial-interpolate.svg"));
+            break;
         case SP_VERB_TUTORIAL_DESIGN:
             // TRANSLATORS: See "tutorial-basic.svg" comment.
             sp_help_open_tutorial(NULL, (gpointer)_("tutorial-elements.svg"));
@@ -2489,6 +2456,8 @@ Verb *Verb::_base_verbs[] = {
                     N_("Edit paths by nodes"), INKSCAPE_ICON_TOOL_NODE_EDITOR),
     new ContextVerb(SP_VERB_CONTEXT_TWEAK, "ToolTweak", N_("Tweak"),
                     N_("Tweak objects by sculpting or painting"), INKSCAPE_ICON_TOOL_TWEAK),
+    new ContextVerb(SP_VERB_CONTEXT_SPRAY, "ToolSpray", N_("Spray"),
+                    N_("Spray objects by sculpting or painting"), INKSCAPE_ICON_TOOL_SPRAY), 
     new ContextVerb(SP_VERB_CONTEXT_RECT, "ToolRect", N_("Rectangle"),
                     N_("Create rectangles and squares"), INKSCAPE_ICON_DRAW_RECTANGLE),
     new ContextVerb(SP_VERB_CONTEXT_3DBOX, "Tool3DBox", N_("3D Box"),
@@ -2530,6 +2499,8 @@ Verb *Verb::_base_verbs[] = {
                     N_("Open Preferences for the Node tool"), NULL),
     new ContextVerb(SP_VERB_CONTEXT_TWEAK_PREFS, "TweakPrefs", N_("Tweak Tool Preferences"),
                     N_("Open Preferences for the Tweak tool"), NULL),
+    new ContextVerb(SP_VERB_CONTEXT_SPRAY_PREFS, "SprayPrefs", N_("Spray Tool Preferences"),
+                    N_("Open Preferences for the Spray tool"), NULL),
     new ContextVerb(SP_VERB_CONTEXT_RECT_PREFS, "RectPrefs", N_("Rectangle Preferences"),
                     N_("Open Preferences for the Rectangle tool"), NULL),
     new ContextVerb(SP_VERB_CONTEXT_3DBOX_PREFS, "3DBoxPrefs", N_("3D Box Preferences"),
@@ -2598,6 +2569,8 @@ Verb *Verb::_base_verbs[] = {
                  N_("Switch to normal display without filters"), NULL),
     new ZoomVerb(SP_VERB_VIEW_MODE_OUTLINE, "ViewModeOutline", N_("_Outline"),
                  N_("Switch to outline (wireframe) display mode"), NULL),
+    new ZoomVerb(SP_VERB_VIEW_MODE_PRINT_COLORS_PREVIEW, "ViewModePrintColorsPreview", N_("_Print Colors Preview"),
+                 N_("Switch to print colors preview mode"), NULL),
     new ZoomVerb(SP_VERB_VIEW_MODE_TOGGLE, "ViewModeToggle", N_("_Toggle"),
                  N_("Toggle between normal and outline display modes"), NULL),
 
@@ -2631,6 +2604,8 @@ Verb *Verb::_base_verbs[] = {
                    N_("Precisely control objects' transformations"), INKSCAPE_ICON_DIALOG_TRANSFORM),
     new DialogVerb(SP_VERB_DIALOG_ALIGN_DISTRIBUTE, "DialogAlignDistribute", N_("_Align and Distribute..."),
                    N_("Align and distribute objects"), INKSCAPE_ICON_DIALOG_ALIGN_AND_DISTRIBUTE),
+    new DialogVerb(SP_VERB_DIALOG_SPRAY_OPTION, "DialogSprayOption", N_("_Spray options..."),
+                   N_("Some options for the spray"), INKSCAPE_ICON_DIALOG_SPRAY_OPTIONS),
     new DialogVerb(SP_VERB_DIALOG_UNDO_HISTORY, "DialogUndoHistory", N_("Undo _History..."),
                    N_("Undo History"), INKSCAPE_ICON_EDIT_UNDO_HISTORY),
     new DialogVerb(SP_VERB_DIALOG_TEXT, "DialogText", N_("_Text and Font..."),
@@ -2671,6 +2646,8 @@ Verb *Verb::_base_verbs[] = {
                    N_("Manage, edit, and apply SVG filters"), NULL),
     new DialogVerb(SP_VERB_DIALOG_SVG_FONTS, "DialogSVGFonts", N_("SVG Font Editor..."),
                    N_("Edit SVG fonts"), NULL),
+    new DialogVerb(SP_VERB_DIALOG_PRINT_COLORS_PREVIEW, "DialogPrintColorsPreview", N_("Print Colors..."),
+                   N_("Select which color separations to render in Print Colors Preview rendermode"), NULL),
 
     /* Help */
     new HelpVerb(SP_VERB_HELP_ABOUT_EXTENSIONS, "HelpAboutExtensions", N_("About E_xtensions"),
@@ -2694,6 +2671,8 @@ Verb *Verb::_base_verbs[] = {
                      N_("Using bitmap tracing"), NULL/*"tutorial_tracing"*/),
     new TutorialVerb(SP_VERB_TUTORIAL_CALLIGRAPHY, "TutorialsCalligraphy", N_("Inkscape: _Calligraphy"),
                      N_("Using the Calligraphy pen tool"), NULL),
+    new TutorialVerb(SP_VERB_TUTORIAL_INTERPOLATE, "TutorialsInterpolate", N_("Inkscape: _Interpolate"),
+                     N_("Using the interpolate extension"), NULL/*"tutorial_interpolate"*/),
     new TutorialVerb(SP_VERB_TUTORIAL_DESIGN, "TutorialsDesign", N_("_Elements of Design"),
                      N_("Principles of design in the tutorial form"), NULL/*"tutorial_design"*/),
     new TutorialVerb(SP_VERB_TUTORIAL_TIPS, "TutorialsTips", N_("_Tips and Tricks"),