Code

Node tool: special case node duplication for endnodes - select new endnode
[inkscape.git] / src / pen-context.h
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     Geom::Point p[5];
35     /** \invar npoints in {0, 2, 5}. */
36     // npoints somehow determines the type of the node (what does it mean, exactly? the number of Bezier handles?)
37     gint npoints;
39     unsigned int mode : 1;
40     unsigned int state : 2;
42     bool polylines_only;
43     bool polylines_paraxial;
44     int num_clicks;
46     unsigned int expecting_clicks_for_LPE; // if positive, finish the path after this many clicks
47     Inkscape::LivePathEffect::Effect *waiting_LPE; // if NULL, waiting_LPE_type in SPDrawContext is taken into account
48     SPLPEItem *waiting_item;
50     SPCanvasItem *c0, *c1, *cl0, *cl1;
51     
52     unsigned int events_disabled : 1;
53 };
55 /// The SPPenContext vtable (empty).
56 struct SPPenContextClass : public SPEventContextClass { };
58 GType sp_pen_context_get_type();
60 inline bool sp_pen_context_has_waiting_LPE(SPPenContext *pc) {
61     // note: waiting_LPE_type is defined in SPDrawContext
62     return (pc->waiting_LPE != NULL ||
63             pc->waiting_LPE_type != Inkscape::LivePathEffect::INVALID_LPE);
64 }
66 void sp_pen_context_set_polyline_mode(SPPenContext *const pc);
67 void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEffect::EffectType effect_type,
68                                               unsigned int num_clicks, bool use_polylines = true);
69 void sp_pen_context_cancel_waiting_for_LPE(SPPenContext *pc);
70 void sp_pen_context_put_into_waiting_mode(SPDesktop *desktop, Inkscape::LivePathEffect::EffectType effect_type,
71                                           unsigned int num_clicks, bool use_polylines = true);
73 #endif /* !SEEN_PEN_CONTEXT_H */
75 /*
76   Local Variables:
77   mode:c++
78   c-file-style:"stroustrup"
79   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
80   indent-tabs-mode:nil
81   fill-column:99
82   End:
83 */
84 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :