gradient-drag.h revision 3f2f2d9a36c8132d316033e29bb2bc116292dc9a
#ifndef SEEN_GRADIENT_DRAG_H
#define SEEN_GRADIENT_DRAG_H
/*
* On-canvas gradient dragging
*
* Authors:
* bulia byak <bulia@users.sf.net>
* Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
* Jon A. Cruz <jon@joncruz.org>
* Tavmjong Bah <tavmjong@free.fr>
*
* Copyright (C) 2012 Authors
* Copyright (C) 2007 Johan Engelen
* Copyright (C) 2005 Authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <stddef.h>
#include <vector>
#include <glib.h>
#include "knot-enums.h"
#include "sp-gradient.h" // TODO refactor enums to external .h file
#include "sp-mesh-array.h"
struct SPKnot;
} // namespace Inkscape
/**
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(SPItem *item, GrPointType point_type, guint point_i, Inkscape::PaintTarget fill_or_stroke);
virtual ~GrDraggable();
return ((item == other->item) && (point_type == other->point_type) && (point_i == other->point_i) && (fill_or_stroke == other->fill_or_stroke));
}
};
/**
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 {
// 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();
bool isSelected();
/* Given one GrDraggable, these all update other draggables belonging to same GrDragger */
void moveThisToDraggable(SPItem *item, GrPointType point_type, gint point_i, Inkscape::PaintTarget fill_or_stroke, bool write_repr);
void moveOtherToDraggable(SPItem *item, GrPointType point_type, gint point_i, Inkscape::PaintTarget 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.
*/
public: // FIXME: make more of this private!
}
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
void deselectAll();
void selectAll();
void deleteSelected(bool just_one = false);
bool keep_selection;
GrDragger *getDraggerFor(SPItem *item, GrPointType point_type, gint point_i, Inkscape::PaintTarget fill_or_stroke);
void grabKnot(SPItem *item, GrPointType point_type, gint point_i, Inkscape::PaintTarget 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();
bool mouseOver();
void selected_move_nowrite(double x, double y, bool scale_radial);
void selected_move_screen(double x, double y);
GrDragger *select_next();
GrDragger *select_prev();
void selected_reverse_vector();
void deselect_all();
void addCurve(SPItem *item, Geom::Point p0, Geom::Point p1, Geom::Point p2, Geom::Point p3, Inkscape::PaintTarget fill_or_stroke);
};
#endif // SEEN_GRADIENT_DRAG_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :