Exemple #1
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
                                     bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
        {
            color.A *= 0.85;
            Cairo.Color selection_color  = color;
            Cairo.Color selection_stroke = CairoExtensions.ColorShade(selection_color, 0.85);
            selection_stroke.A = color.A;

            if (filled)
            {
                Cairo.Color selection_fill_light = CairoExtensions.ColorShade(selection_color, 1.05);
                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_dark);
                grad.AddColorStop(1, selection_fill_light);

                cr.SetSource(grad);
                cr.Rectangle(x, y, width, height);
                cr.Fill();
                grad.Dispose();
            }

            if (stroked && !filled)
            {
                cr.LineWidth = 1.0;
                cr.SetSourceColor(selection_stroke);
                cr.Rectangle(x + 0.5, y + 0.5, width - 1, height - 1);
                cr.Stroke();
            }
        }
Exemple #2
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
                                     bool filled, bool stroked, Cairo.Color color, CairoCorners corners, bool flat_fill)
        {
            var selection_color     = color;
            var selection_highlight = CairoExtensions.ColorShade(selection_color, 1.24);
            var selection_stroke    = CairoExtensions.ColorShade(selection_color, 0.85);

            selection_highlight.A = 0.5;
            selection_stroke.A    = color.A;
            LinearGradient grad = null;

            if (filled)
            {
                if (flat_fill)
                {
                    cr.SetSourceColor(selection_color);
                }
                else
                {
                    var selection_fill_light = CairoExtensions.ColorShade(selection_color, 1.12);
                    var selection_fill_dark  = selection_color;

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

                    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.SetSource(grad);
                }

                CairoExtensions.RoundedRectangle(cr, x, y, width, height, Context.Radius, corners, true);
                cr.Fill();

                if (grad != null)
                {
                    grad.Dispose();
                }
            }

            if (filled && stroked)
            {
                cr.LineWidth = 1.0;
                cr.SetSourceColor(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.SetSourceColor(selection_stroke);
                CairoExtensions.RoundedRectangle(cr, x + 0.5, y + 0.5, width - 1, height - 1,
                                                 Context.Radius, corners, true);
                cr.Stroke();
            }
        }
        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)
            {
                return;
            }

            double p_x = x;
            double p_y = y;

            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 (fill)
            {
                cr.Rectangle(x, y, width, height);
                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();

            if (!drawBorder)
            {
                if (dispose)
                {
                    ((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)
            {
                ((IDisposable)image).Dispose();
            }
        }
Exemple #4
0
 public override void DrawRowCursor(Cairo.Context cr, int x, int y, int width, int height,
                                    Cairo.Color color, CairoCorners corners)
 {
     cr.LineWidth = 1.25;
     cr.Color     = color;
     CairoExtensions.RoundedRectangle(cr, x + cr.LineWidth / 2.0, y + cr.LineWidth / 2.0,
                                      width - cr.LineWidth, height - cr.LineWidth, Context.Radius, corners, true);
     cr.Stroke();
 }
Exemple #5
0
        public static void RoundedRectangle(Cairo.Context cr, double x, double y, double w, double h,
                                            double r, CairoCorners corners)
        {
            if (r < 0.0001 || corners == CairoCorners.None)
            {
                cr.Rectangle(x, y, w, h);
                return;
            }

            if ((corners & CairoCorners.TopLeft) != 0)
            {
                cr.MoveTo(x + r, y);
            }
            else
            {
                cr.MoveTo(x, y);
            }

            if ((corners & CairoCorners.TopRight) != 0)
            {
                cr.Arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
            }
            else
            {
                cr.LineTo(x + w, y);
            }

            if ((corners & CairoCorners.BottomRight) != 0)
            {
                cr.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
            }
            else
            {
                cr.LineTo(x + w, y + h);
            }

            if ((corners & CairoCorners.BottomLeft) != 0)
            {
                cr.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
            }
            else
            {
                cr.LineTo(x, y + h);
            }

            if ((corners & CairoCorners.TopLeft) != 0)
            {
                cr.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
            }
            else
            {
                cr.LineTo(x, y);
            }
        }
Exemple #6
0
        public void DrawFooterBackground(Cairo.Context cr, Gdk.Rectangle alloc, int top_offset, bool fill)
        {
            Color gtk_background_color = GetWidgetColor(GtkColorClass.Background, StateType.Normal);
            Color gtk_base_color       = GetWidgetColor(GtkColorClass.Base, StateType.Normal);
            Color light_color          = gtk_background_color.ColorShade(1.1);
            Color dark_color           = gtk_background_color.ColorShade(0.95);

            const CairoCorners corners = CairoCorners.BottomLeft | CairoCorners.BottomRight;

            if (fill)
            {
                LinearGradient grad = new LinearGradient(alloc.X, alloc.Y, alloc.X, alloc.Y + alloc.Height);
                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 + top_offset, alloc.Width, alloc.Height - top_offset, BORDER_RADIUS, corners);
                cr.Fill();

                cr.Color = gtk_base_color;
                cr.Rectangle(alloc.X, alloc.Y, alloc.Width, top_offset);
                cr.Fill();
            }
            else
            {
                cr.Color = gtk_base_color;
                cr.RoundedRectangle(alloc.X, alloc.Y, alloc.Width, alloc.Height, BORDER_RADIUS, corners);
                cr.Fill();
            }

            cr.LineWidth = 1.0;
            cr.Translate(alloc.Y + 0.5, alloc.Y - 0.5);

            cr.Color = border_color;
            cr.RoundedRectangle(alloc.X, alloc.Y - 4, alloc.Width - 1, alloc.Height + 4, BORDER_RADIUS, corners);
            cr.Stroke();

            if (fill)
            {
                cr.LineWidth = 1;
                cr.Antialias = Cairo.Antialias.None;
                cr.MoveTo(alloc.X + 1, alloc.Y + 1 + top_offset);
                cr.LineTo(alloc.X + alloc.Width - 1, alloc.Y + 1 + top_offset);
                cr.Stroke();
                cr.Antialias = Cairo.Antialias.Default;
            }
        }
Exemple #7
0
        public ClosableExpander()
        {
            header = new ExpanderHeader(this);
            PackStart(header, false, false, 0);

            contentBox              = new VBox();
            contentBox.ExposeEvent += delegate(object o, ExposeEventArgs args) {
                using (var cr = CairoHelper.Create(args.Event.Window)) {
                    CairoCorners corners = CairoCorners.BottomLeft | CairoCorners.BottomRight;
                    int          r       = 10;
                    CairoExtensions.RoundedRectangle(cr, contentBox.Allocation.X + 0.5, contentBox.Allocation.Y + 0.5, contentBox.Allocation.Width - 1, contentBox.Allocation.Height - 1, r, corners, true);
                    cr.LineWidth = 1;
                    cr.Color     = (Mono.TextEditor.HslColor)Style.Dark(StateType.Normal);
                    cr.Stroke();
                }
            };
            expanded = true;
            PackStart(contentBox, true, true, 0);
            ShowAll();
        }
Exemple #8
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();
        }
Exemple #9
0
        public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            Color gtk_background_color = Colors.GetWidgetColor(GtkColorClass.Background, StateType.Normal);
            Color light_color          = CairoExtensions.ColorShade(gtk_background_color, 1.1);
            Color dark_color           = CairoExtensions.ColorShade(gtk_background_color, 0.95);

            CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;

            using (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.SetSource(grad);
                CairoExtensions.RoundedRectangle(cr, alloc.X, alloc.Y, alloc.Width, alloc.Height, Context.Radius, corners);
                cr.Fill();
            }

            cr.SetSourceColor(border_color);
            cr.Rectangle(alloc.X, alloc.Bottom, alloc.Width, BorderWidth);
            cr.Fill();
        }
Exemple #10
0
        public override void DrawHeaderBackground(Cairo.Context cr, Gdk.Rectangle alloc)
        {
            Cairo.Color gtk_background_color =
                CairoExtensions.GdkRGBAToCairoColor(Widget.StyleContext.GetBackgroundColor(StateFlags.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();
        }
Exemple #11
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
            bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
        {
            color.A *= 0.85;
            Cairo.Color selection_color = color;
            Cairo.Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
            selection_stroke.A = color.A;

            if (filled) {
                Cairo.Color selection_fill_light = CairoExtensions.ColorShade (selection_color, 1.05);
                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_dark);
                grad.AddColorStop (1, selection_fill_light);

                cr.SetSource (grad);
                cr.Rectangle (x, y, width, height);
                cr.Fill ();
                grad.Dispose ();
            }

            if (stroked && !filled) {
                cr.LineWidth = 1.0;
                cr.SetSourceColor (selection_stroke);
                cr.Rectangle (x + 0.5, y + 0.5, width - 1, height - 1);
                cr.Stroke ();
            }
        }
Exemple #12
0
 public abstract void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
                                       bool filled, bool stroked, Cairo.Color color, CairoCorners corners);
Exemple #13
0
        public static void RenderThumbnail (Cairo.Context cr, ImageSurface image, bool dispose,
            double x, double y, double width, double height, double radius,
            bool fill, Cairo.Color fillColor, CairoCorners corners, double scale)
        {
            if (image == null || image.Handle == IntPtr.Zero) {
                image = null;
            }

            double p_x = x;
            double p_y = y;

            if (image != null) {
                double scaled_image_width = scale * image.Width;
                double scaled_image_height = scale * image.Height;

                p_x += (scaled_image_width < width ? (width - scaled_image_width) / 2 : 0) / scale;
                p_y += (scaled_image_height < height ? (height - scaled_image_height) / 2 : 0) / scale;
            }

            cr.Antialias = Cairo.Antialias.Default;

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

                cr.Scale (scale, scale);
                CairoExtensions.RoundedRectangle (cr, p_x, p_y, image.Width, image.Height, radius, corners);
                cr.SetSource (image, p_x, p_y);
                cr.Fill ();
                cr.Scale (1.0/scale, 1.0/scale);
            } 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 ();
                }
            }

            cr.Stroke ();

            if (dispose && image != null) {
                ((IDisposable)image).Dispose ();
            }
        }
