1
// BezelGlassRenderClasses.cs
3
// Copyright (C) 2008 GNOME Do
5
// This program is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU General Public License as published by
7
// the Free Software Foundation, either version 3 of the License, or
8
// (at your option) any later version.
10
// This program is distributed in the hope that it will be useful,
11
// but WITHOUT ANY WARRANTY; without even the implied warranty of
12
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
// GNU General Public License for more details.
15
// You should have received a copy of the GNU General Public License
16
// along with this program. If not, see <http://www.gnu.org/licenses/>.
20
using System.Collections.Generic;
27
using Do.Interface.CairoUtils;
31
namespace Do.Interface.AnimationBase
34
public interface IBezelResultItemRenderer
37
void RenderItem (Context cr, Gdk.Point renderAnchor, int width, Do.Universe.Item item, bool drawArrow);
40
public class BezelFullResultItemRenderer : IBezelResultItemRenderer
42
BezelGlassResults parent;
44
public int Height { get { return 36; } }
46
public int IconSize { get { return 32; } }
48
public BezelFullResultItemRenderer (BezelGlassResults parent)
53
public void RenderItem (Context cr, Gdk.Point renderAnchor, int width, Do.Universe.Item item, bool drawArrow)
55
cr.Rectangle (renderAnchor.X, renderAnchor.Y, width, Height);
56
cr.Color = new Cairo.Color (0, 0, 0, 0);
57
cr.Operator = Operator.Source;
59
cr.Operator = Operator.Over;
61
Gdk.Pixbuf pixbuf = IconProvider.PixbufFromIconName (item.Icon, IconSize);
62
Gdk.CairoHelper.SetSourcePixbuf (cr, pixbuf, 2, 2);
67
foreach (int i in parent.Secondary) {
68
if (parent.Results[i] == item) {
69
pixbuf = IconProvider.PixbufFromIconName ("gtk-add", IconSize);
70
Gdk.CairoHelper.SetSourcePixbuf (cr, pixbuf, 2, 2);
71
cr.PaintWithAlpha (.7);
76
Pango.Layout layout = new Pango.Layout (parent.PangoContext);
77
layout.Width = Pango.Units.FromPixels (width - IconSize - 25);
78
layout.Ellipsize = Pango.EllipsizeMode.End;
79
layout.SetMarkup ("<span foreground=\"#" + parent.ItemTextColor + "\">"+GLib.Markup.EscapeText (item.Name)+"</span>");
80
layout.FontDescription = Pango.FontDescription.FromString ("normal bold");
81
layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (10);
83
cr.MoveTo (IconSize + 6, 4);
84
Pango.CairoHelper.ShowLayout (cr, layout);
86
layout.SetMarkup ("<span foreground=\"#" + parent.ItemTextColor + "\">"+GLib.Markup.EscapeText (item.Description)+"</span>");
87
layout.FontDescription.Dispose ();
88
layout.FontDescription = Pango.FontDescription.FromString ("normal");
89
layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (10);
90
cr.MoveTo (IconSize + 8, 19);
91
Pango.CairoHelper.ShowLayout (cr, layout);
94
cr.MoveTo (width - 15, 13);
95
cr.LineTo (width - 15+7, 17);
96
cr.LineTo (width - 15, 21);
97
Gdk.Color gc = new Gdk.Color ();
98
Gdk.Color.Parse ("#" + parent.ItemTextColor, ref gc);
99
cr.Color = gc.ConvertToCairo (1);
104
layout.FontDescription.Dispose ();
106
(cr as IDisposable).Dispose ();
110
public class BezelHalfResultItemRenderer : IBezelResultItemRenderer
112
BezelGlassResults parent;
114
public int Height { get { return 20; } }
116
public int IconSize { get { return 16; } }
118
public BezelHalfResultItemRenderer (BezelGlassResults parent)
120
this.parent = parent;
123
public void RenderItem (Context cr, Gdk.Point renderAnchor, int width, Do.Universe.Item item, bool drawArrow)
125
cr.Rectangle (renderAnchor.X, renderAnchor.Y, width, Height);
126
cr.Color = new Cairo.Color (0, 0, 0, 0);
127
cr.Operator = Operator.Source;
129
cr.Operator = Operator.Over;
131
Gdk.Pixbuf pixbuf = IconProvider.PixbufFromIconName (item.Icon, IconSize);
132
Gdk.CairoHelper.SetSourcePixbuf (cr, pixbuf, 2, 2);
137
foreach (int i in parent.Secondary) {
138
if (parent.Results[i] == item) {
139
pixbuf = IconProvider.PixbufFromIconName ("gtk-add", IconSize);
140
Gdk.CairoHelper.SetSourcePixbuf (cr, pixbuf, 2, 2);
141
cr.PaintWithAlpha (.7);
146
Pango.Layout layout = new Pango.Layout (parent.PangoContext);
147
layout.Width = Pango.Units.FromPixels (width - IconSize - 25);
148
layout.Ellipsize = Pango.EllipsizeMode.End;
149
layout.SetMarkup ("<span foreground=\"#" + parent.ItemTextColor + "\">"+GLib.Markup.EscapeText (item.Name)+"</span>");
150
layout.FontDescription = Pango.FontDescription.FromString ("normal bold");
151
layout.FontDescription.AbsoluteSize = Pango.Units.FromPixels (10);
153
cr.MoveTo (IconSize + 6, 4);
154
Pango.CairoHelper.ShowLayout (cr, layout);
157
cr.MoveTo (width - IconSize+6, 5);
158
cr.LineTo (width - IconSize+10, 10);
159
cr.LineTo (width - IconSize+6, 15);
161
cr.MoveTo (width - IconSize+2, 5);
162
cr.LineTo (width - IconSize+6, 10);
163
cr.LineTo (width - IconSize+2, 15);
164
Gdk.Color gc = new Gdk.Color ();
165
Gdk.Color.Parse ("#" + parent.ItemTextColor, ref gc);
166
cr.Color = gc.ConvertToCairo (1);
170
layout.FontDescription.Dispose ();
172
(cr as IDisposable).Dispose ();