[gnome-games] ui: Respect 'border-radius' CSS property in GameThumbnail



commit dd8d70631dd8807a2f4a322aa0a583e4f314b353
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Tue Aug 14 22:51:40 2018 +0500

    ui: Respect 'border-radius' CSS property in GameThumbnail
    
    Get border radius from CSS instead of hardcoding it.

 src/ui/game-thumbnail.vala | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/ui/game-thumbnail.vala b/src/ui/game-thumbnail.vala
index bbd3ce9a..2489004b 100644
--- a/src/ui/game-thumbnail.vala
+++ b/src/ui/game-thumbnail.vala
@@ -6,7 +6,6 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
 
        private const double EMBLEM_SCALE = 0.125;
        private const double ICON_SCALE = 0.75;
-       private const double FRAME_RADIUS = 2; // Equal to border-radius in style css.
 
        private Uid _uid;
        public Uid uid {
@@ -123,8 +122,10 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
                if (pixbuf == null)
                        return false;
 
+               var border_radius = (int) context.style.get_property (Gtk.STYLE_PROPERTY_BORDER_RADIUS, 
context.state);
+
                context.cr.set_source_rgb (0, 0, 0);
-               rounded_rectangle (context.cr, 0.5, 0.5, context.width - 1, context.height - 1, FRAME_RADIUS);
+               rounded_rectangle (context.cr, 0.5, 0.5, context.width - 1, context.height - 1, 
border_radius);
                context.cr.fill ();
                draw_pixbuf (context, pixbuf);
                draw_border (context);
@@ -278,9 +279,11 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
        private Cairo.Surface get_mask (DrawingContext context) {
                Cairo.ImageSurface mask = new Cairo.ImageSurface (Cairo.Format.A8, context.width, 
context.height);
 
+               var border_radius = (int) context.style.get_property (Gtk.STYLE_PROPERTY_BORDER_RADIUS, 
context.state);
+
                Cairo.Context cr = new Cairo.Context (mask);
                cr.set_source_rgba (0, 0, 0, 0.9);
-               rounded_rectangle (cr, 0.5, 0.5, context.width - 1, context.height - 1, FRAME_RADIUS);
+               rounded_rectangle (cr, 0.5, 0.5, context.width - 1, context.height - 1, border_radius);
                cr.fill ();
 
                return mask;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]