Exemple #14
0
            protected override bool OnExposeEvent(EventExpose evnt)
            {
                Style.PaintBox(Style, evnt.Window, StateType.Insensitive, ShadowType.None, Allocation, this, "base", 0, 0, Allocation.Width, Allocation.Height);
                var expanderBounds = GetExpanderBounds();

                using (var cr = CairoHelper.Create(evnt.Window))
                {
                    CairoCorners corners = CairoCorners.TopLeft | CairoCorners.TopRight;
                    if (!container.Expanded)
                    {
                        corners = CairoCorners.All;
                    }
                    int r = 10;
                    CairoExtensions.RoundedRectangle(cr, 0, 0, Allocation.Width, Allocation.Height, r, corners);


                    var lg    = new Cairo.LinearGradient(0, 0, 0, Allocation.Height);
                    var state = mouseOver ? StateType.Prelight : StateType.Normal;

                    lg.AddColorStop(0, (Mono.TextEditor.HslColor)Style.Mid(state));
                    lg.AddColorStop(1, (Mono.TextEditor.HslColor)Style.Dark(state));

                    cr.Pattern = lg;
                    cr.Fill();

                    if (mouseOver)
                    {
                        CairoExtensions.RoundedRectangle(cr, 0, 0, Allocation.Width, Allocation.Height, r, corners);
                        double rx = mx;
                        double ry = my;
                        Cairo.RadialGradient gradient = new Cairo.RadialGradient(rx, ry, Allocation.Width * 2, rx, ry, 2);
                        gradient.AddColorStop(0, new Cairo.Color(0, 0, 0, 0));
                        Cairo.Color color = (Mono.TextEditor.HslColor)Style.Light(StateType.Normal);
                        color.A = 0.2;
                        gradient.AddColorStop(1, color);
                        cr.Pattern = gradient;
                        cr.Fill();
                    }
                    cr.LineWidth = 1;
                    CairoExtensions.RoundedRectangle(cr, 0.5, 0.5, Allocation.Width - 1, Allocation.Height - 1, r, corners);
                    cr.Color = (Mono.TextEditor.HslColor)Style.Dark(StateType.Normal);
                    cr.Stroke();

                    using (var layout = new Pango.Layout(PangoContext))
                    {
                        layout.SetMarkup(Label);
                        int w, h;
                        layout.GetPixelSize(out w, out h);

                        const int padding = 4;
                        cr.MoveTo(expanderBounds.Right + padding, (Allocation.Height - h) / 2);
                        cr.Color = new Cairo.Color(0, 0, 0);
                        cr.ShowLayout(layout);
                    }

                    DrawCloseButton(cr);
                }


                var state2 = mouseOver && !IsCloseSelected ? StateType.Prelight : StateType.Normal;

                Style.PaintExpander(Style,
                                    evnt.Window,
                                    state2,
                                    evnt.Region.Clipbox,
                                    this,
                                    "expander",
                                    expanderBounds.X + expanderBounds.Width / 2, expanderBounds.Y + expanderBounds.Width / 2,
                                    expanderStyle);



                return(true);
            }
Exemple #15
0
 public static void RoundedRectangle(Cairo.Context cr, double x, double y, double w, double h,
     double r, CairoCorners corners)
 {
     RoundedRectangle(cr, x, y, w, h, r, corners, false);
 }
        public static void RoundedRectangle(this Cairo.Context cr, double x, double y, double w, double h,
                                            double r, CairoCorners corners, bool topBottomFallsThrough)
        {
            if (topBottomFallsThrough && corners == CairoCorners.None)
            {
                cr.MoveTo(x, y - r);
                cr.LineTo(x, y + h + r);
                cr.MoveTo(x + w, y - r);
                cr.LineTo(x + w, y + h + r);
                return;
            }
            else if (r < 0.0001 || corners == CairoCorners.None)
            {
                cr.Rectangle(x, y, w, h);
                return;
            }

            if ((corners & (CairoCorners.TopLeft | CairoCorners.TopRight)) == 0 && topBottomFallsThrough)
            {
                y -= r;
                h += r;
                cr.MoveTo(x + w, y);
            }
            else
            {
                if ((corners & CairoCorners.TopLeft) != 0)
                {
                    cr.MoveTo(x + r, y);
                }
                else
                {
                    cr.MoveTo(x, y);
                }

                if ((corners & CairoCorners.TopRight) != 0)
                {
                    cr.Arc(x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
                }
                else
                {
                    cr.LineTo(x + w, y);
                }
            }

            if ((corners & (CairoCorners.BottomLeft | CairoCorners.BottomRight)) == 0 && topBottomFallsThrough)
            {
                h += r;
                cr.LineTo(x + w, y + h);
                cr.MoveTo(x, y + h);
                cr.LineTo(x, y + r);
                cr.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
            }
            else
            {
                if ((corners & CairoCorners.BottomRight) != 0)
                {
                    cr.Arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
                }
                else
                {
                    cr.LineTo(x + w, y + h);
                }

                if ((corners & CairoCorners.BottomLeft) != 0)
                {
                    cr.Arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
                }
                else
                {
                    cr.LineTo(x, y + h);
                }

                if ((corners & CairoCorners.TopLeft) != 0)
                {
                    cr.Arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
                }
                else
                {
                    cr.LineTo(x, y);
                }
            }
        }
Exemple #17
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.SetSourceColor(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)
                {
                    using (var grad = new LinearGradient(x, y, x, y + height)) {
                        grad.AddColorStop(0, fillColor);
                        grad.AddColorStop(1, CairoExtensions.ColorShade(fillColor, 1.3));
                        cr.SetSource(grad);
                        cr.Fill();
                    }
                }

                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.SetSourceColor(cover_border_light_color);
                cr.Stroke();
            }

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

            if (dispose && image != null)
            {
                ((IDisposable)image).Dispose();
            }
        }
