From 4c8df56193b2e43ea8651b731d31380103f99fe4 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Thu, 1 Jun 2023 18:17:20 +0200 Subject: Distinguish removed files more prettily It's still somewhat bad, but at least no longer ridiculous. --- fiv-browser.c | 34 ++++++++++++++++++++++++++-------- resources/cross-large-symbolic.svg | 4 ++++ resources/resources.gresource.xml | 1 + 3 files changed, 31 insertions(+), 8 deletions(-) create mode 100644 resources/cross-large-symbolic.svg diff --git a/fiv-browser.c b/fiv-browser.c index 8c79ca6..4201232 100644 --- a/fiv-browser.c +++ b/fiv-browser.c @@ -402,7 +402,7 @@ draw_row(FivBrowser *self, cairo_t *cr, const Row *row) // Performance optimization--specifically targeting the checkerboard. if (cairo_image_surface_get_format(item->entry->thumbnail) != - CAIRO_FORMAT_RGB24) { + CAIRO_FORMAT_RGB24 || item->entry->removed) { gtk_render_background(style, cr, border.left, border.top, extents.width, extents.height); } @@ -418,21 +418,39 @@ draw_row(FivBrowser *self, cairo_t *cr, const Row *row) cairo_mask_surface( cr, item->entry->thumbnail, border.left, border.top); } else { + // Distinguish removed items by rendering them only faintly. + if (item->entry->removed) + cairo_push_group(cr); + cairo_set_source_surface( cr, item->entry->thumbnail, border.left, border.top); cairo_paint(cr); - // Here, we could consider multiplying + // Here, we could also consider multiplying // the whole rectangle with the selection color. + if (item->entry->removed) { + cairo_pop_group_to_source(cr); + cairo_paint_with_alpha(cr, 0.25); + } } - // TODO(p): Come up with a better rendition. + // This rendition is about the best I could come up with. + // It might be possible to use more such emblems with entries, + // though they would deserve some kind of a blur-glow. if (item->entry->removed) { - cairo_move_to(cr, 0, border.top + extents.height + border.bottom); - cairo_line_to(cr, border.left + extents.width + border.right, 0); - cairo_set_source_rgb(cr, 0.5, 0.5, 0.5); - cairo_set_line_width(cr, 5); - cairo_stroke(cr); + int size = 32; + cairo_surface_t *cross = gtk_icon_theme_load_surface( + gtk_icon_theme_get_default(), "cross-large-symbolic", + size, gtk_widget_get_scale_factor(GTK_WIDGET(self)), + gtk_widget_get_window(GTK_WIDGET(self)), + GTK_ICON_LOOKUP_FORCE_SYMBOLIC, NULL); + if (cross) { + cairo_set_source_rgb(cr, 1, 0, 0); + cairo_mask_surface(cr, cross, + border.left + extents.width - size - size / 4, + border.top + extents.height - size - size / 4); + cairo_surface_destroy(cross); + } } if (self->show_labels) { diff --git a/resources/cross-large-symbolic.svg b/resources/cross-large-symbolic.svg new file mode 100644 index 0000000..b9b8f9a --- /dev/null +++ b/resources/cross-large-symbolic.svg @@ -0,0 +1,4 @@ + + + + diff --git a/resources/resources.gresource.xml b/resources/resources.gresource.xml index bfa368e..3e4aef3 100644 --- a/resources/resources.gresource.xml +++ b/resources/resources.gresource.xml @@ -6,6 +6,7 @@ text-symbolic.svg circle-filled-symbolic.svg + cross-large-symbolic.svg funnel-symbolic.svg blend-tool-symbolic.svg checkerboard-symbolic.svg -- cgit v1.2.3-70-g09d2