1 #ifndef SEEN_PEN_CONTEXT_H
2 #define SEEN_PEN_CONTEXT_H
4 /** \file
5 * SPPenContext: a context for pen tool events.
6 */
8 #include "draw-context.h"
9 #include "live_effects/effect.h"
11 #define SP_TYPE_PEN_CONTEXT (sp_pen_context_get_type())
12 #define SP_PEN_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_PEN_CONTEXT, SPPenContext))
13 #define SP_PEN_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_PEN_CONTEXT, SPPenContextClass))
14 #define SP_IS_PEN_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_PEN_CONTEXT))
15 #define SP_IS_PEN_CONTEXT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_PEN_CONTEXT))
17 enum {
18 SP_PEN_CONTEXT_POINT,
19 SP_PEN_CONTEXT_CONTROL,
20 SP_PEN_CONTEXT_CLOSE,
21 SP_PEN_CONTEXT_STOP
22 };
24 enum {
25 SP_PEN_CONTEXT_MODE_CLICK,
26 SP_PEN_CONTEXT_MODE_DRAG
27 };
29 /**
30 * SPPenContext: a context for pen tool events.
31 */
32 struct SPPenContext : public SPDrawContext {
33 NR::Point p[5];
35 /** \invar npoints in {0, 2, 5}. */
36 gint npoints;
38 unsigned int mode : 1;
39 unsigned int state : 2;
41 bool polylines_only;
43 unsigned int expecting_clicks_for_LPE; // if positive, finish the path after this many clicks
44 Inkscape::LivePathEffect::Effect *waiting_LPE; // if NULL, waiting_LPE_type in SPDrawContext is taken into account
45 SPLPEItem *waiting_item;
47 SPCanvasItem *c0, *c1, *cl0, *cl1;
49 unsigned int events_disabled : 1;
50 };
52 /// The SPPenContext vtable (empty).
53 struct SPPenContextClass : public SPEventContextClass { };
55 GType sp_pen_context_get_type();
57 inline bool sp_pen_context_has_waiting_LPE(SPPenContext *pc) {
58 // note: waiting_LPE_type is defined in SPDrawContext
59 return (pc->waiting_LPE != NULL ||
60 pc->waiting_LPE_type != Inkscape::LivePathEffect::INVALID_LPE);
61 }
63 void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEffect::EffectType effect_type,
64 unsigned int num_clicks, bool use_polylines = true);
66 #endif /* !SEEN_PEN_CONTEXT_H */
68 /*
69 Local Variables:
70 mode:c++
71 c-file-style:"stroustrup"
72 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
73 indent-tabs-mode:nil
74 fill-column:99
75 End:
76 */
77 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :