imagebox: add support for background color

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2008-10-20 15:56:11 +02:00
parent ba66ae8035
commit 674f522229
1 changed files with 15 additions and 0 deletions

View File

@ -29,6 +29,7 @@ typedef struct
{ {
/** Imagebox image */ /** Imagebox image */
image_t *image; image_t *image;
xcolor_t bg;
} imagebox_data_t; } imagebox_data_t;
/** Draw an image. /** Draw an image.
@ -59,6 +60,8 @@ imagebox_draw(draw_context_t *ctx, int screen __attribute__ ((unused)),
offset, offset,
w->widget->align); w->widget->align);
if(d->bg.initialized)
draw_rectangle(ctx, w->area, 1.0, true, &d->bg);
draw_image(ctx, w->area.x, w->area.y, ctx->height, d->image); draw_image(ctx, w->area.x, w->area.y, ctx->height, d->image);
} }
else else
@ -100,6 +103,9 @@ luaA_imagebox_index(lua_State *L, awesome_token_t token)
case A_TK_IMAGE: case A_TK_IMAGE:
if(d->image) if(d->image)
return luaA_image_userdata_new(L, d->image); return luaA_image_userdata_new(L, d->image);
case A_TK_BG:
luaA_pushcolor(L, &d->bg);
break;
default: default:
break; break;
} }
@ -120,6 +126,9 @@ luaA_imagebox_newindex(lua_State *L, awesome_token_t token)
switch(token) switch(token)
{ {
const char *buf;
size_t len;
case A_TK_IMAGE: case A_TK_IMAGE:
if(lua_isnil(L, 3) if(lua_isnil(L, 3)
|| (image = luaA_checkudata(L, 3, "image"))) || (image = luaA_checkudata(L, 3, "image")))
@ -132,6 +141,12 @@ luaA_imagebox_newindex(lua_State *L, awesome_token_t token)
d->image = NULL; d->image = NULL;
} }
break; break;
case A_TK_BG:
if(lua_isnil(L, 3))
p_clear(&d->bg, 1);
else if((buf = luaL_checklstring(L, 3, &len)))
xcolor_init_reply(xcolor_init_unchecked(&d->bg, buf, len));
break;
default: default:
return 0; return 0;
} }