UI core boiler plate

This commit is contained in:
2023-12-20 11:25:01 +01:00
parent ebda550bf2
commit 70cc2eae8c
9 changed files with 2072 additions and 2 deletions

49
game/ui_widgets.h Normal file
View File

@@ -0,0 +1,49 @@
#ifndef PIXELDEFENSE_UI_H
#define PIXELDEFENSE_UI_H
#include <breeze.h>
#include <raygui.h>
typedef struct UIGrid {
i32 rows;
i32 cols;
f32 rowPadding;
f32 cellPadding;
Rectangle bounds;
} UIGrid;
UIGrid uiGridFromRoot(i32 width, i32 height);
UIGrid uiGridFromGrid(const UIGrid grid, i32 row, i32 col);
UIGrid uiGridFromGridSpan(const UIGrid grid, i32 row, i32 col, i32 rowSpan, i32 colSpan);
Rectangle uiGridCell(const UIGrid grid, i32 row, i32 col);
Rectangle uiGridCellSpan(const UIGrid grid, i32 row, i32 col, i32 rowSpan, i32 colSpan);
void uiGridDrawCells(const UIGrid grid);
typedef enum UIFlexBoxFlag {
UI_FLEX_NONE = 0,
UI_FLEX_DIR_ROW = 0b1,
UI_FLEX_DIR_COLUMN = 0b10,
UI_FLEX_ALIGN_START = 0b100,
UI_FLEX_ALIGN_CENTER = 0b1000,
UI_FLEX_ALIGN_END = 0b10000,
UI_FLEX_JUSTIFY_START = 0b100000,
UI_FLEX_JUSTIFY_CENTER = 0b1000000,
UI_FLEX_JUSTIFY_END = 0b10000000,
} UIFlexBoxFlag;
typedef struct FlexBoxDesc {
Rectangle window;
UIFlexBoxFlag flags;
f32 padding;
} FlexBoxDesc;
void uiFlexBoxCalc(const FlexBoxDesc *desc, i32 numElements, ...);
static f32 uiScale() {
return GetScreenHeight() / 720.0f;
}
#endif //PIXELDEFENSE_UI_H