diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-08-07 13:50:13 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-08-07 13:50:13 (EDT) |
commit | 7dd13e36121da49b80a02297922f02881c4200a6 (patch) | |
tree | 5e58e61108682d9671f07a5ff0d3df246be2bb5d /src | |
parent | 9d9d9fb9eab0213cd305f53a887628a2aca2c365 (diff) | |
download | mazefight-7dd13e36121da49b80a02297922f02881c4200a6.zip mazefight-7dd13e36121da49b80a02297922f02881c4200a6.tar.gz mazefight-7dd13e36121da49b80a02297922f02881c4200a6.tar.bz2 |
tk: Add window origin coordinates
Diffstat (limited to 'src')
-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 |