dirty redraw and SDL framebuffer example
[windtk] / src / widget.c
index 96be755..02c3ff0 100644 (file)
@@ -9,6 +9,7 @@ wt_widget *wt_alloc_widget(wt_widget *par)
                return 0;
        }
        w->type = WT_TYPE_WIDGET;
+       w->dirty = 1;
 
        if(!par) par = wt->root;
        wt_add_child(par, w);
@@ -36,6 +37,17 @@ void wt_free_tree(wt_widget *tree)
        wt_free_widget(tree);
 }
 
+void wt_dirty_widget(wt_widget *w)
+{
+       int i;
+
+       w->dirty = 1;
+
+       for(i=0; i<w->num_child; i++) {
+               wt_dirty_widget(w->child[i]);
+       }
+}
+
 int wt_type(wt_widget *w)
 {
        return w->type;
@@ -156,8 +168,8 @@ void wt_move(wt_widget *w, int x, int y)
 
 void wt_resize(wt_widget *w, int x, int y)
 {
-       w->rect.width = x;
-       w->rect.height = y;
+       w->rect.w = x;
+       w->rect.h = y;
        /* TODO: invalidate something */
 }
 
@@ -170,15 +182,15 @@ int *wt_position(wt_widget *w, int *xret, int *yret)
 
 int *wt_size(wt_widget *w, int *xret, int *yret)
 {
-       if(xret) *xret = w->rect.width;
-       if(yret) *yret = w->rect.height;
-       return &w->rect.width;
+       if(xret) *xret = w->rect.w;
+       if(yret) *yret = w->rect.h;
+       return &w->rect.w;
 }
 
 int wt_hittest(wt_widget *w, int x, int y)
 {
-       return x >= w->rect.x && y >= w->rect.y && x < w->rect.x + w->rect.width &&
-               y < w->rect.y + w->rect.height;
+       return x >= w->rect.x && y >= w->rect.y && x < w->rect.x + w->rect.w &&
+               y < w->rect.y + w->rect.h;
 }
 
 wt_widget *wt_widget_at(int x, int y)