From 7f2987db18e515aec099a281fb4499fad8ffd4e0 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sun, 8 Mar 2026 10:02:09 -0700 Subject: More concise headers --- include/ui.h | 50 ++++++++++---------------------------------------- src/widget/table.h | 6 ++---- src/widget/widget.h | 19 ++++++++----------- 3 files changed, 20 insertions(+), 55 deletions(-) diff --git a/include/ui.h b/include/ui.h index 8570552..d8df105 100644 --- a/include/ui.h +++ b/include/ui.h @@ -139,12 +139,7 @@ typedef struct uiWidgetEvent { // ----------------------------------------------------------------------------- // Library. -/// Initialize the UI library. -/// This should be called once during application startup. bool uiInit(void); - -/// Shutdown the UI library. -/// This should be called once during application shutdown. void uiShutdown(void); // ----------------------------------------------------------------------------- @@ -164,65 +159,40 @@ uiTable* uiGetTablePtr(uiPtr ptr); // Widget. uiWidgetType uiWidgetGetType(const uiWidget*); - -void uiWidgetSetParent(uiPtr child, uiPtr parent); +void uiWidgetSetParent(uiPtr child, uiPtr parent); // ----------------------------------------------------------------------------- // Button. -/// Create a button. uiButton* uiMakeButton(const char* text); // ----------------------------------------------------------------------------- // Frame. -/// Create a frame. uiFrame* uiMakeFrame(void); - -/// Destroy the frame. -void uiDestroyFrame(uiFrame**); - -/// Resize the frame. -void uiResizeFrame(uiFrame*, int width, int height); - -/// Get the frame's dimensions. -uiSize uiGetFrameSize(const uiFrame*); +void uiDestroyFrame(uiFrame**); +void uiResizeFrame(uiFrame*, int width, int height); +uiSize uiGetFrameSize(const uiFrame*); // ----------------------------------------------------------------------------- // Label. -/// Create a label. -uiLabel* uiMakeLabel(const char* text); - -/// Return the label's text. +uiLabel* uiMakeLabel(const char* text); const char* uiLabelGetText(const uiLabel*); // ----------------------------------------------------------------------------- // Table. -/// Create a table. -uiTable* uiMakeTable(int rows, int cols, const char** header); - -/// Clear the table. -/// This clears the contents, but not the header. -void uiTableClear(uiTable*); - -/// Add a row. -void uiTableAddRow(uiTable*, const char** row); - -/// Set the table's cell. -void uiTableSet(uiTable*, int row, int col, uiPtr widget); - -/// Get the table's cell. +uiTable* uiMakeTable(int rows, int cols, const char** header); +void uiTableClear(uiTable*); +void uiTableAddRow(uiTable*, const char** row); +void uiTableSet(uiTable*, int row, int col, uiPtr widget); const uiWidget* uiTableGet(const uiTable*, int row, int col); - -/// Get the table's cell. -uiWidget* uiTableGetMut(uiTable*, int row, int col); +uiWidget* uiTableGetMut(uiTable*, int row, int col); // ----------------------------------------------------------------------------- // Rendering. -/// Render the frame. void uiRender(const uiFrame*, uiSurface*); // ----------------------------------------------------------------------------- diff --git a/src/widget/table.h b/src/widget/table.h index 9f466de..0585140 100644 --- a/src/widget/table.h +++ b/src/widget/table.h @@ -5,7 +5,5 @@ #include "widget.h" const uiCell* GetCell(const uiTable* table, int row, int col); - -uiCell* GetCellMut(uiTable* table, int row, int col); - -uiCell** GetLastRow(uiTable* table); +uiCell* GetCellMut(uiTable* table, int row, int col); +uiCell** GetLastRow(uiTable* table); diff --git a/src/widget/widget.h b/src/widget/widget.h index c75bd65..79a72f3 100644 --- a/src/widget/widget.h +++ b/src/widget/widget.h @@ -9,17 +9,6 @@ DEF_LIST(Widget, uiWidget*) -#define UI_NEW(TYPE) (TYPE*)uiAlloc(1, sizeof(TYPE)) - -static inline void* uiAlloc(size_t count, size_t size) { - void* mem = calloc(count, size); - ASSERT(mem); - return mem; -} - -// ----------------------------------------------------------------------------- -// Widgets. - /// Base widget type. typedef struct uiWidget { uiWidgetType type; @@ -66,3 +55,11 @@ typedef struct uiTable { } uiTable; void DestroyWidget(uiWidget** ppWidget); + +#define UI_NEW(TYPE) (TYPE*)uiAlloc(1, sizeof(TYPE)) + +static inline void* uiAlloc(size_t count, size_t size) { + void* mem = calloc(count, size); + ASSERT(mem); + return mem; +} -- cgit v1.2.3