Code

Split SPCanvasItem and SPCanvasGroup to individual .h files. Removed forward header.
[inkscape.git] / src / ui / tool / control-point.h
index c4b0a42be18ff54bc43000a50636c36e93c4e2ee..3f5fe668d1dd322a2a424d2b2ec42181cd0f06e4 100644 (file)
@@ -17,7 +17,6 @@
 #include <gtkmm.h>
 #include <2geom/point.h>
 
-#include "display/display-forward.h"
 #include "forward.h"
 #include "util/accumulators.h"
 #include "display/sodipodi-ctrl.h"
@@ -73,11 +72,11 @@ public:
 
     /// @name Receive notifications about control point events
     /// @{
-    sigc::signal<void, Geom::Point const &, Geom::Point &, GdkEventMotion*> signal_dragged;
+    /*sigc::signal<void, Geom::Point const &, Geom::Point &, GdkEventMotion*> signal_dragged;
     sigc::signal<bool, GdkEventButton*>::accumulated<RInt> signal_clicked;
     sigc::signal<bool, GdkEventButton*>::accumulated<RInt> signal_doubleclicked;
     sigc::signal<bool, GdkEventMotion*>::accumulated<Int> signal_grabbed;
-    sigc::signal<void, GdkEventButton*> signal_ungrabbed;
+    sigc::signal<void, GdkEventButton*> signal_ungrabbed;*/
     /// @}
 
     /// @name Inspect the state of the control point
@@ -90,12 +89,48 @@ public:
     static sigc::signal<void, ControlPoint*> signal_mouseover_change;
     static Glib::ustring format_tip(char const *format, ...) G_GNUC_PRINTF(1,2);
 
+    // temporarily public, until snap delay is refactored a little
+    virtual bool _eventHandler(GdkEvent *event);
+
 protected:
     ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, Gtk::AnchorType anchor,
         SPCtrlShapeType shape, unsigned int size, ColorSet *cset = 0, SPCanvasGroup *group = 0);
     ControlPoint(SPDesktop *d, Geom::Point const &initial_pos, Gtk::AnchorType anchor,
         Glib::RefPtr<Gdk::Pixbuf> pixbuf, ColorSet *cset = 0, SPCanvasGroup *group = 0);
 
+    /// @name Handle control point events in subclasses
+    /// @{
+    /**
+     * Called when the user moves the point beyond the drag tolerance with the first button held
+     * down. Return true if you called transferGrab() during this method.
+     * @param event Motion event when drag tolerance was exceeded */
+    virtual bool grabbed(GdkEventMotion *event);
+    /**
+     * Called while dragging, but before moving the knot to new position.
+     * @param pos Old position, always equal to position()
+     * @param new_pos New position (after drag). This is passed as a non-const reference,
+     *   so you can change it from the handler - that's how constrained dragging is implemented.
+     * @param event Motion event */
+    virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event);
+    /**
+     * @var ControlPoint::signal_ungrabbed
+     * Emitted when the control point finishes a drag.
+     * @param event Button release event
+     */
+    virtual void ungrabbed(GdkEventButton *event);
+    /**
+     * Called when the control point is clicked, at mouse button release. Your override should
+     * return true if the click had some effect. If it did nothing, return false. Improperly
+     * implementing this method can cause the default context menu not to appear when a control
+     * point is right-clicked.
+     * @param event Button release event */
+    virtual bool clicked(GdkEventButton *event);
+    /**
+     * Called when the control point is doubleclicked, at mouse button release.
+     * @param event Button release event */
+    virtual bool doubleclicked(GdkEventButton *);
+    /// @}
+
     /// @name Manipulate the control point's appearance in subclasses
     /// @{
     virtual void _setState(State state);
@@ -112,14 +147,13 @@ protected:
     void _setPixbuf(Glib::RefPtr<Gdk::Pixbuf>);
     /// @}
 
-    virtual bool _eventHandler(GdkEvent *event);
-    virtual Glib::ustring _getTip(unsigned state) { return ""; }
-    virtual Glib::ustring _getDragTip(GdkEventMotion *event) { return ""; }
+    virtual Glib::ustring _getTip(unsigned /*state*/) { return ""; }
+    virtual Glib::ustring _getDragTip(GdkEventMotion */*event*/) { return ""; }
     virtual bool _hasDragTips() { return false; }
 
     SPDesktop *const _desktop; ///< The desktop this control point resides on.
     SPCanvasItem * _canvas_item; ///< Visual representation of the control point.
-    ColorSet *_cset; ///< Describes the colors used to represent the point
+    ColorSet *_cset; ///< Colors used to represent the point
     State _state;
 
     static int const _grab_event_mask;
@@ -164,4 +198,4 @@ extern ControlPoint::ColorSet invisible_cset;
   fill-column:99
   End:
 */
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :