aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy_ui.c
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-21 21:55:36 -0400
committeriamcheeseman <[email protected]>2026-05-21 21:55:36 -0400
commitc7c1149381f66e1ddb5e32d1ea16f85e76e3c138 (patch)
tree2e2335e32011a9fec8d91ae3031d067e5b8abec7 /teensy/teensy_ui.c
parent29ac539d35c6c0363b59ec3fbb26315563d62308 (diff)
make `tyui_begin_window_ex()` easier to read
Diffstat (limited to 'teensy/teensy_ui.c')
-rw-r--r--teensy/teensy_ui.c50
1 files changed, 28 insertions, 22 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;
+ {
+ 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();
+ title_rect = win->rect;
+ title_rect.h = title_bar_height();
+ }
}
clip_cmd(TY_CLIP_NONE);