private void RenderBarStrokes(Context cr, int w, int h, int r)
        {
            LinearGradient stroke        = MakeSegmentGradient(h, CairoExtensions.RgbaToColor(0x00000040));
            LinearGradient seg_sep_light = MakeSegmentGradient(h, CairoExtensions.RgbaToColor(0xffffff20));
            LinearGradient seg_sep_dark  = MakeSegmentGradient(h, CairoExtensions.RgbaToColor(0x00000020));

            cr.LineWidth = 1;

            double seg_w = 20;
            double x     = seg_w > r ? seg_w : r;

            while (x <= w - r)
            {
                cr.MoveTo(x - 0.5, 1);
                cr.LineTo(x - 0.5, h - 1);
                cr.Pattern = seg_sep_light;
                cr.Stroke();

                cr.MoveTo(x + 0.5, 1);
                cr.LineTo(x + 0.5, h - 1);
                cr.Pattern = seg_sep_dark;
                cr.Stroke();

                x += seg_w;
            }

            CairoExtensions.RoundedRectangle(cr, 0.5, 0.5, w - 1, h - 1, r);
            cr.Pattern = stroke;
            cr.Stroke();

            stroke.Destroy();
            seg_sep_light.Destroy();
            seg_sep_dark.Destroy();
        }
    static void draw(Cairo.Context gr, int width, int height)
    {
        gr.Scale(width, height);
        gr.LineWidth = 0.04;
        LinearGradient pat;

        pat = new LinearGradient(0.0, 0.0, 0.0, 1.0);
        pat.AddColorStop(1, new Color(0, 0, 0, 1));
        pat.AddColorStop(0, new Color(1, 1, 1, 1));
        gr.Rectangle(new PointD(0, 0),
                     1, 1
                     );

        gr.Pattern = pat;
        gr.Fill();
        pat.Destroy();

        RadialGradient pat2 = new RadialGradient(0.45, 0.4, 0.1,
                                                 0.4, 0.4, 0.5);

        pat2.AddColorStop(0, new Color(1, 1, 1, 1));
        pat2.AddColorStop(1, new Color(0, 0, 0, 1));
        gr.Pattern = pat2;
        gr.Arc(0.5, 0.5, 0.3, 0, 2 * M_PI);
        gr.Fill();
        pat2.Destroy();
    }
Exemple #3
0
        protected override void ClippedRender(Hyena.Data.Gui.CellContext context)
        {
            if (!EnsureLayout())
            {
                return;
            }

            var cr = context.Context;

            Foreground = new Brush(context.Theme.Colors.GetWidgetColor(
                                       context.TextAsForeground ? GtkColorClass.Foreground : GtkColorClass.Text, context.State));

            Brush foreground = Foreground;

            if (!foreground.IsValid)
            {
                return;
            }

            cr.Rectangle(0, 0, RenderSize.Width, RenderSize.Height);
            cr.Clip();

            bool fade = Fade && text_alloc.Width > RenderSize.Width;

            if (fade)
            {
                cr.PushGroup();
            }

            cr.MoveTo(text_alloc.X, text_alloc.Y);
            Foreground.Apply(cr);
            UpdateLayout(GetText(), RenderSize.Width, RenderSize.Height, true);
            if (Hyena.PlatformDetection.IsWindows)
            {
                // FIXME windows; working around some unknown issue with ShowLayout; bgo#644311

                cr.Antialias = Cairo.Antialias.None;
                PangoCairoHelper.LayoutPath(cr, layout, true);
            }
            else
            {
                PangoCairoHelper.ShowLayout(cr, layout);
            }
            cr.Fill();

            TooltipMarkup = layout.IsEllipsized ? last_formatted_text : null;

            if (fade)
            {
                LinearGradient mask = new LinearGradient(RenderSize.Width - 20, 0, RenderSize.Width, 0);
                mask.AddColorStop(0, new Color(0, 0, 0, 1));
                mask.AddColorStop(1, new Color(0, 0, 0, 0));

                cr.PopGroupToSource();
                cr.Mask(mask);
                mask.Destroy();
            }

            cr.ResetClip();
        }
Exemple #4
0
        protected sealed override void PaintSurface(DockySurface surface)
        {
            surface.Clear();

            lock (buffers) {
                if (slideCounter > 0 && slideCounter < slideSteps)
                {
                    double offset = Allocation.Width * Math.Log(slideCounter) / Math.Log(slideSteps);

                    if (MovedLeft)
                    {
                        ShowBuffer(surface, Page, offset - Allocation.Width);
                        ShowBuffer(surface, LastPage, offset);
                    }
                    else
                    {
                        ShowBuffer(surface, Page, Allocation.Width - offset);
                        ShowBuffer(surface, LastPage, -offset);
                    }

                    // fade out the edges during a slide
                    Gradient linpat = new LinearGradient(0, surface.Height / 2, surface.Width, surface.Height / 2);
                    linpat.AddColorStop(0, new Color(1, 1, 1, 1));
                    linpat.AddColorStop(2 * (double)BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
                    linpat.AddColorStop(1 - 2 * (double)BUTTON_SIZE / surface.Width, new Color(1, 1, 1, 0));
                    linpat.AddColorStop(1, new Color(1, 1, 1, 1));

                    surface.Context.Save();
                    surface.Context.Operator = Operator.Source;
                    surface.Context.Color    = new Cairo.Color(0, 0, 0, 0);
                    surface.Context.Mask(linpat);
                    surface.Context.PaintWithAlpha(0);
                    surface.Context.Restore();
                    linpat.Destroy();
                }
                else
                {
                    ShowBuffer(surface, Page, 0);
                }
            }

            // overlay the prev/next arrow buttons
            if (buttonBuffer != null && (buttonBuffer.Width != surface.Width || buttonBuffer.Height != surface.Height))
            {
                ResetButtons();
            }

            if (buttonBuffer == null)
            {
                buttonBuffer = new DockySurface(surface.Width, surface.Height, surface);
                DrawButtonsBuffer();
            }

            buttonBuffer.Internal.Show(surface.Context, 0, 0);
        }
Exemple #5
0
        private void RenderLabels(Context cr)
        {
            if (segments.Count == 0)
            {
                return;
            }

            Pango.Layout layout           = null;
            Gdk.RGBA     rgba             = StyleContext.GetColor(StateFlags);
            Color        text_color       = CairoExtensions.GdkRGBAToCairoColor(rgba);
            Color        box_stroke_color = new Color(0, 0, 0, 0.6);

            int x = 0;

            foreach (Segment segment in segments)
            {
                cr.LineWidth = 1;
                cr.Rectangle(x + 0.5, 2 + 0.5, segment_box_size - 1, segment_box_size - 1);
                LinearGradient grad = MakeSegmentGradient(segment_box_size, segment.Color, true);
                cr.Pattern = grad;
                cr.FillPreserve();
                cr.Color = box_stroke_color;
                cr.Stroke();
                grad.Destroy();

                x += segment_box_size + segment_box_spacing;

                int lw, lh;
                layout = CreateAdaptLayout(layout, false, true);
                layout.SetText(FormatSegmentText(segment));
                layout.GetPixelSize(out lw, out lh);

                cr.MoveTo(x, 0);
                text_color.A = 0.9;
                cr.Color     = text_color;
                PangoCairoHelper.ShowLayout(cr, layout);
                cr.Fill();

                layout = CreateAdaptLayout(layout, true, false);
                layout.SetText(FormatSegmentValue(segment));

                cr.MoveTo(x, lh);
                text_color.A = 0.75;
                cr.Color     = text_color;
                PangoCairoHelper.ShowLayout(cr, layout);
                cr.Fill();

                x += segment.LayoutWidth + segment_label_spacing;
            }

            layout.Dispose();
        }
        public override void DrawColumnHighlight(Context cr, Rectangle alloc, Color color)
        {
            Color light_color = color.ColorShade(1.6);
            Color dark_color  = color.ColorShade(1.3);

            LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom - 1);

            grad.AddColorStop(0, light_color);
            grad.AddColorStop(1, dark_color);

            cr.Pattern = grad;
            cr.Rectangle(alloc.X + 1.5, alloc.Y + 1.5, alloc.Width - 3, alloc.Height - 2);
            cr.Fill();
            grad.Destroy();
        }
Exemple #7
0
        public override void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
                                              bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
        {
            Cairo.Color selection_color     = color;
            Cairo.Color selection_highlight = CairoExtensions.ColorShade(selection_color, 1.24);
            Cairo.Color selection_stroke    = CairoExtensions.ColorShade(selection_color, 0.85);
            selection_highlight.A = 0.5;
            selection_stroke.A    = color.A;

            if (filled)
            {
                Cairo.Color selection_fill_light = CairoExtensions.ColorShade(selection_color, 1.12);
                Cairo.Color selection_fill_dark  = selection_color;

                selection_fill_light.A = color.A;
                selection_fill_dark.A  = color.A;

                LinearGradient grad = new LinearGradient(x, y, x, y + height);
                grad.AddColorStop(0, selection_fill_light);
                grad.AddColorStop(0.4, selection_fill_dark);
                grad.AddColorStop(1, selection_fill_light);

                cr.Pattern = grad;
                CairoExtensions.RoundedRectangle(cr, x, y, width, height, Context.Radius, corners, true);
                cr.Fill();
                grad.Destroy();
            }

            if (filled && stroked)
            {
                cr.LineWidth = 1.0;
                cr.Color     = selection_highlight;
                CairoExtensions.RoundedRectangle(cr, x + 1.5, y + 1.5, width - 3, height - 3,
                                                 Context.Radius - 1, corners, true);
                cr.Stroke();
            }

            if (stroked)
            {
                cr.LineWidth = 1.0;
                cr.Color     = selection_stroke;
                CairoExtensions.RoundedRectangle(cr, x + 0.5, y + 0.5, width - 1, height - 1,
                                                 Context.Radius, corners, true);
                cr.Stroke();
            }
        }
Exemple #8
0
        public override void DrawHeaderSortBackground(Context cr, Rectangle alloc)
        {
            //Do not overlap the column divider on the left
            alloc.X     += 2;
            alloc.Width -= 2;

            LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom);

            grad.AddColorStop(0.0, new Color(205d / 255d, 228d / 255d, 248d / 255d));
            grad.AddColorStop(0.4, new Color(145d / 255d, 196d / 255d, 240d / 255d));
            grad.AddColorStop(0.6, new Color(136d / 255d, 192d / 255d, 242d / 255d));
            grad.AddColorStop(1.0, new Color(188d / 255d, 230d / 255d, 246d / 255d));

            cr.Pattern = grad;
            cr.Rectangle(alloc.X, alloc.Y, alloc.Width, alloc.Height - BorderWidth);
            cr.Fill();

            grad.Destroy();
        }
Exemple #9
0
        protected override void ClippedRender(Context cr)
        {
            if (!EnsureLayout())
            {
                return;
            }

            Brush foreground = Foreground;

            if (!foreground.IsValid)
            {
                return;
            }

            cr.Rectangle(0, 0, RenderSize.Width, RenderSize.Height);
            cr.Clip();

            bool fade = text_alloc.Width > RenderSize.Width;

            if (fade)
            {
                cr.PushGroup();
            }

            cr.MoveTo(text_alloc.X, text_alloc.Y);
            Foreground.Apply(cr);
            Pango.CairoHelper.ShowLayout(cr, layout);
            cr.Fill();

            if (fade)
            {
                LinearGradient mask = new LinearGradient(RenderSize.Width - 20, 0, RenderSize.Width, 0);
                mask.AddColorStop(0, new Color(0, 0, 0, 1));
                mask.AddColorStop(1, new Color(0, 0, 0, 0));

                cr.PopGroupToSource();
                cr.Mask(mask);
                mask.Destroy();
            }

            cr.ResetClip();
        }
Exemple #10
0
        public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;

            LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom);

            grad.AddColorStop(0, CairoExtensions.RgbToColor(0xf6f3f3));
            grad.AddColorStop(0.33, CairoExtensions.RgbToColor(0xeeecec));
            grad.AddColorStop(0.66, CairoExtensions.RgbToColor(0xeeecec));
            grad.AddColorStop(1, CairoExtensions.RgbToColor(0xe1dfdf));

            cr.Pattern = grad;
            CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
            cr.Fill();

            cr.Color = CairoExtensions.RgbToColor(0x919191);
            cr.Rectangle(alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
            cr.Fill();
            grad.Destroy();
        }
        public override void DrawFooterBackground(Context cr, Rectangle alloc)
        {
            Color gtk_background_color = Colors.GetWidgetColor(GtkColorClass.Background, StateType.Normal);
            Color light_color          = gtk_background_color.ColorShade(1.05);
            Color dark_color           = gtk_background_color.ColorShade(0.92);

            LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom);

            grad.AddColorStop(0, light_color);
            grad.AddColorStop(0.75, dark_color);
            grad.AddColorStop(0, light_color);

            cr.Pattern = grad;
            cr.RoundedRectangle(alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, CairoCorners.BottomLeft | CairoCorners.BottomRight);
            cr.Fill();

            cr.Color = border_color;
            cr.Rectangle(alloc.X, alloc.Y, alloc.Width, BorderWidth);
            cr.Fill();
            grad.Destroy();
        }
