예제 #1
0
        /// <summary>Draws a ribbon.</summary>
        public void DrawRibbon(Context cr, Gdk.Rectangle bodyAllocation, double roundSize, double lineWidth, Ribbon widget)
        {
            double         lineWidth05 = lineWidth / 2;
            double         lineWidth15 = 3 * lineWidth05;
            double         x0, x1, y0, y1;
            LinearGradient linGrad;

            Ribbon.RibbonPage p = widget.CurrentPage;
            if (p != null)
            {
                //Color c = ColorScheme.GetColor(colorScheme.Bright, 0.92);
                Color c = colorScheme.Normal;

                if (bodyAllocation.Height > 0)
                {
                    /*** PAGE ***/

                    x0 = bodyAllocation.X; x1 = bodyAllocation.X + bodyAllocation.Width;
                    y0 = bodyAllocation.Y; y1 = bodyAllocation.Y + bodyAllocation.Height;

                    cr.Arc(x0 + roundSize, y1 - roundSize, roundSize - lineWidth05, Math.PI / 2, Math.PI);
                    cr.Arc(x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3 * Math.PI / 2);
                    cr.Arc(x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3 * Math.PI / 2, 0);
                    cr.Arc(x1 - roundSize, y1 - roundSize, roundSize - lineWidth05, 0, Math.PI / 2);
                    cr.LineTo(x0 + roundSize, y1 - lineWidth05);

                    /*** BACKGOUND ***/
                    cr.Color = c;
                    cr.FillPreserve();

                    /*** DARK BORDER ***/
                    cr.LineWidth = lineWidth;
                    cr.Color     = ColorScheme.GetColorAbsolute(colorScheme.Normal, 0.75);
                    cr.Stroke();

                    /*** GLASS EFFECT ***/
                    double ymid = Math.Round(y0 + (y1 - y0) * 0.25);

                    cr.Arc(x0 + roundSize, y0 + roundSize, roundSize - lineWidth, Math.PI, 3 * Math.PI / 2);
                    cr.Arc(x1 - roundSize, y0 + roundSize, roundSize - lineWidth, 3 * Math.PI / 2, 0);
                    cr.LineTo(x1 - lineWidth, ymid);
                    cr.LineTo(x0 + lineWidth, ymid);
                    cr.LineTo(x0 + lineWidth, y0 + roundSize);
                    linGrad = new LinearGradient(0, y0, 0, ymid);
                    linGrad.AddColorStop(0.0, new Color(0, 0, 0, 0.0));
                    linGrad.AddColorStop(1.0, new Color(0, 0, 0, 0.075));
                    cr.Pattern = linGrad;
                    cr.Fill();

                    cr.Arc(x0 + roundSize, y1 - roundSize, roundSize - lineWidth, Math.PI / 2, Math.PI);
                    cr.LineTo(x0 + lineWidth, ymid);
                    cr.LineTo(x1 - lineWidth, ymid);
                    cr.Arc(x1 - roundSize, y1 - roundSize, roundSize - lineWidth, 0, Math.PI / 2);
                    cr.LineTo(x0 + roundSize, y1 - lineWidth);
                    linGrad = new LinearGradient(0, ymid, 0, y1);
                    linGrad.AddColorStop(0.0, new Color(0, 0, 0, 0.1));
                    linGrad.AddColorStop(0.5, new Color(0, 0, 0, 0.0));
                    cr.Pattern = linGrad;
                    cr.Fill();
                }

                /*** TAB ***/

                Gdk.Rectangle r = p.LabelAllocation;

                x0 = r.X; x1 = r.X + r.Width;
                y0 = r.Y; y1 = r.Y + r.Height + lineWidth;

                /*** TAB :: BACKGROUND ***/

                cr.MoveTo(x0 + lineWidth05, y1);
                cr.LineTo(x0 + lineWidth05, y0 + roundSize);
                cr.Arc(x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3 * Math.PI / 2);
                cr.Arc(x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3 * Math.PI / 2, 0);
                cr.LineTo(x1 - lineWidth05, y1);

                linGrad = new LinearGradient(0, y0, 0, y1);
                linGrad.AddColorStop(0.0, colorScheme.PrettyBright);
                linGrad.AddColorStop(1.0, c);
                cr.Pattern = linGrad;
                cr.Fill();

                /*** TAB :: DARK BORDER ***/

                cr.MoveTo(x0 + lineWidth05, y1);
                cr.LineTo(x0 + lineWidth05, y0 + roundSize);
                cr.Arc(x0 + roundSize, y0 + roundSize, roundSize - lineWidth05, Math.PI, 3 * Math.PI / 2);
                cr.Arc(x1 - roundSize, y0 + roundSize, roundSize - lineWidth05, 3 * Math.PI / 2, 0);
                cr.LineTo(x1 - lineWidth05, y1);

                cr.LineWidth = lineWidth;
                cr.Color     = ColorScheme.GetColorRelative(colorScheme.Bright, -0.1);
                cr.Stroke();

                y1 -= 1.0;

                /*** TAB :: HIGHLIGHT ***/

                cr.MoveTo(x0 + lineWidth15, y1);
                cr.LineTo(x0 + lineWidth15, y0 + roundSize);
                cr.Arc(x0 + roundSize, y0 + roundSize, roundSize - lineWidth15, Math.PI, 3 * Math.PI / 2);
                cr.Arc(x1 - roundSize, y0 + roundSize, roundSize - lineWidth15, 3 * Math.PI / 2, 0);
                cr.LineTo(x1 - lineWidth15, y1);

                cr.LineWidth = lineWidth;
                linGrad      = new LinearGradient(0, y0 + lineWidth, 0, y1);
                linGrad.AddColorStop(0.0, colorScheme.PrettyBright);
                linGrad.AddColorStop(1.0, ColorScheme.SetAlphaChannel(colorScheme.Bright, 0));
                cr.Pattern = linGrad;
                cr.Stroke();

                /*** TAB :: SHADOW ***/

                cr.MoveTo(x0 - lineWidth05, y1);
                cr.LineTo(x0 - lineWidth05, y0 + roundSize);
                cr.Arc(x0 + roundSize, y0 + roundSize, roundSize + lineWidth05, Math.PI, 3 * Math.PI / 2);
                cr.Arc(x1 - roundSize, y0 + roundSize, roundSize + lineWidth05, 3 * Math.PI / 2, 0);
                cr.LineTo(x1 + lineWidth05, y1);

                cr.LineWidth = lineWidth;
                cr.Color     = new Color(0, 0, 0, 0.2);
                cr.Stroke();
            }
        }
