From fccf9e88058dfc8dac3dfeb80a99fbf2118a7361 Mon Sep 17 00:00:00 2001 From: Daiki Ueno Date: Tue, 1 Mar 2011 16:25:37 +0900 Subject: [PATCH] Fix icon position calculation. --- eek/eek-gtk-renderer.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/eek/eek-gtk-renderer.c b/eek/eek-gtk-renderer.c index ded29f1f..d10ffc11 100644 --- a/eek/eek-gtk-renderer.c +++ b/eek/eek-gtk-renderer.c @@ -73,11 +73,13 @@ eek_gtk_renderer_real_render_key_icon (EekRenderer *self, g_return_if_fail (icon_name); eek_element_get_bounds (EEK_ELEMENT(key), &bounds); + bounds.width *= scale; + bounds.height *= scale; error = NULL; pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (), icon_name, - MIN(bounds.width, bounds.height) * scale, + MIN(bounds.width, bounds.height), 0, &error); g_return_if_fail (pixbuf); @@ -85,12 +87,16 @@ eek_gtk_renderer_real_render_key_icon (EekRenderer *self, width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); - if (bounds.width * scale * height < bounds.height * scale * width) - scale *= bounds.width * scale / width; + if (bounds.width * height < bounds.height * width) + scale = bounds.width / width; else - scale *= bounds.height * scale / height; + scale = bounds.height / height; cairo_save (cr); + cairo_translate (cr, + (bounds.width - width * scale) / 2, + (bounds.height - height * scale) / 2); + eek_renderer_apply_transformation_for_key (self, cr, key, scale, rotate); surface = pixbuf_to_cairo_surface (pixbuf); cairo_set_source_surface (cr, surface, 0.0, 0.0);