Code

fix bug [ 1824359 ] Gradient isn't snapping with ctrl pressed
[inkscape.git] / src / gradient-drag.h
index 4899a8fedc8e6e93a194363c55418536fe1c3eaf..06859c24bb0e5fba115739e6679348f8006b9fc1 100644 (file)
@@ -37,10 +37,12 @@ struct GrDraggable {
        ~GrDraggable();
 
        SPItem *item;
-       guint point_type;
-       guint point_i;  // the stop number of this point ( = 0 for all types except POINT_LG_MID)
+       gint point_type;
+       gint point_i;  // the stop number of this point ( = 0 POINT_LG_BEGIN and POINT_RG_CENTER)
        bool fill_or_stroke;
 
+       SPObject *getServer();
+
        bool mayMerge (GrDraggable *da2);
 
     inline int equals (GrDraggable *other) {
@@ -80,17 +82,19 @@ struct GrDragger {
        
        void select();
        void deselect();
+       bool isSelected();
 
-       void moveThisToDraggable (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, bool write_repr);
-       void moveOtherToDraggable (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, bool write_repr);
+       void moveThisToDraggable (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, bool write_repr);
+       void moveOtherToDraggable (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, bool write_repr);
     void updateMidstopDependencies (GrDraggable *draggable, bool write_repr);
     void updateDependencies (bool write_repr);
 
        bool mayMerge (GrDragger *other);
        bool mayMerge (GrDraggable *da2);
 
-       bool isA (guint point_type);
-       bool isA (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
+    bool isA (gint point_type);
+    bool isA (SPItem *item, gint point_type, bool fill_or_stroke);
+    bool isA (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke);
 
        void fireDraggables (bool write_repr, bool scale_radial = false, bool merging_focus = false);
 };
@@ -102,60 +106,80 @@ and of lines (simple canvas items). It also remembers one of the draggers as sel
 class GrDrag {
 public: // FIXME: make more of this private!
 
-       GrDrag(SPDesktop *desktop);
-       ~GrDrag();
+    GrDrag(SPDesktop *desktop);
+    ~GrDrag();
+
+               bool isNonEmpty() {return (draggers != NULL);}
+               bool hasSelection() {return (selected != NULL);}
+               guint numSelected() {return (selected? g_list_length(selected) : 0);}
+               guint numDraggers() {return (draggers? g_list_length(draggers) : 0);}
+               guint singleSelectedDraggerNumDraggables() {return (selected? g_slist_length(((GrDragger *) selected->data)->draggables) : 0);}
+               guint singleSelectedDraggerSingleDraggableType() {return (selected? ((GrDraggable *) ((GrDragger *) selected->data)->draggables->data)->point_type : 0);}
 
-       // especially the selection must be private, fix gradient-context to remove direct access to it
-       GList *selected; // list of GrDragger*
+    // especially the selection must be private, fix gradient-context to remove direct access to it
+    GList *selected; // list of GrDragger*
     void setSelected (GrDragger *dragger, bool add_to_selection = false, bool override = true);
     void setDeselected (GrDragger *dragger);
     void deselectAll();
+               void selectAll();
+               void selectByCoords(std::vector<NR::Point> coords);
+    void selectRect(NR::Rect const &r);
+
+    bool dropColor(SPItem *item, gchar *c, NR::Point p);
+
+               SPStop *addStopNearPoint (SPItem *item, NR::Point mouse_p, double tolerance);
+    
+    void deleteSelected (bool just_one = false);
+
+    bool copy ();
     
     bool keep_selection;    
     
-       GrDragger *getDraggerFor (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
+    GrDragger *getDraggerFor (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke);
 
-       void grabKnot (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime);
+    void grabKnot (GrDragger *dragger, gint x, gint y, guint32 etime);
+    void grabKnot (SPItem *item, gint point_type, gint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime);
 
-       bool local_change;
+    bool local_change;
 
-       SPDesktop *desktop;
+    SPDesktop *desktop;
 
-       // lists of edges of selection bboxes, to snap draggers to
-       std::vector<double> hor_levels;
-       std::vector<double> vert_levels;
+    // lists of edges of selection bboxes, to snap draggers to
+    std::vector<double> hor_levels;
+    std::vector<double> vert_levels;
 
-       GList *draggers;
-       GSList *lines;
+    GList *draggers;
+    GSList *lines;
 
-       void updateDraggers ();
-       void updateLines ();
-       void updateLevels ();
+    void updateDraggers ();
+    void updateLines ();
+    void updateLevels ();
 
-       void selected_move (double x, double y);
-       void selected_move_screen (double x, double y);
+    void selected_move_nowrite (double x, double y, bool scale_radial);
+    void selected_move (double x, double y, bool write_repr = true, bool scale_radial = false);
+    void selected_move_screen (double x, double y);
 
-       void select_next ();
-       void select_prev ();
+    GrDragger *select_next ();
+    GrDragger *select_prev ();
 
-       void selected_reverse_vector ();
+    void selected_reverse_vector ();
 
 private: 
-       void deselect_all();
+    void deselect_all();
 
-       void addLine (NR::Point p1, NR::Point p2, guint32 rgba);
+    void addLine (SPItem *item, NR::Point p1, NR::Point p2, guint32 rgba);
 
-       void addDragger (GrDraggable *draggable);
+    void addDragger (GrDraggable *draggable);
 
-       void addDraggersRadial (SPRadialGradient *rg, SPItem *item, bool fill_or_stroke);
-       void addDraggersLinear (SPLinearGradient *lg, SPItem *item, bool fill_or_stroke);
+    void addDraggersRadial (SPRadialGradient *rg, SPItem *item, bool fill_or_stroke);
+    void addDraggersLinear (SPLinearGradient *lg, SPItem *item, bool fill_or_stroke);
 
-       Inkscape::Selection *selection;
-       sigc::connection sel_changed_connection;
-       sigc::connection sel_modified_connection;
+    Inkscape::Selection *selection;
+    sigc::connection sel_changed_connection;
+    sigc::connection sel_modified_connection;
 
-       sigc::connection style_set_connection;
-       sigc::connection style_query_connection;
+    sigc::connection style_set_connection;
+    sigc::connection style_query_connection;
 };
 
 #endif