debug console different size when minimized

This commit is contained in:
jacob 2025-05-24 13:59:57 -05:00
parent d48706d1f7
commit 751472eb86

View File

@ -485,11 +485,11 @@ INTERNAL LOG_EVENT_CALLBACK_FUNC_DEF(debug_console_log_callback, log)
sys_mutex_unlock(&lock); sys_mutex_unlock(&lock);
} }
INTERNAL void draw_debug_console(b32 minimized) INTERNAL void draw_debug_console(i32 level, b32 minimized)
{ {
struct temp_arena scratch = scratch_begin_no_conflict(); struct temp_arena scratch = scratch_begin_no_conflict();
struct v2 desired_start_pos = V2(10, 400); struct v2 desired_start_pos = V2(10, minimized ? 100 : 600);
i64 fade_time_ns = NS_FROM_SECONDS(10); i64 fade_time_ns = NS_FROM_SECONDS(10);
f32 fade_curve = 0.5; f32 fade_curve = 0.5;
f32 spacing = 0; f32 spacing = 0;
@ -520,32 +520,34 @@ INTERNAL void draw_debug_console(b32 minimized)
opacity *= math_pow(lin, fade_curve); opacity *= math_pow(lin, fade_curve);
} }
if (draw_pos.y > -desired_start_pos.y && opacity > 0) { if (draw_pos.y > -desired_start_pos.y && opacity > 0) {
/* Draw background */ if (log->level <= level) {
u32 color_index = log->index & 1; /* Alternate colors for greater distinction between logs */ /* Draw background */
u32 color = info_colors[color_index]; u32 color_index = log->index & 1; /* Alternate colors for greater distinction between logs */
switch (log->level) { u32 color = info_colors[color_index];
default: break; switch (log->level) {
case LOG_LEVEL_ERROR: color = error_colors[color_index]; break; default: break;
case LOG_LEVEL_WARNING: color = warning_colors[color_index]; break; case LOG_LEVEL_ERROR: color = error_colors[color_index]; break;
case LOG_LEVEL_SUCCESS: color = success_colors[color_index]; break; case LOG_LEVEL_WARNING: color = warning_colors[color_index]; break;
case LOG_LEVEL_SUCCESS: color = success_colors[color_index]; break;
}
draw_quad(G.ui_cmd_buffer, quad_from_rect(log->bounds), ALPHA_F(color, opacity));
/* Draw text */
struct string text = log->msg;
struct draw_text_params params = DRAW_TEXT_PARAMS(.font = font, .pos = draw_pos, .offset_y = DRAW_TEXT_OFFSET_Y_BOTTOM, .color = ALPHA_F(COLOR_WHITE, opacity), .str = text);
struct rect bounds = draw_text(G.ui_cmd_buffer, params);
struct rect draw_bounds = bounds;
draw_bounds.x -= bg_margin;
draw_bounds.y -= bg_margin;
draw_bounds.width += bg_margin * 2.f;
draw_bounds.height += bg_margin * 2.f;
draw_pos.y -= draw_bounds.height + spacing;
log->bounds = draw_bounds;
bounds_top = min_f32(bounds_top, draw_bounds.y);
bounds_bottom = max_f32(bounds_bottom, draw_bounds.y + draw_bounds.height);
} }
draw_quad(G.ui_cmd_buffer, quad_from_rect(log->bounds), ALPHA_F(color, opacity));
/* Draw text */
struct string text = log->msg;
struct draw_text_params params = DRAW_TEXT_PARAMS(.font = font, .pos = draw_pos, .offset_y = DRAW_TEXT_OFFSET_Y_BOTTOM, .color = ALPHA_F(COLOR_WHITE, opacity), .str = text);
struct rect bounds = draw_text(G.ui_cmd_buffer, params);
struct rect draw_bounds = bounds;
draw_bounds.x -= bg_margin;
draw_bounds.y -= bg_margin;
draw_bounds.width += bg_margin * 2.f;
draw_bounds.height += bg_margin * 2.f;
draw_pos.y -= draw_bounds.height + spacing;
log->bounds = draw_bounds;
bounds_top = min_f32(bounds_top, draw_bounds.y);
bounds_bottom = max_f32(bounds_bottom, draw_bounds.y + draw_bounds.height);
} else { } else {
break; break;
} }
@ -2006,13 +2008,17 @@ INTERNAL void user_update(void)
} }
} }
{
#if DEVELOPER #if DEVELOPER
draw_debug_console(!G.debug_draw); b32 console_minimized = !G.debug_draw;
i32 console_level = LOG_LEVEL_DEBUG;
draw_debug_console(console_level, console_minimized);
#else #else
if (G.debug_draw) { if (G.debug_draw) {
draw_debug_console(false); draw_debug_console(LOG_LEVEL_INFO, false);
} }
#endif #endif
}
/* ========================== * /* ========================== *
* Render * Render