Exemple #18
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)
 {
     DrawRowSelection (cr, x, y, width, height, filled, stroked, color, corners, false);
 }
        private void PaintRows(Rectangle clip)
        {
            sort_column_index = -1;
            for (int i = 0; i < column_cache.Length; i++)
            {
                if (!column_cache [i].Column.Visible)
                {
                    continue;
                }

                Column column = column_cache [i].Column;
                if (sortModel == null)
                {
                    continue;
                }

                CellTextHeader column_cell = column.HeaderCell as CellTextHeader;
                if (column_cell == null)
                {
                    continue;
                }

                if (column.IsSortable && sortModel.SortColumn == column)
                {
                    sort_column_index = i;
                }
            }

            if (sort_column_index != -1 && (!pressed_column_is_dragging || pressed_column_index != sort_column_index))
            {
                CachedColumn col = column_cache [sort_column_index];
                Theme.DrawRowRule(cairo_context,
                                  list_rendering_alloc.X + col.X1 - (int)hadjustment.Value,
                                  header_rendering_alloc.Bottom + Theme.BorderWidth,
                                  col.Width, list_rendering_alloc.Height + Theme.InnerBorderWidth * 2);
            }

            clip.Intersect(list_rendering_alloc);
            cairo_context.Rectangle(clip.X, clip.Y, clip.Width, clip.Height);
            cairo_context.Clip();

            cell_context.Clip             = clip;
            cell_context.TextAsForeground = false;

            int vadjustment_value = (int)vadjustment.Value;
            int first_row         = vadjustment_value / RowHeight;
            int last_row;

            try {
                last_row = Math.Min(model.Count, first_row + RowsInView);
            } catch (DbConnectionLostException) {
                last_row = first_row + RowsInView;
            }
            int offset = list_rendering_alloc.Y - vadjustment_value % RowHeight;

            Rectangle selected_focus_alloc = Rectangle.Zero;
            Rectangle single_list_alloc    = new Rectangle();

            single_list_alloc.X      = list_rendering_alloc.X - (int)(hadjustment.Value);
            single_list_alloc.Y      = offset;
            single_list_alloc.Width  = list_rendering_alloc.Width;
            single_list_alloc.Height = RowHeight;

            int selection_height = 0;
            int selection_y      = 0;

            selected_rows.Clear();

            for (int ri = first_row; ri < last_row; ri++)
            {
                if (Selection != null && Selection.Contains(ri))
                {
                    if (selection_height == 0)
                    {
                        selection_y = single_list_alloc.Y;
                    }

                    selection_height += single_list_alloc.Height;
                    selected_rows.Add(ri);

                    if (Selection.FocusedCell.Row == ri)
                    {
                        selected_focus_alloc = single_list_alloc;
                    }
                }
                else
                {
                    if (rules_hint && ri % 2 != 0)
                    {
                        Theme.DrawRowRule(cairo_context, list_rendering_alloc.X, single_list_alloc.Y,
                                          single_list_alloc.Width, single_list_alloc.Height);
                    }

                    if (ri == drag_reorder_row_index && Reorderable)
                    {
                        cairo_context.Save();
                        cairo_context.LineWidth = 1.0;
                        cairo_context.Antialias = Cairo.Antialias.None;
                        cairo_context.MoveTo(single_list_alloc.Left, single_list_alloc.Top);
                        cairo_context.LineTo(single_list_alloc.Right, single_list_alloc.Top);
                        cairo_context.Color = Theme.Colors.GetWidgetColor(GtkColorClass.Text, StateType.Normal);
                        cairo_context.Stroke();
                        cairo_context.Restore();
                    }

                    if (Selection != null && Selection.FocusedCell.Row == ri && !Selection.Contains(ri) && AllowSelect)
                    {
                        CairoCorners corners = CairoCorners.All;

                        if (Selection.Contains(ri - 1))
                        {
                            corners &= ~(CairoCorners.TopLeft | CairoCorners.TopRight);
                        }

                        if (Selection.Contains(ri + 1))
                        {
                            corners &= ~(CairoCorners.BottomLeft | CairoCorners.BottomRight);
                        }

                        Theme.DrawRowSelection(cairo_context, single_list_alloc.X, single_list_alloc.Y,
                                               single_list_alloc.Width, single_list_alloc.Height, false, true,
                                               Theme.Colors.GetWidgetColor(GtkColorClass.Background, StateType.Selected), corners);
                    }

                    if (selection_height > 0)
                    {
                        Theme.DrawRowSelection(cairo_context, list_rendering_alloc.X, selection_y, list_rendering_alloc.Width, selection_height);
                        selection_height = 0;
                    }

                    PaintRow(ri, single_list_alloc, StateType.Normal);
                }

                single_list_alloc.Y += single_list_alloc.Height;
            }

            if (selection_height > 0)
            {
                Theme.DrawRowSelection(cairo_context, list_rendering_alloc.X, selection_y,
                                       list_rendering_alloc.Width, selection_height);
            }

            if (Selection != null && Selection.Count > 1 &&
                !selected_focus_alloc.Equals(Rectangle.Zero) && HasFocus)
            {
                Theme.DrawRowSelection(cairo_context, selected_focus_alloc.X, selected_focus_alloc.Y,
                                       selected_focus_alloc.Width, selected_focus_alloc.Height, false, true,
                                       Theme.Colors.GetWidgetColor(GtkColorClass.Dark, StateType.Selected));
            }

            foreach (int ri in selected_rows)
            {
                single_list_alloc.Y = offset + ((ri - first_row) * single_list_alloc.Height);
                PaintRow(ri, single_list_alloc, StateType.Selected);
            }

            cairo_context.ResetClip();
        }
        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();
        }
        private void PaintRows(Rectangle clip)
        {
            // TODO factor this out?
            // Render the sort effect to the GdkWindow.
            if (sort_column_index != -1 && (!pressed_column_is_dragging || pressed_column_index != sort_column_index))
            {
                CachedColumn col = column_cache[sort_column_index];
                Theme.DrawRowRule(cairo_context,
                                  list_rendering_alloc.X + col.X1 - HadjustmentValue,
                                  header_rendering_alloc.Bottom + Theme.BorderWidth,
                                  col.Width, list_rendering_alloc.Height + Theme.InnerBorderWidth * 2);
            }

            clip.Intersect(list_rendering_alloc);
            cairo_context.Rectangle(clip.X, clip.Y, clip.Width, clip.Height);
            cairo_context.Clip();

            cell_context.Clip             = clip;
            cell_context.TextAsForeground = false;

            int vadjustment_value = VadjustmentValue;
            int first_row         = vadjustment_value / RowHeight;
            int last_row          = Math.Min(model.Count, first_row + RowsInView);
            int offset            = list_rendering_alloc.Y - vadjustment_value % RowHeight;

            Rectangle selected_focus_alloc = Rectangle.Zero;
            Rectangle single_list_alloc    = new Rectangle();

            single_list_alloc.X      = list_rendering_alloc.X - HadjustmentValue;
            single_list_alloc.Y      = offset;
            single_list_alloc.Width  = list_rendering_alloc.Width + HadjustmentValue;
            single_list_alloc.Height = RowHeight;

            int selection_height = 0;
            int selection_y      = 0;

            selected_rows.Clear();

            for (int ri = first_row; ri < last_row; ri++)
            {
                if (Selection != null && Selection.Contains(ri))
                {
                    if (selection_height == 0)
                    {
                        selection_y = single_list_alloc.Y;
                    }

                    selection_height += single_list_alloc.Height;
                    selected_rows.Add(ri);

                    if (Selection.FocusedIndex == ri)
                    {
                        selected_focus_alloc = single_list_alloc;
                    }
                }
                else
                {
                    if (rules_hint && ri % 2 != 0)
                    {
                        Theme.DrawRowRule(cairo_context, single_list_alloc.X, single_list_alloc.Y,
                                          single_list_alloc.Width, single_list_alloc.Height);
                    }

                    PaintReorderLine(ri, single_list_alloc);

                    if (Selection != null && Selection.FocusedIndex == ri && !Selection.Contains(ri) && HasFocus)
                    {
                        CairoCorners corners = CairoCorners.All;

                        if (Selection.Contains(ri - 1))
                        {
                            corners &= ~(CairoCorners.TopLeft | CairoCorners.TopRight);
                        }

                        if (Selection.Contains(ri + 1))
                        {
                            corners &= ~(CairoCorners.BottomLeft | CairoCorners.BottomRight);
                        }

                        if (HasFocus && !HeaderFocused) // Cursor out of selection.
                        {
                            Theme.DrawRowCursor(cairo_context, single_list_alloc.X, single_list_alloc.Y,
                                                single_list_alloc.Width, single_list_alloc.Height,
                                                CairoExtensions.ColorShade(Theme.Colors.GetWidgetColor(GtkColorClass.Background, StateType.Selected), 0.85));
                        }
                    }

                    if (selection_height > 0)
                    {
                        Cairo.Color selection_color = Theme.Colors.GetWidgetColor(GtkColorClass.Background, StateType.Selected);
                        if (!HasFocus || HeaderFocused)
                        {
                            selection_color = CairoExtensions.ColorShade(selection_color, 1.1);
                        }

                        Theme.DrawRowSelection(cairo_context, list_rendering_alloc.X, selection_y, list_rendering_alloc.Width, selection_height,
                                               true, true, selection_color, CairoCorners.All);
                        selection_height = 0;
                    }

                    PaintRow(ri, single_list_alloc, StateType.Normal);
                }

                single_list_alloc.Y += single_list_alloc.Height;
            }

            // In case the user is dragging to the end of the list
            PaintReorderLine(last_row, single_list_alloc);

            if (selection_height > 0)
            {
                Theme.DrawRowSelection(cairo_context, list_rendering_alloc.X, selection_y,
                                       list_rendering_alloc.Width, selection_height);
            }

            if (Selection != null && Selection.Count > 1 &&
                !selected_focus_alloc.Equals(Rectangle.Zero) &&
                HasFocus && !HeaderFocused)   // Cursor inside selection.
            {
                Theme.DrawRowCursor(cairo_context, selected_focus_alloc.X, selected_focus_alloc.Y,
                                    selected_focus_alloc.Width, selected_focus_alloc.Height,
                                    Theme.Colors.GetWidgetColor(GtkColorClass.Text, StateType.Selected));
            }

            foreach (int ri in selected_rows)
            {
                single_list_alloc.Y = offset + ((ri - first_row) * single_list_alloc.Height);
                PaintRow(ri, single_list_alloc, StateType.Selected);
            }

            cairo_context.ResetClip();
        }