Exemple #12
0
        public override void DrawHeaderBackground(Context cr, Rectangle alloc)
        {
            LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom);

            grad.AddColorStop(0.0, new Color(255d / 255d, 255d / 255d, 255d / 255d));
            grad.AddColorStop(0.2, new Color(255d / 255d, 255d / 255d, 255d / 255d));
            grad.AddColorStop(0.2, new Color(252d / 255d, 252d / 255d, 252d / 255d));
            grad.AddColorStop(0.5, new Color(244d / 255d, 244d / 255d, 244d / 255d));
            grad.AddColorStop(0.5, new Color(236d / 255d, 236d / 255d, 236d / 255d));
            grad.AddColorStop(0.8, new Color(236d / 255d, 236d / 255d, 236d / 255d));
            grad.AddColorStop(1.0, new Color(244d / 255d, 244d / 255d, 244d / 255d));

            cr.Pattern = grad;
            cr.RoundedRectangle(alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, CairoCorners.TopLeft | CairoCorners.TopRight);
            cr.Fill();
            grad.Destroy();

            cr.Color = border_color;
            cr.Rectangle(alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
            cr.Fill();
        }
        public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            Cairo.Color gtk_background_color = Colors.GetWidgetColor(GtkColorClass.Background, StateType.Normal);
            Cairo.Color light_color          = CairoExtensions.ColorShade(gtk_background_color, 1.1);
            Cairo.Color dark_color           = CairoExtensions.ColorShade(gtk_background_color, 0.95);

            CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;

            LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Bottom);

            grad.AddColorStop(0, light_color);
            grad.AddColorStop(0.75, dark_color);
            grad.AddColorStop(0, light_color);

            cr.Pattern = grad;
            CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
            cr.Fill();

            cr.Color = border_color;
            cr.Rectangle(alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
            cr.Fill();
            grad.Destroy();
        }
        public override void DrawRowSelection(Context cr, int x, int y, int width, int height,
                                              bool filled, bool stroked, Color color, CairoCorners corners = CairoCorners.All)
        {
            Color selection_color  = color;
            Color selection_stroke = selection_color.ColorShade(0.85);

            selection_stroke.A = color.A;

            if (filled)
            {
                Color selection_fill_light = selection_color.ColorShade(1.12);
                Color selection_fill_dark  = selection_color;

                selection_fill_light.A = color.A;
                selection_fill_dark.A  = color.A;

                LinearGradient grad = new LinearGradient(x, y, x, y + height);
                grad.AddColorStop(0, selection_fill_light);
                grad.AddColorStop(0.4, selection_fill_dark);
                grad.AddColorStop(1, selection_fill_light);

                cr.Pattern = grad;
                cr.RoundedRectangle(x, y, width, height, Context.Radius, corners, true);
                cr.Fill();
                grad.Destroy();
            }

            if (!stroked)
            {
                return;
            }

            cr.LineWidth = 1.0;
            cr.Color     = selection_stroke;
            cr.RoundedRectangle(x + 0.5, y + 0.5, width - 1, height - 1, Context.Radius, corners, true);
            cr.Stroke();
        }
        protected override void PaintIconSurface(DockySurface surface)
        {
            int     size = Math.Min(surface.Width, surface.Height);
            Context cr   = surface.Context;

            double center = size / 2.0;

            Cairo.Color base_color = new Cairo.Color(1, .3, .3, .5).SetHue(120 * (1 - CPUUtilization));

            double radius = Math.Max(Math.Min(CPUUtilization * 1.3, 1), .001);

            // draw underlay
            cr.Arc(center, center, center * RadiusPercent, 0, Math.PI * 2);
            cr.Color = new Cairo.Color(0, 0, 0, .5);
            cr.FillPreserve();

            RadialGradient rg = new RadialGradient(center, center, 0, center, center, center * RadiusPercent);

            rg.AddColorStop(0, base_color);
            rg.AddColorStop(0.2, base_color);
            rg.AddColorStop(1, new Cairo.Color(base_color.R, base_color.G, base_color.B, 0.15));
            cr.Pattern = rg;
            cr.FillPreserve();

            rg.Destroy();

            // draw cpu indicator
            rg = new RadialGradient(center, center, 0, center, center, center * RadiusPercent * radius);
            rg.AddColorStop(0, new Cairo.Color(base_color.R, base_color.G, base_color.B, 1));
            rg.AddColorStop(0.2, new Cairo.Color(base_color.R, base_color.G, base_color.B, 1));
            rg.AddColorStop(1, new Cairo.Color(base_color.R, base_color.G, base_color.B, Math.Max(0, CPUUtilization * 1.3 - 1)));
            cr.Pattern = rg;
            cr.Fill();

            rg.Destroy();

            // draw highlight
            cr.Arc(center, center * .8, center * .6, 0, Math.PI * 2);
            LinearGradient lg = new LinearGradient(0, 0, 0, center);

            lg.AddColorStop(0, new Cairo.Color(1, 1, 1, .35));
            lg.AddColorStop(1, new Cairo.Color(1, 1, 1, 0));
            cr.Pattern = lg;
            cr.Fill();
            lg.Destroy();

            // draw outer circles
            cr.LineWidth = 1;
            cr.Arc(center, center, center * RadiusPercent, 0, Math.PI * 2);
            cr.Color = new Cairo.Color(1, 1, 1, .75);
            cr.Stroke();

            cr.LineWidth = 1;
            cr.Arc(center, center, center * RadiusPercent - 1, 0, Math.PI * 2);
            cr.Color = new Cairo.Color(.8, .8, .8, .75);
            cr.Stroke();

            // draw memory indicate
            cr.LineWidth = size / 32.0;
            cr.ArcNegative(center, center, center * RadiusPercent - 1, Math.PI, Math.PI - Math.PI * (2 * MemoryUtilization));
            cr.Color = new Cairo.Color(1, 1, 1, .8);
            cr.Stroke();
        }
        protected override bool OnExposeEvent(Gdk.EventExpose evnt)
        {
            if (evnt.Window != GdkWindow)
            {
                return(base.OnExposeEvent(evnt));
            }

            Cairo.Context cr = Gdk.CairoHelper.Create(evnt.Window);

            if (reflect)
            {
                CairoExtensions.PushGroup(cr);
            }

            cr.Operator = Operator.Over;
            cr.Translate(Allocation.X + h_padding, Allocation.Y);
            cr.Rectangle(0, 0, Allocation.Width - h_padding, Math.Max(2 * bar_height,
                                                                      bar_height + bar_label_spacing + layout_height));
            cr.Clip();

            Pattern bar = RenderBar(Allocation.Width - 2 * h_padding, bar_height);

            cr.Save();
            cr.Source = bar;
            cr.Paint();
            cr.Restore();

            if (reflect)
            {
                cr.Save();

                cr.Rectangle(0, bar_height, Allocation.Width - h_padding, bar_height);
                cr.Clip();

                Matrix matrix = new Matrix();
                matrix.InitScale(1, -1);
                matrix.Translate(0, -(2 * bar_height) + 1);
                cr.Transform(matrix);

                cr.Pattern = bar;

                LinearGradient mask = new LinearGradient(0, 0, 0, bar_height);

                mask.AddColorStop(0.25, new Color(0, 0, 0, 0));
                mask.AddColorStop(0.5, new Color(0, 0, 0, 0.125));
                mask.AddColorStop(0.75, new Color(0, 0, 0, 0.4));
                mask.AddColorStop(1.0, new Color(0, 0, 0, 0.7));

                cr.Mask(mask);
                mask.Destroy();

                cr.Restore();

                CairoExtensions.PopGroupToSource(cr);
                cr.Paint();
            }

            if (show_labels)
            {
                cr.Translate((reflect ? Allocation.X : -h_padding) + (Allocation.Width - layout_width) / 2,
                             (reflect ? Allocation.Y : 0) + bar_height + bar_label_spacing);

                RenderLabels(cr);
            }

            bar.Destroy();
            ((IDisposable)cr.Target).Dispose();
            ((IDisposable)cr).Dispose();

            return(true);
        }
Exemple #17
0
        protected override void PaintIconSurface(DockySurface surface)
        {
            if (DeskGrid == null)
            {
                return;
            }

            int cols = DeskGrid.GetLength(0);
            int rows = DeskGrid.GetLength(1);

            Gdk.Color   gdkColor        = Style.Backgrounds [(int)Gtk.StateType.Selected];
            Cairo.Color selection_color = new Cairo.Color((double)gdkColor.Red / ushort.MaxValue,
                                                          (double)gdkColor.Green / ushort.MaxValue,
                                                          (double)gdkColor.Blue / ushort.MaxValue,
                                                          0.5);
            Context cr = surface.Context;

            cr.AlphaPaint();

            LinearGradient lg = new LinearGradient(0, 0, 0, surface.Height);

            lg.AddColorStop(0, new Cairo.Color(.35, .35, .35, .6));
            lg.AddColorStop(1, new Cairo.Color(.05, .05, .05, .7));

            for (int x = 0; x < cols; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    if (DeskGrid[x, y] != null)
                    {
                        Cairo.Rectangle area = DeskAreaOnIcon(surface.Width, surface.Height, x, y);
                        cr.Rectangle(area.X, area.Y, area.Width, area.Height);
                        cr.Pattern = lg;
                        cr.FillPreserve();
                        if (DeskGrid[x, y].IsActive)
                        {
                            cr.Color = selection_color;
                            cr.Fill();
                            if (area.Width >= 16 && area.Height >= 16)
                            {
                                using (Gdk.Pixbuf pbuf = DockServices.Drawing.LoadIcon("desktop", (int)area.Width, (int)area.Height)) {
                                    Gdk.CairoHelper.SetSourcePixbuf(cr, pbuf, (int)area.X + (area.Width - pbuf.Width) / 2, (int)area.Y + (area.Height - pbuf.Height) / 2);
                                    cr.Paint();
                                }
                            }
                        }
                        cr.NewPath();
                    }
                }
            }

            lg.Destroy();

            for (int x = 0; x < cols; x++)
            {
                for (int y = 0; y < rows; y++)
                {
                    if (DeskGrid[x, y] != null)
                    {
                        Cairo.Rectangle area = DeskAreaOnIcon(surface.Width, surface.Height, x, y);
                        cr.Rectangle(area.X, area.Y, area.Width, area.Height);
                    }
                }
            }

            lg = new LinearGradient(0, 0, 0, surface.Height);
            lg.AddColorStop(0, new Cairo.Color(.95, .95, .95, .7));
            lg.AddColorStop(1, new Cairo.Color(.5, .5, .5, .7));
            cr.Pattern = lg;
            cr.StrokePreserve();
            lg.Destroy();
        }
