~centralelyon2010/inkscape/imagelinks2

9012.1.157 by Jon A. Cruz
Initial F&S dialog setting of swatch colors.
1
#ifndef SEEN_SP_GRADIENT_H
2
#define SEEN_SP_GRADIENT_H
1 by mental
moving trunk for module inkscape
3
4
/** \file
5
 * SVG <stop> <linearGradient> and <radialGradient> implementation
6
 *
7
 * Authors:
8
 *   Lauris Kaplinski <lauris@kaplinski.com>
2276 by johanengelen
Sorry, forgot the copyright text.
9
 *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
9012.1.157 by Jon A. Cruz
Initial F&S dialog setting of swatch colors.
10
 *   Jon A. Cruz <jon@joncruz.org>
1 by mental
moving trunk for module inkscape
11
 *
9012.1.157 by Jon A. Cruz
Initial F&S dialog setting of swatch colors.
12
 * Copyrigt  (C) 2010 Jon A. Cruz
2276 by johanengelen
Sorry, forgot the copyright text.
13
 * Copyright (C) 2007 Johan Engelen
1 by mental
moving trunk for module inkscape
14
 * Copyright (C) 1999-2002 Lauris Kaplinski
15
 * Copyright (C) 2000-2001 Ximian, Inc.
16
 *
17
 * Released under GNU GPL, read the file 'COPYING' for more information
18
 */
19
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
20
#include <gdk/gdk.h>
21
#include <glibmm/ustring.h>
22
#include <2geom/affine.h>
1 by mental
moving trunk for module inkscape
23
#include "sp-paint-server.h"
24
#include "sp-gradient-spread.h"
25
#include "sp-gradient-units.h"
26
#include "sp-gradient-vector.h"
27
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
28
#include <stddef.h>
1508 by mental
switch to sigc++ SPObject signals for SPGradient
29
#include <sigc++/connection.h>
30
1 by mental
moving trunk for module inkscape
31
struct SPGradientReference;
32
9012.1.157 by Jon A. Cruz
Initial F&S dialog setting of swatch colors.
33
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
34
#define SP_TYPE_GRADIENT (SPGradient::getType())
9012.1.157 by Jon A. Cruz
Initial F&S dialog setting of swatch colors.
35
#define SP_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GRADIENT, SPGradient))
36
#define SP_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GRADIENT, SPGradientClass))
37
#define SP_IS_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GRADIENT))
38
#define SP_IS_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GRADIENT))
39
1 by mental
moving trunk for module inkscape
40
typedef enum {
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
41
    SP_GRADIENT_TYPE_UNKNOWN,
42
    SP_GRADIENT_TYPE_LINEAR,
43
    SP_GRADIENT_TYPE_RADIAL
1 by mental
moving trunk for module inkscape
44
} SPGradientType;
45
46
typedef enum {
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
47
    SP_GRADIENT_STATE_UNKNOWN,
48
    SP_GRADIENT_STATE_VECTOR,
49
    SP_GRADIENT_STATE_PRIVATE
1 by mental
moving trunk for module inkscape
50
} SPGradientState;
51
52
typedef enum {
2572 by johanengelen
Fixed bug due to adding of new pointtype at the start of the enum which corrupted indexing into the stop shapes and description array.
53
    POINT_LG_BEGIN =0, //start enum at 0 (for indexing into gr_knot_shapes array for example)
2228 by johanengelen
Upgraded gradient tool =)
54
    POINT_LG_END,
55
    POINT_LG_MID,
1 by mental
moving trunk for module inkscape
56
    POINT_RG_CENTER,
57
    POINT_RG_R1,
58
    POINT_RG_R2,
2228 by johanengelen
Upgraded gradient tool =)
59
    POINT_RG_FOCUS,
60
    POINT_RG_MID1,
2572 by johanengelen
Fixed bug due to adding of new pointtype at the start of the enum which corrupted indexing into the stop shapes and description array.
61
    POINT_RG_MID2,
