Code

* Implement node snapping.
[inkscape.git] / src / verbs.cpp
index 43ddc1459ad016eb98ddac80dceb8d7b33575d2c..f03be681a631d68ae11ffb88df3ae7f27a3a2bbc 100644 (file)
@@ -58,7 +58,6 @@
 #include "layer-fns.h"
 #include "layer-manager.h"
 #include "message-stack.h"
-#include "node-context.h"
 #include "path-chemistry.h"
 #include "preferences.h"
 #include "select-context.h"
 #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
-#include "jabber_whiteboard/session-manager.h"
-#endif
+//#ifdef WITH_INKBOARD
+//#include "jabber_whiteboard/session-manager.h"
+//#endif
 
 /**
  * \brief Return the name without underscores and ellipsis, for use in dialog
@@ -799,14 +801,14 @@ FileVerb::perform(SPAction *action, void *data, void */*pdata*/)
             sp_file_import(*parent);
             break;
         case SP_VERB_FILE_EXPORT:
-            sp_file_export_dialog(NULL);
+            sp_file_export_dialog(*parent);
             break;
         case SP_VERB_FILE_IMPORT_FROM_OCAL:
             sp_file_import_from_ocal(*parent);
             break;
-        case SP_VERB_FILE_EXPORT_TO_OCAL:
-            sp_file_export_to_ocal(*parent);
-            break;
+//        case SP_VERB_FILE_EXPORT_TO_OCAL:
+//            sp_file_export_to_ocal(*parent);
+//            break;
         case SP_VERB_FILE_NEXT_DESKTOP:
             inkscape_switch_desktops_next();
             break;
@@ -919,28 +921,32 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
             break;
         case SP_VERB_EDIT_SELECT_ALL:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                ec->shape_editor->select_all_from_subpath(false);
+                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+                nt->_multipath->selectSubpaths();
             } else {
                 sp_edit_select_all(dt);
             }
             break;
         case SP_VERB_EDIT_INVERT:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                ec->shape_editor->select_all_from_subpath(true);
+                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+                nt->_multipath->invertSelectionInSubpaths();
             } else {
                 sp_edit_invert(dt);
             }
             break;
         case SP_VERB_EDIT_SELECT_ALL_IN_ALL_LAYERS:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                ec->shape_editor->select_all(false);
+                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+                nt->_selected_nodes->selectAll();
             } else {
                 sp_edit_select_all_in_all_layers(dt);
             }
             break;
         case SP_VERB_EDIT_INVERT_IN_ALL_LAYERS:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                ec->shape_editor->select_all(true);
+                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+                nt->_selected_nodes->invertSelection();
             } else {
                 sp_edit_invert_in_all_layers(dt);
             }
@@ -948,7 +954,8 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
 
         case SP_VERB_EDIT_SELECT_NEXT:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                ec->shape_editor->select_next();
+                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);
@@ -958,7 +965,8 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
             break;
         case SP_VERB_EDIT_SELECT_PREV:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                ec->shape_editor->select_prev();
+                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);
@@ -969,7 +977,8 @@ EditVerb::perform(SPAction *action, void *data, void */*pdata*/)
 
         case SP_VERB_EDIT_DESELECT:
             if (tools_isactive(dt, TOOLS_NODES)) {
-                ec->shape_editor->deselect();
+                InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+                nt->_selected_nodes->clear();
             } else {
                 sp_desktop_selection(dt)->clear();
             }
@@ -1086,7 +1095,13 @@ SelectionVerb::perform(SPAction *action, void *data, void */*pdata*/)
             sp_selected_path_simplify(dt);
             break;
         case SP_VERB_SELECTION_REVERSE:
-            sp_selected_path_reverse(dt);
+            // 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);
+            }
             break;
         case SP_VERB_SELECTION_TRACE:
             inkscape_dialogs_unhide();
@@ -1365,41 +1380,12 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
             flowtext_to_text();
             break;
         case SP_VERB_OBJECT_FLIP_HORIZONTAL:
-            // When working with the node tool ...
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                Inkscape::NodePath::Node *active_node = Inkscape::NodePath::Path::active_node;
-
-                // ... and one of the nodes is currently mouseovered ...
-                if (active_node) {
-
-                    // ... flip the selected nodes about that node
-                    ec->shape_editor->flip(Geom::X, active_node->pos);
-                } else {
-
-                    // ... or else about the center of their bounding box.
-                    ec->shape_editor->flip(Geom::X);
-                }
-
-            // When working with the selector tool, flip the selection about its rotation center
-            // (if it is visible) or about the center of the bounding box.
-            } else {
-                sp_selection_scale_relative(sel, center, Geom::Scale(-1.0, 1.0));
-            }
+            sp_selection_scale_relative(sel, center, Geom::Scale(-1.0, 1.0));
             sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_HORIZONTAL,
                              _("Flip horizontally"));
             break;
         case SP_VERB_OBJECT_FLIP_VERTICAL:
-            // The behaviour is analogous to flipping horizontally
-            if (tools_isactive(dt, TOOLS_NODES)) {
-                Inkscape::NodePath::Node *active_node = Inkscape::NodePath::Path::active_node;
-                if (active_node) {
-                    ec->shape_editor->flip(Geom::Y, active_node->pos);
-                } else {
-                    ec->shape_editor->flip(Geom::Y);
-                }
-            } else {
-                sp_selection_scale_relative(sel, center, Geom::Scale(1.0, -1.0));
-            }
+            sp_selection_scale_relative(sel, center, Geom::Scale(1.0, -1.0));
             sp_document_done(sp_desktop_document(dt), SP_VERB_OBJECT_FLIP_VERTICAL,
                              _("Flip vertically"));
             break;
@@ -1833,13 +1819,13 @@ DialogVerb::perform(SPAction *action, void *data, void */*pdata*/)
         case SP_VERB_DIALOG_ITEM:
             sp_item_dialog();
             break;
-#ifdef WITH_INKBOARD
+/*#ifdef WITH_INKBOARD
         case SP_VERB_XMPP_CLIENT:
         {
             Inkscape::Whiteboard::SessionManager::showClient();
             break;
         }
-#endif
+#endif*/
         case SP_VERB_DIALOG_INPUT:
             sp_input_dialog();
             break;
@@ -2263,7 +2249,7 @@ Verb *Verb::_base_verbs[] = {
     new FileVerb(SP_VERB_FILE_EXPORT, "FileExport", N_("_Export Bitmap..."),
                  N_("Export this document or a selection as a bitmap image"), INKSCAPE_ICON_DOCUMENT_EXPORT),
     new FileVerb(SP_VERB_FILE_IMPORT_FROM_OCAL, "FileImportFromOCAL", N_("Import From Open Clip Art Library"), N_("Import a document from Open Clip Art Library"), INKSCAPE_ICON_DOCUMENT_IMPORT_OCAL),
-    new FileVerb(SP_VERB_FILE_EXPORT_TO_OCAL, "FileExportToOCAL", N_("Export To Open Clip Art Library"), N_("Export this document to Open Clip Art Library"), INKSCAPE_ICON_DOCUMENT_EXPORT_OCAL),
+//    new FileVerb(SP_VERB_FILE_EXPORT_TO_OCAL, "FileExportToOCAL", N_("Export To Open Clip Art Library"), N_("Export this document to Open Clip Art Library"), INKSCAPE_ICON_DOCUMENT_EXPORT_OCAL),
     new FileVerb(SP_VERB_FILE_NEXT_DESKTOP, "NextWindow", N_("N_ext Window"),
                  N_("Switch to the next document window"), INKSCAPE_ICON_WINDOW_NEXT),
     new FileVerb(SP_VERB_FILE_PREV_DESKTOP, "PrevWindow", N_("P_revious Window"),
@@ -2667,10 +2653,10 @@ Verb *Verb::_base_verbs[] = {
                    N_("Create multiple clones of selected object, arranging them into a pattern or scattering"), INKSCAPE_ICON_DIALOG_TILE_CLONES),
     new DialogVerb(SP_VERB_DIALOG_ITEM, "DialogObjectProperties", N_("_Object Properties..."),
                    N_("Edit the ID, locked and visible status, and other object properties"), INKSCAPE_ICON_DIALOG_OBJECT_PROPERTIES),
-#ifdef WITH_INKBOARD
+/*#ifdef WITH_INKBOARD
     new DialogVerb(SP_VERB_XMPP_CLIENT, "DialogXmppClient",
                    N_("_Instant Messaging..."), N_("Jabber Instant Messaging Client"), NULL),
-#endif
+#endif*/
     new DialogVerb(SP_VERB_DIALOG_INPUT, "DialogInput", N_("_Input Devices..."),
                    N_("Configure extended input devices, such as a graphics tablet"), INKSCAPE_ICON_DIALOG_INPUT_DEVICES),
     new DialogVerb(SP_VERB_DIALOG_INPUT2, "DialogInput2", N_("_Input Devices (new)..."),