wibox: add support for background image (FS#464)

Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
Julien Danjou 2009-03-03 10:22:39 +01:00
parent e56f8f30d0
commit cc54c32c5f
3 changed files with 31 additions and 1 deletions

View File

@ -108,6 +108,8 @@ typedef struct
bool need_update;
/** Cursor */
char *cursor;
/** Background image */
image_t *bg_image;
/** Button bindings */
button_array_t buttons;
} wibox_t;

23
wibox.c
View File

@ -861,6 +861,12 @@ luaA_wibox_index(lua_State *L)
case A_TK_BG:
luaA_pushcolor(L, &(*wibox)->sw.ctx.bg);
break;
case A_TK_BG_IMAGE:
if((*wibox)->bg_image)
luaA_image_userdata_new(L, (*wibox)->bg_image);
else
return 0;
break;
case A_TK_POSITION:
lua_pushstring(L, position_tostr((*wibox)->position));
break;
@ -976,6 +982,23 @@ luaA_wibox_newindex(lua_State *L)
if(xcolor_init_reply(xcolor_init_unchecked(&(*wibox)->sw.ctx.bg, buf, len)))
(*wibox)->need_update = true;
break;
case A_TK_BG_IMAGE:
{
if(lua_isnil(L, 3))
{
image_unref(&(*wibox)->bg_image);
(*wibox)->bg_image = NULL;
(*wibox)->need_update = true;
}
else
{
image_t **img = luaA_checkudata(L, 3, "image");
image_unref(&(*wibox)->bg_image);
(*wibox)->bg_image = image_ref(img);
(*wibox)->need_update = true;
}
}
break;
case A_TK_ALIGN:
buf = luaL_checklstring(L, 3, &len);
(*wibox)->align = draw_align_fromstr(buf, len);

View File

@ -270,9 +270,14 @@ widget_render(wibox_t *wibox)
left += widgets->tab[i].geometry.width;
}
/* draw everything! */
/* draw background image, only if the background color is not opaque */
if(wibox->bg_image && ctx->bg.alpha != 0xffff)
draw_image(ctx, 0, 0, 1.0, wibox->bg_image);
/* draw background color */
draw_rectangle(ctx, rectangle, 1.0, true, &ctx->bg);
/* draw everything! */
for(int i = 0; i < widgets->len; i++)
if(widgets->tab[i].widget->isvisible)
{