~cairo-dock-team/ubuntu/oneiric/cairo-dock/2.3.0-3

« back to all changes in this revision

Viewing changes to src/gldit/cairo-dock-opengl-path.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthieu Baerts (matttbe)
  • Date: 2010-08-09 23:26:12 UTC
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20100809232612-pocdxliaxjdetm37
Tags: upstream-2.2.0~0beta4
ImportĀ upstreamĀ versionĀ 2.2.0~0beta4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
* This file is a part of the Cairo-Dock project
 
3
*
 
4
* Copyright : (C) see the 'copyright' file.
 
5
* E-mail    : see the 'copyright' file.
 
6
*
 
7
* This program is free software; you can redistribute it and/or
 
8
* modify it under the terms of the GNU General Public License
 
9
* as published by the Free Software Foundation; either version 3
 
10
* of the License, or (at your option) any later version.
 
11
*
 
12
* This program is distributed in the hope that it will be useful,
 
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
* GNU General Public License for more details.
 
16
* You should have received a copy of the GNU General Public License
 
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
*/
 
19
 
 
20
 
 
21
#ifndef __CAIRO_DOCK_OPENGL_PATH__
 
22
#define  __CAIRO_DOCK_OPENGL_PATH__
 
23
 
 
24
#include <glib.h>
 
25
 
 
26
#include <gdk/x11/gdkglx.h>
 
27
#include <gtk/gtkgl.h>
 
28
#include <GL/glu.h>
 
29
 
 
30
#include "cairo-dock-struct.h"
 
31
 
 
32
G_BEGIN_DECLS
 
33
 
 
34
/**
 
35
*@file cairo-dock-opengl-path.h This class define OpenGL path, with similar functions as cairo.
 
36
* You create a path with \ref cairo_dock_new_gl_path, then you add lines, curves or arcs to it.
 
37
* Once the path is defined, you can eigher stroke it with \ref cairo_dock_stroke_gl_path or fill it with \ref cairo_dock_fill_gl_path. You can fill a path with the current color or with a texture, in this case you must provide the dimension of the husk.
 
38
* To destroy the path, use \ref cairo_dock_free_gl_path.
 
39
*/
 
40
 
 
41
/// Definition of a CairoDockGLPath.
 
42
struct _CairoDockGLPath {
 
43
        int iNbPoints;
 
44
        GLfloat *pVertices;
 
45
        int iCurrentPt;
 
46
        int iWidth, iHeight;
 
47
        };
 
48
 
 
49
/** Create a new path. It will start at the point (x0, y0). If you want to be abe to fill it with a texture, you can specify here the dimension of the path's husk.
 
50
 * @param iNbVertices maximum number of vertices the path will have
 
51
 * @param x0 x coordinate of the origin point
 
52
 * @param y0 y coordinate of the origin point
 
53
 * @param iWidth width of the husk of the path.
 
54
 * @param iHeight height of the husk of the path
 
55
 * @return a newly allocated path, with 1 point.
 
56
 */
 
57
CairoDockGLPath *cairo_dock_new_gl_path (int iNbVertices, double x0, double y0, int iWidth, int iHeight);
 
58
 
 
59
/** Destroy a path and free its allocated ressources.
 
60
 * @param pPath the path.
 
61
 */
 
62
void cairo_dock_free_gl_path (CairoDockGLPath *pPath);
 
63
 
 
64
/** Rewind the path, defining its origin point. The path has only 1 point after a call to this function.
 
65
 * @param pPath the path.
 
66
 * @param x0 x coordinate of the origin point
 
67
 * @param y0 y coordinate of the origin point
 
68
 */
 
69
void cairo_dock_gl_path_move_to (CairoDockGLPath *pPath, double x0, double y0);
 
70
 
 
71
/** Define the dimension of the hulk. This is needed if you intend to fill the path with a texture.
 
72
 * @param pPath the path.
 
73
 * @param iWidth width of the hulk
 
74
 * @param iHeight height of the hulk
 
75
 */
 
76
void cairo_dock_gl_path_set_extent (CairoDockGLPath *pPath, int iWidth, int iHeight);
 
77
 
 
78
/** Add a line between the current point and a given point.
 
79
 * @param pPath the path.
 
80
 * @param x x coordinate of the point
 
81
 * @param y y coordinate of the point
 
82
 */
 
83
void cairo_dock_gl_path_line_to (CairoDockGLPath *pPath, GLfloat x, GLfloat y);
 
84
 
 
85
/** Add a line defined relatively to the current point.
 
86
 * @param pPath the path.
 
87
 * @param dx horizontal offset
 
88
 * @param dy vertical offset
 
89
 */
 
90
void cairo_dock_gl_path_rel_line_to (CairoDockGLPath *pPath, GLfloat dx, GLfloat dy);
 
91
 
 
92
/** Add a Bezier cubic curve starting from the current point.
 
93
 * @param pPath the path.
 
94
 * @param iNbPoints number of points used to discretize the curve
 
95
 * @param x1 first control point x
 
96
 * @param y1 first control point y
 
97
 * @param x2 second control point x
 
98
 * @param y2 second control point y
 
99
 * @param x3 terminal point of the curve x
 
100
 * @param y3 terminal point of the curve y
 
101
 */
 