62
    // insert new point types here.
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
63
2572 by johanengelen
Fixed bug due to adding of new pointtype at the start of the enum which corrupted indexing into the stop shapes and description array.
64
    POINT_G_INVALID
2228 by johanengelen
Upgraded gradient tool =)
65
} GrPointType;
1 by mental
moving trunk for module inkscape
66
67
/**
68
 * Gradient
69
 *
70
 * Implement spread, stops list
71
 * \todo fixme: Implement more here (Lauris)
72
 */
73
struct SPGradient : public SPPaintServer {
7534 by joncruz
Spaced out for legibility.
74
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
75
    /** Reference (href) */
76
    SPGradientReference *ref;
77
78
    /** State in Inkscape gradient system */
79
    guint state : 2;
80
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
81
private:
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
82
    /** gradientUnits attribute */
83
    SPGradientUnits units;
84
    guint units_set : 1;
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
85
public:
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
86
87
    /** gradientTransform attribute */
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
88
    Geom::Affine gradientTransform;
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
89
    guint gradientTransform_set : 1;
90
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
91
private:
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
92
    /** spreadMethod attribute */
93
    SPGradientSpread spread;
94
    guint spread_set : 1;
95
96
    /** Gradient stops */
97
    guint has_stops : 1;
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
98
public:
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
99
100
    /** Composed vector */
101
    SPGradientVector vector;
102
103
    sigc::connection modified_connection;
104
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
105
    bool hasStops() const;
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
106
9012.1.141 by Jon A. Cruz
New tab in Fill&Stroke dialog for swatch fills.
107
    SPStop* getFirstStop();
108
    int getStopCount() const;
9012.1.157 by Jon A. Cruz
Initial F&S dialog setting of swatch colors.
109
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
110
111
    bool isUnitsSet() const;
112
    SPGradientUnits getUnits() const;
113
    void setUnits(SPGradientUnits units);
114
115
116
    bool isSpreadSet() const;
117
    SPGradientSpread getSpread() const;
118
9012.1.157 by Jon A. Cruz
Initial F&S dialog setting of swatch colors.
119
/**
120
 * Returns private vector of given gradient (the gradient at the end of the href chain which has
121
 * stops), optionally normalizing it.
122
 *
123
 * \pre SP_IS_GRADIENT(gradient).
124
 * \pre There exists a gradient in the chain that has stops.
125
 */
126
    SPGradient *getVector(bool force_private = false);
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
127
128
    static GType getType();
129
130
    /** Forces vector to be built, if not present (i.e. changed) */
131
    void ensureVector();
132
133
    /** Ensures that color array is populated */
134
    void ensureColors();
135
136
    /**
137
     * Set spread property of gradient and emit modified.
138
     */
139
    void setSpread(SPGradientSpread spread);
140
141
    SPGradientSpread fetchSpread();
142
    SPGradientUnits fetchUnits();
143
144
    void setSwatch(bool swatch = true);
145
146
private:
147
    bool invalidateVector();
148
    void rebuildVector();
149
150
    friend class SPGradientImpl;
151
    friend class SPLGPainter;
152
    friend class SPRGPainter;
1 by mental
moving trunk for module inkscape
153
};
154
155
/**
156
 * The SPGradient vtable.
157
 */
158
struct SPGradientClass {
9012.1.128 by Jon A. Cruz
Added method to query "solid paint" status of SPGradient.
159
    SPPaintServerClass parent_class;
1 by mental
moving trunk for module inkscape
160
};
161
162
163
#include "sp-gradient-fns.h"
164
9012.1.157 by Jon A. Cruz
Initial F&S dialog setting of swatch colors.
165
#endif // SEEN_SP_GRADIENT_H
1 by mental
moving trunk for module inkscape
166
167
/*
168
  Local Variables:
169
  mode:c++
170
  c-file-style:"stroustrup"
171
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
172
  indent-tabs-mode:nil
173
  fill-column:99
174
  End:
175
*/
9020 by JazzyNico
Code refactoring and merging with trunk (revision 10599).
176
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :