summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2022-08-10 11:45:15 +0100
committerAntónio Fernandes <antoniof@gnome.org>2022-09-01 12:23:06 +0100
commit6708c4c375ed374302de0193e01e9b669dd738c1 (patch)
tree5c4dc5451fbb83c899012a9721b239f2c2ab8bcc
parentf236675f0fbd2e749cb332a04435ab38839eda66 (diff)
downloadnautilus-6708c4c375ed374302de0193e01e9b669dd738c1.tar.gz
file: Slightly soften thumbnail corners
Sharp corners give an unpolished feel to thumbnail. We've been trying to give the illusion of round corners using shadows. But now that we already use GtkSnapshot, properly clipping round corners is too easy not to do it.
-rw-r--r--src/nautilus-file.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/nautilus-file.c b/src/nautilus-file.c
index 6b4b2319a..02e8307b0 100644
--- a/src/nautilus-file.c
+++ b/src/nautilus-file.c
@@ -5103,6 +5103,7 @@ nautilus_file_get_thumbnail_icon (NautilusFile *file,
double height = gdk_pixbuf_get_height (pixbuf) / scale;
g_autoptr (GdkTexture) texture = gdk_texture_new_for_pixbuf (pixbuf);
g_autoptr (GtkSnapshot) snapshot = gtk_snapshot_new ();
+ GskRoundedRect rounded_rect;
if (MAX (width, height) > size)
{
@@ -5112,6 +5113,11 @@ nautilus_file_get_thumbnail_icon (NautilusFile *file,
height = height / scale_down_factor;
}
+ gsk_rounded_rect_init_from_rect (&rounded_rect,
+ &GRAPHENE_RECT_INIT (0, 0, width, height),
+ 2 /* radius*/);
+ gtk_snapshot_push_rounded_clip (snapshot, &rounded_rect);
+
gdk_paintable_snapshot (GDK_PAINTABLE (texture),
GDK_SNAPSHOT (snapshot),
width, height);
@@ -5122,6 +5128,8 @@ nautilus_file_get_thumbnail_icon (NautilusFile *file,
nautilus_ui_frame_video (snapshot, width, height);
}
+ gtk_snapshot_pop (snapshot); /* End rounded clip */
+
DEBUG ("Returning thumbnailed image, at size %d %d",
(int) (width), (int) (height));
paintable = gtk_snapshot_to_paintable (snapshot, NULL);