~ubuntu-branches/ubuntu/utopic/inkscape/utopic-proposed

« back to all changes in this revision

Viewing changes to src/sp-gradient.h

  • Committer: Bazaar Package Importer
  • Author(s): Alex Valavanis
  • Date: 2010-09-12 19:44:58 UTC
  • mfrom: (1.1.12 upstream) (45.1.3 maverick)
  • Revision ID: james.westby@ubuntu.com-20100912194458-4sjwmbl7dlsrk5dc
Tags: 0.48.0-1ubuntu1
* Merge with Debian unstable (LP: #628048, LP: #401567, LP: #456248, 
  LP: #463602, LP: #591986)
* debian/control: 
  - Ubuntu maintainers
  - Promote python-lxml, python-numpy, python-uniconvertor to Recommends.
  - Demote pstoedit to Suggests (universe package).
  - Suggests ttf-dejavu instead of ttf-bitstream-vera (LP: #513319)
* debian/rules:
  - Run intltool-update on build (Ubuntu-specific).
  - Add translation domain to .desktop files (Ubuntu-specific).
* debian/dirs:
  - Add usr/share/pixmaps.  Allow inkscape.xpm installation
* drop 50-poppler-API.dpatch (now upstream)
* drop 51-paste-in-unwritable-directory.dpatch (now upstream) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef __SP_GRADIENT_H__
2
 
#define __SP_GRADIENT_H__
 
1
#ifndef SEEN_SP_GRADIENT_H
 
2
#define SEEN_SP_GRADIENT_H
3
3
 
4
4
/** \file
5
5
 * SVG <stop> <linearGradient> and <radialGradient> implementation
7
7
 * Authors:
8
8
 *   Lauris Kaplinski <lauris@kaplinski.com>
9
9
 *   Johan Engelen <j.b.c.engelen@ewi.utwente.nl>
 
10
 *   Jon A. Cruz <jon@joncruz.org>
10
11
 *
 
12
 * Copyrigt  (C) 2010 Jon A. Cruz
11
13
 * Copyright (C) 2007 Johan Engelen
12
14
 * Copyright (C) 1999-2002 Lauris Kaplinski
13
15
 * Copyright (C) 2000-2001 Ximian, Inc.
16
18
 */
17
19
 
18
20
#include <gdk/gdktypes.h>
 
21
#include <glibmm/ustring.h>
19
22
#include "libnr/nr-matrix.h"
20
23
#include "sp-paint-server.h"
21
24
#include "sp-gradient-spread.h"
26
29
 
27
30
struct SPGradientReference;
28
31
 
 
32
 
 
33
#define SP_TYPE_GRADIENT (SPGradient::getType())
 
34
#define SP_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), SP_TYPE_GRADIENT, SPGradient))
 
35
#define SP_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), SP_TYPE_GRADIENT, SPGradientClass))
 
36
#define SP_IS_GRADIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), SP_TYPE_GRADIENT))
 
37
#define SP_IS_GRADIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_GRADIENT))
 
38
 
29
39
typedef enum {
30
 
        SP_GRADIENT_TYPE_UNKNOWN,
31
 
        SP_GRADIENT_TYPE_LINEAR,
32
 
        SP_GRADIENT_TYPE_RADIAL
 
40
    SP_GRADIENT_TYPE_UNKNOWN,
 
41
    SP_GRADIENT_TYPE_LINEAR,
 
42
    SP_GRADIENT_TYPE_RADIAL
33
43
} SPGradientType;
34
44
 
35
45
typedef enum {
36
 
        SP_GRADIENT_STATE_UNKNOWN,
37
 
        SP_GRADIENT_STATE_VECTOR,
38
 
        SP_GRADIENT_STATE_PRIVATE
 
46
    SP_GRADIENT_STATE_UNKNOWN,
 
47
    SP_GRADIENT_STATE_VECTOR,
 
48
    SP_GRADIENT_STATE_PRIVATE
39
49
} SPGradientState;
40
50
 
41
51
typedef enum {
49
59
    POINT_RG_MID1,
50
60
    POINT_RG_MID2,
51
61
    // insert new point types here.
52
 
    
 
62
 
53
63
    POINT_G_INVALID
54
64
} GrPointType;
55
65
 
61
71
 */
62
72
struct SPGradient : public SPPaintServer {
63
73
 
64
 
        /** Reference (href) */
65
 
        SPGradientReference *ref;
66
 
 
67
 
        /** State in Inkscape gradient system */
68
 
        guint state : 2;
69
 
 
70
 
        /** gradientUnits attribute */
71
 
        SPGradientUnits units;
72
 
        guint units_set : 1;
73
 
 
74
 
        /** gradientTransform attribute */
75
 
        Geom::Matrix gradientTransform;
76
 
        guint gradientTransform_set : 1;
77
 
 
78
 
        /** spreadMethod attribute */
79
 
        SPGradientSpread spread;
80
 
        guint spread_set : 1;
81
 
 
82
 
        /** Gradient stops */
83
 
        guint has_stops : 1;
84
 
 
85
 
        /** Composed vector */
86
 
        SPGradientVector vector;
87
 
 
88
 
        /** Rendered color array (4 * 1024 bytes) */
89
 
        guchar *color;
90
 
 
91
 
        sigc::connection modified_connection;
 
74
    /** Reference (href) */
 
75
    SPGradientReference *ref;
 
76
 
 
77
    /** State in Inkscape gradient system */
 
78
    guint state : 2;
 
79
 
 
80
private:
 
81
    /** gradientUnits attribute */
 
82
    SPGradientUnits units;
 
83
    guint units_set : 1;
 
84
public:
 
85
 
 
86
    /** gradientTransform attribute */
 
87
    Geom::Matrix gradientTransform;
 
88
    guint gradientTransform_set : 1;
 
89
 
 
90
private:
 
91
    /** spreadMethod attribute */
 
92
    SPGradientSpread spread;
 
93
    guint spread_set : 1;
 
94
 
 
95
    /** Gradient stops */
 
96
    guint has_stops : 1;
 
97
public:
 
98
 
 
99
    /** Composed vector */
 
100
    SPGradientVector vector;
 
101
 
 
102
    /** Rendered color array (4 * 1024 bytes) */
 
103
    guchar *color;
 
104
 
 
105
    sigc::connection modified_connection;
 
106
 
 
107
    bool hasStops() const;
 
108
 
 
109
    SPStop* getFirstStop();
 
110
    int getStopCount() const;
 
111
 
 
112
 
 
113
    bool isUnitsSet() const;
 
114
    SPGradientUnits getUnits() const;
 
115
    void setUnits(SPGradientUnits units);
 
116
 
 
117
 
 
118
    bool isSpreadSet() const;
 
119
    SPGradientSpread getSpread() const;
 
120
 
 
121
/**
 
122
 * Returns private vector of given gradient (the gradient at the end of the href chain which has
 
123
 * stops), optionally normalizing it.
 
124
 *
 
125
 * \pre SP_IS_GRADIENT(gradient).
 
126
 * \pre There exists a gradient in the chain that has stops.
 
127
 */
 
128
    SPGradient *getVector(bool force_private = false);
 
129
 
 
130
    static GType getType();
 
131
 
 
132
    /** Forces vector to be built, if not present (i.e. changed) */
 
133
    void ensureVector();
 
134
 
 
135
    /** Ensures that color array is populated */
 
136
    void ensureColors();
 
137
 
 
138
    /**
 
139
     * Set spread property of gradient and emit modified.
 
140
     */
 
141
    void setSpread(SPGradientSpread spread);
 
142
 
 
143
    SPGradientSpread fetchSpread();
 
144
    SPGradientUnits fetchUnits();
 
145
 
 
146
    void setSwatch(bool swatch = true);
 
147
 
 
148
private:
 
149
    bool invalidateVector();
 
150
    void rebuildVector();
 
151
 
 
152
    friend class SPGradientImpl;
 
153
    friend class SPLGPainter;
 
154
    friend class SPRGPainter;
92
155
};
93
156
 
94
157
/**
95
158
 * The SPGradient vtable.
96
159
 */
97
160
struct SPGradientClass {
98
 
        SPPaintServerClass parent_class;
 
161
    SPPaintServerClass parent_class;
99
162
};
100
163
 
101
164
 
102
165
#include "sp-gradient-fns.h"
103
166
 
104
 
#endif /* !__SP_GRADIENT_H__ */
 
167
#endif // SEEN_SP_GRADIENT_H
105
168
 
106
169
/*
107
170
  Local Variables: