Skip to content

Commit

Permalink
* Theme.cs: Fix background theme for Quick Access Toolbar when there is
Browse files Browse the repository at this point in the history
  no app button

svn path=/trunk/gtk-sharp-ribbon/; revision=107153
  • Loading branch information
Laurent Debacker committed Jul 3, 2008
1 parent ad68e0d commit 572bb68
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 52 deletions.
5 changes: 5 additions & 0 deletions Ribbons/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2008-06-24 Laurent Debacker <debackerl@gmail.com>

* Theme.cs: Fix background theme for Quick Access Toolbar when there is no
app button

2008-06-23 Laurent Debacker <debackerl@gmail.com>

* Theme.cs: Quick Access Toolbar background
Expand Down
132 changes: 80 additions & 52 deletions Ribbons/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,60 +206,88 @@ public void DrawRibbon (Context cr, Gdk.Rectangle menuBarAllocation, Gdk.Rectang
y1 = alloc.Bottom - 1;
double radius = (y1 - y0) / 2;

Gdk.Rectangle alloc2 = widget.ApplicationButton.Allocation;
double cx = alloc2.X + alloc2.Width / 2;
double cy = alloc2.Y + alloc2.Height / 2;
double radius2 = x0 - cx;
double alpha = Math.Asin ((y0 - cy) / radius2);
double beta = Math.Asin ((y1 - cy) / radius2);
double curveWidth0 = Math.Cos (Math.Abs (alpha)) * radius2;
double curveWidth1 = Math.Cos (Math.Abs (beta)) * radius2;
double curveWidth = Math.Min (curveWidth0, curveWidth1);
cr.LineWidth = 1;

cr.Save ();
cr.Rectangle (cx + curveWidth, y0, curveWidth + alloc.Width + 2, alloc.Height);
cr.ClipPreserve ();
cr.ArcNegative (cx, cy, radius2, -alpha, -beta);
linGrad = new LinearGradient (0, y0, 0, y1);
linGrad.AddColorStop (0.0, colorScheme.Bright);
linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
cr.Pattern = linGrad;
//cr.Color = new Color (1, 0, 0);
cr.Fill ();
cr.Restore ();
cr.Arc (x1, y0 + radius, radius - 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();

cr.Arc (cx, cy, radius2, alpha, beta);
cr.Color = new Color (0, 0, 0, 0.6);
cr.Stroke ();
radius2 -= 1;
cr.Arc (cx, cy, radius2, alpha, beta);
cr.Color = new Color (1, 1, 1, 0.4);
cr.Stroke ();

cr.MoveTo (cx + curveWidth0, y0 - 0.5);
cr.LineTo (x1, y0 - 0.5);
cr.Color = new Color (1, 1, 1, 0.4);
cr.Stroke ();

cr.MoveTo (cx + curveWidth0, y0 + 0.5);
cr.LineTo (x1, y0 + 0.5);
cr.Color = new Color (0, 0, 0, 0.6);
cr.Stroke ();

cr.MoveTo (cx + curveWidth1, y1 - 0.5);
cr.LineTo (x1, y1 - 0.5);
cr.Color = new Color (0, 0, 0, 0.6);
cr.Stroke ();

cr.MoveTo (cx + curveWidth1, y1 + 0.5);
cr.LineTo (x1, y1 + 0.5);
cr.Color = new Color (1, 1, 1, 0.4);
cr.Stroke ();
if(widget.ApplicationButton != null)
{
Gdk.Rectangle alloc2 = widget.ApplicationButton.Allocation;
double cx = alloc2.X + alloc2.Width / 2;
double cy = alloc2.Y + alloc2.Height / 2;
double radius2 = x0 - cx;
double alpha = Math.Asin ((y0 - cy) / radius2);
double beta = Math.Asin ((y1 - cy) / radius2);
double curveWidth0 = Math.Cos (Math.Abs (alpha)) * radius2;
double curveWidth1 = Math.Cos (Math.Abs (beta)) * radius2;
double curveWidth = Math.Min (curveWidth0, curveWidth1);

cr.Save ();
cr.Rectangle (cx + curveWidth, y0, x1 - cx - curveWidth, alloc.Height);
cr.ClipPreserve ();
cr.ArcNegative (cx, cy, radius2, -alpha, -beta);
linGrad = new LinearGradient (0, y0, 0, y1);
linGrad.AddColorStop (0.0, colorScheme.Bright);
linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
cr.Pattern = linGrad;
//cr.Color = new Color (1, 0, 0);
cr.Fill ();
cr.Restore ();
cr.Arc (x1, y0 + radius, radius - 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();

cr.Arc (cx, cy, radius2, alpha, beta);
cr.Color = new Color (0, 0, 0, 0.6);
cr.Stroke ();
radius2 -= 1;
cr.Arc (cx, cy, radius2, alpha, beta);
cr.Color = new Color (1, 1, 1, 0.4);
cr.Stroke ();

cr.MoveTo (cx + curveWidth0, y0 - 0.5);
cr.LineTo (x1, y0 - 0.5);
cr.Color = new Color (1, 1, 1, 0.4);
cr.Stroke ();

cr.MoveTo (cx + curveWidth0, y0 + 0.5);
cr.LineTo (x1, y0 + 0.5);
cr.Color = new Color (0, 0, 0, 0.6);
cr.Stroke ();

cr.MoveTo (cx + curveWidth1, y1 - 0.5);
cr.LineTo (x1, y1 - 0.5);
cr.Color = new Color (0, 0, 0, 0.6);
cr.Stroke ();

cr.MoveTo (cx + curveWidth1, y1 + 0.5);
cr.LineTo (x1, y1 + 0.5);
cr.Color = new Color (1, 1, 1, 0.4);
cr.Stroke ();
}
else
{
cr.Rectangle (x0, y0, x1 - x0, alloc.Height);
linGrad = new LinearGradient (0, y0, 0, y1);
linGrad.AddColorStop (0.0, colorScheme.Bright);
linGrad.AddColorStop (1.0, colorScheme.PrettyDark);
cr.Pattern = linGrad;
cr.Fill ();

cr.Arc (x1, y0 + radius, radius - 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
cr.Pattern = linGrad;
cr.Fill ();
linGrad.Destroy ();

cr.MoveTo (x0 + 0.5, y0);
cr.LineTo (x0 + 0.5, y1);
cr.Color = new Color (1, 1, 1, 0.4);
cr.Stroke ();

cr.MoveTo (x0 + 1.5, y0);
cr.LineTo (x0 + 1.5, y1);
cr.Color = new Color (0, 0, 0, 0.6);
cr.Stroke ();
}

cr.Arc (x1, y0 + radius, radius + 0.5, 1.5 * Math.PI, 0.5 * Math.PI);
cr.Color = new Color (1, 1, 1, 0.4);
Expand Down

0 comments on commit 572bb68

Please sign in to comment.