Code

Reduce libsigc++ usage to partially fix performance regressions
[inkscape.git] / src / ui / tool / control-point-selection.h
index 38df5c7e5f76802cdda10fe75173c7a34f74c1a2..025f9bb618be83927473a0e942c4f1396969ec9d 100644 (file)
 #include "ui/tool/commit-events.h"
 #include "ui/tool/manipulator.h"
 
-namespace std { using namespace tr1; }
-
 class SPDesktop;
 
 namespace Inkscape {
 namespace UI {
-
 class TransformHandleSet;
 class SelectableControlPoint;
+}
+}
+
+namespace Inkscape {
+namespace UI {
 
 class ControlPointSelection : public Manipulator {
 public:
     ControlPointSelection(SPDesktop *d, SPCanvasGroup *th_group);
     ~ControlPointSelection();
     typedef std::list<sigc::connection> connlist_type;
-    typedef std::unordered_map< SelectableControlPoint *,
-        boost::shared_ptr<connlist_type> > map_type;
-    typedef std::unordered_set< SelectableControlPoint * > set_type;
+    typedef std::tr1::unordered_set< SelectableControlPoint * > set_type;
     typedef set_type Set; // convenience alias
 
-    typedef map_type::iterator iterator;
-    typedef map_type::const_iterator const_iterator;
-    typedef map_type::size_type size_type;
+    typedef set_type::iterator iterator;
+    typedef set_type::const_iterator const_iterator;
+    typedef set_type::size_type size_type;
     typedef SelectableControlPoint *value_type;
     typedef SelectableControlPoint *key_type;
 
@@ -101,20 +101,23 @@ public:
 
     void showTransformHandles(bool v, bool one_node);
     // the two methods below do not modify the state; they are for use in manipulators
-    // that need to temporarily hide the handles
+    // that need to temporarily hide the handles, for example when moving a node
     void hideTransformHandles();
     void restoreTransformHandles();
-    
-    // TODO this is really only applicable to nodes... maybe derive a NodeSelection?
-    void setSculpting(bool v) { _sculpt_enabled = v; }
+    void toggleTransformHandlesMode();
 
     sigc::signal<void> signal_update;
     sigc::signal<void, SelectableControlPoint *, bool> signal_point_changed;
     sigc::signal<void, CommitEvent> signal_commit;
 private:
-    void _selectionGrabbed(SelectableControlPoint *, GdkEventMotion *);
-    void _selectionDragged(Geom::Point const &, Geom::Point &, GdkEventMotion *);
-    void _selectionUngrabbed();
+    // The functions below are invoked from SelectableControlPoint.
+    // Previously they were connected to handlers when selecting, but this
+    // creates problems when dragging a point that was not selected.
+    void _pointGrabbed();
+    void _pointDragged(Geom::Point const &, Geom::Point &, GdkEventMotion *);
+    void _pointUngrabbed();
+    bool _pointClicked(SelectableControlPoint *, GdkEventButton *);
+
     void _updateTransformHandles(bool preserve_center);
     bool _keyboardMove(GdkEventKey const &, Geom::Point const &);
     bool _keyboardRotate(GdkEventKey const &, int);
@@ -122,7 +125,7 @@ private:
     bool _keyboardFlip(Geom::Dim2);
     void _keyboardTransform(Geom::Matrix const &);
     void _commitTransform(CommitEvent ce);
-    map_type _points;
+    set_type _points;
     set_type _all_points;
     boost::optional<double> _rot_radius;
     TransformHandleSet *_handles;
@@ -130,8 +133,8 @@ private:
     unsigned _dragging         : 1;
     unsigned _handles_visible  : 1;
     unsigned _one_node_handles : 1;
-    unsigned _sculpt_enabled   : 1;
-    unsigned _sculpting        : 1;
+
+    friend class SelectableControlPoint;
 };
 
 } // namespace UI