예제 #2
0
        /// <summary>Draws a group.</summary>
        internal void DrawGroup(Context cr, Rectangle r, double roundSize, double lineWidth, double space, Pango.Layout l, Gtk.Widget expandButton, RibbonGroup w)
        {
            double         lineWidth05 = lineWidth / 2, lineWidth15 = 3 * lineWidth05;
            LinearGradient linGrad;

            double x0 = r.X + roundSize, x1 = r.X + r.Width - roundSize;
            double y0 = r.Y + roundSize, y1 = r.Y + r.Height - roundSize;

            cr.Arc(x1, y1, roundSize - lineWidth05, 0, Math.PI / 2);
            cr.Arc(x0 + lineWidth, y1, roundSize - lineWidth05, Math.PI / 2, Math.PI);
            cr.Arc(x0, y0, roundSize - lineWidth15, Math.PI, 3 * Math.PI / 2);
            cr.Arc(x1, y0 + lineWidth, roundSize - lineWidth05, 3 * Math.PI / 2, 0);
            cr.LineTo(x1 + roundSize - lineWidth05, y1);
            cr.LineWidth = lineWidth;
            cr.Color     = colorScheme.Bright;
            cr.Stroke();

            if (l != null)
            {
                int lblWidth, lblHeight;
                Pango.CairoHelper.UpdateLayout(cr, l);
                l.GetPixelSize(out lblWidth, out lblHeight);

                double bandHeight = lblHeight + 2 * space;
                cr.Arc(x1, y1, roundSize - lineWidth15, 0, Math.PI / 2);
                cr.Arc(x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI / 2, Math.PI);
                double bandY = y1 + roundSize - 2 * lineWidth - bandHeight;
                cr.LineTo(x0 - roundSize + lineWidth05, bandY);
                cr.LineTo(x1 + roundSize - lineWidth15, bandY);
                linGrad = new LinearGradient(0, bandY, 0, bandY + bandHeight);
                linGrad.AddColorStop(0.0, colorScheme.Dark);
                linGrad.AddColorStop(1.0, colorScheme.PrettyDark);
                cr.Pattern = linGrad;
                cr.Fill();

                double frameSize = 2 * lineWidth + space;
                double availableHorizontalSpace = r.Width - 2 * frameSize;
                if (expandButton.Visible)
                {
                    availableHorizontalSpace -= expandButton.WidthRequest + space;
                }

                cr.Save();
                cr.Rectangle(r.X + frameSize, bandY, availableHorizontalSpace, bandHeight);
                cr.Clip();

                cr.Color = new Color(1, 1, 1);
                Pango.CairoHelper.UpdateLayout(cr, l);
                cr.MoveTo(r.X + frameSize + Math.Max(0, (availableHorizontalSpace - lblWidth) / 2), bandY + space);
                Pango.CairoHelper.ShowLayout(cr, l);

                cr.Restore();
            }

            cr.MoveTo(x1 + roundSize - lineWidth15, y1);
            cr.Arc(x1, y1, roundSize - lineWidth15, 0, Math.PI / 2);
            cr.Arc(x0, y1 - lineWidth, roundSize - lineWidth05, Math.PI / 2, Math.PI);
            cr.Arc(x0, y0, roundSize - lineWidth05, Math.PI, 3 * Math.PI / 2);
            cr.Arc(x1 - lineWidth, y0, roundSize - lineWidth05, 3 * Math.PI / 2, 0);
            cr.LineTo(x1 + roundSize - lineWidth15, y1);
            cr.LineWidth = lineWidth;
            linGrad      = new LinearGradient(0, r.Y, 0, r.Y + r.Height - lineWidth);
            linGrad.AddColorStop(0.0, ColorScheme.GetColorRelative(colorScheme.PrettyDark, 0.1));
            linGrad.AddColorStop(1.0, colorScheme.PrettyDark);
            cr.Pattern = linGrad;
            cr.Stroke();
        }