diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/knot-enums.h | 2 | ||||
| -rw-r--r-- | src/knot.cpp | 8 | ||||
| -rw-r--r-- | src/knot.h | 2 | ||||
| -rw-r--r-- | src/knotholder.cpp | 12 | ||||
| -rw-r--r-- | src/knotholder.h | 2 | ||||
| -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 |
10 files changed, 74 insertions, 22 deletions
diff --git a/src/knot-enums.h b/src/knot-enums.h index 4114967f7..737100c29 100644 --- a/src/knot-enums.h +++ b/src/knot-enums.h @@ -38,7 +38,7 @@ typedef enum { SP_KNOT_STATE_HIDDEN } SPKnotStateType; -#define SP_KNOT_VISIBLE_STATES 3 +#define SP_KNOT_VISIBLE_STATES 4 enum { SP_KNOT_VISIBLE = 1 << 0, diff --git a/src/knot.cpp b/src/knot.cpp index 2ae1e2cd9..e44efde4f 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -182,7 +182,6 @@ void SPKnot::startDragging(Geom::Point const &p, gint x, gint y, guint32 etime) } void SPKnot::selectKnot(bool select){ - selected = select; setFlag(SP_KNOT_SELECTED, select); } @@ -224,7 +223,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot knot->startDragging(p, (gint) event->button.x, (gint) event->button.y, event->button.time); knot->mousedown_signal.emit(knot, event->button.state); consumed = TRUE; - knot->selectKnot(!knot->selected); + knot->selectKnot(!(knot->flags & SP_KNOT_SELECTED)); } break; case GDK_BUTTON_RELEASE: @@ -234,9 +233,6 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot sp_event_context_snap_watchdog_callback(knot->desktop->event_context->_delayed_snap_event); } sp_event_context_discard_delayed_snap_event(knot->desktop->event_context); - if(knot->flags & SP_KNOT_MOUSEOVER){ - knot->selectKnot(!knot->selected); - } knot->pressure = 0; if (transform_escaped) { @@ -469,7 +465,7 @@ void SPKnot::_setCtrlState() { state = SP_KNOT_STATE_DRAGGING; } else if (this->flags & SP_KNOT_MOUSEOVER) { state = SP_KNOT_STATE_MOUSEOVER; - } else if (this->flags & SP_KNOT_STATE_SELECTED) { + } else if (this->flags & SP_KNOT_SELECTED) { state = SP_KNOT_STATE_SELECTED; } g_object_set(this->item, "fill_color", this->fill[state], NULL); diff --git a/src/knot.h b/src/knot.h index 26e24da8f..6db0db358 100644 --- a/src/knot.h +++ b/src/knot.h @@ -68,7 +68,7 @@ public: GdkCursor *saved_cursor; void* pixbuf; - bool selected; + char *tip; unsigned long _event_handler_id; diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 98348a59f..681667aa5 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -171,6 +171,18 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) } void +KnotHolder::transform_selected(Geom::Affine transform){ + for (std::list<KnotHolderEntity *>::iterator i = entity.begin(); i != entity.end(); ++i) { + SPKnot *knot = (*i)->knot; + std::cout << transform << "transform\n"; + if (knot->flags & SP_KNOT_SELECTED) { + knot_moved_handler(knot, knot->pos * transform , 0); + knot->selectKnot(true); + } + } +} + +void KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) { if (this->dragging == false) { diff --git a/src/knotholder.h b/src/knotholder.h index c8136da3f..6523988db 100644 --- a/src/knotholder.h +++ b/src/knotholder.h @@ -53,7 +53,7 @@ public: void knot_moved_handler(SPKnot *knot, Geom::Point const &p, unsigned int state); void knot_clicked_handler(SPKnot *knot, unsigned int state); void knot_ungrabbed_handler(SPKnot *knot, unsigned int); - + void transform_selected(Geom::Affine transform); void add(KnotHolderEntity *e); void add_pattern_knotholder(); 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); }; |
