[gnome-music] Re-apply "Add rounded corners to album art in the Albums view" after gjs bug 700529 was fixed



commit 8b6f8c0ba4e811cab0d5a30abac8e8d1246f94d1
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date:   Wed May 22 14:17:45 2013 +0200

    Re-apply "Add rounded corners to album art in the Albums view" after gjs bug 700529 was fixed
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=699808
    
    This reverts commit 55500c9d74d7ff0011939ce120a97dd1b8167b70.

 src/albumArtCache.js |   63 +++++++++++++++++++++++++++++--------------------
 1 files changed, 37 insertions(+), 26 deletions(-)
---
diff --git a/src/albumArtCache.js b/src/albumArtCache.js
index 1cd541b..9dff5a3 100644
--- a/src/albumArtCache.js
+++ b/src/albumArtCache.js
@@ -19,9 +19,11 @@
  */
 
 const Lang = imports.lang;
+const Cairo = imports.cairo;
 const GdkPixbuf = imports.gi.GdkPixbuf;
 const GLib = imports.gi.GLib;
 const Gtk = imports.gi.Gtk;
+const Gdk = imports.gi.Gdk;
 const Gio = imports.gi.Gio;
 const Regex = GLib.Regex;
 const Path = GLib.Path;
@@ -193,35 +195,44 @@ const AlbumArtCache = new Lang.Class({
     },
 
     makeIconFrame: function (pixbuf) {
-        var border = 3;
-        var color = 0xffffffff;
-        var result = GdkPixbuf.Pixbuf.new(pixbuf.get_colorspace(),
-                                true,
-                                pixbuf.get_bits_per_sample(),
-                                pixbuf.get_width(),
-                                pixbuf.get_height());
-        result.fill(color);
+        border = 1.5;
+        pixbuf = pixbuf.scale_simple(pixbuf.get_width() - border * 2,
+                                     pixbuf.get_height() - border * 2,
+                                     0);
+
+        let surface =  new Cairo.ImageSurface (Cairo.Format.ARGB32,
+                                               pixbuf.get_width() + border * 2,
+                                               pixbuf.get_height() + border * 2);
+        let ctx = new Cairo.Context(surface);
+        this.drawRoundedPath(ctx, 0, 0,
+                             pixbuf.get_width()  + border * 2,
+                             pixbuf.get_height()  + border * 2,
+                             3);
+        let result = Gdk.pixbuf_get_from_surface(surface, 0, 0,
+            pixbuf.get_width() + border * 2, pixbuf.get_height() + border * 2);
+
         pixbuf.copy_area(border, border,
-                        pixbuf.get_width() - (border * 2), pixbuf.get_height() - (border * 2),
+                        pixbuf.get_width() - border * 2,
+                        pixbuf.get_height() - border * 2,
                         result,
-                        border, border);
-
-        pixbuf = result;
-
-        border = 1;
-        color = 0x00000044;
-        var result2 = GdkPixbuf.Pixbuf.new(pixbuf.get_colorspace(),
-                                true,
-                                pixbuf.get_bits_per_sample(),
-                                pixbuf.get_width(),
-                                pixbuf.get_height());
-        result2.fill(color);
-        pixbuf.copy_area(border, border,
-                        pixbuf.get_width() - (border * 2), pixbuf.get_height() - (border * 2),
-                        result2,
-                        border, border);
+                        border * 2, border * 2);
+
+        return result;
+    },
 
-        return result2;
+    drawRoundedPath: function (ctx, x, y, width, height, radius, preserve) {
+        let degrees = Math.PI / 180;
+        ctx.newSubPath();
+        ctx.arc(x + width - radius, y + radius, radius - 0.5, -90 * degrees, 0 * degrees);
+        ctx.arc(x + width - radius, y + height - radius, radius - 0.5, 0 * degrees, 90 * degrees);
+        ctx.arc(x + radius, y + height - radius, radius - 0.5, 90 * degrees, 180 * degrees);
+        ctx.arc(x + radius, y + radius, radius - 0.5, 180 * degrees, 270 * degrees);
+        ctx.closePath();
+        ctx.setLineWidth(0.6);
+        ctx.setSourceRGB(0.2, 0.2, 0.2);
+        ctx.strokePreserve();
+        ctx.setSourceRGB(1, 1, 1);
+        ctx.fill()
     },
 
     _keybuilder_funcs: [


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