From c529e9ed9c2f6f4a430b257430d84ef3e9f36fdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 11 Jul 2019 11:32:46 +0200 Subject: [PATCH] render: Simplify drawing Instead of doing scale guessing we know that we get a properly sized image from GTK+ so just scale it down a bit so it gets some border within the drawing area. --- eek/eek-renderer.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/eek/eek-renderer.c b/eek/eek-renderer.c index 7ce82d62..fb38f320 100644 --- a/eek/eek-renderer.c +++ b/eek/eek-renderer.c @@ -492,37 +492,23 @@ render_key (EekRenderer *self, if (!symbol) return; + #define SCALE 0.8 if (eek_symbol_get_icon_name (symbol)) { cairo_surface_t *icon_surface = eek_renderer_get_icon_surface (self, eek_symbol_get_icon_name (symbol), - MIN(bounds.width, bounds.height) * 0.5); + MIN(bounds.width, bounds.height)); if (icon_surface) { gint width = cairo_image_surface_get_width (icon_surface); gint height = cairo_image_surface_get_height (icon_surface); - gdouble scale; - - if (width < bounds.width && height < bounds.height) - scale = 1; - else { - if (height * bounds.width / width <= bounds.height) - scale = bounds.width / width; - else if (width * bounds.height / height <= bounds.width) - scale = bounds.height / height; - else { - if (width * bounds.height < height * bounds.width) - scale = width / bounds.width; - else - scale = height / bounds.height; - } - } cairo_save (cr); cairo_translate (cr, - (bounds.width - width * scale) / 2, - (bounds.height - height * scale) / 2); + (bounds.width - width * SCALE) / 2, + (bounds.height - height * SCALE) / 2); cairo_rectangle (cr, 0, 0, width, height); + cairo_scale (cr, SCALE, SCALE); cairo_clip (cr); /* Draw the shape of the icon using the foreground color */ cairo_set_source_rgba (cr, foreground.red,