Add method for getting unique key id

This commit is contained in:
2023-12-21 18:02:14 +01:00
parent d34783e40b
commit e708d5e2cb
2 changed files with 7 additions and 2 deletions

View File

@@ -49,7 +49,7 @@ typedef struct BzUI {
BzUINode *root;
u64 currFrame;
u64 idCount; // Per-frame
u64 keyIdCount; // Per-frame
} BzUI;
BzUIKey bzUIKeyNull() {
@@ -114,7 +114,7 @@ void bzUIBegin(BzUI *ui, i32 width, i32 height) {
ui->currFrame++;
ui->root->lastFrame = ui->currFrame;
ui->idCount = 1;
ui->keyIdCount = 1;
}
static Rectangle getNodeRect(const BzUINode *node) {
@@ -381,6 +381,10 @@ void bzUIEnd(BzUI *ui) {
renderNode(ui, ui->root);
}
BzUIKey bzUIGetUniqueKey(BzUI *ui) {
return ui->keyIdCount++;
}
BzUINode *bzUINodeMake(BzUI *ui, BzUIKey key, BzUIFlags flags) {
BzUINode *node = NULL;
if (key != bzUIKeyNull())

View File

@@ -119,6 +119,7 @@ void bzUIDestroy(BzUI *ui);
void bzUIBegin(BzUI *ui, i32 width, i32 height);
void bzUIEnd(BzUI *ui);
BzUIKey bzUIGetUniqueKey(BzUI *ui);
BzUINode *bzUINodeMake(BzUI *ui, BzUIKey key, BzUIFlags flags);