summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/tk/box.c2
-rw-r--r--src/tk/grid.c5
-rw-r--r--src/tk/widget.h19
3 files changed, 18 insertions, 8 deletions
diff --git a/src/tk/box.c b/src/tk/box.c
index ced5b3c..10a4ec3 100644
--- a/src/tk/box.c
+++ b/src/tk/box.c
@@ -132,5 +132,7 @@ mftk_box_new(int container_w, int container_h, int own_w, int own_h,
b->bg_color = bg_color;
b->child = child;
+ child->container = w;
+
return w;
}
diff --git a/src/tk/grid.c b/src/tk/grid.c
index 62c5612..9d12b3c 100644
--- a/src/tk/grid.c
+++ b/src/tk/grid.c
@@ -229,6 +229,7 @@ mftk_grid_new_a(int rows, int cols, int row_spacing, int col_spacing,
{
struct mftk_widget *w;
struct mftk_grid *g;
+ int i;
mftk_widget_init(w, g, grid);
@@ -259,6 +260,10 @@ mftk_grid_new_a(int rows, int cols, int row_spacing, int col_spacing,
g->children = children;
g->alignments = alignments;
+ for (i = 0; i < rows * cols; ++i) {
+ children[i]->container = w;
+ }
+
return w;
}
diff --git a/src/tk/widget.h b/src/tk/widget.h
index 310dc56..64b8b58 100644
--- a/src/tk/widget.h
+++ b/src/tk/widget.h
@@ -24,14 +24,17 @@
#include <stdarg.h>
struct mftk_widget {
- int w;
- int h;
- int vis;
- int can_focus;
- void (*layout)(struct mftk_widget *);
- int (*event)(struct mftk_widget *, SDL_Event *, int, int);
- int (*render)(struct mftk_widget *, SDL_Renderer *, int, int);
- void (*destroy)(struct mftk_widget *);
+ int w;
+ int h;
+ struct mftk_widget *container;
+ int vis;
+ int can_focus;
+ void (*layout)(struct mftk_widget *);
+ int (*event)(struct mftk_widget *, SDL_Event *,
+ int, int);
+ int (*render)(struct mftk_widget *, SDL_Renderer *,
+ int, int);
+ void (*destroy)(struct mftk_widget *);
};
struct mftk_widget *