102
void cairo_dock_gl_path_curve_to (CairoDockGLPath *pPath, int iNbPoints, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3);
 
103
 
 
104
/** Add a Bezier cubic curve starting from the current point. The control and terminal points are defined relatively to the current point.
 
105
 * @param pPath the path.
 
106
 * @param iNbPoints number of points used to discretize the curve
 
107
 * @param dx1 first control point offset x
 
108
 * @param dy1 first control point offset y
 
109
 * @param dx2 second control point offset x
 
110
 * @param dy2 second control point offset y
 
111
 * @param dx3 terminal point of the curve offset x
 
112
 * @param dy3 terminal point of the curve offset y
 
113
 */
 
114
void cairo_dock_gl_path_rel_curve_to (CairoDockGLPath *pPath, int iNbPoints, GLfloat dx1, GLfloat dy1, GLfloat dx2, GLfloat dy2, GLfloat dx3, GLfloat dy3);
 
115
 
 
116
/** Add a Bezier bilinear curve starting from the current point
 
117
 * @param pPath the path.
 
118
 * @param iNbPoints number of points used to discretize the curve
 
119
 * @param x1 control point x
 
120
 * @param y1 control point y
 
121
 * @param x2 terminal point of the curve x
 
122
 * @param y2 terminal point of the curve y
 
123
 */
 
124
void cairo_dock_gl_path_simple_curve_to (CairoDockGLPath *pPath, int iNbPoints, GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2);
 
125
 
 
126
/** Add a Bezier bilinear curve starting from the current point. The control and terminal points are defined relatively to the current point.
 
127
 * @param pPath the path.
 
128
 * @param iNbPoints number of points used to discretize the curve
 
129
 * @param dx1 control point offset x
 
130
 * @param dy1 control point offset y
 
131
 * @param dx2 terminal point of the curve offset x
 
132
 * @param dy2 terminal point of the curve offset y
 
133
 */
 
134
void cairo_dock_gl_path_rel_simple_curve_to (CairoDockGLPath *pPath, int iNbPoints, GLfloat dx1, GLfloat dy1, GLfloat dx2, GLfloat dy2);
 
135
 
 
136
/** Add an arc to the path, joining the current point to the beginning of the arc with a line.
 
137
 * @param pPath the path.
 
138
 * @param iNbPoints number of points used to discretize the arc
 
139
 * @param xc x coordinate of the center
 
140
 * @param yx y coordinate of the center
 
141
 * @param r radius
 
142
 * @param teta0 initial angle
 
143
 * @param cone cone of the arc (a negative value means clockwise).
 
144
 */
 
145
void cairo_dock_gl_path_arc (CairoDockGLPath *pPath, int iNbPoints, GLfloat xc, GLfloat yc, double r, double teta0, double cone);
 
146
 
 
147
/** Stroke a path with the current color and with the current line width.
 
148
 * @param pPath the path.
 
149
 * @param bClosePath whether to close the path (that is to say, join the last point with the first one) or not.
 
150
 */
 
151
void cairo_dock_stroke_gl_path (const CairoDockGLPath *pPath, gboolean bClosePath);
 
152
 
 
153
/** Fill a path with a texture, or with the current color if the texture is 0.
 
154
 * @param pPath the path.
 
155
 * @param iTexture the texture, or 0 to fill the path with the current color. To fill the path with a gradation, use GL_COLOR_ARRAY and feed it with a table of colors that matches the vertices.
 
156
 */
 
157
void cairo_dock_fill_gl_path (const CairoDockGLPath *pPath, GLuint iTexture);
 
158
 
 
159
 
 
160
const CairoDockGLPath *cairo_dock_generate_rectangle_path (double fFrameWidth, double fTotalHeight, double fRadius, gboolean bRoundedBottomCorner);
 
161
 
 
162
const CairoDockGLPath *cairo_dock_generate_trapeze_path (double fUpperFrameWidth, double fTotalHeight, double fRadius, gboolean bRoundedBottomCorner, double fInclination, double *fExtraWidth);
 
163
 
 
164
const CairoDockGLPath *cairo_dock_generate_string_path_opengl (CairoDock *pDock, gboolean bIsLoop, gboolean bForceConstantSeparator);
 
165
 
 
166
void cairo_dock_draw_current_path_opengl (double fLineWidth, double *fLineColor, int iNbVertex);
 
167
 
 
168
/** Draw a rectangle with rounded corners. The rectangle will be centered at the current point. The current matrix is not altered.
 
169
*@param fFrameWidth width of the rectangle, without the corners.
 
170
*@param fFrameHeight height of the rectangle, including the corners.
 
171
*@param fRadius radius of the corners (can be 0).
 
172
*@param fLineWidth width of the line. If set to 0, the background will be filled with the provided color, otherwise the path will be stroke with this color.
 
173
*@param fLineColor color of the line if fLineWidth is non nul, or color of the background otherwise.
 
174
*/
 
175
void cairo_dock_draw_rounded_rectangle_opengl (double fFrameWidth, double fFrameHeight, double fRadius, double fLineWidth, double *fLineColor);
 
176
 
 
177
void cairo_dock_draw_string_opengl (CairoDock *pDock, double fStringLineWidth, gboolean bIsLoop, gboolean bForceConstantSeparator);
 
178
 
 
179
 
 
180
G_END_DECLS
 
181
#endif