gradient-drag.h revision cd93ce9bf0509d74332b70b4d61c6ea23aa96693
#ifndef __GRADIENT_DRAG_H__
#define __GRADIENT_DRAG_H__
/*
* On-canvas gradient dragging
*
* 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
*/
#include <vector>
#include <forward.h>
#include <knot-enums.h>
struct SPItem;
struct SPKnot;
}
/**
This class represents a single draggable point of a gradient. It remembers the item
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();
bool 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;
/**
This class holds together a visible on-canvas knot and a list of draggables that need to
be moved when the knot moves. Normally there's one draggable in the list, but there may
be more when draggers are snapped together.
*/
struct GrDragger {
~GrDragger();
// position of the knot, desktop coords
// position of the knot before it began to drag; updated when released
/** Connection to \a knot's "moved" signal, for blocking it (unused?). */
void updateKnotShape();
void updateTip();
void select();
void deselect();
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 updateDependencies (bool write_repr);
};
/**
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();
void deselect_all();
bool keep_selection;
void grabKnot (SPItem *item, guint point_type, guint point_i, bool fill_or_stroke, gint x, gint y, guint32 etime);
bool local_change;
// lists of edges of selection bboxes, to snap draggers to
void updateDraggers ();
void updateLines ();
void updateLevels ();
void selected_move (double x, double y);
void selected_move_screen (double x, double y);
void select_next ();
void select_prev ();
void selected_reverse_vector ();
};
#endif