Files
armorpaint/paint/sources/ui/tab_debug.c
T

95 lines
2.6 KiB
C
Raw Normal View History

2026-05-05 10:42:22 +02:00
2026-06-04 11:00:05 +02:00
#include "../global.h"
2026-05-05 10:42:22 +02:00
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) {
2026-06-08 15:35:04 +02:00
draw_set_color(g_theme->SEPARATOR_COL);
2026-06-08 11:42:44 +02:00
draw_filled_rect(0, g_ui->_y, g_ui->_window_w, UI_ELEMENT_H());
2026-05-05 10:42:22 +02:00
draw_set_color(0xffffffff);
}
if (current_object->children->length > 0) {
2026-08-21 22:35:41 +02:00
f32_array_t *row = f32_array_create_from_raw_tmp(
2026-05-05 10:42:22 +02:00
(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 {
2026-06-08 11:42:44 +02:00
g_ui->_x += 18; // Sign offset
2026-05-05 10:42:22 +02:00
// Draw line that shows parent relations
2026-06-08 15:35:04 +02:00
draw_set_color(g_theme->BUTTON_COL);
2026-06-08 11:42:44 +02:00
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);
2026-05-05 10:42:22 +02:00
draw_set_color(0xffffffff);
ui_text(current_object->name, UI_ALIGN_LEFT, 0x00000000);
2026-06-08 11:42:44 +02:00
g_ui->_x -= 18;
2026-05-05 10:42:22 +02:00
}
tab_debug_line_counter++;
// Undo applied offset for row drawing caused by end_element()
2026-06-08 11:42:44 +02:00
g_ui->_y -= UI_ELEMENT_OFFSET();
2026-05-05 10:42:22 +02:00
if (b) {
2026-06-08 11:42:44 +02:00
i32 current_y = g_ui->_y;
2026-05-05 10:42:22 +02:00
for (i32 i = 0; i < current_object->children->length; ++i) {
object_t *child = current_object->children->buffer[i];
2026-06-08 11:42:44 +02:00
g_ui->_x += 8;
2026-05-05 10:42:22 +02:00
tab_debug_draw_list(list_handle, child);
2026-06-08 11:42:44 +02:00
g_ui->_x -= 8;
2026-05-05 10:42:22 +02:00
}
// Draw line that shows parent relations
2026-06-08 15:35:04 +02:00
draw_set_color(g_theme->BUTTON_COL);
2026-06-08 11:42:44 +02:00
draw_line(g_ui->_x + 14, current_y, g_ui->_x + 14, g_ui->_y - UI_ELEMENT_H() / 2.0, 1.0);
2026-05-05 10:42:22 +02:00
draw_set_color(0xffffffff);
}
}
void tab_debug_draw(ui_handle_t *htab) {
if (ui_tab(htab, tr("Debug"), false, -1, false)) {
ui_handle_t *h0 = ui_handle(__ID__);
if (ui_panel(h0, "Render Targets", false, false, false)) {
string_array_t *rt_keys = map_keys(render_path_render_targets);
array_sort(rt_keys, NULL);
for (i32 i = 0; i < rt_keys->length; ++i) {
render_target_t *rt = any_map_get(render_path_render_targets, rt_keys->buffer[i]);
ui_text(rt_keys->buffer[i], UI_ALIGN_LEFT, 0x00000000);
ui_image(rt->_image, 0xffffffff, -1.0);
}
2026-08-21 22:35:41 +02:00
array_free(rt_keys);
free(rt_keys);
2026-05-05 10:42:22 +02:00
}
ui_handle_t *h1 = ui_handle(__ID__);
if (ui_panel(h1, "Scene", false, false, false)) {
tab_debug_line_counter = 0;
2026-08-14 16:58:51 +02:00
for (i32 i = 0; i < _scene_root->children->length; ++i) {
object_t *c = _scene_root->children->buffer[i];
2026-05-05 10:42:22 +02:00
tab_debug_draw_list(ui_handle(__ID__), c);
}
}
}
}