From 34c0244d5a99d0266a981d75afcd8a811ab1a67f Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 10 Nov 2008 15:22:24 +0100 Subject: [PATCH] imagebox: don't draw anything is not enough space (FS#368) Signed-off-by: Julien Danjou --- widgets/imagebox.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/widgets/imagebox.c b/widgets/imagebox.c index 70747be8..046d4dfe 100644 --- a/widgets/imagebox.c +++ b/widgets/imagebox.c @@ -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);