From c29b8d0730547af5928e059fa9828876f63c4625 Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Fri, 22 May 2026 12:10:48 -0400 Subject: tyui: move window parameters to a struct additionally adds a minimum window size --- teensy/teensy_ui.h | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'teensy/teensy_ui.h') diff --git a/teensy/teensy_ui.h b/teensy/teensy_ui.h index 6230aff..65722ac 100644 --- a/teensy/teensy_ui.h +++ b/teensy/teensy_ui.h @@ -5,14 +5,22 @@ #include "teensy.h" #define TYUI_MAX_LAYOUT_SIZE (16) +#define TYUI_DEFAULT_MIN_WINDOW_SIZE (ty_vec2i(32, 32)) #define TYUI_WIN_NORESIZE (1 << 0) #define TYUI_WIN_NOCLOSE (1 << 1) #define TYUI_WIN_NOMOVE (1 << 2) #define TYUI_WIN_INVISIBLE (1 << 3) -#define tyui_begin_window(title, rect, id) \ - tyui_begin_window_ex(title, rect, id, 0, NULL) +#define tyui_begin_window(_title, _rect, _id) \ + tyui_begin_window_ex((tyui_Window_Conf){ \ + .title = _title, \ + .rect = _rect, \ + .min_size = TYUI_DEFAULT_MIN_WINDOW_SIZE, \ + .id = _id, \ + .flags = 0, \ + }, NULL) + #define tyui_text(...) tyui_text_ex(TYUI_ALIGN_LEFT, __VA_ARGS__) #define tyui_slider(min, max, value_ptr) \ tyui_slider_ex(min, max, value_ptr, true, TYUI_ALIGN_CENTER) @@ -26,6 +34,8 @@ enum { TYUI_ALIGN_CENTER, }; +typedef uint8_t tyui_Id; + typedef struct { ty_Color fg_normal; ty_Color bg_normal; @@ -45,7 +55,13 @@ typedef struct { const char *slider_fmt; } tyui_Style; -typedef uint8_t tyui_Id; +typedef struct { + const char *title; + ty_Recti rect; + ty_Vec2i min_size; + tyui_Id *id; + uint32_t flags; +} tyui_Window_Conf; void tyui_init(const ty_Font *font); void tyui_deinit(void); @@ -53,13 +69,7 @@ void tyui_deinit(void); void tyui_push_layout(const float *column_widths); void tyui_pop_layout(void); -bool tyui_begin_window_ex( - const char *title, - ty_Recti rect, - tyui_Id *id, - uint32_t flags, - bool *closed -); +bool tyui_begin_window_ex(tyui_Window_Conf conf, bool *closed_ptr); void tyui_end_window(void); bool tyui_button(const char *text); -- cgit v1.3-2-g0d8e