Add debug mode flag to UI

This commit is contained in:
2024-01-15 10:21:27 +01:00
parent 087b8f22a7
commit 6a54ba90c1
2 changed files with 8 additions and 1 deletions

View File

@@ -71,6 +71,7 @@ typedef struct BzUI {
bool captureKeyboard; bool captureKeyboard;
bool capturedMouse; bool capturedMouse;
bool capturedKeyboard; bool capturedKeyboard;
bool debugMode;
} BzUI; } BzUI;
BzUIKey bzUIKeyNull() { BzUIKey bzUIKeyNull() {
@@ -171,6 +172,10 @@ void bzUISetCaptureKeyboard(BzUI *ui, bool state) {
ui->captureKeyboard = state; ui->captureKeyboard = state;
} }
void bzUISetDebugMode(BzUI *ui, bool mode) {
ui->debugMode = mode;
}
void bzUIBegin(BzUI *ui, i32 width, i32 height) { void bzUIBegin(BzUI *ui, i32 width, i32 height) {
bzArrayClear(ui->nodeStack); bzArrayClear(ui->nodeStack);
bzArrayPush(ui->nodeStack, ui->root); bzArrayPush(ui->nodeStack, ui->root);
@@ -508,7 +513,7 @@ static void renderNode(BzUI *ui, BzUINode *node) {
drawRect.x, drawRect.y drawRect.x, drawRect.y
}, style.fontSize, style.fontSpacing, color); }, style.fontSize, style.fontSpacing, color);
} }
if (node->flags & BZ_UI_DRAW_DEBUG) { if (node->flags & BZ_UI_DRAW_DEBUG || ui->debugMode) {
DrawRectangleLines(rect.x, rect.y, rect.width, rect.height, RED); DrawRectangleLines(rect.x, rect.y, rect.width, rect.height, RED);
} }

View File

@@ -189,6 +189,8 @@ bool bzUIGetCaptureKeyboard(BzUI *ui);
void bzUISetCaptureMouse(BzUI *ui, bool state); void bzUISetCaptureMouse(BzUI *ui, bool state);
void bzUISetCaptureKeyboard(BzUI *ui, bool state); void bzUISetCaptureKeyboard(BzUI *ui, bool state);
void bzUISetDebugMode(BzUI *ui, bool mode);
void bzUIBegin(BzUI *ui, i32 width, i32 height); void bzUIBegin(BzUI *ui, i32 width, i32 height);
void bzUIEnd(BzUI *ui); void bzUIEnd(BzUI *ui);