diff options
Diffstat (limited to 'teensy/teensy_ui.h')
| -rw-r--r-- | teensy/teensy_ui.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/teensy/teensy_ui.h b/teensy/teensy_ui.h index 65722ac..1e97376 100644 --- a/teensy/teensy_ui.h +++ b/teensy/teensy_ui.h @@ -12,6 +12,7 @@ #define TYUI_WIN_NOMOVE (1 << 2) #define TYUI_WIN_INVISIBLE (1 << 3) +// Marks the beginning of a window, with sane defaults. #define tyui_begin_window(_title, _rect, _id) \ tyui_begin_window_ex((tyui_Window_Conf){ \ .title = _title, \ @@ -21,9 +22,12 @@ .flags = 0, \ }, NULL) +// Displays left-aligned, formatted text. #define tyui_text(...) tyui_text_ex(TYUI_ALIGN_LEFT, __VA_ARGS__) +// Displays a slider with a centered value display. #define tyui_slider(min, max, value_ptr) \ tyui_slider_ex(min, max, value_ptr, true, TYUI_ALIGN_CENTER) +// Displays a slider without a value display. #define tyui_blank_slider(min, max, value_ptr) \ tyui_slider_ex(min, max, value_ptr, false, 0) @@ -34,6 +38,7 @@ enum { TYUI_ALIGN_CENTER, }; +// An ID to refer to resources from TYUI. typedef uint8_t tyui_Id; typedef struct { @@ -66,14 +71,24 @@ typedef struct { void tyui_init(const ty_Font *font); void tyui_deinit(void); +// Pushes a layout to the layout stack. `column_widths` is either whole widths +// in pixels, a negative number to calculate the width from the right side of +// the layout, or a percentage of the width, from 0-1. void tyui_push_layout(const float *column_widths); +// Removes the most recently defined layout. void tyui_pop_layout(void); +// Marks the beginning of a window. Use `tyui_begin_window()` unless you need +// something specific. bool tyui_begin_window_ex(tyui_Window_Conf conf, bool *closed_ptr); +// Marks the end of a window. Must only be called if the window actually opens. void tyui_end_window(void); +// Displays a button. Returns true if it has been clicked. bool tyui_button(const char *text); +// Displays text with a custom text alignment. void tyui_text_ex(tyui_Align align, const char *fmt, ...); +// Displays a slider with custom alignment. void tyui_slider_ex( float min, float max, @@ -82,6 +97,7 @@ void tyui_slider_ex( tyui_Align value_align ); +// Draws all accumulated draw commands and initializes the next frame. void tyui_draw(void); #endif // TEENSY_UI_H_ |
