aboutsummaryrefslogtreecommitdiff
path: root/teensy/teensy_ui.h
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-05-22 12:10:48 -0400
committeriamcheeseman <[email protected]>2026-05-22 12:10:48 -0400
commitc29b8d0730547af5928e059fa9828876f63c4625 (patch)
treeb3c9415e5c40cb8e59c5c0637e2e91433172a977 /teensy/teensy_ui.h
parentd5502bcb8422724f00de4d9778cb375e45a8d4d2 (diff)
tyui: move window parameters to a struct
additionally adds a minimum window size
Diffstat (limited to 'teensy/teensy_ui.h')
-rw-r--r--teensy/teensy_ui.h30
1 files changed, 20 insertions, 10 deletions
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);