Do

Merge lp://qastaging/~jassmith/do/dock-text-cleanup into lp://qastaging/do

Proposed by Jason Smith
Status: Merged
Merged at revision: not available
Proposed branch: lp://qastaging/~jassmith/do/dock-text-cleanup
Merge into: lp://qastaging/do
Diff against target: None lines
To merge this branch: bzr merge lp://qastaging/~jassmith/do/dock-text-cleanup
Reviewer Review Type Date Requested Status
David Siegel (community) Approve
Review via email: mp+4278@code.qastaging.launchpad.net
To post a comment you must log in.
Revision history for this message
David Siegel (djsiegel-deactivatedaccount) wrote :

Looks sexy to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Do.Interface.Linux.Docky/Do.Interface.Linux.Docky.mdp'
2--- Do.Interface.Linux.Docky/Do.Interface.Linux.Docky.mdp 2009-03-06 06:10:27 +0000
3+++ Do.Interface.Linux.Docky/Do.Interface.Linux.Docky.mdp 2009-03-07 22:50:28 +0000
4@@ -90,6 +90,7 @@
5 <File name="src/Docky.Interface/Docky.Interface.Painters/AbstractIntegratedPainter.cs" subtype="Code" buildaction="Compile" />
6 <File name="src/Docky.Interface/Docky.Interface.Menus/AbstractMenuArgs.cs" subtype="Code" buildaction="Compile" />
7 <File name="src/Docky.Interface/Docky.Interface.Menus/WidgetMenuArgs.cs" subtype="Code" buildaction="Compile" />
8+ <File name="src/Docky.Interface/TextRenderContext.cs" subtype="Code" buildaction="Compile" />
9 </Contents>
10 <References>
11 <ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
12
13=== modified file 'Do.Interface.Linux.Docky/Makefile.am'
14--- Do.Interface.Linux.Docky/Makefile.am 2009-03-05 05:00:17 +0000
15+++ Do.Interface.Linux.Docky/Makefile.am 2009-03-07 22:50:28 +0000
16@@ -60,6 +60,7 @@
17 src/Docky.Interface/ItemPositionProvider.cs \
18 src/Docky.Interface/LayoutUtils.cs \
19 src/Docky.Interface/PaintNeededArgs.cs \
20+ src/Docky.Interface/TextRenderContext.cs \
21 src/Docky.Interface/UpdateRequestArgs.cs \
22 src/Docky.Interface/Util.cs \
23 src/Docky.Utilities/DockOrientation.cs \
24
25=== modified file 'Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/DrawingService.cs'
26--- Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/DrawingService.cs 2009-02-22 05:18:44 +0000
27+++ Do.Interface.Linux.Docky/src/Docky.Core/Docky.Core.Default/DrawingService.cs 2009-03-07 23:45:57 +0000
28@@ -27,18 +27,27 @@
29 {
30 #region IDrawingService implementation
31
32- public Pango.Layout GetThemedLayout ()
33+ Pango.Layout GetThemedLayout ()
34 {
35- return new Pango.Layout (DockWindow.Window.CreatePangoContext ());
36+ Pango.Layout layout = new Pango.Layout (DockWindow.Window.CreatePangoContext ());
37+ layout.FontDescription = DockWindow.Window.Style.FontDescription;
38+ return layout;
39 }
40
41- public void TextPathAtPoint (Cairo.Context cr, string text, Gdk.Point point, int maxWidth, Pango.Alignment align)
42+ public Gdk.Rectangle TextPathAtPoint (TextRenderContext context)
43 {
44+ Cairo.Context cr = context.Context;
45+ Gdk.Point point = context.LeftCenteredPoint;
46+
47 Pango.Layout layout = GetThemedLayout ();
48- layout.Width = Pango.Units.FromPixels (maxWidth);
49- layout.SetMarkup (text);
50- layout.Ellipsize = Pango.EllipsizeMode.End;
51- layout.Alignment = align;
52+ layout.Width = Pango.Units.FromPixels (context.MaximumWidth);
53+ layout.SetMarkup (context.Text);
54+ layout.Ellipsize = context.EllipsizeMode;
55+ layout.Alignment = context.Alignment;
56+ layout.Wrap = context.WrapMode;
57+
58+ if (context.FontSize != 0)
59+ layout.FontDescription.Size = Pango.Units.FromPixels (context.FontSize);
60
61 Pango.Rectangle rect1, rect2;
62 layout.GetExtents (out rect1, out rect2);
63@@ -47,6 +56,12 @@
64 cr.Translate (point.X, transY);
65 Pango.CairoHelper.LayoutPath (cr, layout);
66 cr.Translate (0 - point.X, 0 - transY);
67+
68+ Gdk.Rectangle textArea = new Gdk.Rectangle (Pango.Units.ToPixels (rect2.X),
69+ Pango.Units.ToPixels (rect2.Y),
70+ Pango.Units.ToPixels (rect2.Width),
71+ Pango.Units.ToPixels (rect2.Height));
72+ return textArea;
73 }
74
75 #endregion
76
77=== modified file 'Do.Interface.Linux.Docky/src/Docky.Core/IDrawingService.cs'
78--- Do.Interface.Linux.Docky/src/Docky.Core/IDrawingService.cs 2009-02-10 03:03:55 +0000
79+++ Do.Interface.Linux.Docky/src/Docky.Core/IDrawingService.cs 2009-03-07 23:45:57 +0000
80@@ -18,12 +18,12 @@
81
82 using System;
83
84+using Docky.Interface;
85+
86 namespace Docky.Core
87 {
88 public interface IDrawingService : IDockService
89 {
90- Pango.Layout GetThemedLayout ();
91-
92- void TextPathAtPoint (Cairo.Context cr, string text, Gdk.Point leftCenterPoint, int maxWidth, Pango.Alignment align);
93+ Gdk.Rectangle TextPathAtPoint (TextRenderContext context);
94 }
95 }
96
97=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs'
98--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs 2009-03-04 05:17:38 +0000
99+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/AbstractMenuButtonArgs.cs 2009-03-07 22:50:28 +0000
100@@ -59,6 +59,8 @@
101
102 protected virtual string Icon { get; set; }
103
104+ protected virtual bool UseTooltip { get; set; }
105+
106 public AbstractMenuButtonArgs ()
107 {
108
109@@ -83,6 +85,8 @@
110 button.HeightRequest = Height;
111
112 button.SetCompositeColormap ();
113+ if (UseTooltip)
114+ button.TooltipText = Description;
115
116 return button;
117 }
118@@ -129,16 +133,16 @@
119 cr.Paint ();
120 lg.Destroy ();
121
122- Gdk.Point textPoint;
123- int width;
124- textPoint = new Gdk.Point (area.X + WidthBuffer + 25, area.Y + area.Height / 2);
125- width = area.Width - WidthBuffer * 2 - 25;
126-
127- DockServices.DrawingService.TextPathAtPoint (cr,
128- string.Format (FormatString, Description),
129- textPoint,
130- width,
131- Pango.Alignment.Left);
132+ int width = area.Width - WidthBuffer * 2 - 25;
133+
134+ TextRenderContext renderContext = new TextRenderContext (cr, string.Format (FormatString, Description), width);
135+
136+ renderContext.LeftCenteredPoint = new Gdk.Point (area.X + WidthBuffer + 25, area.Y + area.Height / 2);
137+ renderContext.Alignment = Pango.Alignment.Left;
138+ renderContext.EllipsizeMode = Pango.EllipsizeMode.End;
139+
140+ DockServices.DrawingService.TextPathAtPoint (renderContext);
141+
142 cr.Color = new Cairo.Color (1, 1, 1);
143 cr.Fill ();
144
145
146=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockPopupMenu.cs'
147--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockPopupMenu.cs 2009-03-04 18:28:37 +0000
148+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/DockPopupMenu.cs 2009-03-07 22:50:28 +0000
149@@ -46,6 +46,7 @@
150 const double Pointiness = 1.5;
151 const double Curviness = 1;
152 const double Bluntness = 2;
153+ const string FormatString = "<b>{0}</b>";
154
155 int horizontal_offset;
156 int vertical_offset;
157@@ -210,11 +211,11 @@
158 cr.LineWidth = 1;
159 cr.Stroke ();
160
161- Core.DockServices.DrawingService.TextPathAtPoint (cr,
162- string.Format ("<b>{0}</b>", header),
163- new Gdk.Point (8, HeaderTextOffset),
164- Width - 16,
165- Pango.Alignment.Center);
166+ TextRenderContext context = new TextRenderContext (cr, string.Format (FormatString, header), Width - 16);
167+ context.LeftCenteredPoint = new Gdk.Point (8, HeaderTextOffset);
168+ context.Alignment = Pango.Alignment.Center;
169+
170+ Core.DockServices.DrawingService.TextPathAtPoint (context);
171 cr.Color = new Cairo.Color (1, 1, 1);
172 cr.Fill ();
173 }
174
175=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/WindowMenuButtonArgs.cs'
176--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/WindowMenuButtonArgs.cs 2009-03-04 05:05:46 +0000
177+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Menus/WindowMenuButtonArgs.cs 2009-03-07 22:50:28 +0000
178@@ -44,6 +44,7 @@
179 public WindowMenuButtonArgs (Wnck.Window window, string description, string icon) : base (description, icon)
180 {
181 this.window = window;
182+ UseTooltip = true;
183 }
184
185 public override void Action ()
186
187=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Painters/CalendarPainter.cs'
188--- Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Painters/CalendarPainter.cs 2009-03-04 19:28:14 +0000
189+++ Do.Interface.Linux.Docky/src/Docky.Interface/Docky.Interface.Painters/CalendarPainter.cs 2009-03-07 22:50:28 +0000
190@@ -36,6 +36,7 @@
191 {
192 const int LineHeight = 16;
193 const double lowlight = .35;
194+ const string BoldFormatString = "<b>{0}</b>";
195
196 ClockDockItem Clock { get; set; }
197
198@@ -80,17 +81,15 @@
199 int centerLine = paintArea.Y + LineHeight / 2 + ((paintArea.Height % LineHeight) / 2);
200 int offsetSize = paintArea.Width / 9;
201
202- string text;
203 DateTime day = CalendarStartDate;
204+ TextRenderContext textContext = new TextRenderContext (cr, string.Empty, offsetSize);
205+ textContext.Alignment = Pango.Alignment.Center;
206
207 cr.Color = new Cairo.Color (1, 1, 1, .5);
208 for (int i = 1; i < 8; i++) {
209- text =string.Format ("<b>{0}</b>", day.ToString ("ddd").ToUpper ());
210- DockServices.DrawingService.TextPathAtPoint (cr,
211- text,
212- new Gdk.Point (paintArea.X + offsetSize * i, centerLine),
213- offsetSize,
214- Pango.Alignment.Center);
215+ textContext.Text = string.Format (BoldFormatString, day.ToString ("ddd").ToUpper ());
216+ textContext.LeftCenteredPoint = new Gdk.Point (paintArea.X + offsetSize * i, centerLine);
217+ DockServices.DrawingService.TextPathAtPoint (textContext);
218 cr.Fill ();
219 day = day.AddDays (1);
220 }
221@@ -102,40 +101,36 @@
222 int offsetSize = paintArea.Width / 9;
223 int centerLine = paintArea.Y + LineHeight / 2 + LineHeight * line + ((paintArea.Height % LineHeight) / 2);
224
225- Pango.Alignment align;
226- string text;
227 int dayOffset = 0;
228+ TextRenderContext textContext = new TextRenderContext (cr, string.Empty, offsetSize);
229 for (int i = 0; i < 9; i++) {
230 if (i == 8) {
231 cr.Color = new Cairo.Color (1, 1, 1, lowlight);
232- text = string.Format ("<b>{0}</b>", lineStart.AddDays (6).ToString ("MMM").ToUpper ());
233- align = Pango.Alignment.Left;
234+ textContext.Text = string.Format (BoldFormatString, lineStart.AddDays (6).ToString ("MMM").ToUpper ());
235+ textContext.Alignment = Pango.Alignment.Left;
236 } else if (i == 0) {
237 cr.Color = new Cairo.Color (1, 1, 1, lowlight);
238 int woy = CultureInfo.CurrentCulture.Calendar.GetWeekOfYear (lineStart,
239 DateTimeFormatInfo.CurrentInfo.CalendarWeekRule,
240 DateTimeFormatInfo.CurrentInfo.FirstDayOfWeek);
241- text = string.Format ("<b>W{0:00}</b>", woy);
242- align = Pango.Alignment.Right;
243+ textContext.Text = string.Format ("<b>W{0:00}</b>", woy);
244+ textContext.Alignment = Pango.Alignment.Right;
245 } else {
246 DateTime day = lineStart.AddDays (dayOffset);
247- align = Pango.Alignment.Center;
248+ textContext.Alignment = Pango.Alignment.Center;
249
250 if (day.Month == CalendarStartDate.Month)
251 cr.Color = new Cairo.Color (1, 1, 1);
252 else
253 cr.Color = new Cairo.Color (1, 1, 1, .8);
254
255- text = string.Format ("{0:00}", day.Day);
256+ textContext.Text = string.Format ("{0:00}", day.Day);
257 if (day.Date == DateTime.Today)
258- text = string.Format ("<b>{0}</b>", text);
259+ textContext.Text = string.Format (BoldFormatString, textContext.Text);
260 dayOffset++;
261 }
262- DockServices.DrawingService.TextPathAtPoint (cr,
263- text,
264- new Gdk.Point (paintArea.X + offsetSize * i, centerLine),
265- offsetSize,
266- align);
267+ textContext.LeftCenteredPoint = new Gdk.Point (paintArea.X + offsetSize * i, centerLine);
268+ DockServices.DrawingService.TextPathAtPoint (textContext);
269 cr.Fill ();
270
271 }
272
273=== added file 'Do.Interface.Linux.Docky/src/Docky.Interface/TextRenderContext.cs'
274--- Do.Interface.Linux.Docky/src/Docky.Interface/TextRenderContext.cs 1970-01-01 00:00:00 +0000
275+++ Do.Interface.Linux.Docky/src/Docky.Interface/TextRenderContext.cs 2009-03-07 23:40:51 +0000
276@@ -0,0 +1,56 @@
277+//
278+// Copyright (C) 2009 GNOME Do
279+//
280+// This program is free software: you can redistribute it and/or modify
281+// it under the terms of the GNU General Public License as published by
282+// the Free Software Foundation, either version 3 of the License, or
283+// (at your option) any later version.
284+//
285+// This program is distributed in the hope that it will be useful,
286+// but WITHOUT ANY WARRANTY; without even the implied warranty of
287+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
288+// GNU General Public License for more details.
289+//
290+// You should have received a copy of the GNU General Public License
291+// along with this program. If not, see <http://www.gnu.org/licenses/>.
292+//
293+
294+using System;
295+
296+using Cairo;
297+using Gdk;
298+using Pango;
299+
300+namespace Docky.Interface
301+{
302+
303+
304+ public struct TextRenderContext
305+ {
306+ public Pango.Alignment Alignment { get; set; }
307+
308+ public Cairo.Context Context { get; set; }
309+
310+ public Pango.EllipsizeMode EllipsizeMode { get; set; }
311+
312+ public Gdk.Point LeftCenteredPoint { get; set; }
313+
314+ public int MaximumWidth { get; set; }
315+
316+ public int FontSize { get; set; }
317+
318+ public string Text { get; set; }
319+
320+ public Pango.WrapMode WrapMode { get; set; }
321+
322+ public TextRenderContext (Cairo.Context cr, string text, int width)
323+ {
324+ Context = cr;
325+ Text = text;
326+ Alignment = Alignment.Left;
327+ MaximumWidth = width;
328+ WrapMode = WrapMode.WordChar;
329+ EllipsizeMode = EllipsizeMode.End;
330+ }
331+ }
332+}
333
334=== modified file 'Do.Interface.Linux.Docky/src/Docky.Interface/Util.cs'
335--- Do.Interface.Linux.Docky/src/Docky.Interface/Util.cs 2009-02-23 04:38:44 +0000
336+++ Do.Interface.Linux.Docky/src/Docky.Interface/Util.cs 2009-03-07 23:43:30 +0000
337@@ -58,6 +58,7 @@
338 public static class Util
339 {
340 const int Height = 35;
341+ const string FormatString = "<span weight=\"600\">{0}</span>";
342
343 public static Surface GetBorderedTextSurface (string text, int maxWidth, Surface similar)
344 {
345@@ -86,23 +87,15 @@
346 sr = similar.CreateSimilar (similar.Content, maxWidth, Height);
347
348 Context cr = new Context (sr);
349-
350- Pango.Layout layout = Core.DockServices.DrawingService.GetThemedLayout ();
351- layout.Width = Pango.Units.FromPixels (maxWidth - 18);
352- layout.SetMarkup ("<span weight=\"600\">" + text + "</span>");
353- layout.Alignment = Pango.Alignment.Center;
354- layout.Ellipsize = Pango.EllipsizeMode.End;
355-
356- Pango.Rectangle rect1, rect2;
357- layout.GetExtents (out rect1, out rect2);
358-
359- int localHeight = Pango.Units.ToPixels (rect2.Height);
360-
361- cr.SetRoundedRectanglePath (Pango.Units.ToPixels (rect2.X) + .5,
362- .5,
363- Pango.Units.ToPixels (rect2.Width) + 20 - 1,
364- localHeight + 10 - 1,
365- 5);
366+
367+ TextRenderContext textContext = new TextRenderContext (cr, string.Format (FormatString, text), maxWidth - 18);
368+ textContext.Alignment = Pango.Alignment.Center;
369+
370+ Gdk.Rectangle textArea = Core.DockServices.DrawingService.TextPathAtPoint (textContext);
371+ cr.NewPath ();
372+
373+ int localHeight = textArea.Height;
374+ cr.SetRoundedRectanglePath (textArea.X + .5, .5, textArea.Width + 20 - 1, localHeight + 10 - 1, 5);
375
376 cr.Color = new Cairo.Color (0.1, 0.1, 0.1, .75);
377 cr.FillPreserve ();
378@@ -111,23 +104,20 @@
379 cr.LineWidth = 1;
380 cr.Stroke ();
381
382- Pango.Layout shadow = layout.Copy();
383- shadow.Indent = 1;
384-
385- cr.Translate (10, 5);
386 cr.Translate(1,1);
387- Pango.CairoHelper.LayoutPath (cr, shadow);
388+
389+ textContext.LeftCenteredPoint = new Gdk.Point (10, (localHeight + 10) / 2);
390+ Core.DockServices.DrawingService.TextPathAtPoint (textContext);
391 cr.Color = new Cairo.Color (0, 0, 0, 0.6);
392 cr.Fill ();
393+
394 cr.Translate(-1,-1);
395
396- Pango.CairoHelper.LayoutPath (cr, layout);
397+ Core.DockServices.DrawingService.TextPathAtPoint (textContext);
398 cr.Color = new Cairo.Color (1, 1, 1);
399 cr.Fill ();
400
401 (cr as IDisposable).Dispose ();
402- shadow.Dispose ();
403- layout.Dispose ();
404 return sr;
405 }
406 }