[gnome-games] game-thumbnail: Scale emblem icon



commit f9bc25193e101b9a9fec3550bc2bb8ee3ca3a4b8
Author: theawless <theawless gmail com>
Date:   Tue Jul 3 00:50:16 2018 +0530

    game-thumbnail: Scale emblem icon
    
    This commit allows the emblem to have a relative size to the thumbnail.
    This will make game thumbnail reusable.

 src/ui/game-thumbnail.vala | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/ui/game-thumbnail.vala b/src/ui/game-thumbnail.vala
index 33944281..c85d4697 100644
--- a/src/ui/game-thumbnail.vala
+++ b/src/ui/game-thumbnail.vala
@@ -4,6 +4,7 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
        private const Gtk.CornerType[] right_corners = { Gtk.CornerType.TOP_RIGHT, 
Gtk.CornerType.BOTTOM_RIGHT };
        private const Gtk.CornerType[] bottom_corners = { Gtk.CornerType.BOTTOM_LEFT, 
Gtk.CornerType.BOTTOM_RIGHT };
 
+       private const double EMBLEM_SCALE = 0.125;
        private const double ICON_SCALE = 0.75;
        private const double COVER_MARGIN = 0;
        private const double FRAME_RADIUS = 2;
@@ -127,18 +128,19 @@ private class Games.GameThumbnail: Gtk.DrawingArea {
 
        public void draw_default (DrawingContext context) {
                draw_background (context);
-               draw_emblem_icon (context, "applications-games-symbolic", center_emblem_size);
+               draw_emblem_icon (context, "applications-games-symbolic", EMBLEM_SCALE);
                draw_border (context);
        }
 
-       private void draw_emblem_icon (DrawingContext context, string icon_name, int size) {
+       private void draw_emblem_icon (DrawingContext context, string icon_name, double scale) {
                Gdk.Pixbuf? emblem = null;
 
                var color = context.style.get_color (context.state);
 
                var theme = Gtk.IconTheme.get_default ();
+               var size = int.min (context.width, context.height) * scale;
                try {
-                       var icon_info = theme.lookup_icon (icon_name, size, Gtk.IconLookupFlags.FORCE_SIZE);
+                       var icon_info = theme.lookup_icon (icon_name, (int) size, 
Gtk.IconLookupFlags.FORCE_SIZE);
                        emblem = icon_info.load_symbolic (color);
                } catch (GLib.Error error) {
                        warning (@"Unable to get icon “$icon_name”: $(error.message)");


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