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