Merge lp:~docky-core/plank/item-foreground-buffer into lp:plank
- item-foreground-buffer
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Robert Dyer | ||||
Approved revision: | 812 | ||||
Merged at revision: | 816 | ||||
Proposed branch: | lp:~docky-core/plank/item-foreground-buffer | ||||
Merge into: | lp:plank | ||||
Prerequisite: | lp:~docky-core/plank/item-shadows | ||||
Diff against target: |
363 lines (+151/-57) 3 files modified
lib/DockRenderer.vala (+62/-27) lib/Drawing/DockSurface.vala (+16/-0) lib/Items/DockItem.vala (+73/-30) |
||||
To merge this branch: | bzr merge lp:~docky-core/plank/item-foreground-buffer | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Dyer (community) | Approve | ||
Review via email: mp+160124@code.launchpad.net |
Commit message
Description of the change
* Refactor the way item-layers are drawn.
* Draw item-shadows behind the dock-background. (The theme should disable the shadows if TopPadding isn't < 0)
* Puts the badge/progress-bar onto a foreground_surface owned by the dock-item. This avoids the redraw from scratch of the badge/progress-bar on every dock-redraw.
- 805. By Rico Tzschichholz
-
build: Use LT_LIB_M instead of hardcoding -lm
- 806. By Rico Tzschichholz
-
Add theme-configurable icon-shaped shadows
This adds new DockTheme preference "IconShadowSize" to adjust the shadow
with a default of 1.0
Robert Dyer (psybers) wrote : | # |
the blocks 194-200 and 210-217 are the same, arent they? you can refactor this code to eliminate this duplication
Rico Tzschichholz (ricotz) wrote : | # |
> Lines 9-13 - this check shouldnt be here. Always pass in the func and instead
> do this check inside the item itself (let the item decide if it needs to draw
> overlay, based on its own count/progress)
Checking it that early and passing null as func saves a cr.set_
Rico Tzschichholz (ricotz) wrote : | # |
> the blocks 194-200 and 210-217 are the same, arent they? you can refactor this
> code to eliminate this duplication
It is nearly identical except for their sizes which depend on the func==null condition, an alternative might be to put it in an extra inline function.
Suggest a diff then.
- 807. By Rico Tzschichholz
-
positionmanager: Refactor get_background_
position to get_background_ region This makes its usage in DockRenderer easier.
- 808. By Rico Tzschichholz
-
Use compact way to initialize structs
Note that all fields need be qualified in their defined order.
- 809. By Rico Tzschichholz
-
titledseparator
menuitem: Don't use deprecated gtk+ api It didn't work before and doesnt completely now either.
- 811. By Rico Tzschichholz
-
Draw item-shadows separately behind the dock background
- 812. By Rico Tzschichholz
-
Refactor the item drawing
Robert Dyer (psybers) : | # |
Preview Diff
1 | === modified file 'lib/DockRenderer.vala' | |||
2 | --- lib/DockRenderer.vala 2013-04-24 07:55:37 +0000 | |||
3 | +++ lib/DockRenderer.vala 2013-04-25 12:50:31 +0000 | |||
4 | @@ -40,6 +40,7 @@ | |||
5 | 40 | Gdk.Rectangle background_rect; | 40 | Gdk.Rectangle background_rect; |
6 | 41 | DockSurface? main_buffer; | 41 | DockSurface? main_buffer; |
7 | 42 | DockSurface? indicator_buffer; | 42 | DockSurface? indicator_buffer; |
8 | 43 | DockSurface? shadow_buffer; | ||
9 | 43 | DockSurface? urgent_indicator_buffer; | 44 | DockSurface? urgent_indicator_buffer; |
10 | 44 | DockSurface? urgent_glow_buffer; | 45 | DockSurface? urgent_glow_buffer; |
11 | 45 | 46 | ||
12 | @@ -236,6 +237,7 @@ | |||
13 | 236 | main_buffer = null; | 237 | main_buffer = null; |
14 | 237 | background_buffer = null; | 238 | background_buffer = null; |
15 | 238 | indicator_buffer = null; | 239 | indicator_buffer = null; |
16 | 240 | shadow_buffer = null; | ||
17 | 239 | urgent_indicator_buffer = null; | 241 | urgent_indicator_buffer = null; |
18 | 240 | urgent_glow_buffer = null; | 242 | urgent_glow_buffer = null; |
19 | 241 | 243 | ||
20 | @@ -276,13 +278,19 @@ | |||
21 | 276 | var start = new DateTime.now_local (); | 278 | var start = new DateTime.now_local (); |
22 | 277 | #endif | 279 | #endif |
23 | 278 | 280 | ||
24 | 281 | var width = position_manager.DockWidth; | ||
25 | 282 | var height = position_manager.DockHeight; | ||
26 | 283 | |||
27 | 279 | if (main_buffer == null) { | 284 | if (main_buffer == null) { |
28 | 280 | var width = position_manager.DockWidth; | ||
29 | 281 | var height = position_manager.DockHeight; | ||
30 | 282 | main_buffer = new DockSurface.with_surface (width, height, cr.get_target ()); | 285 | main_buffer = new DockSurface.with_surface (width, height, cr.get_target ()); |
31 | 283 | } | 286 | } |
32 | 284 | 287 | ||
33 | 288 | if (shadow_buffer == null) { | ||
34 | 289 | shadow_buffer = new DockSurface.with_surface (width, height, cr.get_target ()); | ||
35 | 290 | } | ||
36 | 291 | |||
37 | 285 | main_buffer.clear (); | 292 | main_buffer.clear (); |
38 | 293 | shadow_buffer.clear (); | ||
39 | 286 | 294 | ||
40 | 287 | #if BENCHMARK | 295 | #if BENCHMARK |
41 | 288 | var start2 = new DateTime.now_local (); | 296 | var start2 = new DateTime.now_local (); |
42 | @@ -316,6 +324,9 @@ | |||
43 | 316 | 324 | ||
44 | 317 | // draw the dock on the window | 325 | // draw the dock on the window |
45 | 318 | cr.set_operator (Operator.SOURCE); | 326 | cr.set_operator (Operator.SOURCE); |
46 | 327 | cr.set_source_surface (shadow_buffer.Internal, x_offset, y_offset); | ||
47 | 328 | cr.paint (); | ||
48 | 329 | cr.set_operator (Operator.OVER); | ||
49 | 319 | cr.set_source_surface (main_buffer.Internal, x_offset, y_offset); | 330 | cr.set_source_surface (main_buffer.Internal, x_offset, y_offset); |
50 | 320 | cr.paint (); | 331 | cr.paint (); |
51 | 321 | 332 | ||
52 | @@ -363,6 +374,7 @@ | |||
53 | 363 | unowned DragManager drag_manager = controller.drag_manager; | 374 | unowned DragManager drag_manager = controller.drag_manager; |
54 | 364 | 375 | ||
55 | 365 | unowned Context main_cr = main_buffer.Context; | 376 | unowned Context main_cr = main_buffer.Context; |
56 | 377 | unowned Context shadow_cr = shadow_buffer.Context; | ||
57 | 366 | var icon_size = position_manager.IconSize; | 378 | var icon_size = position_manager.IconSize; |
58 | 367 | var shadow_size = controller.position_manager.IconShadowSize; | 379 | var shadow_size = controller.position_manager.IconShadowSize; |
59 | 368 | 380 | ||
60 | @@ -370,12 +382,20 @@ | |||
61 | 370 | #if BENCHMARK | 382 | #if BENCHMARK |
62 | 371 | var start = new DateTime.now_local (); | 383 | var start = new DateTime.now_local (); |
63 | 372 | #endif | 384 | #endif |
65 | 373 | unowned DrawItemFunc? shadow_func = null; | 385 | var icon_surface = item.get_surface_copy (icon_size, icon_size, main_buffer); |
66 | 386 | unowned Context icon_cr = icon_surface.Context; | ||
67 | 387 | |||
68 | 388 | DockSurface? icon_shadow_surface = null; | ||
69 | 374 | if (shadow_size > 0) | 389 | if (shadow_size > 0) |
74 | 375 | shadow_func = draw_item_shadow; | 390 | icon_shadow_surface = item.get_background_surface (draw_item_shadow); |
75 | 376 | 391 | ||
76 | 377 | var icon_surface = item.get_surface_copy (icon_size, icon_size, main_buffer, shadow_func); | 392 | DockSurface? icon_overlay_surface = null; |
77 | 378 | unowned Context icon_cr = icon_surface.Context; | 393 | if (item.CountVisible || item.ProgressVisible) |
78 | 394 | icon_overlay_surface = item.get_foreground_surface (draw_item_overlay); | ||
79 | 395 | |||
80 | 396 | if (icon_overlay_surface != null) | ||
81 | 397 | icon_cr.set_source_surface (icon_overlay_surface.Internal, 0, 0); | ||
82 | 398 | |||
83 | 379 | #if BENCHMARK | 399 | #if BENCHMARK |
84 | 380 | var end = new DateTime.now_local (); | 400 | var end = new DateTime.now_local (); |
85 | 381 | benchmark.add (" item.get_surface time - %f ms".printf (end.difference (start) / 1000.0)); | 401 | benchmark.add (" item.get_surface time - %f ms".printf (end.difference (start) / 1000.0)); |
86 | @@ -444,22 +464,6 @@ | |||
87 | 444 | icon_cr.set_operator (Cairo.Operator.OVER); | 464 | icon_cr.set_operator (Cairo.Operator.OVER); |
88 | 445 | } | 465 | } |
89 | 446 | 466 | ||
90 | 447 | |||
91 | 448 | // TODO put them onto a cached icon_overlay_surface for performance reasons? | ||
92 | 449 | // maybe even draw outside of the item-draw-area (considering the hover-area) | ||
93 | 450 | |||
94 | 451 | var urgent_color = get_styled_color (); | ||
95 | 452 | urgent_color.add_hue (theme.UrgentHueShift); | ||
96 | 453 | |||
97 | 454 | // draw item's count | ||
98 | 455 | if (item.CountVisible) | ||
99 | 456 | theme.draw_item_count (icon_surface, icon_size, urgent_color, item.Count); | ||
100 | 457 | |||
101 | 458 | // draw item's progress | ||
102 | 459 | if (item.ProgressVisible) | ||
103 | 460 | theme.draw_item_progress (icon_surface, icon_size, urgent_color, item.Progress); | ||
104 | 461 | |||
105 | 462 | |||
106 | 463 | // darken the icon | 467 | // darken the icon |
107 | 464 | if (darken > 0) { | 468 | if (darken > 0) { |
108 | 465 | icon_cr.rectangle (0, 0, icon_surface.Width, icon_surface.Height); | 469 | icon_cr.rectangle (0, 0, icon_surface.Width, icon_surface.Height); |
109 | @@ -501,8 +505,14 @@ | |||
110 | 501 | theme.draw_active_glow (main_buffer, background_rect, glow_rect, item.AverageIconColor, opacity, controller.prefs.Position); | 505 | theme.draw_active_glow (main_buffer, background_rect, glow_rect, item.AverageIconColor, opacity, controller.prefs.Position); |
111 | 502 | } | 506 | } |
112 | 503 | 507 | ||
113 | 508 | // draw the icon shadow | ||
114 | 509 | if (icon_shadow_surface != null) { | ||
115 | 510 | shadow_cr.set_source_surface (icon_shadow_surface.Internal, draw_rect.x - shadow_size, draw_rect.y - shadow_size); | ||
116 | 511 | shadow_cr.paint (); | ||
117 | 512 | } | ||
118 | 513 | |||
119 | 504 | // draw the icon | 514 | // draw the icon |
121 | 505 | main_cr.set_source_surface (icon_surface.Internal, draw_rect.x - shadow_size, draw_rect.y - shadow_size); | 515 | main_cr.set_source_surface (icon_surface.Internal, draw_rect.x, draw_rect.y); |
122 | 506 | main_cr.paint (); | 516 | main_cr.paint (); |
123 | 507 | 517 | ||
124 | 508 | // draw indicators | 518 | // draw indicators |
125 | @@ -510,6 +520,34 @@ | |||
126 | 510 | draw_indicator_state (hover_rect, item.Indicator, item.State); | 520 | draw_indicator_state (hover_rect, item.Indicator, item.State); |
127 | 511 | } | 521 | } |
128 | 512 | 522 | ||
129 | 523 | DockSurface draw_item_overlay (DockItem item, DockSurface icon_surface, DockSurface? current_surface) | ||
130 | 524 | { | ||
131 | 525 | unowned PositionManager position_manager = controller.position_manager; | ||
132 | 526 | var width = icon_surface.Width; | ||
133 | 527 | var height = icon_surface.Height; | ||
134 | 528 | |||
135 | 529 | if (current_surface != null | ||
136 | 530 | && width == current_surface.Width && height == current_surface.Height) | ||
137 | 531 | return current_surface; | ||
138 | 532 | |||
139 | 533 | Logger.verbose ("DockItem.draw_item_overlay (width = %i, height = %i)", width, height); | ||
140 | 534 | var surface = new DockSurface.with_dock_surface (width, height, icon_surface); | ||
141 | 535 | |||
142 | 536 | var icon_size = position_manager.IconSize; | ||
143 | 537 | var urgent_color = get_styled_color (); | ||
144 | 538 | urgent_color.add_hue (theme.UrgentHueShift); | ||
145 | 539 | |||
146 | 540 | // draw item's count | ||
147 | 541 | if (item.CountVisible) | ||
148 | 542 | theme.draw_item_count (surface, icon_size, urgent_color, item.Count); | ||
149 | 543 | |||
150 | 544 | // draw item's progress | ||
151 | 545 | if (item.ProgressVisible) | ||
152 | 546 | theme.draw_item_progress (surface, icon_size, urgent_color, item.Progress); | ||
153 | 547 | |||
154 | 548 | return surface; | ||
155 | 549 | } | ||
156 | 550 | |||
157 | 513 | DockSurface draw_item_shadow (DockItem item, DockSurface icon_surface, DockSurface? current_surface) | 551 | DockSurface draw_item_shadow (DockItem item, DockSurface icon_surface, DockSurface? current_surface) |
158 | 514 | { | 552 | { |
159 | 515 | var shadow_size = controller.position_manager.IconShadowSize; | 553 | var shadow_size = controller.position_manager.IconShadowSize; |
160 | @@ -548,9 +586,6 @@ | |||
161 | 548 | cr.paint_with_alpha (0.44); | 586 | cr.paint_with_alpha (0.44); |
162 | 549 | surface.gaussian_blur (shadow_size); | 587 | surface.gaussian_blur (shadow_size); |
163 | 550 | 588 | ||
164 | 551 | cr.set_source_surface (icon_surface.Internal, shadow_size, shadow_size); | ||
165 | 552 | cr.paint (); | ||
166 | 553 | |||
167 | 554 | return surface; | 589 | return surface; |
168 | 555 | } | 590 | } |
169 | 556 | 591 | ||
170 | 557 | 592 | ||
171 | === modified file 'lib/Drawing/DockSurface.vala' | |||
172 | --- lib/Drawing/DockSurface.vala 2013-04-19 12:37:27 +0000 | |||
173 | +++ lib/Drawing/DockSurface.vala 2013-04-25 12:50:31 +0000 | |||
174 | @@ -111,6 +111,22 @@ | |||
175 | 111 | } | 111 | } |
176 | 112 | 112 | ||
177 | 113 | /** | 113 | /** |
178 | 114 | * Create a copy of the surface | ||
179 | 115 | * | ||
180 | 116 | * @return copy of this surface | ||
181 | 117 | */ | ||
182 | 118 | public DockSurface copy () | ||
183 | 119 | { | ||
184 | 120 | var copy = new DockSurface.with_dock_surface (Width, Height, this); | ||
185 | 121 | unowned Cairo.Context cr = copy.Context; | ||
186 | 122 | |||
187 | 123 | cr.set_source_surface (Internal, 0, 0); | ||
188 | 124 | cr.paint (); | ||
189 | 125 | |||
190 | 126 | return copy; | ||
191 | 127 | } | ||
192 | 128 | |||
193 | 129 | /** | ||
194 | 114 | * Saves the current dock surface to a {@link Gdk.Pixbuf}. | 130 | * Saves the current dock surface to a {@link Gdk.Pixbuf}. |
195 | 115 | * | 131 | * |
196 | 116 | * @return the {@link Gdk.Pixbuf} | 132 | * @return the {@link Gdk.Pixbuf} |
197 | 117 | 133 | ||
198 | === modified file 'lib/Items/DockItem.vala' | |||
199 | --- lib/Items/DockItem.vala 2013-04-22 13:19:32 +0000 | |||
200 | +++ lib/Items/DockItem.vala 2013-04-25 12:50:31 +0000 | |||
201 | @@ -29,7 +29,7 @@ | |||
202 | 29 | * Draws a modified surface onto another newly created or given surface | 29 | * Draws a modified surface onto another newly created or given surface |
203 | 30 | * | 30 | * |
204 | 31 | * @param item the dock-item | 31 | * @param item the dock-item |
206 | 32 | * @param source original surface | 32 | * @param source original surface which may not be changed |
207 | 33 | * @param target the previously modified surface | 33 | * @param target the previously modified surface |
208 | 34 | * @return the modified surface or passed through target | 34 | * @return the modified surface or passed through target |
209 | 35 | */ | 35 | */ |
210 | @@ -289,6 +289,7 @@ | |||
211 | 289 | 289 | ||
212 | 290 | DockSurface? surface = null; | 290 | DockSurface? surface = null; |
213 | 291 | DockSurface? background_surface = null; | 291 | DockSurface? background_surface = null; |
214 | 292 | DockSurface? foreground_surface = null; | ||
215 | 292 | 293 | ||
216 | 293 | /** | 294 | /** |
217 | 294 | * Creates a new dock item. | 295 | * Creates a new dock item. |
218 | @@ -304,6 +305,11 @@ | |||
219 | 304 | Gtk.IconTheme.get_default ().changed.connect (icon_theme_changed); | 305 | Gtk.IconTheme.get_default ().changed.connect (icon_theme_changed); |
220 | 305 | notify["Icon"].connect (reset_icon_buffer); | 306 | notify["Icon"].connect (reset_icon_buffer); |
221 | 306 | notify["ForcePixbuf"].connect (reset_icon_buffer); | 307 | notify["ForcePixbuf"].connect (reset_icon_buffer); |
222 | 308 | |||
223 | 309 | notify["Count"].connect (reset_foreground_buffer); | ||
224 | 310 | notify["CountVisible"].connect (reset_foreground_buffer); | ||
225 | 311 | notify["Progress"].connect (reset_foreground_buffer); | ||
226 | 312 | notify["ProgressVisible"].connect (reset_foreground_buffer); | ||
227 | 307 | } | 313 | } |
228 | 308 | 314 | ||
229 | 309 | ~DockItem () | 315 | ~DockItem () |
230 | @@ -312,6 +318,11 @@ | |||
231 | 312 | Gtk.IconTheme.get_default ().changed.disconnect (icon_theme_changed); | 318 | Gtk.IconTheme.get_default ().changed.disconnect (icon_theme_changed); |
232 | 313 | notify["Icon"].disconnect (reset_icon_buffer); | 319 | notify["Icon"].disconnect (reset_icon_buffer); |
233 | 314 | notify["ForcePixbuf"].disconnect (reset_icon_buffer); | 320 | notify["ForcePixbuf"].disconnect (reset_icon_buffer); |
234 | 321 | |||
235 | 322 | notify["Count"].disconnect (reset_foreground_buffer); | ||
236 | 323 | notify["CountVisible"].disconnect (reset_foreground_buffer); | ||
237 | 324 | notify["Progress"].disconnect (reset_foreground_buffer); | ||
238 | 325 | notify["ProgressVisible"].disconnect (reset_foreground_buffer); | ||
239 | 315 | } | 326 | } |
240 | 316 | 327 | ||
241 | 317 | /** | 328 | /** |
242 | @@ -337,6 +348,7 @@ | |||
243 | 337 | { | 348 | { |
244 | 338 | surface = null; | 349 | surface = null; |
245 | 339 | background_surface = null; | 350 | background_surface = null; |
246 | 351 | foreground_surface = null; | ||
247 | 340 | 352 | ||
248 | 341 | needs_redraw (); | 353 | needs_redraw (); |
249 | 342 | } | 354 | } |
250 | @@ -347,6 +359,12 @@ | |||
251 | 347 | public void reset_buffers () | 359 | public void reset_buffers () |
252 | 348 | { | 360 | { |
253 | 349 | background_surface = null; | 361 | background_surface = null; |
254 | 362 | foreground_surface = null; | ||
255 | 363 | } | ||
256 | 364 | |||
257 | 365 | void reset_foreground_buffer () | ||
258 | 366 | { | ||
259 | 367 | foreground_surface = null; | ||
260 | 350 | } | 368 | } |
261 | 351 | 369 | ||
262 | 352 | void icon_theme_changed () | 370 | void icon_theme_changed () |
263 | @@ -359,7 +377,7 @@ | |||
264 | 359 | }); | 377 | }); |
265 | 360 | } | 378 | } |
266 | 361 | 379 | ||
268 | 362 | DockSurface get_surface (int width, int height, DockSurface model) | 380 | unowned DockSurface get_surface (int width, int height, DockSurface model) |
269 | 363 | { | 381 | { |
270 | 364 | if (surface == null || width != surface.Width || height != surface.Height) { | 382 | if (surface == null || width != surface.Width || height != surface.Height) { |
271 | 365 | surface = new DockSurface.with_dock_surface (width, height, model); | 383 | surface = new DockSurface.with_dock_surface (width, height, model); |
272 | @@ -374,38 +392,63 @@ | |||
273 | 374 | } | 392 | } |
274 | 375 | 393 | ||
275 | 376 | /** | 394 | /** |
281 | 377 | * Returns a copy of the dock surface for this item and triggers an | 395 | * Returns the background surface for this item. |
282 | 378 | * internal redraw if the requested size isn't matching the cache. | 396 | * |
283 | 379 | * | 397 | * The draw_func may pass through the given previously computed surface |
284 | 380 | * @param width width of the requested surface | 398 | * or change it as needed. This surface will be buffered internally. |
285 | 381 | * @param height height of the requested surface | 399 | * |
286 | 400 | * Passing null as draw_func will destroy the internal background buffer. | ||
287 | 401 | * | ||
288 | 402 | * @param draw_func function which creates/changes the background surface | ||
289 | 403 | * @return the background surface of this item which may not be changed | ||
290 | 404 | */ | ||
291 | 405 | public unowned DockSurface? get_background_surface (DrawItemFunc? draw_func = null) | ||
292 | 406 | requires (surface != null) | ||
293 | 407 | { | ||
294 | 408 | if (draw_func != null) | ||
295 | 409 | background_surface = draw_func (this, surface, background_surface); | ||
296 | 410 | else | ||
297 | 411 | background_surface = null; | ||
298 | 412 | |||
299 | 413 | return background_surface; | ||
300 | 414 | } | ||
301 | 415 | |||
302 | 416 | /** | ||
303 | 417 | * Returns the foreground surface for this item. | ||
304 | 418 | * | ||
305 | 419 | * The draw_func may pass through the given previously computed surface | ||
306 | 420 | * or change it as needed. This surface will be buffered internally. | ||
307 | 421 | * | ||
308 | 422 | * Passing null as draw_func will destroy the internal foreground buffer. | ||
309 | 423 | * | ||
310 | 424 | * @param draw_func function which creates/changes the foreground surface | ||
311 | 425 | * @return the background surface of this item which may not be changed | ||
312 | 426 | */ | ||
313 | 427 | public unowned DockSurface? get_foreground_surface (DrawItemFunc? draw_func = null) | ||
314 | 428 | requires (surface != null) | ||
315 | 429 | { | ||
316 | 430 | if (draw_func != null) | ||
317 | 431 | foreground_surface = draw_func (this, surface, foreground_surface); | ||
318 | 432 | else | ||
319 | 433 | foreground_surface = null; | ||
320 | 434 | |||
321 | 435 | return foreground_surface; | ||
322 | 436 | } | ||
323 | 437 | |||
324 | 438 | /** | ||
325 | 439 | * Returns a copy of the dock surface for this item. | ||
326 | 440 | * | ||
327 | 441 | * It will trigger an internal redraw if the requested size | ||
328 | 442 | * isn't matching the cache. | ||
329 | 443 | * | ||
330 | 444 | * @param width width of the icon surface | ||
331 | 445 | * @param height height of the icon surface | ||
332 | 382 | * @param model existing surface to use as basis of new surface | 446 | * @param model existing surface to use as basis of new surface |
333 | 383 | * @param draw_func function which manipulates the resulting surface | ||
334 | 384 | * @return the copied dock surface for this item | 447 | * @return the copied dock surface for this item |
335 | 385 | */ | 448 | */ |
337 | 386 | public DockSurface get_surface_copy (int width, int height, DockSurface model, DrawItemFunc? draw_func = null) | 449 | public DockSurface get_surface_copy (int width, int height, DockSurface model) |
338 | 387 | { | 450 | { |
360 | 388 | var icon_surface = get_surface (width, height, model); | 451 | return get_surface (width, height, model).copy (); |
340 | 389 | |||
341 | 390 | if (draw_func == null) { | ||
342 | 391 | var surface_copy = new DockSurface.with_dock_surface (width, height, model); | ||
343 | 392 | unowned Cairo.Context cr = surface_copy.Context; | ||
344 | 393 | |||
345 | 394 | cr.set_source_surface (icon_surface.Internal, 0, 0); | ||
346 | 395 | cr.paint (); | ||
347 | 396 | |||
348 | 397 | return surface_copy; | ||
349 | 398 | } | ||
350 | 399 | |||
351 | 400 | background_surface = draw_func (this, icon_surface, background_surface); | ||
352 | 401 | |||
353 | 402 | var surface_copy = new DockSurface.with_dock_surface (background_surface.Width, background_surface.Height, model); | ||
354 | 403 | unowned Cairo.Context cr = surface_copy.Context; | ||
355 | 404 | |||
356 | 405 | cr.set_source_surface (background_surface.Internal, 0, 0); | ||
357 | 406 | cr.paint (); | ||
358 | 407 | |||
359 | 408 | return surface_copy; | ||
361 | 409 | } | 452 | } |
362 | 410 | 453 | ||
363 | 411 | /** | 454 | /** |
Lines 9-13 - this check shouldnt be here. Always pass in the func and instead do this check inside the item itself (let the item decide if it needs to draw overlay, based on its own count/progress)