Exemple #18
0
        void PaintProgressSurface(DockySurface surface)
        {
            if (Progress <= 0)
            {
                return;
            }

            double padding = 2.0;
            double width   = surface.Width - 2 * padding;
            double height  = Math.Min(26.0, 0.18 * surface.Height);
            double x       = padding;
            double y       = surface.Height - height - padding;

            double lineSize = 1.0;

            surface.Context.LineWidth = lineSize;

            // draw the outer stroke
            x      += lineSize / 2.0;
            y      += lineSize / 2.0;
            width  -= lineSize;
            height -= lineSize;

            LinearGradient outer_stroke = new LinearGradient(0, y, 0, y + height);

            outer_stroke.AddColorStop(0, new Cairo.Color(0, 0, 0, 0.3));
            outer_stroke.AddColorStop(1, new Cairo.Color(1, 1, 1, 0.3));

            DrawRoundedLine(surface, x, y, width, height, true, true, outer_stroke, null);
            outer_stroke.Destroy();

            // draw the finished stroke/fill
            x      += lineSize;
            y      += lineSize;
            width  -= 2 * lineSize;
            height -= 2 * lineSize;
            double finishedWidth = Progress * width - lineSize / 2.0;

            LinearGradient finished_stroke = new LinearGradient(0, y, 0, y + height);

            finished_stroke.AddColorStop(0, new Cairo.Color(67 / 255.0, 165 / 255.0, 226 / 255.0, 1));
            finished_stroke.AddColorStop(1, new Cairo.Color(32 / 255.0, 94 / 255.0, 136 / 255.0, 1));
            LinearGradient finished_fill = new LinearGradient(0, y, 0, y + height);

            finished_fill.AddColorStop(0, new Cairo.Color(91 / 255.0, 174 / 255.0, 226 / 255.0, 1));
            finished_fill.AddColorStop(1, new Cairo.Color(35 / 255.0, 115 / 255.0, 164 / 255.0, 1));

            DrawRoundedLine(surface, x, y, finishedWidth, height, true, false, finished_stroke, finished_fill);
            finished_stroke.Destroy();
            finished_fill.Destroy();

            // draw the remaining stroke/fill
            LinearGradient remaining_stroke = new LinearGradient(0, y, 0, y + height);

            remaining_stroke.AddColorStop(0, new Cairo.Color(82 / 255.0, 82 / 255.0, 82 / 255.0, 1));
            remaining_stroke.AddColorStop(1, new Cairo.Color(148 / 255.0, 148 / 255.0, 148 / 255.0, 1));
            LinearGradient remaining_fill = new LinearGradient(0, y, 0, y + height);

            remaining_fill.AddColorStop(0, new Cairo.Color(106 / 255.0, 106 / 255.0, 106 / 255.0, 1));
            remaining_fill.AddColorStop(1, new Cairo.Color(159 / 255.0, 159 / 255.0, 159 / 255.0, 1));

            DrawRoundedLine(surface, x + finishedWidth + lineSize, y, width - finishedWidth, height, false, true, remaining_stroke, remaining_fill);
            remaining_stroke.Destroy();
            remaining_fill.Destroy();

            // draw the highlight on the finished part
            x      += lineSize;
            y      += lineSize;
            width  -= lineSize;
            height -= 2 * lineSize;

            LinearGradient finished_highlight = new LinearGradient(0, y, 0, y + height);

            finished_highlight.AddColorStop(0, new Cairo.Color(1, 1, 1, 0.3));
            finished_highlight.AddColorStop(0.2, new Cairo.Color(1, 1, 1, 0));

            DrawRoundedLine(surface, x, y, finishedWidth, height, true, false, finished_highlight, null);
            finished_highlight.Destroy();
        }
