#ifndef TEENSY_UI_H_ #define TEENSY_UI_H_ #include "teensy_common.h" #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((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) #define tyui_blank_slider(min, max, value_ptr) \ tyui_slider_ex(min, max, value_ptr, false, 0) typedef uint8_t tyui_Align; enum { TYUI_ALIGN_LEFT, TYUI_ALIGN_RIGHT, TYUI_ALIGN_CENTER, }; typedef uint8_t tyui_Id; typedef struct { ty_Color fg_normal; ty_Color bg_normal; ty_Color fg_hover; ty_Color bg_hover; ty_Color fg_pressed; ty_Color bg_pressed; ty_Color win_bg; ty_Color win_border; ty_Color win_title; ty_Color frame; int title_bar_height; int padding; int control_padding; int frame_size; int grabber_size; const char *slider_fmt; } tyui_Style; 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); void tyui_push_layout(const float *column_widths); void tyui_pop_layout(void); bool tyui_begin_window_ex(tyui_Window_Conf conf, bool *closed_ptr); void tyui_end_window(void); bool tyui_button(const char *text); void tyui_text_ex(tyui_Align align, const char *fmt, ...); void tyui_slider_ex( float min, float max, float *value_ptr, bool show_value, tyui_Align value_align ); void tyui_draw(void); #endif // TEENSY_UI_H_