aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorMarvin Borner2021-04-27 23:32:05 +0200
committerMarvin Borner2021-04-27 23:32:05 +0200
commit895a58b1b57a0ae8028576404a90f12e0133cf5f (patch)
tree0130860f90ffd69b493f540987dc992257b5f974 /libs
parent51a80930a9bc25fae0728994cab1e0df3b63ef48 (diff)
Chess (-> and libgui) improvements
Diffstat (limited to 'libs')
-rw-r--r--libs/libgui/gfx.c5
-rw-r--r--libs/libgui/gfx.h1
-rw-r--r--libs/libgui/gui.c20
-rw-r--r--libs/libgui/gui.h1
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;