Merge lp:~ricotz/docky/pangolayout into lp:docky
- pangolayout
- Merge into trunk
Proposed by
Rico Tzschichholz
Status: | Needs review |
---|---|
Proposed branch: | lp:~ricotz/docky/pangolayout |
Merge into: | lp:docky |
Diff against target: |
1371 lines (+566/-558) 9 files modified
Docky.Items/Docky.Items/AbstractDockItem.cs (+93/-91) Docky.Items/Docky.Items/IconEmblem.cs (+1/-0) Docky/Docky/Interface/DockWindow.cs (+29/-26) Docky/Docky/Menus/MenuItemWidget.cs (+45/-45) Docky/Docky/Menus/SeparatorWidget.cs (+31/-21) StandardPlugins/Clock/src/CalendarPainter.cs (+100/-98) StandardPlugins/Clock/src/ClockDockItem.cs (+119/-123) StandardPlugins/Weather/src/WeatherDocklet.cs (+33/-29) StandardPlugins/Weather/src/WeatherPainter.cs (+115/-125) |
To merge this branch: | bzr merge lp:~ricotz/docky/pangolayout |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Dyer (community) | Needs Fixing | ||
Review via email: mp+37947@code.launchpad.net |
Commit message
Description of the change
Use static Pango.Layouts to hopefully reduce memory leaks and get some more performance.
To post a comment you must log in.
lp:~ricotz/docky/pangolayout
updated
- 1654. By Rico Tzschichholz
-
fix leaking FontDescriptions
Revision history for this message
Robert Dyer (psybers) wrote : | # |
In ADI, you can lift the FontDescription stuff for hover_layout
review:
Needs Fixing
Revision history for this message
Robert Dyer (psybers) wrote : | # |
Same thing in DockWindow
review:
Needs Fixing
Revision history for this message
Robert Dyer (psybers) wrote : | # |
You need to override Dispose *everywhere* and properly dispose the layouts and font descriptions, since they are now global in the class!
review:
Needs Fixing
lp:~ricotz/docky/pangolayout
updated
- 1655. By Rico Tzschichholz
-
merge trunk 1736
- 1656. By Rico Tzschichholz
-
fix build
- 1657. By Rico Tzschichholz
-
remove Width settings
- 1658. By Rico Tzschichholz
-
and more layout-stuff moved
- 1659. By Rico Tzschichholz
-
reset Width
- 1660. By Rico Tzschichholz
-
still one more
- 1661. By Rico Tzschichholz
-
merge trunk 1745
- 1662. By Rico Tzschichholz
-
fix leak
Unmerged revisions
- 1662. By Rico Tzschichholz
-
fix leak
- 1661. By Rico Tzschichholz
-
merge trunk 1745
- 1660. By Rico Tzschichholz
-
still one more
- 1659. By Rico Tzschichholz
-
reset Width
- 1658. By Rico Tzschichholz
-
and more layout-stuff moved
- 1657. By Rico Tzschichholz
-
remove Width settings
- 1656. By Rico Tzschichholz
-
fix build
- 1655. By Rico Tzschichholz
-
merge trunk 1736
- 1654. By Rico Tzschichholz
-
fix leaking FontDescriptions
- 1653. By Rico Tzschichholz
-
Use static Pango.Layouts instead of creating new one everytime
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'Docky.Items/Docky.Items/AbstractDockItem.cs' |
2 | --- Docky.Items/Docky.Items/AbstractDockItem.cs 2010-12-28 16:43:48 +0000 |
3 | +++ Docky.Items/Docky.Items/AbstractDockItem.cs 2011-01-03 11:34:09 +0000 |
4 | @@ -44,6 +44,35 @@ |
5 | |
6 | public abstract class AbstractDockItem : IDisposable |
7 | { |
8 | + const int HoverTextFontSize = 11; |
9 | + |
10 | + static Pango.Layout badge_layout; |
11 | + static Pango.Layout hover_layout; |
12 | + static Pango.Layout message_layout; |
13 | + |
14 | + static AbstractDockItem () |
15 | + { |
16 | + Gtk.Style style = new Gtk.Style (); |
17 | + |
18 | + badge_layout = DockServices.Drawing.ThemedPangoLayout (); |
19 | + badge_layout.Ellipsize = Pango.EllipsizeMode.None; |
20 | + badge_layout.FontDescription = style.FontDescription; |
21 | + badge_layout.FontDescription.Weight = Pango.Weight.Bold; |
22 | + |
23 | + hover_layout = DockServices.Drawing.ThemedPangoLayout (); |
24 | + hover_layout.Ellipsize = Pango.EllipsizeMode.End; |
25 | + hover_layout.FontDescription = style.FontDescription; |
26 | + hover_layout.FontDescription.Weight = Pango.Weight.Bold; |
27 | + hover_layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (HoverTextFontSize); |
28 | + |
29 | + message_layout = DockServices.Drawing.ThemedPangoLayout (); |
30 | + message_layout.Ellipsize = Pango.EllipsizeMode.None; |
31 | + message_layout.FontDescription = style.FontDescription; |
32 | + message_layout.FontDescription.Weight = Pango.Weight.Normal; |
33 | + |
34 | + style.Dispose (); |
35 | + } |
36 | + |
37 | string hover_text, remote_text; |
38 | string badge_text, remote_badge_text; |
39 | bool[] redraw; |
40 | @@ -696,29 +725,20 @@ |
41 | } |
42 | } |
43 | |
44 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) |
45 | - { |
46 | - layout.Width = Pango.Units.FromPixels (surface.Width - iconSize - 8); |
47 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
48 | - layout.FontDescription = new Gtk.Style ().FontDescription; |
49 | - layout.FontDescription.Weight = Pango.Weight.Normal; |
50 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) slotHeight - 6); |
51 | - layout.SetText (message); |
52 | - |
53 | - Pango.Rectangle inkRect, logicalRect; |
54 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
55 | - |
56 | - surface.Context.MoveTo (surface.Width - 4 - logicalRect.Width, yOffset + (slotHeight - 2 - logicalRect.Height) / 2); |
57 | - |
58 | - Pango.CairoHelper.LayoutPath (surface.Context, layout); |
59 | - surface.Context.LineWidth = 2; |
60 | - surface.Context.StrokePreserve (); |
61 | - surface.Context.Color = new Cairo.Color (1, 1, 1, 1); |
62 | - surface.Context.Fill (); |
63 | - |
64 | - layout.FontDescription.Dispose (); |
65 | - layout.Context.Dispose (); |
66 | - } |
67 | + message_layout.Width = Pango.Units.FromPixels (surface.Width - iconSize - 8); |
68 | + message_layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) slotHeight - 6); |
69 | + message_layout.SetText (message); |
70 | + |
71 | + Pango.Rectangle inkRect, logicalRect; |
72 | + message_layout.GetPixelExtents (out inkRect, out logicalRect); |
73 | + |
74 | + surface.Context.MoveTo (surface.Width - 4 - logicalRect.Width, yOffset + (slotHeight - 2 - logicalRect.Height) / 2); |
75 | + |
76 | + Pango.CairoHelper.LayoutPath (surface.Context, message_layout); |
77 | + surface.Context.LineWidth = 2; |
78 | + surface.Context.StrokePreserve (); |
79 | + surface.Context.Color = new Cairo.Color (1, 1, 1, 1); |
80 | + surface.Context.Fill (); |
81 | } |
82 | |
83 | void PaintProgressSurface (DockySurface surface) |
84 | @@ -862,47 +882,38 @@ |
85 | padding = 2; |
86 | } |
87 | |
88 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) |
89 | - { |
90 | - layout.Width = Pango.Units.FromPixels (surface.Height / 2); |
91 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
92 | - layout.FontDescription = new Gtk.Style ().FontDescription; |
93 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
94 | - |
95 | - Pango.Rectangle inkRect, logicalRect; |
96 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (surface.Height / 2); |
97 | - layout.SetText (BadgeText); |
98 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
99 | - |
100 | - size -= 2 * padding + 2 * lineWidth; |
101 | - |
102 | - double scale = Math.Min (1, Math.Min (size / (double) logicalRect.Width, size / (double) logicalRect.Height)); |
103 | - |
104 | - if (!IsSmall) { |
105 | - surface.Context.Color = new Cairo.Color (0, 0, 0, 0.2); |
106 | - } else { |
107 | - surface.Context.Color = new Cairo.Color (0, 0, 0, 0.6); |
108 | - x = surface.Width - scale * logicalRect.Width / 2; |
109 | - y = scale * logicalRect.Height / 2; |
110 | - } |
111 | - |
112 | - surface.Context.MoveTo (x - scale * logicalRect.Width / 2, y - scale * logicalRect.Height / 2); |
113 | - |
114 | - // draw text |
115 | - surface.Context.Save (); |
116 | - if (scale < 1) |
117 | - surface.Context.Scale (scale, scale); |
118 | - |
119 | - surface.Context.LineWidth = 2; |
120 | - Pango.CairoHelper.LayoutPath (surface.Context, layout); |
121 | - surface.Context.StrokePreserve (); |
122 | - surface.Context.Color = new Cairo.Color (1, 1, 1, 1); |
123 | - surface.Context.Fill (); |
124 | - surface.Context.Restore (); |
125 | - |
126 | - layout.FontDescription.Dispose (); |
127 | - layout.Context.Dispose (); |
128 | + badge_layout.Width = Pango.Units.FromPixels (surface.Height / 2); |
129 | + |
130 | + Pango.Rectangle inkRect, logicalRect; |
131 | + badge_layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (surface.Height / 2); |
132 | + badge_layout.SetText (BadgeText); |
133 | + badge_layout.GetPixelExtents (out inkRect, out logicalRect); |
134 | + |
135 | + size -= 2 * padding + 2 * lineWidth; |
136 | + |
137 | + double scale = Math.Min (1, Math.Min (size / (double) logicalRect.Width, size / (double) logicalRect.Height)); |
138 | + |
139 | + if (!IsSmall) { |
140 | + surface.Context.Color = new Cairo.Color (0, 0, 0, 0.2); |
141 | + } else { |
142 | + surface.Context.Color = new Cairo.Color (0, 0, 0, 0.6); |
143 | + x = surface.Width - scale * logicalRect.Width / 2; |
144 | + y = scale * logicalRect.Height / 2; |
145 | } |
146 | + |
147 | + surface.Context.MoveTo (x - scale * logicalRect.Width / 2, y - scale * logicalRect.Height / 2); |
148 | + |
149 | + // draw text |
150 | + surface.Context.Save (); |
151 | + if (scale < 1) |
152 | + surface.Context.Scale (scale, scale); |
153 | + |
154 | + surface.Context.LineWidth = 2; |
155 | + Pango.CairoHelper.LayoutPath (surface.Context, badge_layout); |
156 | + surface.Context.StrokePreserve (); |
157 | + surface.Context.Color = new Cairo.Color (1, 1, 1, 1); |
158 | + surface.Context.Fill (); |
159 | + surface.Context.Restore (); |
160 | } |
161 | |
162 | /// <summary> |
163 | @@ -923,35 +934,26 @@ |
164 | return null; |
165 | |
166 | if (text_buffer == null) { |
167 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
168 | - layout.FontDescription = style.FontDescription; |
169 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (11); |
170 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
171 | - layout.Ellipsize = Pango.EllipsizeMode.End; |
172 | - |
173 | - layout.SetText (HoverText); |
174 | - |
175 | - Pango.Rectangle inkRect, logicalRect; |
176 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
177 | - if (logicalRect.Width > 0.8 * Gdk.Screen.Default.Width) { |
178 | - layout.Width = Pango.Units.FromPixels ((int) (0.8 * Gdk.Screen.Default.Width)); |
179 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
180 | - } |
181 | - |
182 | - int textWidth = logicalRect.Width; |
183 | - int textHeight = logicalRect.Height; |
184 | - int buffer = HoverTextHeight - textHeight; |
185 | - text_buffer = new DockySurface (Math.Max (HoverTextHeight, textWidth + buffer), HoverTextHeight, model); |
186 | - |
187 | - Cairo.Context cr = text_buffer.Context; |
188 | - |
189 | - cr.MoveTo (buffer / 2, buffer / 2); |
190 | - Pango.CairoHelper.LayoutPath (cr, layout); |
191 | - cr.Color = isLight ? new Cairo.Color (0.1, 0.1, 0.1) : new Cairo.Color (1, 1, 1); |
192 | - cr.Fill (); |
193 | - |
194 | - layout.Context.Dispose (); |
195 | + hover_layout.SetText (HoverText); |
196 | + |
197 | + Pango.Rectangle inkRect, logicalRect; |
198 | + hover_layout.GetPixelExtents (out inkRect, out logicalRect); |
199 | + if (logicalRect.Width > 0.8 * Gdk.Screen.Default.Width) { |
200 | + hover_layout.Width = Pango.Units.FromPixels ((int) (0.8 * Gdk.Screen.Default.Width)); |
201 | + hover_layout.GetPixelExtents (out inkRect, out logicalRect); |
202 | } |
203 | + |
204 | + int textWidth = inkRect.Width; |
205 | + int textHeight = logicalRect.Height; |
206 | + int buffer = HoverTextHeight - textHeight; |
207 | + text_buffer = new DockySurface (Math.Max (HoverTextHeight, textWidth + buffer), HoverTextHeight, model); |
208 | + |
209 | + Cairo.Context cr = text_buffer.Context; |
210 | + |
211 | + cr.MoveTo ((text_buffer.Width - textWidth) / 2, buffer / 2); |
212 | + Pango.CairoHelper.LayoutPath (cr, hover_layout); |
213 | + cr.Color = isLight ? new Cairo.Color (0.1, 0.1, 0.1) : new Cairo.Color (1, 1, 1); |
214 | + cr.Fill (); |
215 | } |
216 | |
217 | return text_buffer; |
218 | |
219 | === modified file 'Docky.Items/Docky.Items/IconEmblem.cs' |
220 | --- Docky.Items/Docky.Items/IconEmblem.cs 2010-06-25 13:06:51 +0000 |
221 | +++ Docky.Items/Docky.Items/IconEmblem.cs 2011-01-03 11:34:09 +0000 |
222 | @@ -97,6 +97,7 @@ |
223 | return; |
224 | } |
225 | ForcePixbuf = info.LoadIcon (); |
226 | + info.Dispose (); |
227 | } |
228 | |
229 | public Pixbuf GetPixbuf (int parentWidth, int parentHeight) { |
230 | |
231 | === modified file 'Docky/Docky/Interface/DockWindow.cs' |
232 | --- Docky/Docky/Interface/DockWindow.cs 2010-11-22 08:46:18 +0000 |
233 | +++ Docky/Docky/Interface/DockWindow.cs 2011-01-03 11:34:09 +0000 |
234 | @@ -135,7 +135,9 @@ |
235 | const int NormalIndicatorSize = 20; |
236 | const int UrgentIndicatorSize = 26; |
237 | const int GlowSize = 30; |
238 | - |
239 | + const int HoverTextHeight = 26; |
240 | + const int HoverTextFontSize = 11; |
241 | + |
242 | const int WaitGroups = 3; |
243 | const int WaitArmsPerGroup = 8; |
244 | |
245 | @@ -338,31 +340,20 @@ |
246 | |
247 | DockySurface DrawHoverText (DockySurface surface, string text) |
248 | { |
249 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
250 | - layout.FontDescription = Style.FontDescription; |
251 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (11); |
252 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
253 | - layout.Ellipsize = Pango.EllipsizeMode.End; |
254 | - layout.Width = Pango.Units.FromPixels (500); |
255 | - |
256 | - layout.SetText (text); |
257 | - |
258 | - Pango.Rectangle inkRect, logicalRect; |
259 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
260 | - |
261 | - const int HoverTextHeight = 26; |
262 | - int textWidth = inkRect.Width; |
263 | - int textHeight = logicalRect.Height; |
264 | - int buffer = HoverTextHeight - textHeight; |
265 | - surface = new DockySurface (Math.Max (HoverTextHeight, textWidth + buffer), HoverTextHeight, background_buffer); |
266 | - |
267 | - surface.Context.MoveTo ((surface.Width - textWidth) / 2, buffer / 2); |
268 | - Pango.CairoHelper.LayoutPath (surface.Context, layout); |
269 | - surface.Context.Color = HoverTextManager.IsLight ? new Cairo.Color (0.1, 0.1, 0.1) : new Cairo.Color (1, 1, 1); |
270 | - surface.Context.Fill (); |
271 | - |
272 | - layout.Context.Dispose (); |
273 | - } |
274 | + hover_layout.SetText (text); |
275 | + |
276 | + Pango.Rectangle inkRect, logicalRect; |
277 | + hover_layout.GetPixelExtents (out inkRect, out logicalRect); |
278 | + |
279 | + int textWidth = inkRect.Width; |
280 | + int textHeight = logicalRect.Height; |
281 | + int buffer = HoverTextHeight - textHeight; |
282 | + surface = new DockySurface (Math.Max (HoverTextHeight, textWidth + buffer), HoverTextHeight, background_buffer); |
283 | + |
284 | + surface.Context.MoveTo ((surface.Width - textWidth) / 2, buffer / 2); |
285 | + Pango.CairoHelper.LayoutPath (surface.Context, hover_layout); |
286 | + surface.Context.Color = HoverTextManager.IsLight ? new Cairo.Color (0.1, 0.1, 0.1) : new Cairo.Color (1, 1, 1); |
287 | + surface.Context.Fill (); |
288 | |
289 | return surface; |
290 | } |
291 | @@ -676,9 +667,21 @@ |
292 | |
293 | #endregion |
294 | |
295 | + static Pango.Layout hover_layout; |
296 | + |
297 | static DockWindow () |
298 | { |
299 | DockyItem = new DockyItem (); |
300 | + |
301 | + Gtk.Style style = new Gtk.Style (); |
302 | + |
303 | + hover_layout = DockServices.Drawing.ThemedPangoLayout (); |
304 | + hover_layout.Ellipsize = Pango.EllipsizeMode.End; |
305 | + hover_layout.FontDescription = style.FontDescription; |
306 | + hover_layout.FontDescription.Weight = Pango.Weight.Bold; |
307 | + hover_layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (HoverTextFontSize); |
308 | + |
309 | + style.Dispose (); |
310 | } |
311 | |
312 | public DockWindow () : base(Gtk.WindowType.Toplevel) |
313 | |
314 | === modified file 'Docky/Docky/Menus/MenuItemWidget.cs' |
315 | --- Docky/Docky/Menus/MenuItemWidget.cs 2010-11-14 14:17:17 +0000 |
316 | +++ Docky/Docky/Menus/MenuItemWidget.cs 2011-01-03 11:34:09 +0000 |
317 | @@ -63,6 +63,21 @@ |
318 | |
319 | DockySurface icon_surface, emblem_surface; |
320 | |
321 | + static Pango.Layout layout; |
322 | + |
323 | + static MenuItemWidget () |
324 | + { |
325 | + Gtk.Style style = new Gtk.Style (); |
326 | + |
327 | + layout = DockServices.Drawing.ThemedPangoLayout (); |
328 | + layout.Ellipsize = Pango.EllipsizeMode.End; |
329 | + layout.FontDescription = style.FontDescription; |
330 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (FontSize); |
331 | + layout.FontDescription.Weight = Pango.Weight.Bold; |
332 | + |
333 | + style.Dispose (); |
334 | + } |
335 | + |
336 | internal MenuItemWidget (MenuItem item) : base() |
337 | { |
338 | TextColor = new Cairo.Color (1, 1, 1); |
339 | @@ -91,26 +106,19 @@ |
340 | |
341 | void CalcTextWidth () |
342 | { |
343 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
344 | - char accel; |
345 | - |
346 | - if (item.Mnemonic.HasValue) |
347 | - layout.SetMarkupWithAccel (item.Text, '_', out accel); |
348 | - else |
349 | - layout.SetMarkup (item.Text); |
350 | - layout.FontDescription = Style.FontDescription; |
351 | - layout.Ellipsize = Pango.EllipsizeMode.End; |
352 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (FontSize); |
353 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
354 | - |
355 | - Pango.Rectangle logical, ink; |
356 | - layout.GetPixelExtents (out ink, out logical); |
357 | - |
358 | - TextWidth = Math.Min (MaxWidth, Math.Max (MinWidth, logical.Width)); |
359 | - HasTooltip = TextWidth < logical.Width; |
360 | - |
361 | - layout.Context.Dispose (); |
362 | - } |
363 | + char accel; |
364 | + |
365 | + if (item.Mnemonic.HasValue) |
366 | + layout.SetMarkupWithAccel (item.Text, '_', out accel); |
367 | + else |
368 | + layout.SetMarkup (item.Text); |
369 | + |
370 | + layout.Width = -1; |
371 | + Pango.Rectangle logical, ink; |
372 | + layout.GetPixelExtents (out ink, out logical); |
373 | + |
374 | + TextWidth = Math.Min (MaxWidth, Math.Max (MinWidth, logical.Width)); |
375 | + HasTooltip = TextWidth < logical.Width; |
376 | |
377 | SetSize (); |
378 | } |
379 | @@ -265,31 +273,23 @@ |
380 | } |
381 | } |
382 | |
383 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
384 | - char accel; |
385 | - if (item.Mnemonic.HasValue) |
386 | - layout.SetMarkupWithAccel (item.Text, '_', out accel); |
387 | - else |
388 | - layout.SetMarkup (item.Text); |
389 | - layout.Width = Pango.Units.FromPixels (TextWidth); |
390 | - layout.FontDescription = Style.FontDescription; |
391 | - layout.Ellipsize = Pango.EllipsizeMode.End; |
392 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (FontSize); |
393 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
394 | - |
395 | - Pango.Rectangle logical, ink; |
396 | - layout.GetPixelExtents (out ink, out logical); |
397 | - |
398 | - int offset = Padding; |
399 | - if (MenuShowingIcons) |
400 | - offset += MenuHeight + Padding; |
401 | - cr.MoveTo (allocation.X + offset, allocation.Y + (allocation.Height - logical.Height) / 2); |
402 | - Pango.CairoHelper.LayoutPath (cr, layout); |
403 | - cr.Color = TextColor.SetAlpha (item.Disabled ? 0.5 : 1); |
404 | - cr.Fill (); |
405 | - |
406 | - layout.Context.Dispose (); |
407 | - } |
408 | + char accel; |
409 | + if (item.Mnemonic.HasValue) |
410 | + layout.SetMarkupWithAccel (item.Text, '_', out accel); |
411 | + else |
412 | + layout.SetMarkup (item.Text); |
413 | + layout.Width = Pango.Units.FromPixels (TextWidth); |
414 | + |
415 | + Pango.Rectangle logical, ink; |
416 | + layout.GetPixelExtents (out ink, out logical); |
417 | + |
418 | + int offset = Padding; |
419 | + if (MenuShowingIcons) |
420 | + offset += MenuHeight + Padding; |
421 | + cr.MoveTo (allocation.X + offset, allocation.Y + (allocation.Height - logical.Height) / 2); |
422 | + Pango.CairoHelper.LayoutPath (cr, layout); |
423 | + cr.Color = TextColor.SetAlpha (item.Disabled ? 0.5 : 1); |
424 | + cr.Fill (); |
425 | |
426 | (cr.Target as IDisposable).Dispose (); |
427 | } |
428 | |
429 | === modified file 'Docky/Docky/Menus/SeparatorWidget.cs' |
430 | --- Docky/Docky/Menus/SeparatorWidget.cs 2010-10-15 15:32:36 +0000 |
431 | +++ Docky/Docky/Menus/SeparatorWidget.cs 2011-01-03 11:34:09 +0000 |
432 | @@ -28,12 +28,29 @@ |
433 | { |
434 | public class SeparatorWidget : EventBox |
435 | { |
436 | + const int FontSize = 8; |
437 | + |
438 | string title; |
439 | |
440 | public Cairo.Color TextColor { get; set; } |
441 | |
442 | public bool DrawLine { get; set; } |
443 | |
444 | + static Pango.Layout layout; |
445 | + |
446 | + static SeparatorWidget () |
447 | + { |
448 | + Gtk.Style style = new Gtk.Style (); |
449 | + |
450 | + layout = DockServices.Drawing.ThemedPangoLayout (); |
451 | + layout.Ellipsize = Pango.EllipsizeMode.End; |
452 | + layout.FontDescription = style.FontDescription; |
453 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (FontSize); |
454 | + layout.FontDescription.Weight = Pango.Weight.Bold; |
455 | + |
456 | + style.Dispose (); |
457 | + } |
458 | + |
459 | public SeparatorWidget (string title) |
460 | { |
461 | this.title = title; |
462 | @@ -63,27 +80,20 @@ |
463 | int xMiddle = x + width / 2; |
464 | double yMiddle = Allocation.Y + Allocation.Height / 2.0; |
465 | |
466 | - if (!string.IsNullOrEmpty (title)) |
467 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
468 | - layout.SetText (title); |
469 | - layout.Width = Pango.Units.FromPixels (Allocation.Width - Allocation.Height); |
470 | - layout.FontDescription = Style.FontDescription; |
471 | - layout.Ellipsize = Pango.EllipsizeMode.End; |
472 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (8); |
473 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
474 | - |
475 | - Pango.Rectangle logical, ink; |
476 | - layout.GetPixelExtents (out ink, out logical); |
477 | - |
478 | - cr.MoveTo (Allocation.X + 2, Allocation.Y + (Allocation.Height - logical.Height) / 2); |
479 | - Pango.CairoHelper.LayoutPath (cr, layout); |
480 | - cr.Color = TextColor.SetAlpha (.6); |
481 | - cr.Fill (); |
482 | - |
483 | - x += logical.Width + 5; |
484 | - |
485 | - layout.Context.Dispose (); |
486 | - } |
487 | + if (!string.IsNullOrEmpty (title)) { |
488 | + layout.SetText (title); |
489 | + layout.Width = Pango.Units.FromPixels (Allocation.Width - Allocation.Height); |
490 | + |
491 | + Pango.Rectangle logical, ink; |
492 | + layout.GetPixelExtents (out ink, out logical); |
493 | + |
494 | + cr.MoveTo (Allocation.X + 2, Allocation.Y + (Allocation.Height - logical.Height) / 2); |
495 | + Pango.CairoHelper.LayoutPath (cr, layout); |
496 | + cr.Color = TextColor.SetAlpha (.6); |
497 | + cr.Fill (); |
498 | + |
499 | + x += logical.Width + 5; |
500 | + } |
501 | |
502 | if (DrawLine) { |
503 | cr.MoveTo (x, yMiddle); |
504 | |
505 | === modified file 'StandardPlugins/Clock/src/CalendarPainter.cs' |
506 | --- StandardPlugins/Clock/src/CalendarPainter.cs 2010-07-15 07:44:12 +0000 |
507 | +++ StandardPlugins/Clock/src/CalendarPainter.cs 2011-01-03 11:34:09 +0000 |
508 | @@ -42,6 +42,31 @@ |
509 | } |
510 | } |
511 | |
512 | + static Pango.Layout header_layout; |
513 | + static Pango.Layout line_layout; |
514 | + static Pango.Layout month_layout; |
515 | + |
516 | + static CalendarPainter () |
517 | + { |
518 | + Gtk.Style style = new Gtk.Style (); |
519 | + |
520 | + header_layout = DockServices.Drawing.ThemedPangoLayout (); |
521 | + header_layout.FontDescription = style.FontDescription; |
522 | + header_layout.FontDescription.Weight = Pango.Weight.Bold; |
523 | + header_layout.Ellipsize = Pango.EllipsizeMode.None; |
524 | + |
525 | + line_layout = DockServices.Drawing.ThemedPangoLayout (); |
526 | + line_layout.FontDescription = style.FontDescription; |
527 | + line_layout.Ellipsize = Pango.EllipsizeMode.None; |
528 | + |
529 | + month_layout = DockServices.Drawing.ThemedPangoLayout (); |
530 | + month_layout.FontDescription = style.FontDescription; |
531 | + month_layout.FontDescription.Weight = Pango.Weight.Bold; |
532 | + month_layout.Ellipsize = Pango.EllipsizeMode.None; |
533 | + |
534 | + style.Dispose (); |
535 | + } |
536 | + |
537 | public CalendarPainter () : base (3) |
538 | { |
539 | StartDate = DateTime.Today.AddDays (1 - DateTime.Today.Day); |
540 | @@ -106,33 +131,25 @@ |
541 | { |
542 | string month = StartDate.ToString ("MMMM").ToUpper (); |
543 | |
544 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
545 | - layout.FontDescription = new Gtk.Style().FontDescription; |
546 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
547 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
548 | - layout.Width = Pango.Units.FromPixels (Allocation.Height); |
549 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (Allocation.Height / 6); |
550 | - |
551 | - cr.Save (); |
552 | - cr.Color = new Cairo.Color (1, 1, 1, .5); |
553 | - layout.SetText (month); |
554 | - |
555 | - Pango.Rectangle inkRect, logicalRect; |
556 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
557 | - double scale = Math.Min (1, Math.Min (Allocation.Height / (double) inkRect.Width, (Allocation.Width / 9.0) / (double) logicalRect.Height)); |
558 | - |
559 | - cr.Rotate (Math.PI / -2.0); |
560 | - cr.MoveTo ((Allocation.Height - scale * inkRect.Width) / 2 - Allocation.Height, Allocation.Width / 9 - scale * logicalRect.Height); |
561 | - if (scale < 1) |
562 | - cr.Scale (scale, scale); |
563 | - |
564 | - Pango.CairoHelper.LayoutPath (cr, layout); |
565 | - cr.Fill (); |
566 | - cr.Restore (); |
567 | - |
568 | - layout.FontDescription.Dispose (); |
569 | - layout.Context.Dispose (); |
570 | - } |
571 | + month_layout.Width = Pango.Units.FromPixels (Allocation.Height); |
572 | + month_layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (Allocation.Height / 6); |
573 | + |
574 | + cr.Save (); |
575 | + cr.Color = new Cairo.Color (1, 1, 1, .5); |
576 | + month_layout.SetText (month); |
577 | + |
578 | + Pango.Rectangle inkRect, logicalRect; |
579 | + month_layout.GetPixelExtents (out inkRect, out logicalRect); |
580 | + double scale = Math.Min (1, Math.Min (Allocation.Height / (double) inkRect.Width, (Allocation.Width / 9.0) / (double) logicalRect.Height)); |
581 | + |
582 | + cr.Rotate (Math.PI / -2.0); |
583 | + cr.MoveTo ((Allocation.Height - scale * inkRect.Width) / 2 - Allocation.Height, Allocation.Width / 9 - scale * logicalRect.Height); |
584 | + if (scale < 1) |
585 | + cr.Scale (scale, scale); |
586 | + |
587 | + Pango.CairoHelper.LayoutPath (cr, month_layout); |
588 | + cr.Fill (); |
589 | + cr.Restore (); |
590 | } |
591 | |
592 | void RenderHeader (Context cr, DateTime start) |
593 | @@ -142,28 +159,20 @@ |
594 | |
595 | DateTime day = CalendarStartDate; |
596 | |
597 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
598 | - layout.FontDescription = new Gtk.Style().FontDescription; |
599 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
600 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
601 | - layout.Width = Pango.Units.FromPixels (offsetSize); |
602 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (0.625 * LineHeight)); |
603 | - |
604 | - cr.Color = new Cairo.Color (1, 1, 1, .5); |
605 | - for (int i = 0; i < 7; i++) { |
606 | - layout.SetText (day.ToString ("ddd").ToUpper ()); |
607 | - |
608 | - Pango.Rectangle inkRect, logicalRect; |
609 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
610 | - cr.MoveTo (offsetSize + offsetSize * i + (offsetSize - inkRect.Width) / 2, centerLine - logicalRect.Height); |
611 | - |
612 | - Pango.CairoHelper.LayoutPath (cr, layout); |
613 | - cr.Fill (); |
614 | - day = day.AddDays (1); |
615 | - } |
616 | - |
617 | - layout.FontDescription.Dispose (); |
618 | - layout.Context.Dispose (); |
619 | + header_layout.Width = Pango.Units.FromPixels (offsetSize); |
620 | + header_layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (0.625 * LineHeight)); |
621 | + |
622 | + cr.Color = new Cairo.Color (1, 1, 1, .5); |
623 | + for (int i = 0; i < 7; i++) { |
624 | + header_layout.SetText (day.ToString ("ddd").ToUpper ()); |
625 | + |
626 | + Pango.Rectangle inkRect, logicalRect; |
627 | + header_layout.GetPixelExtents (out inkRect, out logicalRect); |
628 | + cr.MoveTo (offsetSize + offsetSize * i + (offsetSize - inkRect.Width) / 2, centerLine - logicalRect.Height); |
629 | + |
630 | + Pango.CairoHelper.LayoutPath (cr, header_layout); |
631 | + cr.Fill (); |
632 | + day = day.AddDays (1); |
633 | } |
634 | } |
635 | |
636 | @@ -174,58 +183,51 @@ |
637 | int centerLine = LineHeight + LineHeight * line + ((Allocation.Height % LineHeight) / 2); |
638 | int dayOffset = 0; |
639 | |
640 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
641 | - Pango.Rectangle inkRect, logicalRect; |
642 | - |
643 | - layout.FontDescription = new Gtk.Style().FontDescription; |
644 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
645 | - layout.Width = Pango.Units.FromPixels (offsetSize); |
646 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (0.625 * LineHeight)); |
647 | - |
648 | - for (int i = 0; i < 7; i++) { |
649 | - layout.FontDescription.Weight = Pango.Weight.Normal; |
650 | - |
651 | - DateTime day = lineStart.AddDays (dayOffset); |
652 | - |
653 | - if (day.Month == CalendarStartDate.AddDays (6).Month) |
654 | - cr.Color = new Cairo.Color (1, 1, 1); |
655 | - else |
656 | - cr.Color = new Cairo.Color (1, 1, 1, 0.5); |
657 | - |
658 | - if (day.Date == DateTime.Today) |
659 | - { |
660 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
661 | - Gdk.Color color = Style.Backgrounds [(int) StateType.Selected].SetMinimumValue (100); |
662 | - cr.Color = new Cairo.Color ((double) color.Red / ushort.MaxValue, |
663 | - (double) color.Green / ushort.MaxValue, |
664 | - (double) color.Blue / ushort.MaxValue, |
665 | - 1.0); |
666 | - } |
667 | - dayOffset++; |
668 | - |
669 | - layout.SetText (string.Format ("{0:00}", day.Day)); |
670 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
671 | - cr.MoveTo (offsetSize + offsetSize * i + (offsetSize - inkRect.Width) / 2, centerLine - logicalRect.Height); |
672 | - |
673 | - Pango.CairoHelper.LayoutPath (cr, layout); |
674 | - cr.Fill (); |
675 | + Pango.Rectangle inkRect, logicalRect; |
676 | + |
677 | + line_layout.Width = Pango.Units.FromPixels (offsetSize); |
678 | + line_layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (0.625 * LineHeight)); |
679 | + |
680 | + for (int i = 0; i < 7; i++) { |
681 | + line_layout.FontDescription.Weight = Pango.Weight.Normal; |
682 | + |
683 | + DateTime day = lineStart.AddDays (dayOffset); |
684 | + |
685 | + if (day.Month == CalendarStartDate.AddDays (6).Month) |
686 | + cr.Color = new Cairo.Color (1, 1, 1); |
687 | + else |
688 | + cr.Color = new Cairo.Color (1, 1, 1, 0.5); |
689 | + |
690 | + if (day.Date == DateTime.Today) |
691 | + { |
692 | + line_layout.FontDescription.Weight = Pango.Weight.Bold; |
693 | + Gdk.Color color = Style.Backgrounds [(int) StateType.Selected].SetMinimumValue (100); |
694 | + cr.Color = new Cairo.Color ((double) color.Red / ushort.MaxValue, |
695 | + (double) color.Green / ushort.MaxValue, |
696 | + (double) color.Blue / ushort.MaxValue, |
697 | + 1.0); |
698 | } |
699 | - |
700 | - cr.Color = new Cairo.Color (1, 1, 1, 0.4); |
701 | - int woy = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear (lineStart.AddDays (6), |
702 | - DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, |
703 | - DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek); |
704 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
705 | - layout.SetText (string.Format ("W{0:00}", woy)); |
706 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
707 | - cr.MoveTo (offsetSize * 8, centerLine - logicalRect.Height); |
708 | - |
709 | - Pango.CairoHelper.LayoutPath (cr, layout); |
710 | + dayOffset++; |
711 | + |
712 | + line_layout.SetText (string.Format ("{0:00}", day.Day)); |
713 | + line_layout.GetPixelExtents (out inkRect, out logicalRect); |
714 | + cr.MoveTo (offsetSize + offsetSize * i + (offsetSize - inkRect.Width) / 2, centerLine - logicalRect.Height); |
715 | + |
716 | + Pango.CairoHelper.LayoutPath (cr, line_layout); |
717 | cr.Fill (); |
718 | - |
719 | - layout.FontDescription.Dispose (); |
720 | - layout.Context.Dispose (); |
721 | } |
722 | + |
723 | + cr.Color = new Cairo.Color (1, 1, 1, 0.4); |
724 | + int woy = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear (lineStart.AddDays (6), |
725 | + DateTimeFormatInfo.CurrentInfo.CalendarWeekRule, |
726 | + DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek); |
727 | + line_layout.FontDescription.Weight = Pango.Weight.Bold; |
728 | + line_layout.SetText (string.Format ("W{0:00}", woy)); |
729 | + line_layout.GetPixelExtents (out inkRect, out logicalRect); |
730 | + cr.MoveTo (offsetSize * 8, centerLine - logicalRect.Height); |
731 | + |
732 | + Pango.CairoHelper.LayoutPath (cr, line_layout); |
733 | + cr.Fill (); |
734 | } |
735 | |
736 | protected override void OnShown () |
737 | |
738 | === modified file 'StandardPlugins/Clock/src/ClockDockItem.cs' |
739 | --- StandardPlugins/Clock/src/ClockDockItem.cs 2010-11-21 22:19:54 +0000 |
740 | +++ StandardPlugins/Clock/src/ClockDockItem.cs 2011-01-03 11:34:09 +0000 |
741 | @@ -141,6 +141,20 @@ |
742 | } |
743 | } |
744 | |
745 | + static Pango.Layout layout; |
746 | + |
747 | + static ClockDockItem () |
748 | + { |
749 | + Gtk.Style style = new Gtk.Style (); |
750 | + |
751 | + layout = DockServices.Drawing.ThemedPangoLayout (); |
752 | + layout.FontDescription = style.FontDescription; |
753 | + layout.FontDescription.Weight = Pango.Weight.Bold; |
754 | + layout.Ellipsize = Pango.EllipsizeMode.None; |
755 | + |
756 | + style.Dispose (); |
757 | + } |
758 | + |
759 | public ClockDockItem () |
760 | { |
761 | ScalableRendering = !ShowDigital; |
762 | @@ -215,78 +229,69 @@ |
763 | int center = surface.Height / 2; |
764 | |
765 | // shared by all text |
766 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
767 | - layout.FontDescription = new Gtk.Style().FontDescription; |
768 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
769 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
770 | - layout.Width = Pango.Units.FromPixels (surface.Width); |
771 | - |
772 | - |
773 | - // draw the time, outlined |
774 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (timeSize); |
775 | - |
776 | - if (ShowMilitary) |
777 | - layout.SetText (DateTime.Now.ToString ("HH:mm")); |
778 | - else |
779 | - layout.SetText (DateTime.Now.ToString ("h:mm")); |
780 | - |
781 | - Pango.Rectangle inkRect, logicalRect; |
782 | + layout.Width = Pango.Units.FromPixels (surface.Width); |
783 | + |
784 | + // draw the time, outlined |
785 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (timeSize); |
786 | + |
787 | + if (ShowMilitary) |
788 | + layout.SetText (DateTime.Now.ToString ("HH:mm")); |
789 | + else |
790 | + layout.SetText (DateTime.Now.ToString ("h:mm")); |
791 | + |
792 | + Pango.Rectangle inkRect, logicalRect; |
793 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
794 | + |
795 | + int timeYOffset = ShowMilitary ? timeSize : timeSize / 2; |
796 | + int timeXOffset = (surface.Width - inkRect.Width) / 2; |
797 | + if (ShowDate) |
798 | + cr.MoveTo (timeXOffset, timeYOffset); |
799 | + else |
800 | + cr.MoveTo (timeXOffset, timeYOffset + timeSize / 2); |
801 | + |
802 | + Pango.CairoHelper.LayoutPath (cr, layout); |
803 | + cr.LineWidth = 3; |
804 | + cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
805 | + cr.StrokePreserve (); |
806 | + cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
807 | + cr.Fill (); |
808 | + |
809 | + // draw the date, outlined |
810 | + if (ShowDate) { |
811 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize); |
812 | + |
813 | + layout.SetText (DateTime.Now.ToString ("MMM dd")); |
814 | layout.GetPixelExtents (out inkRect, out logicalRect); |
815 | - |
816 | - int timeYOffset = ShowMilitary ? timeSize : timeSize / 2; |
817 | - int timeXOffset = (surface.Width - inkRect.Width) / 2; |
818 | - if (ShowDate) |
819 | - cr.MoveTo (timeXOffset, timeYOffset); |
820 | - else |
821 | - cr.MoveTo (timeXOffset, timeYOffset + timeSize / 2); |
822 | + cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize); |
823 | |
824 | Pango.CairoHelper.LayoutPath (cr, layout); |
825 | - cr.LineWidth = 3; |
826 | + cr.LineWidth = 2.5; |
827 | cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
828 | cr.StrokePreserve (); |
829 | cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
830 | cr.Fill (); |
831 | - |
832 | - // draw the date, outlined |
833 | - if (ShowDate) { |
834 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize); |
835 | - |
836 | - layout.SetText (DateTime.Now.ToString ("MMM dd")); |
837 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
838 | - cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize); |
839 | - |
840 | - Pango.CairoHelper.LayoutPath (cr, layout); |
841 | - cr.LineWidth = 2.5; |
842 | - cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
843 | - cr.StrokePreserve (); |
844 | - cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
845 | - cr.Fill (); |
846 | - } |
847 | - |
848 | - if (!ShowMilitary) { |
849 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (ampmSize); |
850 | - |
851 | - int yOffset = ShowDate ? center - spacing : surface.Height - spacing - ampmSize; |
852 | - |
853 | - // draw AM indicator |
854 | - layout.SetText ("am"); |
855 | - cr.Color = new Cairo.Color (1, 1, 1, DateTime.Now.Hour < 12 ? 0.8 : 0.2); |
856 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
857 | - cr.MoveTo ((center - inkRect.Width) / 2, yOffset); |
858 | - Pango.CairoHelper.LayoutPath (cr, layout); |
859 | - cr.Fill (); |
860 | - |
861 | - // draw PM indicator |
862 | - layout.SetText ("pm"); |
863 | - cr.Color = new Cairo.Color (1, 1, 1, DateTime.Now.Hour > 11 ? 0.8 : 0.2); |
864 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
865 | - cr.MoveTo (center + (center - inkRect.Width) / 2, yOffset); |
866 | - Pango.CairoHelper.LayoutPath (cr, layout); |
867 | - cr.Fill (); |
868 | - } |
869 | - |
870 | - layout.FontDescription.Dispose (); |
871 | - layout.Context.Dispose (); |
872 | + } |
873 | + |
874 | + if (!ShowMilitary) { |
875 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (ampmSize); |
876 | + |
877 | + int yOffset = ShowDate ? center - spacing : surface.Height - spacing - ampmSize; |
878 | + |
879 | + // draw AM indicator |
880 | + layout.SetText ("am"); |
881 | + cr.Color = new Cairo.Color (1, 1, 1, DateTime.Now.Hour < 12 ? 0.8 : 0.2); |
882 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
883 | + cr.MoveTo ((center - inkRect.Width) / 2, yOffset); |
884 | + Pango.CairoHelper.LayoutPath (cr, layout); |
885 | + cr.Fill (); |
886 | + |
887 | + // draw PM indicator |
888 | + layout.SetText ("pm"); |
889 | + cr.Color = new Cairo.Color (1, 1, 1, DateTime.Now.Hour > 11 ? 0.8 : 0.2); |
890 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
891 | + cr.MoveTo (center + (center - inkRect.Width) / 2, yOffset); |
892 | + Pango.CairoHelper.LayoutPath (cr, layout); |
893 | + cr.Fill (); |
894 | } |
895 | } |
896 | |
897 | @@ -301,72 +306,63 @@ |
898 | int spacing = timeSize / 2; |
899 | |
900 | // shared by all text |
901 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
902 | - layout.FontDescription = new Gtk.Style().FontDescription; |
903 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
904 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
905 | - layout.Width = Pango.Units.FromPixels (surface.Width); |
906 | - |
907 | - |
908 | - // draw the time, outlined |
909 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (timeSize); |
910 | - |
911 | - if (ShowMilitary) |
912 | - layout.SetText (DateTime.Now.ToString ("HH:mm")); |
913 | + layout.Width = Pango.Units.FromPixels (surface.Width); |
914 | + |
915 | + // draw the time, outlined |
916 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (timeSize); |
917 | + |
918 | + if (ShowMilitary) |
919 | + layout.SetText (DateTime.Now.ToString ("HH:mm")); |
920 | + else |
921 | + layout.SetText (DateTime.Now.ToString ("h:mm")); |
922 | + |
923 | + Pango.Rectangle inkRect, logicalRect; |
924 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
925 | + |
926 | + int timeYOffset = timeSize / 2; |
927 | + if (!ShowDate) |
928 | + timeYOffset += timeSize / 2; |
929 | + cr.MoveTo ((surface.Width - inkRect.Width) / 2, timeYOffset); |
930 | + |
931 | + Pango.CairoHelper.LayoutPath (cr, layout); |
932 | + cr.LineWidth = 2; |
933 | + cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
934 | + cr.StrokePreserve (); |
935 | + cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
936 | + cr.Fill (); |
937 | + |
938 | + // draw the date, outlined |
939 | + if (ShowDate) { |
940 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize); |
941 | + |
942 | + layout.SetText (DateTime.Now.ToString ("MMM dd")); |
943 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
944 | + cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize); |
945 | + |
946 | + Pango.CairoHelper.LayoutPath (cr, layout); |
947 | + cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
948 | + cr.StrokePreserve (); |
949 | + cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
950 | + cr.Fill (); |
951 | + } |
952 | + |
953 | + if (!ShowMilitary) { |
954 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (ampmSize); |
955 | + |
956 | + if (DateTime.Now.Hour < 12) |
957 | + layout.SetText ("am"); |
958 | else |
959 | - layout.SetText (DateTime.Now.ToString ("h:mm")); |
960 | + layout.SetText ("pm"); |
961 | |
962 | - Pango.Rectangle inkRect, logicalRect; |
963 | layout.GetPixelExtents (out inkRect, out logicalRect); |
964 | - |
965 | - int timeYOffset = timeSize / 2; |
966 | + int yOffset = timeSize; |
967 | if (!ShowDate) |
968 | - timeYOffset += timeSize / 2; |
969 | - cr.MoveTo ((surface.Width - inkRect.Width) / 2, timeYOffset); |
970 | + yOffset += timeSize / 2; |
971 | + cr.MoveTo (surface.Width - logicalRect.Width, yOffset - inkRect.Height); |
972 | |
973 | Pango.CairoHelper.LayoutPath (cr, layout); |
974 | - cr.LineWidth = 2; |
975 | - cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
976 | - cr.StrokePreserve (); |
977 | cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
978 | cr.Fill (); |
979 | - |
980 | - // draw the date, outlined |
981 | - if (ShowDate) { |
982 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (dateSize); |
983 | - |
984 | - layout.SetText (DateTime.Now.ToString ("MMM dd")); |
985 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
986 | - cr.MoveTo ((surface.Width - inkRect.Width) / 2, surface.Height - spacing - dateSize); |
987 | - |
988 | - Pango.CairoHelper.LayoutPath (cr, layout); |
989 | - cr.Color = new Cairo.Color (0, 0, 0, 0.5); |
990 | - cr.StrokePreserve (); |
991 | - cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
992 | - cr.Fill (); |
993 | - } |
994 | - |
995 | - if (!ShowMilitary) { |
996 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (ampmSize); |
997 | - |
998 | - if (DateTime.Now.Hour < 12) |
999 | - layout.SetText ("am"); |
1000 | - else |
1001 | - layout.SetText ("pm"); |
1002 | - |
1003 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1004 | - int yOffset = timeSize; |
1005 | - if (!ShowDate) |
1006 | - yOffset += timeSize / 2; |
1007 | - cr.MoveTo (surface.Width - logicalRect.Width, yOffset - inkRect.Height); |
1008 | - |
1009 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1010 | - cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
1011 | - cr.Fill (); |
1012 | - } |
1013 | - |
1014 | - layout.FontDescription.Dispose (); |
1015 | - layout.Context.Dispose (); |
1016 | } |
1017 | } |
1018 | |
1019 | |
1020 | === modified file 'StandardPlugins/Weather/src/WeatherDocklet.cs' |
1021 | --- StandardPlugins/Weather/src/WeatherDocklet.cs 2010-11-21 22:19:54 +0000 |
1022 | +++ StandardPlugins/Weather/src/WeatherDocklet.cs 2011-01-03 11:34:09 +0000 |
1023 | @@ -62,6 +62,20 @@ |
1024 | |
1025 | ConfigDialog Config; |
1026 | |
1027 | + static Pango.Layout layout; |
1028 | + |
1029 | + static WeatherDocklet () |
1030 | + { |
1031 | + Gtk.Style style = new Gtk.Style (); |
1032 | + |
1033 | + layout = DockServices.Drawing.ThemedPangoLayout (); |
1034 | + layout.FontDescription = style.FontDescription; |
1035 | + layout.FontDescription.Weight = Pango.Weight.Bold; |
1036 | + layout.Ellipsize = Pango.EllipsizeMode.None; |
1037 | + |
1038 | + style.Dispose (); |
1039 | + } |
1040 | + |
1041 | /// <summary> |
1042 | /// Creates a new weather docklet. |
1043 | /// </summary> |
1044 | @@ -154,35 +168,25 @@ |
1045 | int size = Math.Min (surface.Width, surface.Height); |
1046 | Context cr = surface.Context; |
1047 | |
1048 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) |
1049 | - { |
1050 | - layout.FontDescription = new Gtk.Style().FontDescription; |
1051 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
1052 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
1053 | - |
1054 | - Pango.Rectangle inkRect, logicalRect; |
1055 | - |
1056 | - layout.Width = Pango.Units.FromPixels (size); |
1057 | - layout.SetText (WeatherController.Weather.Temp + AbstractWeatherSource.TempUnit); |
1058 | - if (IsSmall) |
1059 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (size / 2.5)); |
1060 | - else |
1061 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (size / 3.5)); |
1062 | - |
1063 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1064 | - cr.MoveTo ((size - inkRect.Width) / 2, size - logicalRect.Height); |
1065 | - |
1066 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1067 | - cr.LineWidth = 2; |
1068 | - cr.Color = new Cairo.Color (0, 0, 0, 0.8); |
1069 | - cr.StrokePreserve (); |
1070 | - |
1071 | - cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
1072 | - cr.Fill (); |
1073 | - |
1074 | - layout.FontDescription.Dispose (); |
1075 | - layout.Context.Dispose (); |
1076 | - } |
1077 | + Pango.Rectangle inkRect, logicalRect; |
1078 | + |
1079 | + layout.Width = Pango.Units.FromPixels (size); |
1080 | + layout.SetText (WeatherController.Weather.Temp + AbstractWeatherSource.TempUnit); |
1081 | + if (IsSmall) |
1082 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (size / 2.5)); |
1083 | + else |
1084 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (size / 3.5)); |
1085 | + |
1086 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1087 | + cr.MoveTo ((size - inkRect.Width) / 2, size - logicalRect.Height); |
1088 | + |
1089 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1090 | + cr.LineWidth = 2; |
1091 | + cr.Color = new Cairo.Color (0, 0, 0, 0.8); |
1092 | + cr.StrokePreserve (); |
1093 | + |
1094 | + cr.Color = new Cairo.Color (1, 1, 1, 0.8); |
1095 | + cr.Fill (); |
1096 | } |
1097 | |
1098 | protected override Gdk.Pixbuf ProcessPixbuf (Gdk.Pixbuf pbuf) |
1099 | |
1100 | === modified file 'StandardPlugins/Weather/src/WeatherPainter.cs' |
1101 | --- StandardPlugins/Weather/src/WeatherPainter.cs 2010-06-24 11:45:49 +0000 |
1102 | +++ StandardPlugins/Weather/src/WeatherPainter.cs 2011-01-03 11:34:09 +0000 |
1103 | @@ -49,6 +49,20 @@ |
1104 | /// </value> |
1105 | static readonly Cairo.Color colorLow = new Cairo.Color (0.427, 0.714, 0.945, 1); |
1106 | |
1107 | + static Pango.Layout layout; |
1108 | + |
1109 | + static WeatherPainter () |
1110 | + { |
1111 | + Gtk.Style style = new Gtk.Style (); |
1112 | + |
1113 | + layout = DockServices.Drawing.ThemedPangoLayout (); |
1114 | + layout.FontDescription = style.FontDescription; |
1115 | + layout.FontDescription.Weight = Pango.Weight.Bold; |
1116 | + layout.Ellipsize = Pango.EllipsizeMode.None; |
1117 | + |
1118 | + style.Dispose (); |
1119 | + } |
1120 | + |
1121 | /// <summary> |
1122 | /// Creates a new weather painter object. |
1123 | /// </summary> |
1124 | @@ -102,68 +116,60 @@ |
1125 | int xOffset = BUTTON_SIZE; |
1126 | int cellWidth = (Allocation.Width - 2 * BUTTON_SIZE) / (WeatherController.Weather.ForecastDays * 2); |
1127 | |
1128 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
1129 | - Pango.Rectangle inkRect, logicalRect; |
1130 | - |
1131 | - layout.FontDescription = new Gtk.Style().FontDescription; |
1132 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
1133 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
1134 | - layout.Width = Pango.Units.FromPixels (cellWidth); |
1135 | - |
1136 | - for (int day = 0; day < WeatherController.Weather.ForecastDays; day++) |
1137 | - { |
1138 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (cellWidth / 5)); |
1139 | - |
1140 | - cr.Color = colorTitle; |
1141 | - layout.SetText (string.Format ("{0}", WeatherForecast.DayShortName (WeatherController.Weather.Forecasts [day].dow))); |
1142 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1143 | - cr.MoveTo (xOffset + (cellWidth - inkRect.Width) / 2, 0); |
1144 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1145 | - cr.Fill (); |
1146 | - |
1147 | - cr.Color = colorHigh; |
1148 | - layout.SetText (string.Format ("{0}{1}", WeatherController.Weather.Forecasts [day].high, AbstractWeatherSource.TempUnit)); |
1149 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1150 | - cr.MoveTo (xOffset + (cellWidth - inkRect.Width) / 2, Allocation.Height / 2 - logicalRect.Height / 2); |
1151 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1152 | - cr.Fill (); |
1153 | - |
1154 | - cr.Color = colorLow; |
1155 | - layout.SetText (string.Format ("{0}{1}", WeatherController.Weather.Forecasts [day].low, AbstractWeatherSource.TempUnit)); |
1156 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1157 | - cr.MoveTo (xOffset + (cellWidth - inkRect.Width) / 2, Allocation.Height - logicalRect.Height); |
1158 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1159 | - cr.Fill (); |
1160 | - |
1161 | - using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (WeatherController.Weather.Forecasts [day].image, cellWidth - 5)) |
1162 | - { |
1163 | - Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, xOffset + cellWidth + 2, 5 + (Allocation.Height - cellWidth) / 2); |
1164 | - cr.PaintWithAlpha (WeatherController.Weather.Forecasts [day].chanceOf ? .6 : 1); |
1165 | - } |
1166 | - |
1167 | - if (WeatherController.Weather.Forecasts [day].chanceOf) |
1168 | - { |
1169 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (cellWidth / 2)); |
1170 | - |
1171 | - layout.SetText ("?"); |
1172 | - |
1173 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1174 | - cr.MoveTo (xOffset + cellWidth + (cellWidth - inkRect.Width) / 2, Allocation.Height / 2 - logicalRect.Height / 2); |
1175 | - |
1176 | - cr.LineWidth = 4; |
1177 | - cr.Color = new Cairo.Color (0, 0, 0, 0.3); |
1178 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1179 | - cr.StrokePreserve (); |
1180 | - |
1181 | - cr.Color = new Cairo.Color (1, 1, 1, .6); |
1182 | - cr.Fill (); |
1183 | - } |
1184 | - |
1185 | - xOffset += 2 * cellWidth; |
1186 | - } |
1187 | - |
1188 | - layout.FontDescription.Dispose (); |
1189 | - layout.Context.Dispose (); |
1190 | + Pango.Rectangle inkRect, logicalRect; |
1191 | + |
1192 | + layout.Width = Pango.Units.FromPixels (cellWidth); |
1193 | + |
1194 | + for (int day = 0; day < WeatherController.Weather.ForecastDays; day++) |
1195 | + { |
1196 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (cellWidth / 5)); |
1197 | + |
1198 | + cr.Color = colorTitle; |
1199 | + layout.SetText (string.Format ("{0}", WeatherForecast.DayShortName (WeatherController.Weather.Forecasts [day].dow))); |
1200 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1201 | + cr.MoveTo (xOffset + (cellWidth - inkRect.Width) / 2, 0); |
1202 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1203 | + cr.Fill (); |
1204 | + |
1205 | + cr.Color = colorHigh; |
1206 | + layout.SetText (string.Format ("{0}{1}", WeatherController.Weather.Forecasts [day].high, AbstractWeatherSource.TempUnit)); |
1207 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1208 | + cr.MoveTo (xOffset + (cellWidth - inkRect.Width) / 2, Allocation.Height / 2 - logicalRect.Height / 2); |
1209 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1210 | + cr.Fill (); |
1211 | + |
1212 | + cr.Color = colorLow; |
1213 | + layout.SetText (string.Format ("{0}{1}", WeatherController.Weather.Forecasts [day].low, AbstractWeatherSource.TempUnit)); |
1214 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1215 | + cr.MoveTo (xOffset + (cellWidth - inkRect.Width) / 2, Allocation.Height - logicalRect.Height); |
1216 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1217 | + cr.Fill (); |
1218 | + |
1219 | + using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon (WeatherController.Weather.Forecasts [day].image, cellWidth - 5)) |
1220 | + { |
1221 | + Gdk.CairoHelper.SetSourcePixbuf (cr, pbuf, xOffset + cellWidth + 2, 5 + (Allocation.Height - cellWidth) / 2); |
1222 | + cr.PaintWithAlpha (WeatherController.Weather.Forecasts [day].chanceOf ? .6 : 1); |
1223 | + } |
1224 | + |
1225 | + if (WeatherController.Weather.Forecasts [day].chanceOf) |
1226 | + { |
1227 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (cellWidth / 2)); |
1228 | + |
1229 | + layout.SetText ("?"); |
1230 | + |
1231 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1232 | + cr.MoveTo (xOffset + cellWidth + (cellWidth - inkRect.Width) / 2, Allocation.Height / 2 - logicalRect.Height / 2); |
1233 | + |
1234 | + cr.LineWidth = 4; |
1235 | + cr.Color = new Cairo.Color (0, 0, 0, 0.3); |
1236 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1237 | + cr.StrokePreserve (); |
1238 | + |
1239 | + cr.Color = new Cairo.Color (1, 1, 1, .6); |
1240 | + cr.Fill (); |
1241 | + } |
1242 | + |
1243 | + xOffset += 2 * cellWidth; |
1244 | } |
1245 | } |
1246 | |
1247 | @@ -192,47 +198,39 @@ |
1248 | if (max <= min) |
1249 | return; |
1250 | |
1251 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
1252 | - Pango.Rectangle inkRect, logicalRect; |
1253 | - |
1254 | - layout.FontDescription = new Gtk.Style().FontDescription; |
1255 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
1256 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
1257 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (Allocation.Height / 5)); |
1258 | - |
1259 | - // high/low temp |
1260 | - layout.Width = Pango.Units.FromPixels (Allocation.Height); |
1261 | - cr.Color = colorHigh; |
1262 | - layout.SetText (string.Format ("{0}{1}", max, AbstractWeatherSource.TempUnit)); |
1263 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1264 | - cr.MoveTo (Allocation.Width - Allocation.Height + (Allocation.Height - inkRect.Width) / 2 - BUTTON_SIZE, Allocation.Height / 6 - logicalRect.Height / 2); |
1265 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1266 | - cr.Fill (); |
1267 | - |
1268 | - cr.Color = colorLow; |
1269 | - layout.SetText (string.Format ("{0}{1}", min, AbstractWeatherSource.TempUnit)); |
1270 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1271 | - cr.MoveTo (Allocation.Width - Allocation.Height + (Allocation.Height - inkRect.Width) / 2 - BUTTON_SIZE, Allocation.Height * 6 / 9 - logicalRect.Height / 2); |
1272 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1273 | - cr.Fill (); |
1274 | - |
1275 | - // day names |
1276 | - layout.Width = Pango.Units.FromPixels (2 * Allocation.Height); |
1277 | - |
1278 | - cr.Color = colorTitle; |
1279 | - for (int day = 0; day < WeatherController.Weather.ForecastDays; day++) |
1280 | - { |
1281 | - layout.SetText (WeatherForecast.DayShortName (WeatherController.Weather.Forecasts [day].dow)); |
1282 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1283 | - cr.MoveTo (BUTTON_SIZE + day * Allocation.Height * 2 + (Allocation.Height - inkRect.Width) / 2, Allocation.Height * 8 / 9 - logicalRect.Height / 2); |
1284 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1285 | - } |
1286 | - cr.Fill (); |
1287 | - cr.Save (); |
1288 | - |
1289 | - layout.FontDescription.Dispose (); |
1290 | - layout.Context.Dispose (); |
1291 | + Pango.Rectangle inkRect, logicalRect; |
1292 | + |
1293 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (Allocation.Height / 5)); |
1294 | + |
1295 | + // high/low temp |
1296 | + layout.Width = Pango.Units.FromPixels (Allocation.Height); |
1297 | + cr.Color = colorHigh; |
1298 | + layout.SetText (string.Format ("{0}{1}", max, AbstractWeatherSource.TempUnit)); |
1299 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1300 | + cr.MoveTo (Allocation.Width - Allocation.Height + (Allocation.Height - inkRect.Width) / 2 - BUTTON_SIZE, Allocation.Height / 6 - logicalRect.Height / 2); |
1301 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1302 | + cr.Fill (); |
1303 | + |
1304 | + cr.Color = colorLow; |
1305 | + layout.SetText (string.Format ("{0}{1}", min, AbstractWeatherSource.TempUnit)); |
1306 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1307 | + cr.MoveTo (Allocation.Width - Allocation.Height + (Allocation.Height - inkRect.Width) / 2 - BUTTON_SIZE, Allocation.Height * 6 / 9 - logicalRect.Height / 2); |
1308 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1309 | + cr.Fill (); |
1310 | + |
1311 | + // day names |
1312 | + layout.Width = Pango.Units.FromPixels (2 * Allocation.Height); |
1313 | + |
1314 | + cr.Color = colorTitle; |
1315 | + for (int day = 0; day < WeatherController.Weather.ForecastDays; day++) |
1316 | + { |
1317 | + layout.SetText (WeatherForecast.DayShortName (WeatherController.Weather.Forecasts [day].dow)); |
1318 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1319 | + cr.MoveTo (BUTTON_SIZE + day * Allocation.Height * 2 + (Allocation.Height - inkRect.Width) / 2, Allocation.Height * 8 / 9 - logicalRect.Height / 2); |
1320 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1321 | } |
1322 | + cr.Fill (); |
1323 | + cr.Save (); |
1324 | |
1325 | // draw tick lines |
1326 | cr.Color = new Cairo.Color (0.627, 0.627, 0.627, .8); |
1327 | @@ -359,29 +357,21 @@ |
1328 | |
1329 | void DrawConditionText (Cairo.Context cr, int x, int xWidth, int yCenter, string text) |
1330 | { |
1331 | - using (Pango.Layout layout = DockServices.Drawing.ThemedPangoLayout ()) { |
1332 | - Pango.Rectangle inkRect, logicalRect; |
1333 | - |
1334 | - layout.FontDescription = new Gtk.Style().FontDescription; |
1335 | - layout.FontDescription.Weight = Pango.Weight.Bold; |
1336 | - layout.Ellipsize = Pango.EllipsizeMode.None; |
1337 | - layout.Width = Pango.Units.FromPixels (Allocation.Width - BUTTON_SIZE - x); |
1338 | - |
1339 | - if (WeatherController.Weather.ForecastDays < 6) |
1340 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (Allocation.Height / 5)); |
1341 | - else |
1342 | - layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (Allocation.Height / 3.5)); |
1343 | - |
1344 | - cr.Color = new Cairo.Color (1, 1, 1, 0.9); |
1345 | - layout.SetText (text); |
1346 | - layout.GetPixelExtents (out inkRect, out logicalRect); |
1347 | - cr.MoveTo (x + (xWidth - logicalRect.Width) / 2, yCenter - logicalRect.Height / 2); |
1348 | - Pango.CairoHelper.LayoutPath (cr, layout); |
1349 | - cr.Fill (); |
1350 | - |
1351 | - layout.FontDescription.Dispose (); |
1352 | - layout.Context.Dispose (); |
1353 | - } |
1354 | + Pango.Rectangle inkRect, logicalRect; |
1355 | + |
1356 | + layout.Width = Pango.Units.FromPixels (Allocation.Width - BUTTON_SIZE - x); |
1357 | + |
1358 | + if (WeatherController.Weather.ForecastDays < 6) |
1359 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (Allocation.Height / 5)); |
1360 | + else |
1361 | + layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels ((int) (Allocation.Height / 3.5)); |
1362 | + |
1363 | + cr.Color = new Cairo.Color (1, 1, 1, 0.9); |
1364 | + layout.SetText (text); |
1365 | + layout.GetPixelExtents (out inkRect, out logicalRect); |
1366 | + cr.MoveTo (x + (xWidth - logicalRect.Width) / 2, yCenter - logicalRect.Height / 2); |
1367 | + Pango.CairoHelper.LayoutPath (cr, layout); |
1368 | + cr.Fill (); |
1369 | } |
1370 | |
1371 | /// <summary> |
In CalendarPainter, you dont need 3 layouts. Look where you create them, 2 are the same.