Exemple #19
0
        public static void RenderThumbnail(Cairo.Context cr, ImageSurface image, bool dispose,
                                           double x, double y, double width, double height, bool drawBorder, double radius,
                                           bool fill, Color fillColor, CairoCorners corners)
        {
            if (image == null || image.Handle == IntPtr.Zero)
            {
                image = null;
            }

            double p_x = x;
            double p_y = y;

            if (image != null)
            {
                p_x += image.Width < width ? (width - image.Width) / 2 : 0;
                p_y += image.Height < height ? (height - image.Height) / 2 : 0;
            }

            cr.Antialias = Cairo.Antialias.Default;

            if (image != null)
            {
                if (fill)
                {
                    CairoExtensions.RoundedRectangle(cr, x, y, width, height, radius, corners);
                    cr.Color = fillColor;
                    cr.Fill();
                }

                CairoExtensions.RoundedRectangle(cr, p_x, p_y, image.Width, image.Height, radius, corners);
                cr.SetSource(image, p_x, p_y);
                cr.Fill();
            }
            else
            {
                CairoExtensions.RoundedRectangle(cr, x, y, width, height, radius, corners);

                if (fill)
                {
                    var grad = new LinearGradient(x, y, x, y + height);
                    grad.AddColorStop(0, fillColor);
                    grad.AddColorStop(1, CairoExtensions.ColorShade(fillColor, 1.3));
                    cr.Pattern = grad;
                    cr.Fill();
                    grad.Destroy();
                }

                Banshee.CairoGlyphs.BansheeLineLogo.Render(cr,
                                                           new Rectangle(x + 15, y + 15, width - 30, height - 30),
                                                           CairoExtensions.RgbaToColor(0x00000044),
                                                           CairoExtensions.RgbaToColor(0x00000055));
            }

            if (!drawBorder)
            {
                if (dispose && image != null)
                {
                    ((IDisposable)image).Dispose();
                }

                return;
            }

            cr.LineWidth = 1.0;
            if (radius < 1)
            {
                cr.Antialias = Antialias.None;

                CairoExtensions.RoundedRectangle(cr, x + 1.5, y + 1.5, width - 3, height - 3, radius, corners);
                cr.Color = cover_border_light_color;
                cr.Stroke();
            }

            CairoExtensions.RoundedRectangle(cr, x + 0.5, y + 0.5, width - 1, height - 1, radius, corners);
            cr.Color = cover_border_dark_color;
            cr.Stroke();

            if (dispose && image != null)
            {
                ((IDisposable)image).Dispose();
            }
        }
Exemple #20
0
        protected override bool OnDrawn(Cairo.Context cr)
        {
            if (!CairoHelper.ShouldDrawWindow(cr, Window))
            {
                return(base.OnDrawn(cr));
            }

            if (reflect)
            {
                CairoExtensions.PushGroup(cr);
            }

            cr.Operator = Operator.Over;
            cr.Translate(h_padding, 0);
            cr.Rectangle(0, 0, Allocation.Width - h_padding, Math.Max(2 * bar_height,
                                                                      bar_height + bar_label_spacing + layout_height));
            cr.Clip();

            Pattern bar = RenderBar(Allocation.Width - 2 * h_padding, bar_height);

            cr.Save();
            cr.Source = bar;
            cr.Paint();
            cr.Restore();

            if (reflect)
            {
                cr.Save();

                cr.Rectangle(0, bar_height, Allocation.Width - h_padding, bar_height);
                cr.Clip();

                Matrix matrix = new Matrix();
                matrix.InitScale(1, -1);
                matrix.Translate(0, -(2 * bar_height) + 1);
                cr.Transform(matrix);

                cr.Pattern = bar;

                LinearGradient mask = new LinearGradient(0, 0, 0, bar_height);

                mask.AddColorStop(0.25, new Color(0, 0, 0, 0));
                mask.AddColorStop(0.5, new Color(0, 0, 0, 0.125));
                mask.AddColorStop(0.75, new Color(0, 0, 0, 0.4));
                mask.AddColorStop(1.0, new Color(0, 0, 0, 0.7));

                cr.Mask(mask);
                mask.Destroy();

                cr.Restore();

                CairoExtensions.PopGroupToSource(cr);
                cr.Paint();
            }

            if (show_labels)
            {
                cr.Translate((reflect ? 0 : -h_padding) + (Allocation.Width - layout_width) / 2,
                             bar_height + bar_label_spacing);
                RenderLabels(cr);
            }

            bar.Destroy();

            return(true);
        }