Exemple #22
0
		public abstract void DrawRowSelection (Cairo.Context cr, int x, int y, int width, int height, bool filled, bool stroked, Cairo.Color color, CairoCorners corners);
        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();
            }
        }
        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 #25
0
        private void PaintList(Cairo.Context cr, Rectangle clip)
        {
            if (ChildSize.Height <= 0)
            {
                return;
            }

            // TODO factor this out?
            // Render the sort effect to the GdkWindow.
            if (sort_column_index != -1 && (!pressed_column_is_dragging || pressed_column_index != sort_column_index))
            {
                CachedColumn col = column_cache[sort_column_index];
                StyleContext.AddRegion("column", RegionFlags.Sorted);
                StyleContext.RenderBackground(cr,
                                              list_rendering_alloc.X + col.X1 - HadjustmentValue,
                                              header_rendering_alloc.Bottom + Theme.BorderWidth,
                                              col.Width, list_rendering_alloc.Height + Theme.InnerBorderWidth * 2);
                StyleContext.RemoveRegion("column");
            }

            clip.Intersect(list_rendering_alloc);
            cr.Rectangle(clip.X, clip.Y, clip.Width, clip.Height);
            cr.Clip();

            cell_context.Clip             = clip;
            cell_context.TextAsForeground = false;

            int vadjustment_value = VadjustmentValue;
            int first_row         = vadjustment_value / ChildSize.Height;
            int last_row          = Math.Min(model.Count, first_row + RowsInView);
            int offset            = list_rendering_alloc.Y - vadjustment_value % ChildSize.Height;

            Rectangle selected_focus_alloc = Rectangle.Zero;
            Rectangle single_list_alloc    = new Rectangle();

            single_list_alloc.X      = list_rendering_alloc.X - HadjustmentValue;
            single_list_alloc.Y      = offset;
            single_list_alloc.Width  = list_rendering_alloc.Width + HadjustmentValue;
            single_list_alloc.Height = ChildSize.Height;

            int selection_height = 0;
            int selection_y      = 0;

            selected_rows.Clear();

            for (int ri = first_row; ri < last_row; ri++)
            {
                if (Selection != null && Selection.Contains(ri))
                {
                    if (selection_height == 0)
                    {
                        selection_y = single_list_alloc.Y;
                    }

                    selection_height += single_list_alloc.Height;
                    selected_rows.Add(ri);

                    if (Selection.FocusedIndex == ri)
                    {
                        selected_focus_alloc = single_list_alloc;
                    }
                }
                else
                {
                    StyleContext.AddClass("cell");
                    if (rules_hint)   // TODO: check also gtk_widget_style_get(widget,"allow-rules",&allow_rules,NULL);
                    {
                        StyleContext.AddRegion("row", ri % 2 != 0 ? RegionFlags.Odd : RegionFlags.Even);
                    }
                    StyleContext.RenderBackground(cr, single_list_alloc.X, single_list_alloc.Y,
                                                  single_list_alloc.Width, single_list_alloc.Height);
                    StyleContext.RemoveRegion("row");
                    StyleContext.RemoveClass("cell");

                    PaintReorderLine(cr, ri, single_list_alloc);

                    if (Selection != null && Selection.FocusedIndex == ri && !Selection.Contains(ri) && HasFocus)
                    {
                        CairoCorners corners = CairoCorners.All;

                        if (Selection.Contains(ri - 1))
                        {
                            corners &= ~(CairoCorners.TopLeft | CairoCorners.TopRight);
                        }

                        if (Selection.Contains(ri + 1))
                        {
                            corners &= ~(CairoCorners.BottomLeft | CairoCorners.BottomRight);
                        }

                        if (HasFocus && !HeaderFocused) // Cursor out of selection.
                        {
                            Theme.DrawRowCursor(cr, single_list_alloc.X, single_list_alloc.Y,
                                                single_list_alloc.Width, single_list_alloc.Height,
                                                CairoExtensions.ColorShade(CairoExtensions.GdkRGBAToCairoColor(StyleContext.GetBackgroundColor(StateFlags.Selected)), 0.85));
                        }
                    }

                    if (selection_height > 0)
                    {
                        StyleContext.AddClass("cell");
                        var bg_selected_color = StyleContext.GetBackgroundColor(StateFlags.Selected);

                        if (bg_selected_color.Equals(StyleContext.GetBackgroundColor(StateFlags.Normal)))
                        {
                            // see https://bugs.launchpad.net/bugs/1211831
                            Hyena.Log.Warning("Buggy CSS theme: same background-color for .cell:selected and .cell");
                            StyleContext.RemoveClass("cell");
                            bg_selected_color = StyleContext.GetBackgroundColor(StateFlags.Selected);
                            StyleContext.AddClass("cell");
                        }
                        Cairo.Color selection_color = CairoExtensions.GdkRGBAToCairoColor(bg_selected_color);

                        if (!HasFocus || HeaderFocused)
                        {
                            selection_color = CairoExtensions.ColorShade(selection_color, 1.1);
                        }

                        Theme.DrawRowSelection(cr, list_rendering_alloc.X, selection_y, list_rendering_alloc.Width, selection_height,
                                               true, true, selection_color, CairoCorners.All);
                        StyleContext.RemoveClass("cell");
                        selection_height = 0;
                    }

                    PaintRow(cr, ri, single_list_alloc, StateFlags.Normal);
                }

                single_list_alloc.Y += single_list_alloc.Height;
            }

            // In case the user is dragging to the end of the list
            PaintReorderLine(cr, last_row, single_list_alloc);

            if (selection_height > 0)
            {
                Theme.DrawRowSelection(cr, list_rendering_alloc.X, selection_y,
                                       list_rendering_alloc.Width, selection_height);
            }

            if (Selection != null && Selection.Count > 1 &&
                !selected_focus_alloc.Equals(Rectangle.Zero) &&
                HasFocus && !HeaderFocused)   // Cursor inside selection.
            // Use entry to get text color
            {
                StyleContext.Save();
                StyleContext.AddClass("entry");
                Cairo.Color text_color = CairoExtensions.GdkRGBAToCairoColor(StyleContext.GetColor(StateFlags.Selected));
                StyleContext.Restore();

                Theme.DrawRowCursor(cr, selected_focus_alloc.X, selected_focus_alloc.Y,
                                    selected_focus_alloc.Width, selected_focus_alloc.Height, text_color);
            }

            foreach (int ri in selected_rows)
            {
                single_list_alloc.Y = offset + ((ri - first_row) * single_list_alloc.Height);
                PaintRow(cr, ri, single_list_alloc, StateFlags.Selected);
            }

            cr.ResetClip();
        }
