#pragma once #include #include #include #include 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; uiRect rect; Widget_list children; } uiWidget; /// Button. typedef struct uiButton { uiWidget widget; string text; } uiButton; /// Frame. typedef struct uiFrame { uiWidget widget; } uiFrame; /// Label. typedef struct uiLabel { uiWidget widget; string text; } uiLabel; /// Table cell. typedef struct uiCell { uiWidget* child; } uiCell; /// Table. typedef struct uiTable { uiWidget widget; int rows; int cols; int* widths; // Width, in pixels, for each column. uiCell* header; // If non-null, row of 'cols' header cells. uiCell** cells; // Array of 'rows' rows, each of 'cols' cells. int offset; // Offset into the rows of the table. Units: rows. struct { bool vertical_overflow : 1; // True if contents overflow vertically. } flags; } uiTable; void DestroyWidget(uiWidget** ppWidget);