[gnome-music/wip/mschraal/gtk4-v3: 160/187] coverpaintable: Fix rounded corners
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gtk4-v3: 160/187] coverpaintable: Fix rounded corners
- Date: Thu, 10 Feb 2022 10:42:29 +0000 (UTC)
commit 555fd2786f914eef2126a91e772bcf9ca7f34210
Author: Marinus Schraal <mschraal gnome org>
Date: Fri Feb 4 08:53:19 2022 +0100
coverpaintable: Fix rounded corners
gnomemusic/coverpaintable.py | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
---
diff --git a/gnomemusic/coverpaintable.py b/gnomemusic/coverpaintable.py
index cf8179648..dc4b24b01 100644
--- a/gnomemusic/coverpaintable.py
+++ b/gnomemusic/coverpaintable.py
@@ -1,7 +1,6 @@
import gi
-gi.require_versions({"Gdk": "4.0", "Gtk": "4.0"})
-# from gi.repository import Gsk, Gtk, GObject, Graphene, Gdk
-from gi.repository import Gtk, GObject, Graphene, Gdk
+gi.require_versions({"Gdk": "4.0", "Gtk": "4.0", "Gsk": "4.0"})
+from gi.repository import Gsk, Gtk, GObject, Graphene, Gdk
class CoverPaintable(GObject.GObject, Gdk.Paintable):
@@ -14,33 +13,33 @@ class CoverPaintable(GObject.GObject, Gdk.Paintable):
self._texture = texture
self._art_size = art_size
- def do_snapshot(self, snapshot, width, height):
- w = width
- h = height
+ def do_snapshot(self, snapshot, w, h):
+ rect = Graphene.Rect().init(0, 0, w, h)
+ rounded_rect = Gsk.RoundedRect()
+ rounded_rect.init_from_rect(rect, 9)
+ snapshot.push_rounded_clip(rounded_rect)
if self._texture is not None:
- # Anything Gsk related seems to be failing, no rounded
- # clips for now. Related: pygobject#471
- #
- # gskrr = Gsk.RoundedRect().init_from_rect(rect2, 10)
- # snapshot.push_rounded_clip(gskrr)
- snapshot.translate(Graphene.Point().init(width / 2, height / 2))
+ snapshot.translate(Graphene.Point().init(w / 2, h / 2))
rect = Graphene.Rect().init(-(w / 2), -(h / 2), w, h)
snapshot.append_texture(self._texture, rect)
- # snapshot.pop()
+
else:
snapshot.append_color(
Gdk.RGBA(1, 1, 1, 1), Graphene.Rect().init(0, 0, w, h))
-
snapshot.translate(
Graphene.Point().init((w / 2) - (w / 6), (h / 2) - (h / 6)))
+
theme = Gtk.IconTheme.new()
icon_pt = theme.lookup_icon(
"folder-music-symbolic", None, w / 3, 1, 0, 0)
+
snapshot.push_opacity(0.7)
icon_pt.snapshot(snapshot, w / 3, h / 3)
snapshot.pop()
+ snapshot.pop()
+
def do_get_flags(self):
return Gdk.PaintableFlags.SIZE | Gdk.PaintableFlags.CONTENTS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]