Code

Filters. Custom predefined filters update and new ABC filters.
[inkscape.git] / src / knot-holder-entity.h
1 #ifndef SEEN_KNOT_HOLDER_ENTITY_H
2 #define SEEN_KNOT_HOLDER_ENTITY_H
4 /** \file
5  * KnotHolderEntity definition.
6  *
7  * Authors:
8  *   Mitsuru Oka <oka326@parkcity.ne.jp>
9  *   Maximilian Albert <maximilian.albert@gmail.com>
10  *
11  * Copyright (C) 1999-2001 Lauris Kaplinski
12  * Copyright (C) 2000-2001 Ximian, Inc.
13  * Copyright (C) 2001 Mitsuru Oka
14  * Copyright (C) 2004 Monash University
15  * Copyright (C) 2008 Maximilian Albert
16  *
17  * Released under GNU GPL
18  */
20 #include <glib/gtypes.h>
21 #include "knot.h"
22 #include <2geom/forward.h>
23 #include "snapper.h"
25 struct SPItem;
26 struct SPKnot;
28 class SPDesktop;
29 class KnotHolder;
31 typedef void (* SPKnotHolderSetFunc) (SPItem *item, Geom::Point const &p, Geom::Point const &origin, guint state);
32 typedef Geom::Point (* SPKnotHolderGetFunc) (SPItem *item);
33 /* fixme: Think how to make callbacks most sensitive (Lauris) */
34 typedef void (* SPKnotHolderReleasedFunc) (SPItem *item);
36 class KnotHolderEntity {
37 public:
38     KnotHolderEntity() {}
39     virtual ~KnotHolderEntity();
40     virtual void create(SPDesktop *desktop, SPItem *item, KnotHolder *parent, const gchar *tip = "",
41                         SPKnotShapeType shape = SP_KNOT_SHAPE_DIAMOND,
42                         SPKnotModeType mode = SP_KNOT_MODE_XOR,
43                         guint32 color = 0xffffff00);
45     /* derived classes used for LPE knotholder handles use this to indicate that they
46        must not be deleted when a knotholder is destroyed */
47     // TODO: it would be nice to ditch this but then we need to dynamically create instances of different
48     //       KnotHolderEntity classes in Effect::addKnotHolderEntities. How to do this???
49     virtual bool isDeletable() { return true; }
51     /* the get/set/click handlers are virtual functions; each handler class for a knot
52        should be derived from KnotHolderEntity and override these functions */
53     virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) = 0;
54     virtual Geom::Point knot_get() = 0;
55     virtual void knot_click(guint /*state*/) {}
57     void update_knot();
59 //private:
60     Geom::Point snap_knot_position(Geom::Point const &p);
61     Geom::Point snap_knot_position_constrained(Geom::Point const &p, Inkscape::Snapper::SnapConstraint const &constraint);
63     SPKnot *knot;
64     SPItem *item;
65     SPDesktop *desktop;
67     KnotHolder *parent_holder;
69     int my_counter;
70     static int counter;
72     /** Connection to \a knot's "moved" signal. */
73     guint   handler_id;
74     /** Connection to \a knot's "clicked" signal. */
75     guint   _click_handler_id;
76     /** Connection to \a knot's "ungrabbed" signal. */
77     guint   _ungrab_handler_id;
79     sigc::connection _moved_connection;
80     sigc::connection _click_connection;
81     sigc::connection _ungrabbed_connection;
82 };
84 // derived KnotHolderEntity class for LPEs
85 class LPEKnotHolderEntity : public KnotHolderEntity {
86     virtual bool isDeletable() { return false; }
87 };
89 /* pattern manipulation */
91 class PatternKnotHolderEntityXY : public KnotHolderEntity {
92 public:
93     virtual Geom::Point knot_get();
94     virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
95 };
97 class PatternKnotHolderEntityAngle : public KnotHolderEntity {
98 public:
99     virtual Geom::Point knot_get();
100     virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
101 };
103 class PatternKnotHolderEntityScale : public KnotHolderEntity {
104 public:
105     virtual Geom::Point knot_get();
106     virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
107 };
109 #endif /* !SEEN_KNOT_HOLDER_ENTITY_H */
111 /*
112   Local Variables:
113   mode:c++
114   c-file-style:"stroustrup"
115   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
116   indent-tabs-mode:nil
117   fill-column:99
118   End:
119 */
120 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :