Code

merge ::dragging and ::dynahand
[inkscape.git] / src / dyna-draw-context.h
1 #ifndef __SP_DYNA_DRAW_CONTEXT_H__
2 #define __SP_DYNA_DRAW_CONTEXT_H__
4 /*
5  * Handwriting-like drawing mode
6  *
7  * Authors:
8  *   Mitsuru Oka <oka326@parkcity.ne.jp>
9  *   Lauris Kaplinski <lauris@kaplinski.com>
10  *
11  * The original dynadraw code:
12  *   Paul Haeberli <paul@sgi.com>
13  *
14  * Copyright (C) 1998 The Free Software Foundation
15  * Copyright (C) 1999-2002 authors
16  * Copyright (C) 2001-2002 Ximian, Inc.
17  *
18  * Released under GNU GPL, read the file 'COPYING' for more information
19  */
21 #include "display/curve.h"
22 #include "event-context.h"
23 #include <display/display-forward.h>
24 #include <libnr/nr-point.h>
26 #define SP_TYPE_DYNA_DRAW_CONTEXT (sp_dyna_draw_context_get_type())
27 #define SP_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_CAST((o), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContext))
28 #define SP_DYNA_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), SP_TYPE_DYNA_DRAW_CONTEXT, SPDynaDrawContextClass))
29 #define SP_IS_DYNA_DRAW_CONTEXT(o) (GTK_CHECK_TYPE((o), SP_TYPE_DYNA_DRAW_CONTEXT))
30 #define SP_IS_DYNA_DRAW_CONTEXT_CLASS(k) (GTK_CHECK_CLASS_TYPE((k), SP_TYPE_DYNA_DRAW_CONTEXT))
32 class SPDynaDrawContext;
33 class SPDynaDrawContextClass;
35 #define SAMPLING_SIZE 8        /* fixme: ?? */
37 #define DDC_MIN_PRESSURE      0.0
38 #define DDC_MAX_PRESSURE      1.0
39 #define DDC_DEFAULT_PRESSURE  1.0
41 #define DDC_MIN_TILT         -1.0
42 #define DDC_MAX_TILT          1.0
43 #define DDC_DEFAULT_TILT      0.0
45 struct SPDynaDrawContext
46 {
47     SPEventContext event_context;
49     /** accumulated shape which ultimately goes in svg:path */
50     SPCurve *accumulated;
52     /** canvas items for "comitted" segments */
53     GSList *segments;
55     /** canvas item for red "leading" segment */
56     SPCanvasItem *currentshape;
57     /** shape of red "leading" segment */
58     SPCurve *currentcurve;
60     /** left edge of the stroke; combined to get accumulated */
61     SPCurve *cal1;
62     /** right edge of the stroke; combined to get accumulated */
63     SPCurve *cal2;
65     /** left edge points for this segment */
66     NR::Point point1[SAMPLING_SIZE];
67     /** right edge points for this segment */
68     NR::Point point2[SAMPLING_SIZE];
69     /** number of edge points for this segment */
70     gint npoints;
72     /* repr */
73     Inkscape::XML::Node *repr;
75     /* time_id if use timeout */
76     gint timer_id;
78     /* DynaDraw */
79     NR::Point cur;
80     NR::Point vel;
81     NR::Point acc;
82     NR::Point ang;
83     NR::Point last;
84     NR::Point del;
85     /* extended input data */
86     gdouble pressure;
87     gdouble xtilt;
88     gdouble ytilt;
89     /* attributes */
90     guint dragging : 1;           /* mouse state: mouse is dragging */
91     guint use_timeout : 1;
92     double mass, drag;
93     double angle;
94     double width;
95     guint usepressure : 1;
96     guint usetilt : 1;
98     double vel_thin;
99     double flatness;
100     double tremor;
102     Inkscape::MessageContext *_message_context;
104     bool is_drawing;
105 };
107 struct SPDynaDrawContextClass
109     SPEventContextClass parent_class;
110 };
112 GtkType sp_dyna_draw_context_get_type(void);
114 #endif
116 /*
117   Local Variables:
118   mode:c++
119   c-file-style:"stroustrup"
120   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
121   indent-tabs-mode:nil
122   fill-column:99
123   End:
124 */
125 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :