mirror of
https://github.com/lbonn/rofi
synced 2025-02-17 13:28:31 +00:00
Correctly center and scale image, even if not rectangular
This commit is contained in:
parent
87d9caec60
commit
0596f7c1a1
1 changed files with 5 additions and 4 deletions
|
@ -430,11 +430,12 @@ static void textbox_draw ( widget *wid, cairo_t *draw )
|
|||
cairo_save ( draw );
|
||||
|
||||
int iconh = cairo_image_surface_get_height ( tb->icon );
|
||||
double scale = (double) iconheight / iconh;
|
||||
|
||||
cairo_translate ( draw, x, y );
|
||||
int iconw = cairo_image_surface_get_width ( tb->icon );
|
||||
int icons = MAX(iconh, iconw);
|
||||
double scale = (double) iconheight / icons;
|
||||
cairo_translate ( draw, x+(iconheight-iconw*scale)/2.0, y+(iconheight-iconh*scale)/2.0 );
|
||||
cairo_scale ( draw, scale, scale );
|
||||
cairo_set_source_surface ( draw, tb->icon, 0, 0 );
|
||||
cairo_set_source_surface ( draw, tb->icon, 0,0);
|
||||
cairo_paint ( draw );
|
||||
cairo_restore ( draw );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue