1
/* GlossyRoundedFrame.cs
3
* GNOME Do is the legal property of its developers. Please refer to the
4
* COPYRIGHT file distributed with this source distribution.
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
26
namespace Do.Interface.Widgets
28
public class GlossyRoundedFrame : Frame
30
protected double glossHeight = .5;
31
protected int glossAngle = -25;
33
public GlossyRoundedFrame ()
38
public double GlossHeight
40
get { return glossHeight; }
42
if (value >= 0 || value <= 1)
49
get { return glossAngle; }
50
set { glossAngle = value; }
53
protected void GlossOverlay (Context glare)
55
Cairo.PointD pt1, pt2, pt3;
57
int localGlossHeight = (int) (height * glossHeight);
59
pt1 = new Cairo.PointD (x, localGlossHeight);
60
pt2 = new Cairo.PointD (x+2*width/3, localGlossHeight+glossAngle);
61
pt3 = new Cairo.PointD (x+width/3, localGlossHeight+glossAngle);
64
glare.MoveTo (x+radius, y);
65
glare.Arc (x+width-radius, y+radius, radius, (Math.PI*1.5), (Math.PI*2));
66
glare.LineTo (x+width, localGlossHeight);
67
glare.CurveTo (pt2, pt3, pt1);
68
glare.Arc (x+radius, y+radius, radius, Math.PI, (Math.PI*1.5));
71
glare.LineTo (x+width, y);
72
glare.LineTo (x+width, localGlossHeight);
73
glare.CurveTo (pt2, pt3, pt1);
79
protected override LinearGradient GetGradient ()
83
LinearGradient gloss = base.GetGradient ();
84
r = (double) fillColor.Red / ushort.MaxValue;
85
g = (double) fillColor.Green / ushort.MaxValue;
86
b = (double) fillColor.Blue / ushort.MaxValue;
88
gloss.AddColorStop (0, new Cairo.Color (r+.25, g+.25, b+.25, fillAlpha));
89
gloss.AddColorStop (.25, new Cairo.Color (r, g, b, fillAlpha));
90
gloss.AddColorStop (.75, new Cairo.Color (r-.15, g-.15, b-.15, fillAlpha));
96
protected override void PaintFill ()
102
fade = new Cairo.LinearGradient (0, 0, 0, height);
103
fade.AddColorStop (0, new Cairo.Color (1, 1, 1, 0));
104
fade.AddColorStop (.75, new Cairo.Color (1, 1, 1, .25));
108
GlossOverlay (cairo);
110
cairo.Pattern = fade;
111
cairo.FillPreserve ();