From c7c1149381f66e1ddb5e32d1ea16f85e76e3c138 Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Thu, 21 May 2026 21:55:36 -0400 Subject: make `tyui_begin_window_ex()` easier to read --- teensy/teensy_ui.c | 52 +++++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/teensy/teensy_ui.c b/teensy/teensy_ui.c index 5450502..b68b7ab 100644 --- a/teensy/teensy_ui.c +++ b/teensy/teensy_ui.c @@ -330,36 +330,42 @@ bool tyui_begin_window_ex( mouse_pos.x -= md.x; mouse_pos.y -= md.y; - ty_Recti title_rect = win->rect; - title_rect.h = title_bar_height(); + bool hovering_resizer = false; // Grabbing resizer? - ty_Vec2i win_end = ty_recti_end(win->rect); - ty_Recti resize_rect = ty_recti( - win_end.x - 10, win_end.y - 10 + TEXT_HEIGHT, - 20, 20 - ); + { + ty_Vec2i win_end = ty_recti_end(win->rect); + ty_Recti resize_rect = ty_recti( + win_end.x - 10, win_end.y - 10 + TEXT_HEIGHT, + 20, 20 + ); - bool hovering_resizer = - ty_pointi_in_recti(mouse_pos, resize_rect) || - ty_pointi_in_recti(ty_mouse_pos(), resize_rect); + hovering_resizer = + ty_pointi_in_recti(mouse_pos, resize_rect) || + ty_pointi_in_recti(ty_mouse_pos(), resize_rect); - if (ty_button_down(TY_BTN_DB_LMB) && hovering_resizer) { - win->rect.w += md.x; - win->rect.h += md.y; + if (ty_button_down(TY_BTN_DB_LMB) && hovering_resizer) { + win->rect.w += md.x; + win->rect.h += md.y; + } } + ty_Recti title_rect = win->rect; + title_rect.h = title_bar_height(); + // Grabbing title bar? - if ( - ty_button_down(TY_BTN_DB_LMB) && - (ty_pointi_in_recti(mouse_pos, title_rect) || - ty_pointi_in_recti(ty_mouse_pos(), title_rect)) - ) { - win->rect.x += md.x; - win->rect.y += md.y; - - title_rect = win->rect; - title_rect.h = title_bar_height(); + { + if ( + ty_button_down(TY_BTN_DB_LMB) && + (ty_pointi_in_recti(mouse_pos, title_rect) || + ty_pointi_in_recti(ty_mouse_pos(), title_rect)) + ) { + win->rect.x += md.x; + win->rect.y += md.y; + + title_rect = win->rect; + title_rect.h = title_bar_height(); + } } clip_cmd(TY_CLIP_NONE); -- cgit v1.3-2-g0d8e