Fix icon position calculation.
This commit is contained in:
@ -73,11 +73,13 @@ eek_gtk_renderer_real_render_key_icon (EekRenderer *self,
|
|||||||
g_return_if_fail (icon_name);
|
g_return_if_fail (icon_name);
|
||||||
|
|
||||||
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
|
eek_element_get_bounds (EEK_ELEMENT(key), &bounds);
|
||||||
|
bounds.width *= scale;
|
||||||
|
bounds.height *= scale;
|
||||||
|
|
||||||
error = NULL;
|
error = NULL;
|
||||||
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
|
pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
|
||||||
icon_name,
|
icon_name,
|
||||||
MIN(bounds.width, bounds.height) * scale,
|
MIN(bounds.width, bounds.height),
|
||||||
0,
|
0,
|
||||||
&error);
|
&error);
|
||||||
g_return_if_fail (pixbuf);
|
g_return_if_fail (pixbuf);
|
||||||
@ -85,12 +87,16 @@ eek_gtk_renderer_real_render_key_icon (EekRenderer *self,
|
|||||||
width = gdk_pixbuf_get_width (pixbuf);
|
width = gdk_pixbuf_get_width (pixbuf);
|
||||||
height = gdk_pixbuf_get_height (pixbuf);
|
height = gdk_pixbuf_get_height (pixbuf);
|
||||||
|
|
||||||
if (bounds.width * scale * height < bounds.height * scale * width)
|
if (bounds.width * height < bounds.height * width)
|
||||||
scale *= bounds.width * scale / width;
|
scale = bounds.width / width;
|
||||||
else
|
else
|
||||||
scale *= bounds.height * scale / height;
|
scale = bounds.height / height;
|
||||||
|
|
||||||
cairo_save (cr);
|
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);
|
eek_renderer_apply_transformation_for_key (self, cr, key, scale, rotate);
|
||||||
surface = pixbuf_to_cairo_surface (pixbuf);
|
surface = pixbuf_to_cairo_surface (pixbuf);
|
||||||
cairo_set_source_surface (cr, surface, 0.0, 0.0);
|
cairo_set_source_surface (cr, surface, 0.0, 0.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user