X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;ds=sidebyside;f=src%2Ftui.c;h=7f20e9480de46054c7287328095c242af39c23b8;hb=e603acae4b6cf020307b149f9874bf41d1da5337;hp=106b28fa241104a55a80067e8a84f21221c6c582;hpb=2ba6401e39bcfaaccaa45e6b7ef780a7a15b0c48;p=oftp diff --git a/src/tui.c b/src/tui.c index 106b28f..7f20e94 100644 --- a/src/tui.c +++ b/src/tui.c @@ -6,6 +6,7 @@ #include "tuipriv.h" #include "tgfx.h" #include "darray.h" +#include "util.h" int tui_init(void) @@ -78,6 +79,11 @@ struct tui_widget *tui_parent(struct tui_widget *w) return w->par; } +int tui_isdirty(struct tui_widget *w) +{ + return w->dirty; +} + void tui_draw(struct tui_widget *w) { struct tui_widget *iter; @@ -85,6 +91,7 @@ void tui_draw(struct tui_widget *w) if(w->cbfunc[TUI_DRAW]) { w->cbfunc[TUI_DRAW](w, 0); } + w->dirty = 0; iter = w->child; while(iter) { @@ -101,6 +108,36 @@ void tui_set_callback(struct tui_widget *w, int type, tui_callback func, void *c w->cbcls[type] = cls; } +void tui_call_callback(struct tui_widget *w, int type) +{ + if(w->cbfunc[type]) { + w->cbfunc[type](w, w->cbcls[type]); + } +} + +void tui_focus(struct tui_widget *w, int focus) +{ + focus = focus ? 1 : 0; + if(w->focus == focus) { + return; + } + w->focus = focus; + w->dirty = 1; + tui_call_callback(w, TUI_ONFOCUS); +} + +int tui_set_title(struct tui_widget *w, const char *s) +{ + free(w->title); + w->title = strdup_nf(s); + return 0; +} + +const char *tui_get_title(struct tui_widget *w) +{ + return w->title; +} + struct tui_widget *tui_window(const char *title, int x, int y, int width, int height) { struct tui_widget *w;