diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/libgui/gfx.c | 5 | ||||
-rw-r--r-- | libs/libgui/gfx.h | 1 | ||||
-rw-r--r-- | libs/libgui/gui.c | 20 | ||||
-rw-r--r-- | libs/libgui/gui.h | 1 |
4 files changed, 25 insertions, 2 deletions
diff --git a/libs/libgui/gfx.c b/libs/libgui/gfx.c index bddd5ed..15c44b1 100644 --- a/libs/libgui/gfx.c +++ b/libs/libgui/gfx.c @@ -266,6 +266,11 @@ void gfx_draw_rectangle(struct context *ctx, vec2 pos1, vec2 pos2, u32 c) draw_rectangle(ctx, pos1, pos2, c); } +void gfx_clear(struct context *ctx) +{ + memset(ctx->fb, 0, ctx->bytes); +} + void gfx_fill(struct context *ctx, u32 c) { draw_rectangle(ctx, vec2(0, 0), vec2(ctx->size.x, ctx->size.y), c); diff --git a/libs/libgui/gfx.h b/libs/libgui/gfx.h index 5cf12f8..d0d0e1e 100644 --- a/libs/libgui/gfx.h +++ b/libs/libgui/gfx.h @@ -83,6 +83,7 @@ void gfx_load_wallpaper(struct context *ctx, const char *path) NONNULL; void gfx_copy(struct context *dest, struct context *src, vec2 pos, vec2 size) NONNULL; void gfx_ctx_on_ctx(struct context *dest, struct context *src, vec2 pos, u8 alpha) NONNULL; void gfx_draw_rectangle(struct context *ctx, vec2 pos1, vec2 pos2, u32 c) NONNULL; +void gfx_clear(struct context *ctx); void gfx_fill(struct context *ctx, u32 c) NONNULL; void gfx_border(struct context *ctx, u32 c, u32 width) NONNULL; diff --git a/libs/libgui/gui.c b/libs/libgui/gui.c index 046e8bf..891a0e4 100644 --- a/libs/libgui/gui.c +++ b/libs/libgui/gui.c @@ -120,6 +120,22 @@ static void gui_connect_wm(void) * GFX wrappers */ +res gui_clear(u32 win_id, u32 widget_id, enum gui_layer layer) +{ + struct gui_widget *widget = gui_widget_by_id(win_id, widget_id); + if (!widget) + return_errno(ENOENT); + + if (layer == GUI_LAYER_BG) + gfx_clear(&widget->bg); + else if (layer == GUI_LAYER_FG) + gfx_clear(&widget->fg); + else + return_errno(EINVAL); + + return_errno(EOK); +} + res gui_fill(u32 win_id, u32 widget_id, enum gui_layer layer, u32 c) { struct gui_widget *widget = gui_widget_by_id(win_id, widget_id); @@ -243,8 +259,8 @@ static res gui_sync_sub_widgets(struct gui_widget *widget) struct node *iterator = widget->children->head; while (iterator) { struct gui_widget *w = iterator->data; - gfx_ctx_on_ctx(&widget->bg, &w->bg, w->pos, GFX_ALPHA); - gfx_ctx_on_ctx(&widget->fg, &w->fg, w->pos, GFX_ALPHA); + gfx_ctx_on_ctx(&widget->bg, &w->bg, w->pos, GFX_NON_ALPHA); + gfx_ctx_on_ctx(&widget->fg, &w->fg, w->pos, GFX_NON_ALPHA); iterator = iterator->next; } diff --git a/libs/libgui/gui.h b/libs/libgui/gui.h index abc50fb..9473bd9 100644 --- a/libs/libgui/gui.h +++ b/libs/libgui/gui.h @@ -21,6 +21,7 @@ enum gui_layer { res gui_new_window(u32 *id); res gui_redraw_window(u32 id); +res gui_clear(u32 win_id, u32 widget_id, enum gui_layer layer); res gui_fill(u32 win_id, u32 widget_id, enum gui_layer layer, u32 c); res gui_load_image(u32 win_id, u32 widget_id, enum gui_layer layer, vec2 pos, vec2 size, const char *path) NONNULL; |