diff options
-rw-r--r-- | src/menu.c | 2 | ||||
-rw-r--r-- | src/tk.h | 2 | ||||
-rw-r--r-- | src/tk/window.c | 10 |
3 files changed, 9 insertions, 5 deletions
@@ -230,7 +230,7 @@ mf_menu(SDL_Renderer *renderer) text_color.r = MF_COLOR_FORE_R, text_color.g = MF_COLOR_FORE_G; text_color.b = MF_COLOR_FORE_B, text_color.a = MF_COLOR_FORE_A; - win = mftk_window_new(mftk_box_new(MF_WINDOW_W, MF_WINDOW_H, 0, 0, + win = mftk_window_new(0, 0, mftk_box_new(MF_WINDOW_W, MF_WINDOW_H, 0, 0, MF_SPLASH_FORM_P, &form_color, mftk_grid_new(2, 1, MF_SPLASH_TITLE_M, 0, mftk_label_new(title_font, "Maze Fight", @@ -27,7 +27,7 @@ struct mftk_window; struct mftk_widget; struct mftk_window * -mftk_window_new(struct mftk_widget *root); +mftk_window_new(int x, int y, struct mftk_widget *root); int mftk_window_event(struct mftk_window *w, SDL_Event *e); diff --git a/src/tk/window.c b/src/tk/window.c index 5062f24..0c8302e 100644 --- a/src/tk/window.c +++ b/src/tk/window.c @@ -25,13 +25,15 @@ #include "widget.h" struct mftk_window { + int x; + int y; struct mftk_widget *root; struct mftk_widget *first; struct mftk_widget *focus; }; struct mftk_window * -mftk_window_new(struct mftk_widget *root) +mftk_window_new(int x, int y, struct mftk_widget *root) { struct mftk_window *w; @@ -43,6 +45,8 @@ mftk_window_new(struct mftk_widget *root) return NULL; } + w->x = x; + w->y = y; w->root = root; mftk_widget_layout(w->root); @@ -99,7 +103,7 @@ mftk_window_event(struct mftk_window *w, SDL_Event *e) case SDL_TEXTINPUT: return mftk_widget_key_event(w->focus, e); case SDL_MOUSEBUTTONUP: - return mftk_widget_mouse_event(w->root, e, 0, 0); + return mftk_widget_mouse_event(w->root, e, w->x, w->y); default: break; } @@ -120,7 +124,7 @@ mftk_window_focus(struct mftk_window *win, struct mftk_widget *wid) int mftk_window_render(struct mftk_window *w, SDL_Renderer *renderer) { - return mftk_widget_render(w->root, renderer, 0, 0); + return mftk_widget_render(w->root, renderer, w->x, w->y); } void |