Merge lp:~cairo-dock-team/cairo-dock-plug-ins/desklet-rendering-pan-view into lp:~cairo-dock-team/cairo-dock-plug-ins/plug-ins
- desklet-rendering-pan-view
- Merge into plug-ins
Proposed by
Tofe
Status: | Merged |
---|---|
Approved by: | Tofe |
Approved revision: | 1702 |
Merged at revision: | 1702 |
Proposed branch: | lp:~cairo-dock-team/cairo-dock-plug-ins/desklet-rendering-pan-view |
Merge into: | lp:~cairo-dock-team/cairo-dock-plug-ins/plug-ins |
Diff against target: |
826 lines (+768/-2) 5 files modified
Folders/src/applet-load-icons.c (+1/-1) desklet-rendering/src/CMakeLists.txt (+1/-0) desklet-rendering/src/rendering-desklet-viewport.c (+707/-0) desklet-rendering/src/rendering-desklet-viewport.h (+56/-0) desklet-rendering/src/rendering-init.c (+3/-1) |
To merge this branch: | bzr merge lp:~cairo-dock-team/cairo-dock-plug-ins/desklet-rendering-pan-view |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tofe (community) | Approve | ||
Review via email: mp+30172@code.launchpad.net |
Commit message
Description of the change
Added view "Viewport", which is alike "Slide", but with panning possibilites. Also default view of "Folders" is now "Viewport".
To post a comment you must log in.
Revision history for this message
Tofe (chris-chapuis) : | # |
review:
Approve
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Folders/src/applet-load-icons.c' | |||
2 | --- Folders/src/applet-load-icons.c 2010-07-17 00:33:47 +0000 | |||
3 | +++ Folders/src/applet-load-icons.c 2010-07-17 12:02:42 +0000 | |||
4 | @@ -353,7 +353,7 @@ | |||
5 | 353 | pList = g_list_prepend (pList, pIcon); | 353 | pList = g_list_prepend (pList, pIcon); |
6 | 354 | } | 354 | } |
7 | 355 | pList = g_list_reverse (pList); | 355 | pList = g_list_reverse (pList); |
9 | 356 | CD_APPLET_LOAD_MY_ICONS_LIST (pList, myConfig.cRenderer, "Slide", NULL); | 356 | CD_APPLET_LOAD_MY_ICONS_LIST (pList, myConfig.cRenderer, "Viewport", NULL); |
10 | 357 | myData.iNbIcons = myConfig.iNbIcons; | 357 | myData.iNbIcons = myConfig.iNbIcons; |
11 | 358 | 358 | ||
12 | 359 | //\_______________________ On se place en ecoute. | 359 | //\_______________________ On se place en ecoute. |
13 | 360 | 360 | ||
14 | === modified file 'desklet-rendering/src/CMakeLists.txt' | |||
15 | --- desklet-rendering/src/CMakeLists.txt 2010-07-06 00:03:56 +0000 | |||
16 | +++ desklet-rendering/src/CMakeLists.txt 2010-07-17 12:02:42 +0000 | |||
17 | @@ -9,6 +9,7 @@ | |||
18 | 9 | rendering-desklet-simple.c rendering-desklet-simple.h | 9 | rendering-desklet-simple.c rendering-desklet-simple.h |
19 | 10 | rendering-desklet-decorations.c rendering-desklet-decorations.h | 10 | rendering-desklet-decorations.c rendering-desklet-decorations.h |
20 | 11 | rendering-desklet-slide.c rendering-desklet-slide.h | 11 | rendering-desklet-slide.c rendering-desklet-slide.h |
21 | 12 | rendering-desklet-viewport.c rendering-desklet-viewport.h | ||
22 | 12 | rendering-struct.h | 13 | rendering-struct.h |
23 | 13 | ) | 14 | ) |
24 | 14 | 15 | ||
25 | 15 | 16 | ||
26 | === modified file 'desklet-rendering/src/rendering-desklet-slide.c' (properties changed: +x to -x) | |||
27 | === modified file 'desklet-rendering/src/rendering-desklet-slide.h' (properties changed: +x to -x) | |||
28 | === added file 'desklet-rendering/src/rendering-desklet-viewport.c' | |||
29 | --- desklet-rendering/src/rendering-desklet-viewport.c 1970-01-01 00:00:00 +0000 | |||
30 | +++ desklet-rendering/src/rendering-desklet-viewport.c 2010-07-17 12:02:42 +0000 | |||
31 | @@ -0,0 +1,707 @@ | |||
32 | 1 | /** | ||
33 | 2 | * This file is a part of the Cairo-Dock project | ||
34 | 3 | * | ||
35 | 4 | * Copyright : (C) see the 'copyright' file. | ||
36 | 5 | * E-mail : see the 'copyright' file. | ||
37 | 6 | * | ||
38 | 7 | * This program is free software; you can redistribute it and/or | ||
39 | 8 | * modify it under the terms of the GNU General Public License | ||
40 | 9 | * as published by the Free Software Foundation; either version 3 | ||
41 | 10 | * of the License, or (at your option) any later version. | ||
42 | 11 | * | ||
43 | 12 | * This program is distributed in the hope that it will be useful, | ||
44 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
45 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
46 | 15 | * GNU General Public License for more details. | ||
47 | 16 | * You should have received a copy of the GNU General Public License | ||
48 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
49 | 18 | */ | ||
50 | 19 | |||
51 | 20 | #include <string.h> | ||
52 | 21 | #include <math.h> | ||
53 | 22 | #include <cairo-dock.h> | ||
54 | 23 | |||
55 | 24 | #include "rendering-desklet-viewport.h" | ||
56 | 25 | |||
57 | 26 | #define _cairo_dock_set_path_as_current(...) _cairo_dock_set_vertex_pointer(pVertexTab) | ||
58 | 27 | |||
59 | 28 | |||
60 | 29 | static gboolean on_enter_icon_viewport (gpointer pUserData, Icon *pPointedIcon, CairoContainer *pContainer, gboolean *bStartAnimation) | ||
61 | 30 | { | ||
62 | 31 | gtk_widget_queue_draw (pContainer->pWidget); // et oui, on n'a rien d'autre a faire. | ||
63 | 32 | |||
64 | 33 | return CAIRO_DOCK_LET_PASS_NOTIFICATION; | ||
65 | 34 | } | ||
66 | 35 | |||
67 | 36 | static inline void _viewport_pan_delta(CairoDesklet *pDesklet, double fDeltaX, double fDeltaY) | ||
68 | 37 | { | ||
69 | 38 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
70 | 39 | pViewportConf->fCurrentPanXSpeed = fDeltaX; | ||
71 | 40 | pViewportConf->fCurrentPanYSpeed = fDeltaY; | ||
72 | 41 | pViewportConf->iCurrentOffsetX += fDeltaX; | ||
73 | 42 | pViewportConf->iCurrentOffsetY += fDeltaY; | ||
74 | 43 | if (pViewportConf->iCurrentOffsetX < 0) | ||
75 | 44 | { | ||
76 | 45 | pViewportConf->iCurrentOffsetX = 0; | ||
77 | 46 | pViewportConf->fCurrentPanXSpeed = 0; | ||
78 | 47 | } | ||
79 | 48 | else if( pViewportConf->iCurrentOffsetX > pViewportConf->iMaxOffsetX ) | ||
80 | 49 | { | ||
81 | 50 | pViewportConf->iCurrentOffsetX = pViewportConf->iMaxOffsetX; | ||
82 | 51 | pViewportConf->fCurrentPanXSpeed = 0; | ||
83 | 52 | } | ||
84 | 53 | if (pViewportConf->iCurrentOffsetY < 0) | ||
85 | 54 | { | ||
86 | 55 | pViewportConf->iCurrentOffsetY = 0; | ||
87 | 56 | pViewportConf->fCurrentPanYSpeed = 0; | ||
88 | 57 | } | ||
89 | 58 | else if( pViewportConf->iCurrentOffsetY > pViewportConf->iMaxOffsetY ) | ||
90 | 59 | { | ||
91 | 60 | pViewportConf->iCurrentOffsetY = pViewportConf->iMaxOffsetY; | ||
92 | 61 | pViewportConf->fCurrentPanYSpeed = 0; | ||
93 | 62 | } | ||
94 | 63 | |||
95 | 64 | gtk_widget_queue_draw (pDesklet->container.pWidget); | ||
96 | 65 | } | ||
97 | 66 | |||
98 | 67 | static gboolean on_update_desklet (gpointer pUserData, CairoDesklet *pDesklet, gboolean *bContinueAnimation) | ||
99 | 68 | { | ||
100 | 69 | if (pDesklet->icons != NULL) | ||
101 | 70 | { | ||
102 | 71 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
103 | 72 | if (pViewportConf == NULL) | ||
104 | 73 | return CAIRO_DOCK_LET_PASS_NOTIFICATION; | ||
105 | 74 | |||
106 | 75 | if (! pDesklet->container.bInside) // on est en-dehors du desklet, on ralentit. | ||
107 | 76 | { | ||
108 | 77 | _viewport_pan_delta (pDesklet, pViewportConf->fCurrentPanXSpeed*.85, pViewportConf->fCurrentPanYSpeed*.85); | ||
109 | 78 | if (fabs (pViewportConf->fCurrentPanXSpeed)+fabs (pViewportConf->fCurrentPanYSpeed) < pViewportConf->iIconSize/15) | ||
110 | 79 | // vitesse de translation epsilonesque, on quitte. | ||
111 | 80 | { | ||
112 | 81 | pViewportConf->fCurrentPanXSpeed = 0; | ||
113 | 82 | pViewportConf->fCurrentPanYSpeed = 0; | ||
114 | 83 | return CAIRO_DOCK_LET_PASS_NOTIFICATION; | ||
115 | 84 | } | ||
116 | 85 | *bContinueAnimation = TRUE; | ||
117 | 86 | } | ||
118 | 87 | else | ||
119 | 88 | { | ||
120 | 89 | double fDeltaX = 0; | ||
121 | 90 | double fDeltaY = 0; | ||
122 | 91 | // si on est dans la marge de 20% de la largeur du desklet a gauche, | ||
123 | 92 | // alors on translate a droite | ||
124 | 93 | if (pDesklet->container.iMouseX <= pDesklet->container.iWidth*0.2) | ||
125 | 94 | { | ||
126 | 95 | // La force de translation va de 0 (lorsqu'on est a 20%) jusqu'a | ||
127 | 96 | // pViewportConf->iIconSize / 2. (lorsqu'on est a 0%) | ||
128 | 97 | fDeltaX = (pViewportConf->iIconSize / 10) * | ||
129 | 98 | (pDesklet->container.iWidth*0.2 - pDesklet->container.iMouseX)/(pDesklet->container.iWidth*0.2); | ||
130 | 99 | *bContinueAnimation = TRUE; | ||
131 | 100 | } | ||
132 | 101 | // si on est dans la marge de 20% de la largeur du desklet a droite, | ||
133 | 102 | // alors on translate a gauche (-1) | ||
134 | 103 | else if( pDesklet->container.iMouseX >= pDesklet->container.iWidth*0.8 ) | ||
135 | 104 | { | ||
136 | 105 | // La force de translation va de 0 (lorsqu'on est a 80%) jusqu'a | ||
137 | 106 | // pViewportConf->iIconSize / 2. (lorsqu'on est a 100%) | ||
138 | 107 | fDeltaX = -(pViewportConf->iIconSize / 10) * | ||
139 | 108 | (pDesklet->container.iMouseX - pDesklet->container.iWidth*0.8)/(pDesklet->container.iWidth*0.2); | ||
140 | 109 | *bContinueAnimation = TRUE; | ||
141 | 110 | } | ||
142 | 111 | // si on est dans la marge de 20% de la hauteur du desklet en haut, | ||
143 | 112 | // alors on translate en bas | ||
144 | 113 | if (pDesklet->container.iMouseY <= pDesklet->container.iHeight*0.2) | ||
145 | 114 | { | ||
146 | 115 | // La force de translation va de 0 (lorsqu'on est a 20%) jusqu'a | ||
147 | 116 | // pViewportConf->iIconSize / 2. (lorsqu'on est a 0%) | ||
148 | 117 | fDeltaY = -(pViewportConf->iIconSize / 10) * | ||
149 | 118 | (pDesklet->container.iHeight*0.2 - pDesklet->container.iMouseY)/(pDesklet->container.iHeight*0.2); | ||
150 | 119 | *bContinueAnimation = TRUE; | ||
151 | 120 | } | ||
152 | 121 | // si on est dans la marge de 20% de la hauteur du desklet en bas, | ||
153 | 122 | // alors on translate en haut (-1) | ||
154 | 123 | else if( pDesklet->container.iMouseY >= pDesklet->container.iHeight*0.8 ) | ||
155 | 124 | { | ||
156 | 125 | // La force de translation va de 0 (lorsqu'on est a 80%) jusqu'a | ||
157 | 126 | // pViewportConf->iIconSize / 2. (lorsqu'on est a 100%) | ||
158 | 127 | fDeltaY = (pViewportConf->iIconSize / 10) * | ||
159 | 128 | (pDesklet->container.iMouseY - pDesklet->container.iHeight*0.8)/(pDesklet->container.iHeight*0.2); | ||
160 | 129 | *bContinueAnimation = TRUE; | ||
161 | 130 | } | ||
162 | 131 | if( *bContinueAnimation == TRUE ) | ||
163 | 132 | { | ||
164 | 133 | _viewport_pan_delta( pDesklet, fDeltaX, fDeltaY ); | ||
165 | 134 | } | ||
166 | 135 | else | ||
167 | 136 | { | ||
168 | 137 | pViewportConf->fCurrentPanXSpeed = 0.; | ||
169 | 138 | pViewportConf->fCurrentPanYSpeed = 0.; | ||
170 | 139 | } | ||
171 | 140 | } | ||
172 | 141 | } | ||
173 | 142 | return CAIRO_DOCK_LET_PASS_NOTIFICATION; | ||
174 | 143 | } | ||
175 | 144 | |||
176 | 145 | static gboolean on_mouse_move (gpointer pUserData, CairoDesklet *pDesklet, gboolean *bStartAnimation) | ||
177 | 146 | { | ||
178 | 147 | if (pDesklet->icons != NULL) | ||
179 | 148 | { | ||
180 | 149 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
181 | 150 | if (pViewportConf == NULL) | ||
182 | 151 | return CAIRO_DOCK_LET_PASS_NOTIFICATION; | ||
183 | 152 | if (pViewportConf->bInfiniteWidth && (pDesklet->container.iMouseX <= pDesklet->container.iWidth*0.2 || pDesklet->container.iMouseX >= pDesklet->container.iWidth*0.8)) | ||
184 | 153 | *bStartAnimation = TRUE; | ||
185 | 154 | if (pViewportConf->bInfiniteHeight && (pDesklet->container.iMouseY <= pDesklet->container.iHeight*0.2 || pDesklet->container.iMouseY >= pDesklet->container.iHeight*0.8)) | ||
186 | 155 | *bStartAnimation = TRUE; | ||
187 | 156 | } | ||
188 | 157 | return CAIRO_DOCK_LET_PASS_NOTIFICATION; | ||
189 | 158 | } | ||
190 | 159 | |||
191 | 160 | static CDViewportParameters *configure (CairoDesklet *pDesklet, gpointer *pConfig) // gboolean, int, gdouble[4] | ||
192 | 161 | { | ||
193 | 162 | CDViewportParameters *pViewportConf = g_new0 (CDViewportParameters, 1); | ||
194 | 163 | if (pConfig != NULL) | ||
195 | 164 | { | ||
196 | 165 | pViewportConf->bRoundedRadius = GPOINTER_TO_INT (pConfig[0]); | ||
197 | 166 | pViewportConf->iRadius = GPOINTER_TO_INT (pConfig[1]); | ||
198 | 167 | if (pConfig[2] != NULL) | ||
199 | 168 | memcpy (pViewportConf->fLineColor, pConfig[2], 4 * sizeof (gdouble)); | ||
200 | 169 | } | ||
201 | 170 | |||
202 | 171 | pViewportConf->iLineWidth = 2; | ||
203 | 172 | pViewportConf->iGapBetweenIcons = 10; | ||
204 | 173 | pViewportConf->iMinimumIconSize = 48; | ||
205 | 174 | pViewportConf->iCurrentOffsetX = 0; | ||
206 | 175 | pViewportConf->iCurrentOffsetY = 0; | ||
207 | 176 | pViewportConf->fCurrentPanXSpeed = 0; | ||
208 | 177 | pViewportConf->fCurrentPanYSpeed = 0; | ||
209 | 178 | pViewportConf->iMaxOffsetX = 0; | ||
210 | 179 | pViewportConf->iMaxOffsetY = 0; | ||
211 | 180 | pViewportConf->bInfiniteHeight=TRUE; | ||
212 | 181 | pViewportConf->bInfiniteWidth=FALSE; | ||
213 | 182 | |||
214 | 183 | cairo_dock_register_notification_on_container (CAIRO_CONTAINER (pDesklet), CAIRO_DOCK_ENTER_ICON, (CairoDockNotificationFunc) on_enter_icon_viewport, CAIRO_DOCK_RUN_FIRST, NULL); | ||
215 | 184 | |||
216 | 185 | cairo_dock_register_notification_on_container (CAIRO_CONTAINER (pDesklet), CAIRO_DOCK_UPDATE_DESKLET, (CairoDockNotificationFunc) on_update_desklet, CAIRO_DOCK_RUN_AFTER, NULL); | ||
217 | 186 | cairo_dock_register_notification_on_container (CAIRO_CONTAINER (pDesklet), CAIRO_DOCK_MOUSE_MOVED, (CairoDockNotificationFunc) on_mouse_move, CAIRO_DOCK_RUN_AFTER, NULL); | ||
218 | 187 | |||
219 | 188 | return pViewportConf; | ||
220 | 189 | } | ||
221 | 190 | |||
222 | 191 | |||
223 | 192 | static inline void _compute_icons_grid (CairoDesklet *pDesklet, CDViewportParameters *pViewportConf) | ||
224 | 193 | { | ||
225 | 194 | pViewportConf->fMargin = (pViewportConf->bRoundedRadius ? | ||
226 | 195 | .5 * pViewportConf->iLineWidth + (1. - sqrt (2) / 2) * pViewportConf->iRadius : | ||
227 | 196 | .5 * pViewportConf->iLineWidth + .5 * pViewportConf->iRadius); | ||
228 | 197 | |||
229 | 198 | int iNbIcons = 0; | ||
230 | 199 | Icon *pIcon; | ||
231 | 200 | GList *ic; | ||
232 | 201 | for (ic = pDesklet->icons; ic != NULL; ic = ic->next) | ||
233 | 202 | { | ||
234 | 203 | pIcon = ic->data; | ||
235 | 204 | if (! CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pIcon)) | ||
236 | 205 | iNbIcons ++; | ||
237 | 206 | } | ||
238 | 207 | pViewportConf->iNbIcons = iNbIcons; | ||
239 | 208 | |||
240 | 209 | double w = pDesklet->container.iWidth - 2 * pViewportConf->fMargin; | ||
241 | 210 | double h = pDesklet->container.iHeight - 2 * pViewportConf->fMargin; | ||
242 | 211 | int dh = myLabels.iLabelSize; // taille verticale ajoutee a chaque icone. | ||
243 | 212 | int dw = 2 * dh; // taille horizontale ajoutee a chaque icone. | ||
244 | 213 | int di = pViewportConf->iGapBetweenIcons; // ecart entre 2 lignes/colonnes. | ||
245 | 214 | |||
246 | 215 | int p, q; // nombre de lignes et colonnes. | ||
247 | 216 | int iSize; | ||
248 | 217 | pViewportConf->iIconSize = 0, pViewportConf->iNbLines = 0, pViewportConf->iNbColumns = 0; | ||
249 | 218 | //g_print ("%d icones sur %dx%d (%d)\n", pViewportConf->iNbIcons, (int)w, (int)h, myLabels.iLabelSize); | ||
250 | 219 | for (p = 1; p <= pViewportConf->iNbIcons; p ++) | ||
251 | 220 | { | ||
252 | 221 | q = (int) ceil ((double)pViewportConf->iNbIcons / p); | ||
253 | 222 | iSize = MIN ((h - (p - 1) * di) / p - dh, (w - (q - 1) * di) / q - dw); | ||
254 | 223 | //g_print (" %dx%d -> %d\n", p, q, iSize); | ||
255 | 224 | if (iSize > pViewportConf->iIconSize) | ||
256 | 225 | { | ||
257 | 226 | pViewportConf->iIconSize = iSize; | ||
258 | 227 | pViewportConf->iNbLines = p; | ||
259 | 228 | pViewportConf->iNbColumns = q; | ||
260 | 229 | } | ||
261 | 230 | else if(iSize > 0) // there is only one maximum | ||
262 | 231 | { | ||
263 | 232 | break; | ||
264 | 233 | } | ||
265 | 234 | } | ||
266 | 235 | // si les icones sont trop petites, et qu'on a une largeur et/ou une | ||
267 | 236 | // hauteur infinie(s), essayer d'avoir au moins une taille minimale | ||
268 | 237 | if( pViewportConf->iIconSize < pViewportConf->iMinimumIconSize && | ||
269 | 238 | (pViewportConf->bInfiniteWidth || pViewportConf->bInfiniteHeight) ) | ||
270 | 239 | { | ||
271 | 240 | if( pViewportConf->bInfiniteWidth && pViewportConf->bInfiniteHeight ) | ||
272 | 241 | { | ||
273 | 242 | // surface infinie: on garde le meme nb de colonnes&lignes, | ||
274 | 243 | // mais on met la taille d'icone a iMinimumIconSize | ||
275 | 244 | pViewportConf->iIconSize = pViewportConf->iMinimumIconSize; | ||
276 | 245 | } | ||
277 | 246 | else if( pViewportConf->bInfiniteHeight ) | ||
278 | 247 | { | ||
279 | 248 | // hauteur infinie et largeur fixe: on calcule le nombre de colonnes | ||
280 | 249 | // maxi avec pViewportConf->iIconSize = pViewportConf->iMinimumIconSize | ||
281 | 250 | pViewportConf->iIconSize = pViewportConf->iMinimumIconSize; | ||
282 | 251 | pViewportConf->iNbColumns = (w + di) / ( pViewportConf->iIconSize + dw + di ); | ||
283 | 252 | if( pViewportConf->iNbColumns < 1 ) | ||
284 | 253 | { | ||
285 | 254 | pViewportConf->iNbColumns = 1; | ||
286 | 255 | pViewportConf->iIconSize = w - dw; | ||
287 | 256 | } | ||
288 | 257 | pViewportConf->iNbLines = (int) ceil ((double)pViewportConf->iNbIcons / pViewportConf->iNbColumns); | ||
289 | 258 | } | ||
290 | 259 | else if( pViewportConf->bInfiniteWidth ) | ||
291 | 260 | { | ||
292 | 261 | // largeur infinie et hauteur fixe: on calcule le nombre de lignes | ||
293 | 262 | // maxi avec pViewportConf->iIconSize = pViewportConf->iMinimumIconSize | ||
294 | 263 | pViewportConf->iIconSize = pViewportConf->iMinimumIconSize; | ||
295 | 264 | pViewportConf->iNbLines = (h + di) / ( pViewportConf->iIconSize + dh + di ); | ||
296 | 265 | if( pViewportConf->iNbLines < 1 ) | ||
297 | 266 | { | ||
298 | 267 | pViewportConf->iNbLines = 1; | ||
299 | 268 | pViewportConf->iIconSize = h - dh; | ||
300 | 269 | } | ||
301 | 270 | pViewportConf->iNbColumns = (int) ceil ((double)pViewportConf->iNbIcons / pViewportConf->iNbLines); | ||
302 | 271 | } | ||
303 | 272 | // on calcule l'offset maximal atteignable en X | ||
304 | 273 | pViewportConf->iMaxOffsetX = MAX(( pViewportConf->iIconSize + dw + di )*pViewportConf->iNbColumns - (w + di), 0); | ||
305 | 274 | // on calcule l'offset maximal atteignable en Y | ||
306 | 275 | pViewportConf->iMaxOffsetY = MAX(( pViewportConf->iIconSize + dh + di )*pViewportConf->iNbLines - (h + di), 0); | ||
307 | 276 | } | ||
308 | 277 | } | ||
309 | 278 | |||
310 | 279 | static void load_data (CairoDesklet *pDesklet) | ||
311 | 280 | { | ||
312 | 281 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
313 | 282 | if (pViewportConf == NULL) | ||
314 | 283 | return ; | ||
315 | 284 | |||
316 | 285 | _compute_icons_grid (pDesklet, pViewportConf); | ||
317 | 286 | } | ||
318 | 287 | |||
319 | 288 | |||
320 | 289 | static void free_data (CairoDesklet *pDesklet) | ||
321 | 290 | { | ||
322 | 291 | cairo_dock_remove_notification_func_on_container (CAIRO_CONTAINER (pDesklet), CAIRO_DOCK_ENTER_ICON, (CairoDockNotificationFunc) on_enter_icon_viewport, NULL); | ||
323 | 292 | |||
324 | 293 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
325 | 294 | if (pViewportConf == NULL) | ||
326 | 295 | return ; | ||
327 | 296 | |||
328 | 297 | g_free (pViewportConf); | ||
329 | 298 | pDesklet->pRendererData = NULL; | ||
330 | 299 | } | ||
331 | 300 | |||
332 | 301 | |||
333 | 302 | static void set_icon_size (CairoDesklet *pDesklet, Icon *pIcon) | ||
334 | 303 | { | ||
335 | 304 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
336 | 305 | if (pViewportConf == NULL) | ||
337 | 306 | return ; | ||
338 | 307 | |||
339 | 308 | if (pIcon == pDesklet->pIcon) | ||
340 | 309 | { | ||
341 | 310 | pIcon->fWidth = 0.; | ||
342 | 311 | pIcon->fHeight = 0.; | ||
343 | 312 | } | ||
344 | 313 | else | ||
345 | 314 | { | ||
346 | 315 | pIcon->fWidth = pViewportConf->iIconSize; | ||
347 | 316 | pIcon->fHeight = pViewportConf->iIconSize; | ||
348 | 317 | } | ||
349 | 318 | } | ||
350 | 319 | |||
351 | 320 | static void calculate_icons (CairoDesklet *pDesklet) | ||
352 | 321 | { | ||
353 | 322 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
354 | 323 | if (pViewportConf == NULL) | ||
355 | 324 | return ; | ||
356 | 325 | |||
357 | 326 | _compute_icons_grid (pDesklet, pViewportConf); | ||
358 | 327 | cd_debug ("pViewportConf->iIconSize : %d\n", pViewportConf->iIconSize); | ||
359 | 328 | |||
360 | 329 | Icon *pIcon = pDesklet->pIcon; | ||
361 | 330 | if (pIcon != NULL) // on ne veut pas charger cette icone. | ||
362 | 331 | { | ||
363 | 332 | pIcon->fWidth = -1; | ||
364 | 333 | pIcon->fHeight = -1; | ||
365 | 334 | } | ||
366 | 335 | |||
367 | 336 | GList* ic; | ||
368 | 337 | for (ic = pDesklet->icons; ic != NULL; ic = ic->next) | ||
369 | 338 | { | ||
370 | 339 | pIcon = ic->data; | ||
371 | 340 | if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pIcon)) | ||
372 | 341 | { | ||
373 | 342 | pIcon->fWidth = -1; | ||
374 | 343 | pIcon->fHeight = -1; | ||
375 | 344 | } | ||
376 | 345 | else | ||
377 | 346 | { | ||
378 | 347 | pIcon->fWidth = pViewportConf->iIconSize; | ||
379 | 348 | pIcon->fHeight = pViewportConf->iIconSize; | ||
380 | 349 | |||
381 | 350 | pIcon->fScale = 1.; | ||
382 | 351 | pIcon->fAlpha = 1.; | ||
383 | 352 | pIcon->fWidthFactor = 1.; | ||
384 | 353 | pIcon->fHeightFactor = 1.; | ||
385 | 354 | pIcon->fGlideScale = 1.; | ||
386 | 355 | } | ||
387 | 356 | } | ||
388 | 357 | } | ||
389 | 358 | |||
390 | 359 | |||
391 | 360 | static void render (cairo_t *pCairoContext, CairoDesklet *pDesklet) | ||
392 | 361 | { | ||
393 | 362 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
394 | 363 | //g_print ("%s(%x)\n", __func__, pViewportConf); | ||
395 | 364 | if (pViewportConf == NULL) | ||
396 | 365 | return ; | ||
397 | 366 | |||
398 | 367 | double fRadius = pViewportConf->iRadius; | ||
399 | 368 | double fLineWidth = pViewportConf->iLineWidth; | ||
400 | 369 | // le cadre. | ||
401 | 370 | cairo_set_line_width (pCairoContext, pViewportConf->iLineWidth); | ||
402 | 371 | if (pViewportConf->bRoundedRadius) | ||
403 | 372 | { | ||
404 | 373 | cairo_translate (pCairoContext, 0., .5 * fLineWidth); | ||
405 | 374 | cairo_dock_draw_rounded_rectangle (pCairoContext, | ||
406 | 375 | fRadius, | ||
407 | 376 | fLineWidth, | ||
408 | 377 | pDesklet->container.iWidth - 2 * fRadius - fLineWidth, | ||
409 | 378 | pDesklet->container.iHeight - 2*fLineWidth); | ||
410 | 379 | } | ||
411 | 380 | else | ||
412 | 381 | { | ||
413 | 382 | cairo_move_to (pCairoContext, 0., 0.); | ||
414 | 383 | cairo_rel_line_to (pCairoContext, | ||
415 | 384 | 0., | ||
416 | 385 | pDesklet->container.iHeight - fRadius - fLineWidth); | ||
417 | 386 | cairo_rel_line_to (pCairoContext, | ||
418 | 387 | pViewportConf->iRadius, | ||
419 | 388 | pViewportConf->iRadius); | ||
420 | 389 | cairo_rel_line_to (pCairoContext, | ||
421 | 390 | pDesklet->container.iWidth - fRadius - fLineWidth, | ||
422 | 391 | 0.); | ||
423 | 392 | } | ||
424 | 393 | cairo_set_source_rgba (pCairoContext, pViewportConf->fLineColor[0], pViewportConf->fLineColor[1], pViewportConf->fLineColor[2], pViewportConf->fLineColor[3]); | ||
425 | 394 | cairo_stroke (pCairoContext); | ||
426 | 395 | |||
427 | 396 | // les icones. | ||
428 | 397 | double w = pDesklet->container.iWidth - 2 * pViewportConf->fMargin; | ||
429 | 398 | double h = pDesklet->container.iHeight - 2 * pViewportConf->fMargin; | ||
430 | 399 | int dh = myLabels.iLabelSize; // taille verticale ajoutee a chaque icone. | ||
431 | 400 | int dw = 2 * dh; // taille horizontale ajoutee a chaque icone. | ||
432 | 401 | if( pViewportConf->iMaxOffsetY == 0 ) | ||
433 | 402 | { | ||
434 | 403 | dh = (h - pViewportConf->iNbLines * (pViewportConf->iIconSize + myLabels.iLabelSize)) / pViewportConf->iNbLines; // ecart entre 2 lignes. | ||
435 | 404 | } | ||
436 | 405 | if( pViewportConf->iMaxOffsetX == 0 ) | ||
437 | 406 | { | ||
438 | 407 | dw = (w - pViewportConf->iNbColumns * pViewportConf->iIconSize) / pViewportConf->iNbColumns; // ecart entre 2 colonnes. | ||
439 | 408 | } | ||
440 | 409 | |||
441 | 410 | // on determine la 1ere icone a tracer : l'icone suivant l'icone pointee. | ||
442 | 411 | |||
443 | 412 | double x = pViewportConf->fMargin + dw/2, y = pViewportConf->fMargin + dh/2; | ||
444 | 413 | int q = 0; | ||
445 | 414 | Icon *pIcon; | ||
446 | 415 | GList *ic; | ||
447 | 416 | GList *pVisibleIcons = NULL; | ||
448 | 417 | for (ic = pDesklet->icons; ic != NULL; ic = ic->next) | ||
449 | 418 | { | ||
450 | 419 | pIcon = ic->data; | ||
451 | 420 | if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pIcon)) | ||
452 | 421 | continue; | ||
453 | 422 | |||
454 | 423 | pIcon->fDrawX = x - pViewportConf->iCurrentOffsetX; | ||
455 | 424 | pIcon->fDrawY = y - pViewportConf->iCurrentOffsetY; | ||
456 | 425 | |||
457 | 426 | x += pViewportConf->iIconSize + dw; | ||
458 | 427 | q ++; | ||
459 | 428 | if (q == pViewportConf->iNbColumns) | ||
460 | 429 | { | ||
461 | 430 | q = 0; | ||
462 | 431 | x = pViewportConf->fMargin + dw/2; | ||
463 | 432 | y += pViewportConf->iIconSize + myLabels.iLabelSize + dh; | ||
464 | 433 | } | ||
465 | 434 | // On ne dessine que les icones qui sont visibles | ||
466 | 435 | if( pIcon->fDrawX - pViewportConf->fMargin + dw/2 >= 0 && | ||
467 | 436 | pIcon->fDrawY - pViewportConf->fMargin + myLabels.iLabelSize >= 0 && | ||
468 | 437 | pIcon->fDrawX - pViewportConf->fMargin + dw/2 <= w - (pViewportConf->iIconSize + dw) && | ||
469 | 438 | pIcon->fDrawY - pViewportConf->fMargin + myLabels.iLabelSize <= h - (pViewportConf->iIconSize + myLabels.iLabelSize + dh)) | ||
470 | 439 | { | ||
471 | 440 | pVisibleIcons = g_list_append(pVisibleIcons, pIcon); | ||
472 | 441 | } | ||
473 | 442 | } | ||
474 | 443 | |||
475 | 444 | GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pVisibleIcons); | ||
476 | 445 | if (pFirstDrawnElement == NULL) | ||
477 | 446 | return; | ||
478 | 447 | ic = pFirstDrawnElement; | ||
479 | 448 | do | ||
480 | 449 | { | ||
481 | 450 | pIcon = ic->data; | ||
482 | 451 | if (pIcon->pIconBuffer != NULL && ! CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pIcon)) | ||
483 | 452 | { | ||
484 | 453 | cairo_save (pCairoContext); | ||
485 | 454 | |||
486 | 455 | cairo_dock_render_one_icon_in_desklet (pIcon, pCairoContext, FALSE, FALSE, pDesklet->container.iWidth); | ||
487 | 456 | |||
488 | 457 | cairo_restore (pCairoContext); | ||
489 | 458 | |||
490 | 459 | |||
491 | 460 | if (pIcon->pTextBuffer != NULL) | ||
492 | 461 | { | ||
493 | 462 | cairo_save (pCairoContext); | ||
494 | 463 | cairo_translate (pCairoContext, pIcon->fDrawX, pIcon->fDrawY); | ||
495 | 464 | |||
496 | 465 | double fOffsetX = 0., fAlpha; | ||
497 | 466 | if (pIcon->bPointed) | ||
498 | 467 | { | ||
499 | 468 | fAlpha = 1.; | ||
500 | 469 | if (pIcon->fDrawX + pIcon->fWidth/2 + pIcon->iTextWidth/2 > pDesklet->container.iWidth) | ||
501 | 470 | fOffsetX = pDesklet->container.iWidth - (pIcon->fDrawX + pIcon->fWidth/2 + pIcon->iTextWidth/2); | ||
502 | 471 | if (pIcon->fDrawX + pIcon->fWidth/2 - pIcon->iTextWidth/2 < 0) | ||
503 | 472 | fOffsetX = pIcon->iTextWidth/2 - (pIcon->fDrawX + pIcon->fWidth/2); | ||
504 | 473 | cairo_set_source_surface (pCairoContext, | ||
505 | 474 | pIcon->pTextBuffer, | ||
506 | 475 | fOffsetX + pIcon->fWidth/2 - pIcon->iTextWidth/2, | ||
507 | 476 | -myLabels.iLabelSize); | ||
508 | 477 | cairo_paint_with_alpha (pCairoContext, fAlpha); | ||
509 | 478 | } | ||
510 | 479 | else | ||
511 | 480 | { | ||
512 | 481 | fAlpha = .6; | ||
513 | 482 | if (pIcon->iTextWidth > pIcon->fWidth + 2 * myLabels.iLabelSize) | ||
514 | 483 | { | ||
515 | 484 | fOffsetX = - myLabels.iLabelSize; | ||
516 | 485 | cairo_pattern_t *pGradationPattern = cairo_pattern_create_linear (fOffsetX, | ||
517 | 486 | 0., | ||
518 | 487 | fOffsetX + pIcon->fWidth + 2*myLabels.iLabelSize, | ||
519 | 488 | 0.); | ||
520 | 489 | cairo_pattern_set_extend (pGradationPattern, CAIRO_EXTEND_NONE); | ||
521 | 490 | cairo_pattern_add_color_stop_rgba (pGradationPattern, | ||
522 | 491 | 0., | ||
523 | 492 | 0., | ||
524 | 493 | 0., | ||
525 | 494 | 0., | ||
526 | 495 | fAlpha); | ||
527 | 496 | cairo_pattern_add_color_stop_rgba (pGradationPattern, | ||
528 | 497 | 0.75, | ||
529 | 498 | 0., | ||
530 | 499 | 0., | ||
531 | 500 | 0., | ||
532 | 501 | fAlpha); | ||
533 | 502 | cairo_pattern_add_color_stop_rgba (pGradationPattern, | ||
534 | 503 | 1., | ||
535 | 504 | 0., | ||
536 | 505 | 0., | ||
537 | 506 | 0., | ||
538 | 507 | 0.); | ||
539 | 508 | cairo_set_source_surface (pCairoContext, | ||
540 | 509 | pIcon->pTextBuffer, | ||
541 | 510 | fOffsetX, | ||
542 | 511 | -myLabels.iLabelSize); | ||
543 | 512 | cairo_mask (pCairoContext, pGradationPattern); | ||
544 | 513 | cairo_pattern_destroy (pGradationPattern); | ||
545 | 514 | } | ||
546 | 515 | else | ||
547 | 516 | { | ||
548 | 517 | fOffsetX = pIcon->fWidth/2 - pIcon->iTextWidth/2; | ||
549 | 518 | cairo_set_source_surface (pCairoContext, | ||
550 | 519 | pIcon->pTextBuffer, | ||
551 | 520 | fOffsetX, | ||
552 | 521 | -myLabels.iLabelSize); | ||
553 | 522 | cairo_paint_with_alpha (pCairoContext, fAlpha); | ||
554 | 523 | } | ||
555 | 524 | } | ||
556 | 525 | |||
557 | 526 | cairo_restore (pCairoContext); | ||
558 | 527 | } | ||
559 | 528 | } | ||
560 | 529 | ic = cairo_dock_get_next_element (ic, pVisibleIcons); | ||
561 | 530 | } | ||
562 | 531 | while (ic != pFirstDrawnElement); | ||
563 | 532 | } | ||
564 | 533 | |||
565 | 534 | |||
566 | 535 | static void render_opengl (CairoDesklet *pDesklet) | ||
567 | 536 | { | ||
568 | 537 | CDViewportParameters *pViewportConf = (CDViewportParameters *) pDesklet->pRendererData; | ||
569 | 538 | if (pViewportConf == NULL) | ||
570 | 539 | return ; | ||
571 | 540 | |||
572 | 541 | // le cadre. | ||
573 | 542 | double fRadius = (pViewportConf->bRoundedRadius ? pViewportConf->iRadius : 0.); | ||
574 | 543 | double fLineWidth = pViewportConf->iLineWidth; | ||
575 | 544 | if (fLineWidth != 0 && pViewportConf->fLineColor[3] != 0) | ||
576 | 545 | { | ||
577 | 546 | cairo_dock_draw_rounded_rectangle_opengl (pDesklet->container.iWidth - 2 * fRadius, | ||
578 | 547 | pDesklet->container.iHeight, | ||
579 | 548 | fRadius, | ||
580 | 549 | fLineWidth, | ||
581 | 550 | pViewportConf->fLineColor); | ||
582 | 551 | glTranslatef (-pDesklet->container.iWidth/2, -pDesklet->container.iHeight/2, 0.); | ||
583 | 552 | } | ||
584 | 553 | |||
585 | 554 | glTranslatef (-pDesklet->container.iWidth/2, -pDesklet->container.iHeight/2, 0.); | ||
586 | 555 | |||
587 | 556 | // les icones. | ||
588 | 557 | double w = pDesklet->container.iWidth - 2 * pViewportConf->fMargin; | ||
589 | 558 | double h = pDesklet->container.iHeight - 2 * pViewportConf->fMargin; | ||
590 | 559 | int dh = myLabels.iLabelSize; // taille verticale ajoutee a chaque icone. | ||
591 | 560 | int dw = 2 * dh; // taille horizontale ajoutee a chaque icone. | ||
592 | 561 | if( pViewportConf->iMaxOffsetY == 0 ) | ||
593 | 562 | { | ||
594 | 563 | // ecart entre 2 lignes si il faut repartir vertivalement les icones. | ||
595 | 564 | dh = (h - pViewportConf->iNbLines * (pViewportConf->iIconSize + myLabels.iLabelSize) - 2*pViewportConf->fMargin - myLabels.iLabelSize) / pViewportConf->iNbLines; | ||
596 | 565 | } | ||
597 | 566 | if( pViewportConf->iMaxOffsetX == 0 ) | ||
598 | 567 | { | ||
599 | 568 | // ecart entre 2 colonnes si il faut repartir horizontalement les icones. | ||
600 | 569 | dw = (w - pViewportConf->iNbColumns * pViewportConf->iIconSize - 2*pViewportConf->fMargin) / pViewportConf->iNbColumns; | ||
601 | 570 | } | ||
602 | 571 | |||
603 | 572 | _cairo_dock_enable_texture (); | ||
604 | 573 | _cairo_dock_set_blend_alpha (); | ||
605 | 574 | _cairo_dock_set_alpha (1.); | ||
606 | 575 | |||
607 | 576 | |||
608 | 577 | double x = pViewportConf->fMargin + dw/2, y = pViewportConf->fMargin + myLabels.iLabelSize + dh/2; | ||
609 | 578 | int q = 0; | ||
610 | 579 | Icon *pIcon; | ||
611 | 580 | GList *ic; | ||
612 | 581 | GList *pVisibleIcons = NULL; | ||
613 | 582 | for (ic = pDesklet->icons; ic != NULL; ic = ic->next) | ||
614 | 583 | { | ||
615 | 584 | pIcon = ic->data; | ||
616 | 585 | if (CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pIcon)) | ||
617 | 586 | continue; | ||
618 | 587 | |||
619 | 588 | pIcon->fDrawX = x - pViewportConf->iCurrentOffsetX; | ||
620 | 589 | pIcon->fDrawY = y - pViewportConf->iCurrentOffsetY; | ||
621 | 590 | |||
622 | 591 | x += pViewportConf->iIconSize + dw; | ||
623 | 592 | q ++; | ||
624 | 593 | if (q == pViewportConf->iNbColumns) | ||
625 | 594 | { | ||
626 | 595 | q = 0; | ||
627 | 596 | x = pViewportConf->fMargin + dw/2; | ||
628 | 597 | y += pViewportConf->iIconSize + myLabels.iLabelSize + dh; | ||
629 | 598 | } | ||
630 | 599 | // On ne dessine que les icones qui sont visibles | ||
631 | 600 | if( pIcon->fDrawX - pViewportConf->fMargin - dw/2 >= 0 && | ||
632 | 601 | pIcon->fDrawY - pViewportConf->fMargin - myLabels.iLabelSize - dh/2 >= 0 && | ||
633 | 602 | pIcon->fDrawX - pViewportConf->fMargin - dw/2 <= w - (pViewportConf->iIconSize + dw/2) && | ||
634 | 603 | pIcon->fDrawY - pViewportConf->fMargin - myLabels.iLabelSize - dh/2 <= h - (pViewportConf->iIconSize + myLabels.iLabelSize + dh/2)) | ||
635 | 604 | { | ||
636 | 605 | pVisibleIcons = g_list_append(pVisibleIcons, pIcon); | ||
637 | 606 | } | ||
638 | 607 | } | ||
639 | 608 | |||
640 | 609 | |||
641 | 610 | GList *pFirstDrawnElement = cairo_dock_get_first_drawn_element_linear (pVisibleIcons); | ||
642 | 611 | if (pFirstDrawnElement == NULL) | ||
643 | 612 | return; | ||
644 | 613 | ic = pFirstDrawnElement; | ||
645 | 614 | do | ||
646 | 615 | { | ||
647 | 616 | pIcon = ic->data; | ||
648 | 617 | |||
649 | 618 | if (pIcon->iIconTexture != 0 && ! CAIRO_DOCK_ICON_TYPE_IS_SEPARATOR (pIcon)) | ||
650 | 619 | { | ||
651 | 620 | glPushMatrix (); | ||
652 | 621 | |||
653 | 622 | glTranslatef (pIcon->fDrawX + pIcon->fWidth/2, | ||
654 | 623 | pDesklet->container.iHeight - pIcon->fDrawY - pIcon->fHeight/2, | ||
655 | 624 | 0.); | ||
656 | 625 | //g_print (" %d) %d;%d %dx%d\n", pIcon->iIconTexture, (int)(pIcon->fDrawX + pIcon->fWidth/2), (int)(pDesklet->container.iHeight - pIcon->fDrawY - pIcon->fHeight/2), (int)(pIcon->fWidth/2), (int)(pIcon->fHeight/2)); | ||
657 | 626 | _cairo_dock_apply_texture_at_size (pIcon->iIconTexture, pIcon->fWidth, pIcon->fHeight); | ||
658 | 627 | |||
659 | 628 | /// generer une notification ... | ||
660 | 629 | /*if (pIcon->bHasIndicator && g_pIndicatorBuffer.iTexture != 0) | ||
661 | 630 | { | ||
662 | 631 | glPushMatrix (); | ||
663 | 632 | glTranslatef (0., - pIcon->fHeight/2 + g_pIndicatorBuffer.iHeight/2 * pIcon->fWidth / g_pIndicatorBuffer.iWidth, 0.); | ||
664 | 633 | _cairo_dock_apply_texture_at_size (g_pIndicatorBuffer.iTexture, pIcon->fWidth, g_pIndicatorBuffer.iHeight * pIcon->fWidth / g_pIndicatorBuffer.iWidth); | ||
665 | 634 | glPopMatrix (); | ||
666 | 635 | }*/ | ||
667 | 636 | |||
668 | 637 | if (pIcon->iLabelTexture != 0) | ||
669 | 638 | { | ||
670 | 639 | glPushMatrix (); | ||
671 | 640 | |||
672 | 641 | double dx = .5 * (pIcon->iTextWidth & 1); // on decale la texture pour la coller sur la grille des coordonnees entieres. | ||
673 | 642 | double dy = .5 * (pIcon->iTextHeight & 1); | ||
674 | 643 | double u0 = 0., u1 = 1.; | ||
675 | 644 | double fOffsetX = 0.; | ||
676 | 645 | if (pIcon->bPointed) | ||
677 | 646 | { | ||
678 | 647 | _cairo_dock_set_alpha (1.); | ||
679 | 648 | if (pIcon->fDrawX + pIcon->fWidth/2 + pIcon->iTextWidth/2 > pDesklet->container.iWidth) | ||
680 | 649 | fOffsetX = pDesklet->container.iWidth - (pIcon->fDrawX + pIcon->fWidth/2 + pIcon->iTextWidth/2); | ||
681 | 650 | if (pIcon->fDrawX + pIcon->fWidth/2 - pIcon->iTextWidth/2 < 0) | ||
682 | 651 | fOffsetX = pIcon->iTextWidth/2 - (pIcon->fDrawX + pIcon->fWidth/2); | ||
683 | 652 | } | ||
684 | 653 | else | ||
685 | 654 | { | ||
686 | 655 | _cairo_dock_set_alpha (.6); | ||
687 | 656 | if (pIcon->iTextWidth > pIcon->fWidth + 2 * myLabels.iLabelSize) | ||
688 | 657 | { | ||
689 | 658 | fOffsetX = 0.; | ||
690 | 659 | u1 = (double) (pIcon->fWidth + 2 * myLabels.iLabelSize) / pIcon->iTextWidth; | ||
691 | 660 | } | ||
692 | 661 | } | ||
693 | 662 | |||
694 | 663 | glTranslatef (ceil (fOffsetX) + dx, ceil (pIcon->fHeight/2 + pIcon->iTextHeight / 2) + dy, 0.); | ||
695 | 664 | |||
696 | 665 | glBindTexture (GL_TEXTURE_2D, pIcon->iLabelTexture); | ||
697 | 666 | _cairo_dock_apply_current_texture_portion_at_size_with_offset (u0, 0., | ||
698 | 667 | u1 - u0, 1., | ||
699 | 668 | pIcon->iTextWidth * (u1 - u0), pIcon->iTextHeight, | ||
700 | 669 | 0., 0.); | ||
701 | 670 | _cairo_dock_set_alpha (1.); | ||
702 | 671 | |||
703 | 672 | glPopMatrix (); | ||
704 | 673 | } | ||
705 | 674 | |||
706 | 675 | if (pIcon->iQuickInfoTexture != 0) | ||
707 | 676 | { | ||
708 | 677 | glTranslatef (0., (- pIcon->fHeight + pIcon->iQuickInfoHeight)/2, 0.); | ||
709 | 678 | |||
710 | 679 | _cairo_dock_apply_texture_at_size (pIcon->iQuickInfoTexture, | ||
711 | 680 | pIcon->iQuickInfoWidth, | ||
712 | 681 | pIcon->iQuickInfoHeight); | ||
713 | 682 | } | ||
714 | 683 | |||
715 | 684 | glPopMatrix (); | ||
716 | 685 | } | ||
717 | 686 | |||
718 | 687 | ic = cairo_dock_get_next_element (ic, pVisibleIcons); | ||
719 | 688 | |||
720 | 689 | } while (ic != pFirstDrawnElement); | ||
721 | 690 | |||
722 | 691 | _cairo_dock_disable_texture (); | ||
723 | 692 | } | ||
724 | 693 | |||
725 | 694 | |||
726 | 695 | |||
727 | 696 | void rendering_register_viewport_desklet_renderer (void) | ||
728 | 697 | { | ||
729 | 698 | CairoDeskletRenderer *pRenderer = g_new0 (CairoDeskletRenderer, 1); | ||
730 | 699 | pRenderer->render = (CairoDeskletRenderFunc) render; | ||
731 | 700 | pRenderer->configure = (CairoDeskletConfigureRendererFunc) configure; | ||
732 | 701 | pRenderer->load_data = (CairoDeskletLoadRendererDataFunc) load_data; | ||
733 | 702 | pRenderer->free_data = (CairoDeskletFreeRendererDataFunc) free_data; | ||
734 | 703 | pRenderer->calculate_icons = (CairoDeskletCalculateIconsFunc) calculate_icons; | ||
735 | 704 | pRenderer->render_opengl = (CairoDeskletGLRenderFunc) render_opengl; | ||
736 | 705 | |||
737 | 706 | cairo_dock_register_desklet_renderer ("Viewport", pRenderer); | ||
738 | 707 | } | ||
739 | 0 | 708 | ||
740 | === added file 'desklet-rendering/src/rendering-desklet-viewport.h' | |||
741 | --- desklet-rendering/src/rendering-desklet-viewport.h 1970-01-01 00:00:00 +0000 | |||
742 | +++ desklet-rendering/src/rendering-desklet-viewport.h 2010-07-17 12:02:42 +0000 | |||
743 | @@ -0,0 +1,56 @@ | |||
744 | 1 | /** | ||
745 | 2 | * This file is a part of the Cairo-Dock project | ||
746 | 3 | * | ||
747 | 4 | * Copyright : (C) see the 'copyright' file. | ||
748 | 5 | * E-mail : see the 'copyright' file. | ||
749 | 6 | * | ||
750 | 7 | * This program is free software; you can redistribute it and/or | ||
751 | 8 | * modify it under the terms of the GNU General Public License | ||
752 | 9 | * as published by the Free Software Foundation; either version 3 | ||
753 | 10 | * of the License, or (at your option) any later version. | ||
754 | 11 | * | ||
755 | 12 | * This program is distributed in the hope that it will be useful, | ||
756 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
757 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
758 | 15 | * GNU General Public License for more details. | ||
759 | 16 | * You should have received a copy of the GNU General Public License | ||
760 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
761 | 18 | */ | ||
762 | 19 | |||
763 | 20 | |||
764 | 21 | #ifndef __RENDERING_DESKLET_VIEWPORT__ | ||
765 | 22 | #define __RENDERING_DESKLET_VIEWPORT__ | ||
766 | 23 | |||
767 | 24 | #include "cairo-dock.h" | ||
768 | 25 | |||
769 | 26 | |||
770 | 27 | typedef struct { | ||
771 | 28 | // from config | ||
772 | 29 | gboolean bRoundedRadius; | ||
773 | 30 | gint iRadius; | ||
774 | 31 | gdouble fLineColor[4]; | ||
775 | 32 | gint iLineWidth; | ||
776 | 33 | gint iGapBetweenIcons; | ||
777 | 34 | gint iMinimumIconSize; | ||
778 | 35 | gboolean bInfiniteWidth; | ||
779 | 36 | gboolean bInfiniteHeight; | ||
780 | 37 | // computed data | ||
781 | 38 | gdouble fMargin; | ||
782 | 39 | gint iNbIcons; | ||
783 | 40 | GList* iFirstIconToShow; | ||
784 | 41 | gint iIconSize; | ||
785 | 42 | gint iNbLines, iNbColumns; | ||
786 | 43 | gint iMaxOffsetX; | ||
787 | 44 | gint iMaxOffsetY; | ||
788 | 45 | // current state | ||
789 | 46 | gint iCurrentOffsetX; | ||
790 | 47 | gint iCurrentOffsetY; | ||
791 | 48 | gint fCurrentPanXSpeed; | ||
792 | 49 | gint fCurrentPanYSpeed; | ||
793 | 50 | } CDViewportParameters; | ||
794 | 51 | |||
795 | 52 | |||
796 | 53 | void rendering_register_viewport_desklet_renderer (void); | ||
797 | 54 | |||
798 | 55 | |||
799 | 56 | #endif | ||
800 | 0 | 57 | ||
801 | === modified file 'desklet-rendering/src/rendering-init.c' | |||
802 | --- desklet-rendering/src/rendering-init.c 2010-07-06 00:03:56 +0000 | |||
803 | +++ desklet-rendering/src/rendering-init.c 2010-07-17 12:02:42 +0000 | |||
804 | @@ -26,12 +26,13 @@ | |||
805 | 26 | //#include "rendering-desklet-controler.h" | 26 | //#include "rendering-desklet-controler.h" |
806 | 27 | //#include "rendering-desklet-mediaplayer.h" | 27 | //#include "rendering-desklet-mediaplayer.h" |
807 | 28 | #include "rendering-desklet-slide.h" | 28 | #include "rendering-desklet-slide.h" |
808 | 29 | #include "rendering-desklet-viewport.h" | ||
809 | 29 | #include "rendering-desklet-decorations.h" | 30 | #include "rendering-desklet-decorations.h" |
810 | 30 | #include "rendering-init.h" | 31 | #include "rendering-init.h" |
811 | 31 | 32 | ||
812 | 32 | 33 | ||
813 | 33 | CD_APPLET_DEFINE_BEGIN (N_("desklet rendering"), | 34 | CD_APPLET_DEFINE_BEGIN (N_("desklet rendering"), |
815 | 34 | 2,0,0, | 35 | 2,1,0, |
816 | 35 | CAIRO_DOCK_CATEGORY_THEME, | 36 | CAIRO_DOCK_CATEGORY_THEME, |
817 | 36 | N_("This module provides different views for your desklets."), | 37 | N_("This module provides different views for your desklets."), |
818 | 37 | "Fabounet (Fabrice Rey)") | 38 | "Fabounet (Fabrice Rey)") |
819 | @@ -47,6 +48,7 @@ | |||
820 | 47 | //rendering_register_controler_desklet_renderer (); | 48 | //rendering_register_controler_desklet_renderer (); |
821 | 48 | //rendering_register_mediaplayer_desklet_renderer (); // By ChAnGFu | 49 | //rendering_register_mediaplayer_desklet_renderer (); // By ChAnGFu |
822 | 49 | rendering_register_slide_desklet_renderer (); // By ChAnGFu | 50 | rendering_register_slide_desklet_renderer (); // By ChAnGFu |
823 | 51 | rendering_register_viewport_desklet_renderer (); // By Tofe | ||
824 | 50 | 52 | ||
825 | 51 | //\_______________ On enregistre les decorations. | 53 | //\_______________ On enregistre les decorations. |
826 | 52 | cd_rendering_register_desklet_decorations (); | 54 | cd_rendering_register_desklet_decorations (); |