summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2026-03-08 10:02:09 -0700
committer3gg <3gg@shellblade.net>2026-03-08 10:02:09 -0700
commit7f2987db18e515aec099a281fb4499fad8ffd4e0 (patch)
tree1f02ec715f721e4d1ef02162cb070c2d2b365045
parentb1bf31177f7d3e6fc65b00d2cdeaee36c634a0b0 (diff)
More concise headers
-rw-r--r--include/ui.h50
-rw-r--r--src/widget/table.h6
-rw-r--r--src/widget/widget.h19
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 {
139// ----------------------------------------------------------------------------- 139// -----------------------------------------------------------------------------
140// Library. 140// Library.
141 141
142/// Initialize the UI library.
143/// This should be called once during application startup.
144bool uiInit(void); 142bool uiInit(void);
145
146/// Shutdown the UI library.
147/// This should be called once during application shutdown.
148void uiShutdown(void); 143void uiShutdown(void);
149 144
150// ----------------------------------------------------------------------------- 145// -----------------------------------------------------------------------------
@@ -164,65 +159,40 @@ uiTable* uiGetTablePtr(uiPtr ptr);
164// Widget. 159// Widget.
165 160
166uiWidgetType uiWidgetGetType(const uiWidget*); 161uiWidgetType uiWidgetGetType(const uiWidget*);
167 162void uiWidgetSetParent(uiPtr child, uiPtr parent);
168void uiWidgetSetParent(uiPtr child, uiPtr parent);
169 163
170// ----------------------------------------------------------------------------- 164// -----------------------------------------------------------------------------
171// Button. 165// Button.
172 166
173/// Create a button.
174uiButton* uiMakeButton(const char* text); 167uiButton* uiMakeButton(const char* text);
175 168
176// ----------------------------------------------------------------------------- 169// -----------------------------------------------------------------------------
177// Frame. 170// Frame.
178 171
179/// Create a frame.
180uiFrame* uiMakeFrame(void); 172uiFrame* uiMakeFrame(void);
181 173void uiDestroyFrame(uiFrame**);
182/// Destroy the frame. 174void uiResizeFrame(uiFrame*, int width, int height);
183void uiDestroyFrame(uiFrame**); 175uiSize uiGetFrameSize(const uiFrame*);
184
185/// Resize the frame.
186void uiResizeFrame(uiFrame*, int width, int height);
187
188/// Get the frame's dimensions.
189uiSize uiGetFrameSize(const uiFrame*);
190 176
191// ----------------------------------------------------------------------------- 177// -----------------------------------------------------------------------------
192// Label. 178// Label.
193 179
194/// Create a label. 180uiLabel* uiMakeLabel(const char* text);
195uiLabel* uiMakeLabel(const char* text);
196
197/// Return the label's text.
198const char* uiLabelGetText(const uiLabel*); 181const char* uiLabelGetText(const uiLabel*);
199 182
200// ----------------------------------------------------------------------------- 183// -----------------------------------------------------------------------------
201// Table. 184// Table.
202 185
203/// Create a table. 186uiTable* uiMakeTable(int rows, int cols, const char** header);
204uiTable* uiMakeTable(int rows, int cols, const char** header); 187void uiTableClear(uiTable*);
205 188void uiTableAddRow(uiTable*, const char** row);
206/// Clear the table. 189void uiTableSet(uiTable*, int row, int col, uiPtr widget);
207/// This clears the contents, but not the header.
208void uiTableClear(uiTable*);
209
210/// Add a row.
211void uiTableAddRow(uiTable*, const char** row);
212
213/// Set the table's cell.
214void uiTableSet(uiTable*, int row, int col, uiPtr widget);
215
216/// Get the table's cell.
217const uiWidget* uiTableGet(const uiTable*, int row, int col); 190const uiWidget* uiTableGet(const uiTable*, int row, int col);
218 191uiWidget* uiTableGetMut(uiTable*, int row, int col);
219/// Get the table's cell.
220uiWidget* uiTableGetMut(uiTable*, int row, int col);
221 192
222// ----------------------------------------------------------------------------- 193// -----------------------------------------------------------------------------
223// Rendering. 194// Rendering.
224 195
225/// Render the frame.
226void uiRender(const uiFrame*, uiSurface*); 196void uiRender(const uiFrame*, uiSurface*);
227 197
228// ----------------------------------------------------------------------------- 198// -----------------------------------------------------------------------------
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 @@
5#include "widget.h" 5#include "widget.h"
6 6
7const uiCell* GetCell(const uiTable* table, int row, int col); 7const uiCell* GetCell(const uiTable* table, int row, int col);
8 8uiCell* GetCellMut(uiTable* table, int row, int col);
9uiCell* GetCellMut(uiTable* table, int row, int col); 9uiCell** GetLastRow(uiTable* table);
10
11uiCell** 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 @@
9 9
10DEF_LIST(Widget, uiWidget*) 10DEF_LIST(Widget, uiWidget*)
11 11
12#define UI_NEW(TYPE) (TYPE*)uiAlloc(1, sizeof(TYPE))
13
14static inline void* uiAlloc(size_t count, size_t size) {
15 void* mem = calloc(count, size);
16 ASSERT(mem);
17 return mem;
18}
19
20// -----------------------------------------------------------------------------
21// Widgets.
22
23/// Base widget type. 12/// Base widget type.
24typedef struct uiWidget { 13typedef struct uiWidget {
25 uiWidgetType type; 14 uiWidgetType type;
@@ -66,3 +55,11 @@ typedef struct uiTable {
66} uiTable; 55} uiTable;
67 56
68void DestroyWidget(uiWidget** ppWidget); 57void DestroyWidget(uiWidget** ppWidget);
58
59#define UI_NEW(TYPE) (TYPE*)uiAlloc(1, sizeof(TYPE))
60
61static inline void* uiAlloc(size_t count, size_t size) {
62 void* mem = calloc(count, size);
63 ASSERT(mem);
64 return mem;
65}