From 062f7fad97ade06b21889070f40de3f8516f0f67 Mon Sep 17 00:00:00 2001 From: Cedric Roux <cedric.roux@eurecom.fr> Date: Mon, 11 Apr 2016 18:31:37 +0200 Subject: [PATCH] add clear function to the gui --- common/utils/T/tracer/gui/event.c | 1 + common/utils/T/tracer/gui/gui_defs.h | 1 + common/utils/T/tracer/gui/widget.c | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/common/utils/T/tracer/gui/event.c b/common/utils/T/tracer/gui/event.c index fe7f9fbb4..d5ead45a7 100644 --- a/common/utils/T/tracer/gui/event.c +++ b/common/utils/T/tracer/gui/event.c @@ -132,6 +132,7 @@ static void dirty_event(struct gui *g, int id) if (win == NULL) { WARN("widget id %d not contained in a window\n", id); return; } g->xwin = win->x; + w->clear(g, w); w->paint(g, w); g->xwin = NULL; g->repainted = 1; diff --git a/common/utils/T/tracer/gui/gui_defs.h b/common/utils/T/tracer/gui/gui_defs.h index d7032f95d..8a3e4b770 100644 --- a/common/utils/T/tracer/gui/gui_defs.h +++ b/common/utils/T/tracer/gui/gui_defs.h @@ -46,6 +46,7 @@ struct widget { void (*allocate)(gui *g, widget *this, int x, int y, int width, int height); void (*hints)(gui *g, widget *this, int *width, int *height); void (*paint)(gui *g, widget *this); + void (*clear)(gui *g, widget *this); }; struct widget_list { diff --git a/common/utils/T/tracer/gui/widget.c b/common/utils/T/tracer/gui/widget.c index 8304420aa..103d36d45 100644 --- a/common/utils/T/tracer/gui/widget.c +++ b/common/utils/T/tracer/gui/widget.c @@ -6,6 +6,7 @@ #include <stdarg.h> #include <string.h> +static void default_clear(gui *gui, widget *_this); static void default_repack(gui *gui, widget *_this); static void default_allocate( gui *gui, widget *_this, int x, int y, int width, int height); @@ -41,6 +42,7 @@ widget *new_widget(struct gui *g, enum widget_type type, int size) ret = calloc(1, size); if (ret == NULL) OOM; + ret->clear = default_clear; ret->repack = default_repack; ret->add_child = default_add_child; ret->allocate = default_allocate; @@ -120,6 +122,14 @@ repack: /* default functions */ /*************************************************************************/ +static void default_clear(gui *_gui, widget *_this) +{ + struct gui *g = _gui; + struct widget *this = _this; + x_fill_rectangle(g->x, g->xwin, BACKGROUND_COLOR, + this->x, this->y, this->width, this->height); +} + static void default_repack(gui *gui, widget *_this) { struct widget *this = _this; -- GitLab