X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fknot-holder-entity.h;h=1f5ea8e2c98330a38e1a53848e45da5af4c91e1e;hb=f5e01381df27a3dd9343e50b4e03bf92ca79edbc;hp=1e9001e67839107e7b037a7e9abbc550b2b03fd0;hpb=6b15695578f07a3f72c4c9475c1a261a3021472a;p=inkscape.git diff --git a/src/knot-holder-entity.h b/src/knot-holder-entity.h index 1e9001e67..1f5ea8e2c 100644 --- a/src/knot-holder-entity.h +++ b/src/knot-holder-entity.h @@ -2,51 +2,107 @@ #define SEEN_KNOT_HOLDER_ENTITY_H /** \file - * SPKnotHolderEntity definition. + * KnotHolderEntity definition. * * Authors: * Mitsuru Oka + * Maximilian Albert * * Copyright (C) 1999-2001 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. * Copyright (C) 2001 Mitsuru Oka * Copyright (C) 2004 Monash University + * Copyright (C) 2008 Maximilian Albert * * Released under GNU GPL */ #include +#include "knot.h" +#include <2geom/forward.h> struct SPItem; struct SPKnot; -namespace NR { -class Point; -} -/// SPKnotHolderEntity definition. -struct SPKnotHolderEntity { +class SPDesktop; +class KnotHolder; + +typedef void (* SPKnotHolderSetFunc) (SPItem *item, Geom::Point const &p, Geom::Point const &origin, guint state); +typedef Geom::Point (* SPKnotHolderGetFunc) (SPItem *item); +/* fixme: Think how to make callbacks most sensitive (Lauris) */ +typedef void (* SPKnotHolderReleasedFunc) (SPItem *item); + +class KnotHolderEntity { +public: + KnotHolderEntity() {} + virtual ~KnotHolderEntity(); + virtual void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, const gchar *tip = "", + SPKnotShapeType shape = SP_KNOT_SHAPE_DIAMOND, + SPKnotModeType mode = SP_KNOT_MODE_XOR, + guint32 color = 0xffffff00); + + /* derived classes used for LPE knotholder handles use this to indicate that they + must not be deleted when a knotholder is destroyed */ + // TODO: it would be nice to ditch this but then we need to dynamically create instances of different + // KnotHolderEntity classes in Effect::addKnotHolderEntities. How to do this??? + virtual bool isDeletable() { return true; } + + /* the get/set/click handlers are virtual functions; each handler class for a knot + should be derived from KnotHolderEntity and override these functions */ + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) = 0; + virtual Geom::Point knot_get() = 0; + virtual void knot_click(guint /*state*/) {} + + void update_knot(); + +//private: + Geom::Point snap_knot_position(Geom::Point const &p); + SPKnot *knot; + SPItem *item; + SPDesktop *desktop; + + KnotHolder *parent_holder; + + int my_counter; + static int counter; /** Connection to \a knot's "moved" signal. */ guint handler_id; + /** Connection to \a knot's "clicked" signal. */ + guint _click_handler_id; + /** Connection to \a knot's "ungrabbed" signal. */ + guint _ungrab_handler_id; - /** - * Called solely from knot_moved_handler. - * - * \param p Requested position of the knot, in item coordinates - * \param origin Position where the knot started being dragged - * \param state GTK event state (for keyboard modifiers) - */ - void (* knot_set) (SPItem *item, NR::Point const &p, NR::Point const &origin, guint state); - - /** - * Returns the position of the knot representation, in item coordinates. - */ - NR::Point (* knot_get) (SPItem *item); - - void (* knot_click) (SPItem *item, guint state); + sigc::connection _moved_connection; + sigc::connection _click_connection; + sigc::connection _ungrabbed_connection; }; +// derived KnotHolderEntity class for LPEs +class LPEKnotHolderEntity : public KnotHolderEntity { + virtual bool isDeletable() { return false; } +}; + +/* pattern manipulation */ + +class PatternKnotHolderEntityXY : public KnotHolderEntity { +public: + virtual Geom::Point knot_get(); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); +}; + +class PatternKnotHolderEntityAngle : public KnotHolderEntity { +public: + virtual Geom::Point knot_get(); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); +}; + +class PatternKnotHolderEntityScale : public KnotHolderEntity { +public: + virtual Geom::Point knot_get(); + virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state); +}; #endif /* !SEEN_KNOT_HOLDER_ENTITY_H */