diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-07-01 00:35:09 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-07-01 00:35:09 +0000 |
| commit | ff04a08000adfa762ad1f4bc4f4df64c11ed499c (patch) | |
| tree | 9e6f4bcf3c8f87fcecdc8d11dd2eb0ec2d37c0c9 /src/ui | |
| parent | Merge branch 'master' of https://gitlab.com/jabiertxof/inkscape into selectab... (diff) | |
| download | inkscape-ff04a08000adfa762ad1f4bc4f4df64c11ed499c.tar.gz inkscape-ff04a08000adfa762ad1f4bc4f4df64c11ed499c.zip | |
working on knots selection
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/shape-editor.cpp | 11 | ||||
| -rw-r--r-- | src/ui/shape-editor.h | 7 | ||||
| -rw-r--r-- | src/ui/tool/control-point-selection.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 40 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.h | 10 |
5 files changed, 57 insertions, 13 deletions
diff --git a/src/ui/shape-editor.cpp b/src/ui/shape-editor.cpp index 98320ed8c..288c6dc5e 100644 --- a/src/ui/shape-editor.cpp +++ b/src/ui/shape-editor.cpp @@ -17,6 +17,8 @@ #include "desktop.h" #include "document.h" #include "knotholder.h" +#include "sp-ellipse.h" +#include "inkscape.h" #include "ui/object-edit.h" #include "ui/shape-editor.h" #include "xml/node-event-vector.h" @@ -81,7 +83,7 @@ const SPItem *ShapeEditor::get_item() { return item; } -void ShapeEditor::event_attr_changed(Inkscape::XML::Node *, gchar const *name, gchar const *, gchar const *, bool, void *data) +void ShapeEditor::event_attr_changed(Inkscape::XML::Node * node, gchar const *name, gchar const *, gchar const *, bool, void *data) { g_assert(data); ShapeEditor *sh = static_cast<ShapeEditor *>(data); @@ -94,7 +96,12 @@ void ShapeEditor::event_attr_changed(Inkscape::XML::Node *, gchar const *name, g if (changed_kh) { // this can happen if an LPEItem's knotholder handle was dragged, in which case we want // to keep the knotholder; in all other cases (e.g., if the LPE itself changes) we delete it - sh->reset_item(!strcmp(name, "d")); + sh->reset_item(!strcmp(name, "d") || + !strcmp(node->name(),"svg:rect") );//|| +// !strcmp(node->name(),"svg:star") || +// !strcmp(node->name(),"svg:spiral") || +// !strcmp(node->name(),"svg:ellipse") || +// SP_IS_GENERICELLIPSE(SP_ACTIVE_DOCUMENT->getObjectById(node->attribute("id")))); } } } diff --git a/src/ui/shape-editor.h b/src/ui/shape-editor.h index 142a2493b..7f435efca 100644 --- a/src/ui/shape-editor.h +++ b/src/ui/shape-editor.h @@ -35,20 +35,17 @@ public: void decrement_local_change(); bool knot_mouseover() const; - + KnotHolder *knotholder; + bool has_knotholder(); static void blockSetItem(bool b) { _blockSetItem = b; } // kludge - static void event_attr_changed(Inkscape::XML::Node * /*repr*/, char const *name, char const * /*old_value*/, char const * /*new_value*/, bool /*is_interactive*/, void *data); private: - bool has_knotholder(); void reset_item (bool keep_knotholder = true); const SPItem *get_item(); - static bool _blockSetItem; SPDesktop *desktop; - KnotHolder *knotholder; Inkscape::XML::Node *knotholder_listener_attached_for; }; diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp index a5611addc..81c6851c7 100644 --- a/src/ui/tool/control-point-selection.cpp +++ b/src/ui/tool/control-point-selection.cpp @@ -645,7 +645,7 @@ void ControlPointSelection::_commitHandlesTransform(CommitEvent ce) signal_commit.emit(ce); } -bool ControlPointSelection::event(Inkscape::UI::Tools::ToolBase * /*event_context*/, GdkEvent *event) +bool ControlPointSelection::event(Inkscape::UI::Tools::ToolBase * event_context, GdkEvent *event) { // implement generic event handling that should apply for all control point selections here; // for example, keyboard moves and transformations. This way this functionality doesn't need diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index 0467b984e..9d08cfcb6 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -31,6 +31,8 @@ #include "ui/tools/tool-base.h" #include "ui/tools-switch.h" #include "ui/tools/lpe-tool.h" +#include "ui/tool/commit-events.h" +#include "ui/tool/event-utils.h" #include <gdk/gdkkeysyms.h> #include <glibmm/i18n.h> @@ -304,6 +306,33 @@ static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration, return scroll_multiply; } +/** Moves the selected points along the supplied unit vector according to + * the modifier state of the supplied event. */ +bool ToolBase::_keyboardMove(GdkEventKey const &event, Geom::Point const &dir) +{ + if (held_control(event)) return false; + unsigned num = 1 + combine_key_events(shortcut_key(event), 0); + Geom::Point delta = dir * num; + if (held_shift(event)) delta *= 10; + if (held_alt(event)) { + delta /= desktop->current_zoom(); + } else { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + double nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); + delta *= nudge; + } + std::cout << num << "zzzzzzzzzzzzzzzzzzzzzzzzzzzwww\n"; + if (this->shape_editor && this->shape_editor->has_knotholder()) { + std::cout << num << "zzzzzzzzzzzzzzzzzzzzzzzzzzz\n"; + KnotHolder * knotholder = shape_editor->knotholder; + if (knotholder) { + std::cout << num << "wwwwwwwwwwwwwwwwwwwwww\n"; + knotholder->transform_selected(Geom::Translate(delta)); + } + } + return true; +} + bool ToolBase::root_handler(GdkEvent* event) { // ui_dump_event (event, "ToolBase::root_handler"); @@ -559,7 +588,8 @@ bool ToolBase::root_handler(GdkEvent* event) { int const key_scroll = prefs->getIntLimited("/options/keyscroll/value", 10, 0, 1000); - switch (get_group0_keyval(&event->key)) { + switch(shortcut_key(event->key)) { + //switch (get_group0_keyval(&event->key)) { // GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets // in the editing window). So we resteal them back and run our regular shortcut // invoker on them. @@ -615,6 +645,8 @@ bool ToolBase::root_handler(GdkEvent* event) { gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(i, 0)); ret = TRUE; + } else { + ret = _keyboardMove(event->key, Geom::Point(-1, 0)); } break; @@ -628,6 +660,8 @@ bool ToolBase::root_handler(GdkEvent* event) { gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(0, i)); ret = TRUE; + } else { + ret = _keyboardMove(event->key, Geom::Point(0, 1)); } break; @@ -641,6 +675,8 @@ bool ToolBase::root_handler(GdkEvent* event) { gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(-i, 0)); ret = TRUE; + } else { + ret = _keyboardMove(event->key, Geom::Point(1, 0)); } break; @@ -654,6 +690,8 @@ bool ToolBase::root_handler(GdkEvent* event) { gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK); this->desktop->scroll_relative(Geom::Point(0, -i)); ret = TRUE; + } else { + ret = _keyboardMove(event->key, Geom::Point(0, -1)); } break; diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index b0140cecb..52f641ecb 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -14,12 +14,12 @@ #include <stddef.h> #include <string> - +#include "knot.h" +#include "knotholder.h" #include <2geom/point.h> #include <gdk/gdk.h> #include <glib-object.h> #include <sigc++/trackable.h> -#include "knot.h" #include "preferences.h" @@ -30,7 +30,7 @@ namespace Glib { class GrDrag; class SPDesktop; class SPItem; - +class KnotHolder; namespace Inkscape { class MessageContext; class SelCue; @@ -42,6 +42,7 @@ namespace Inkscape { namespace Inkscape { namespace UI { + class ShapeEditor; namespace Tools { @@ -219,7 +220,6 @@ public: SPDesktop *desktop; bool _uses_snap; // TODO: make protected or private - protected: /// An xpm containing the shape of the tool's cursor. gchar const *const *cursor_shape; @@ -229,7 +229,9 @@ protected: private: ToolBase(const ToolBase&); ToolBase& operator=(const ToolBase&); + bool _keyboardMove(GdkEventKey const &event, Geom::Point const &dir); + void sp_event_context_set_cursor(GdkCursorType cursor_type); }; |
