diff options
author | Alexey Yakovenko <waker@users.sourceforge.net> | 2013-11-11 21:57:32 +0100 |
---|---|---|
committer | Alexey Yakovenko <waker@users.sourceforge.net> | 2013-11-11 21:57:32 +0100 |
commit | 88d7e5b0b071c6c60f15c6b606dabdc186d2ec5e (patch) | |
tree | c2d4fd80ab2f3355ff7b36f353860418d16e34e4 /plugins | |
parent | fc8dfc977757014d453c053a42ddd8825446a082 (diff) |
gtkui: center image in the cover widget
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/gtkui/widgets.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c index 7e18e676..a07106a7 100644 --- a/plugins/gtkui/widgets.c +++ b/plugins/gtkui/widgets.c @@ -2170,9 +2170,17 @@ coverart_draw (GtkWidget *widget, cairo_t *cr, gpointer user_data) { art_scale *= (float)gdk_pixbuf_get_width (pixbuf) / gdk_pixbuf_get_height (pixbuf); } int ph = pw; - cairo_rectangle (cr, 0, 0, pw, ph); + int x = 0; + int y = 0; + if (gdk_pixbuf_get_width (pixbuf) > gdk_pixbuf_get_height (pixbuf)) { + y = (a.height - gdk_pixbuf_get_height (pixbuf)) / 2; + } + else if (gdk_pixbuf_get_width (pixbuf) < gdk_pixbuf_get_height (pixbuf)) { + x = (a.width - gdk_pixbuf_get_width (pixbuf)) / 2; + } + cairo_rectangle (cr, x, y, pw, ph); cairo_scale (cr, art_scale, art_scale); - gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); + gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); cairo_pattern_set_filter (cairo_get_source(cr), hq ? CAIRO_FILTER_GAUSSIAN : CAIRO_FILTER_FAST); cairo_fill (cr); g_object_unref (pixbuf); |