Exemple #26
0
 public abstract void DrawRowCursor(Cairo.Context cr, int x, int y, int width, int height, Cairo.Color color, CairoCorners corners);
Exemple #27
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)
        {
            if (!IsSourceViewWidget)
            {
                base.DrawRowSelection(cr, x, y, width, height, filled,
                                      stroked, color, corners, true);
                return;
            }

            y      -= 1;
            x      -= 1;
            width  += 1;
            height += 1;

            color = TextMidColor;

            base.DrawRowSelection(cr, x, y, width, height,
                                  filled, false, color, corners, true);

            if (stroked)
            {
                cr.Color     = color;
                cr.LineWidth = 1.0;
                cr.Antialias = Cairo.Antialias.None;

                cr.MoveTo(x, y);
                cr.LineTo(x + width, y);
                cr.Stroke();

                cr.MoveTo(x, y + height);
                cr.LineTo(x + width, y + height);
                cr.Stroke();

                cr.Antialias = Cairo.Antialias.Default;
            }
        }
Exemple #28
0
 public override void DrawRowCursor(Cairo.Context cr, int x, int y, int width, int height,
                                     Cairo.Color color, CairoCorners corners)
 {
     cr.LineWidth = 1.25;
     cr.Color = color;
     CairoExtensions.RoundedRectangle (cr, x + cr.LineWidth/2.0, y + cr.LineWidth/2.0,
         width - cr.LineWidth, height - cr.LineWidth, Context.Radius, corners, true);
     cr.Stroke ();
 }
