diff --git a/src/gradient-drag.h b/src/gradient-drag.h
index 365da9b9253beb43b7a6221aa23daca0f2c94754..3f12cc09c50e2a86dda7b3602a4437c036ec134f 100644 (file)
--- a/src/gradient-drag.h
+++ b/src/gradient-drag.h
*
* Authors:
* bulia byak <bulia@users.sf.net>
+ * Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
*
+ * Copyright (C) 2007 Johan Engelen
* Copyright (C) 2005 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
/**
This class represents a single draggable point of a gradient. It remembers the item
-which has the gradient, whether it's fill or stroke, and the point number (from the
-GrPoint enum).
+which has the gradient, whether it's fill or stroke, the point type (from the
+GrPointType enum), and the point number (needed if more than 2 stops are present).
*/
struct GrDraggable {
- GrDraggable(SPItem *item, guint point_num, bool fill_or_stroke);
+ GrDraggable(SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
~GrDraggable();
SPItem *item;
- guint point_num;
+ guint point_type;
+ guint point_i; // the stop number of this point ( = 0 for all types except POINT_LG_MID)
bool fill_or_stroke;
bool mayMerge (GrDraggable *da2);
inline int equals (GrDraggable *other) {
- return ((item == other->item) && (point_num == other->point_num) && (fill_or_stroke == other->fill_or_stroke));
+ return ((item == other->item) && (point_type == other->point_type) && (point_i == other->point_i) && (fill_or_stroke == other->fill_or_stroke));
}
};
-struct GrDrag;
+class GrDrag;
/**
This class holds together a visible on-canvas knot and a list of draggables that need to
void updateKnotShape();
void updateTip();
+
+ void select();
+ void deselect();
- void moveThisToDraggable (SPItem *item, guint point_num, bool fill_or_stroke, bool write_repr);
- void moveOtherToDraggable (SPItem *item, guint point_num, bool fill_or_stroke, bool write_repr);
- void updateDependencies (bool write_repr);
+ 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 updateMidstopDependencies (GrDraggable *draggable, bool write_repr);
+ void updateDependencies (bool write_repr);
bool mayMerge (GrDragger *other);
bool mayMerge (GrDraggable *da2);
- bool isA (guint point_num);
- bool isA (SPItem *item, guint point_num, bool fill_or_stroke);
+ bool isA (guint point_type);
+ bool isA (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
void fireDraggables (bool write_repr, bool scale_radial = false, bool merging_focus = false);
};
This is the root class of the gradient dragging machinery. It holds lists of GrDraggers
and of lines (simple canvas items). It also remembers one of the draggers as selected.
*/
-struct GrDrag {
- GrDrag(SPDesktop *desktop);
- ~GrDrag();
+class GrDrag {
+public: // FIXME: make more of this private!
- void addLine (NR::Point p1, NR::Point p2, guint32 rgba);
+ GrDrag(SPDesktop *desktop);
+ ~GrDrag();
- void addDragger (GrDraggable *draggable);
+ // 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 deleteSelected (bool just_one = false);
+
+ bool keep_selection;
+
+ GrDragger *getDraggerFor (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke);
- void addDraggersRadial (SPRadialGradient *rg, SPItem *item, bool fill_or_stroke);
- void addDraggersLinear (SPLinearGradient *lg, SPItem *item, bool fill_or_stroke);
+ void grabKnot (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime);
- GrDragger *selected;
- void setSelected (GrDragger *dragger);
+ bool local_change;
- GrDragger *getDraggerFor (SPItem *item, guint point_num, bool fill_or_stroke);
+ SPDesktop *desktop;
- void grabKnot (SPItem *item, guint point_num, bool fill_or_stroke, gint x, gint y, guint32 etime);
+ // lists of edges of selection bboxes, to snap draggers to
+ std::vector<double> hor_levels;
+ std::vector<double> vert_levels;
- bool local_change;
+ GList *draggers;
+ GSList *lines;
- SPDesktop *desktop;
- Inkscape::Selection *selection;
- sigc::connection sel_changed_connection;
- sigc::connection sel_modified_connection;
+ void updateDraggers ();
+ void updateLines ();
+ void updateLevels ();
- sigc::connection style_set_connection;
- sigc::connection style_query_connection;
+ void selected_move (double x, double y);
+ void selected_move_screen (double x, double y);
- // lists of edges of selection bboxes, to snap draggers to
- std::vector<double> hor_levels;
- std::vector<double> vert_levels;
+ void select_next ();
+ void select_prev ();
- GList *draggers;
- GSList *lines;
+ void selected_reverse_vector ();
- void updateDraggers ();
- void updateLines ();
- void updateLevels ();
+private:
+ void deselect_all();
- void selected_move (double x, double y);
- void selected_move_screen (double x, double y);
+ void addLine (NR::Point p1, NR::Point p2, guint32 rgba);
- void select_next ();
- void select_prev ();
+ void addDragger (GrDraggable *draggable);
- void selected_reverse_vector ();
+ 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;
+
+ sigc::connection style_set_connection;
+ sigc::connection style_query_connection;
};
#endif