paint: add frame time to debug tab

This commit is contained in:
luboslenco
2026-08-26 07:16:17 +02:00
parent 603bd98516
commit 8bf8d84dbc
+2 -71
View File
@@ -1,70 +1,6 @@
#include "../global.h"
i32 tab_debug_line_counter = 0;
void tab_debug_draw_list(ui_handle_t *list_handle, object_t *current_object) {
if (string_equals(char_at(current_object->name, 0), ".")) {
return; // Hidden
}
bool b = false;
// Highlight every other line
if (tab_debug_line_counter % 2 == 0) {
draw_set_color(g_theme->SEPARATOR_COL);
draw_filled_rect(0, g_ui->_y, g_ui->_window_w, UI_ELEMENT_H());
draw_set_color(0xffffffff);
}
if (current_object->children->length > 0) {
f32_array_t *row = f32_array_create_from_raw_tmp(
(f32[]){
1 / 13.0,
12 / 13.0,
},
2);
ui_row(row);
ui_handle_t *h = ui_nest(list_handle, tab_debug_line_counter);
if (h->init) {
h->b = true;
}
b = ui_panel(h, "", true, false, false);
ui_text(current_object->name, UI_ALIGN_LEFT, 0x00000000);
}
else {
g_ui->_x += 18; // Sign offset
// Draw line that shows parent relations
draw_set_color(g_theme->BUTTON_COL);
draw_line(g_ui->_x - 10, g_ui->_y + UI_ELEMENT_H() / 2.0, g_ui->_x, g_ui->_y + UI_ELEMENT_H() / 2.0, 1.0);
draw_set_color(0xffffffff);
ui_text(current_object->name, UI_ALIGN_LEFT, 0x00000000);
g_ui->_x -= 18;
}
tab_debug_line_counter++;
// Undo applied offset for row drawing caused by end_element()
g_ui->_y -= UI_ELEMENT_OFFSET();
if (b) {
i32 current_y = g_ui->_y;
for (i32 i = 0; i < current_object->children->length; ++i) {
object_t *child = current_object->children->buffer[i];
g_ui->_x += 8;
tab_debug_draw_list(list_handle, child);
g_ui->_x -= 8;
}
// Draw line that shows parent relations
draw_set_color(g_theme->BUTTON_COL);
draw_line(g_ui->_x + 14, current_y, g_ui->_x + 14, g_ui->_y - UI_ELEMENT_H() / 2.0, 1.0);
draw_set_color(0xffffffff);
}
}
void tab_debug_draw(ui_handle_t *htab) {
if (ui_tab(htab, tr("Debug"), false, -1, false)) {
@@ -82,13 +18,8 @@ void tab_debug_draw(ui_handle_t *htab) {
}
ui_handle_t *h1 = ui_handle(__ID__);
if (ui_panel(h1, "Scene", false, false, false)) {
tab_debug_line_counter = 0;
for (i32 i = 0; i < _scene_root->children->length; ++i) {
object_t *c = _scene_root->children->buffer[i];
tab_debug_draw_list(ui_handle(__ID__), c);
}
if (ui_panel(h1, "Performance", false, false, false)) {
ui_text(string_tmp("%.2f ms", sys_real_delta() * 1000.0f), UI_ALIGN_LEFT, 0x00000000);
}
}
}