Exemple #29
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)
        {
            if (!IsSourceViewWidget) {
                base.DrawRowSelection (cr, x, y, width, height, filled,
                    stroked, color, corners, true);
                return;
            }

            y -= 1;
            x -= 1;
            width += 1;
            height += 1;

            color = TextMidColor;

            base.DrawRowSelection (cr, x, y, width, height,
                filled, false, color, corners, true);

            if (stroked) {
                cr.SetSourceColor (color);
                cr.LineWidth = 1.0;
                cr.Antialias = Cairo.Antialias.None;

                cr.MoveTo (x, y);
                cr.LineTo (x + width, y);
                cr.Stroke ();

                cr.MoveTo (x, y + height);
                cr.LineTo (x + width, y + height);
                cr.Stroke ();

                cr.Antialias = Cairo.Antialias.Default;
            }
        }
Exemple #30
0
        public void DrawRowSelection(Cairo.Context cr, int x, int y, int width, int height,
            bool filled, bool stroked, Cairo.Color color, CairoCorners corners, bool flat_fill)
        {
            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;
            LinearGradient grad = null;

            if (filled) {
                if (flat_fill) {
                    cr.Color = selection_color;
                } else {
                    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;

                    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 ();

                if (grad != null) {
                    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 #31
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)
 {
     DrawRowSelection(cr, x, y, width, height, filled, stroked, color, corners, false);
 }
 public static void RoundedRectangle(this Cairo.Context cr, double x, double y, double w, double h,
                                     double r, CairoCorners corners)
 {
     RoundedRectangle(cr, x, y, w, h, r, corners, false);
 }
Exemple #33
0
 public abstract void DrawRowCursor(Cairo.Context cr, int x, int y, int width, int height, Cairo.Color color, CairoCorners corners);
Exemple #34
0
		public static void RoundedRectangle (Cairo.Context cr, double x, double y, double w, double h, 
						     double r, CairoCorners corners)
		{
			if (r < 0.0001 || corners == CairoCorners.None) {
				cr.Rectangle (x, y, w, h);
				return;
			}
			
			if ((corners & CairoCorners.TopLeft) != 0) {
				cr.MoveTo (x + r, y);
			} else {
				cr.MoveTo (x, y);
			}
			
			if ((corners & CairoCorners.TopRight) != 0) {
				cr.Arc (x + w - r, y + r, r, Math.PI * 1.5, Math.PI * 2);
			} else {
				cr.LineTo (x + w, y);
			}
			
			if ((corners & CairoCorners.BottomRight) != 0) {
				cr.Arc (x + w - r, y + h - r, r, 0, Math.PI * 0.5);
			} else {
				cr.LineTo (x + w, y + h);
			}
			
			if ((corners & CairoCorners.BottomLeft) != 0) {
				cr.Arc (x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
			} else {
				cr.LineTo (x, y + h);
			}
			
			if ((corners & CairoCorners.TopLeft) != 0) {
				cr.Arc (x + r, y + r, r, Math.PI, Math.PI * 1.5);
			} else {
				cr.LineTo (x, y);
			}
		}
Exemple #35
0
        public override void DrawRowSelection(Context cr, int x, int y, int width, int height, bool filled, bool stroked, Cairo.Color color, CairoCorners corners)
        {
            Color selection_color = color;
            Color selection_highlight = CairoExtensions.ColorShade (selection_color, 1.24);
            Color selection_stroke = CairoExtensions.ColorShade (selection_color, 0.85);
            selection_highlight.A = 0.5;
            selection_stroke.A = color.A;

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

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

                using (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.SetSource (grad);
                    CairoExtensions.RoundedRectangle (cr, x, y, width, height, Context.Radius, corners, true);
                    cr.Fill ();
                }
            }

            if (filled && stroked) {
                cr.LineWidth = 1.0;
                cr.SetSourceColor (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.SetSourceColor (selection_stroke);
                CairoExtensions.RoundedRectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1, Context.Radius, corners, true);
                cr.Stroke ();
            }
        }
		public static void RoundedRectangle(Cairo.Context cr, double x, double y, double w, double h,
		                                    double r, CairoCorners corners, bool topBottomFallsThrough)
		{
			if(topBottomFallsThrough && corners == CairoCorners.None) {
				cr.MoveTo(x, y - r);
				cr.LineTo(x, y + h + r);
				cr.MoveTo(x + w, y - r);
				cr.LineTo(x + w, y + h + r);
				return;
			} else if(r < 0.0001 || corners == CairoCorners.None) {
				cr.Rectangle(x, y, w, h);
				return;
			}
			
			if((corners & (CairoCorners.TopLeft | CairoCorners.TopRight)) == 0 && topBottomFallsThrough) {
				y -= r;
				h += r;
				cr.MoveTo(x + w, y);
			} else {
				if((corners & CairoCorners.TopLeft) != 0) {
					cr.MoveTo(x + r, y);
				} else {
					cr.MoveTo(x, y);
				}
				if((corners & CairoCorners.TopRight) != 0) {
					cr.Arc(x + w - r, y + r, r, System.Math.PI * 1.5, System.Math.PI * 2);
				} else {
					cr.LineTo(x + w, y);
				}
			}
			
			if((corners & (CairoCorners.BottomLeft | CairoCorners.BottomRight)) == 0 && topBottomFallsThrough) {
				h += r;
				cr.LineTo(x + w, y + h);
				cr.MoveTo(x, y + h);
				cr.LineTo(x, y + r);
				cr.Arc(x + r, y + r, r, System.Math.PI, System.Math.PI * 1.5);
			} else {
				if((corners & CairoCorners.BottomRight) != 0) {
					cr.Arc(x + w - r, y + h - r, r, 0, System.Math.PI * 0.5);
				} else {
					cr.LineTo(x + w, y + h);
				}
				
				if((corners & CairoCorners.BottomLeft) != 0) {
					cr.Arc(x + r, y + h - r, r, System.Math.PI * 0.5, System.Math.PI);
				} else {
					cr.LineTo(x, y + h);
				}
				
				if((corners & CairoCorners.TopLeft) != 0) {
					cr.Arc(x + r, y + r, r, System.Math.PI, System.Math.PI * 1.5);
				} else {
					cr.LineTo(x, y);
				}
			}
		}
Exemple #37
0
        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  = new Color(56d / 255, 117d / 255, 215d / 255, color.A);
            Color selection_stroke = selection_color.ColorShade(0.85);

            selection_stroke.A = color.A;

            if (filled)
            {
                cr.Color = selection_color;
                cr.RoundedRectangle(x, y, width, height, Context.Radius, corners, true);
                cr.Fill();
            }

            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();
        }