imagebox: don't draw anything is not enough space (FS#368)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-11-10 15:22:24 +01:00
parent b117f2cf47
commit 34c0244d5a
1 changed files with 18 additions and 4 deletions

View File

@ -43,11 +43,25 @@ imagebox_geometry(widget_t *widget, int screen, int height, int width)
if(d->image)
{
if(d->resize)
{
geometry.width = ((double) height / (double) d->image->height) * d->image->width;
else
geometry.height = height;
if(geometry.width > width)
{
geometry.width = 0;
geometry.height = 0;
}
}
else if(d->image->width <= width)
{
geometry.width = d->image->width;
geometry.height = height;
geometry.height = height;
}
else
{
geometry.width = 0;
geometry.height = 0;
}
}
else
{
@ -71,7 +85,7 @@ imagebox_draw(widget_t *widget, draw_context_t *ctx, area_t geometry,
{
imagebox_data_t *d = widget->data;
if(d->image)
if(d->image && geometry.width && geometry.height)
{
if(d->bg.initialized)
draw_rectangle(ctx, geometry, 1.0, true, &d->bg);