debug console different size when minimized
This commit is contained in:
parent
d48706d1f7
commit
751472eb86
68
src/user.c
68
src/user.c
@ -485,11 +485,11 @@ INTERNAL LOG_EVENT_CALLBACK_FUNC_DEF(debug_console_log_callback, log)
|
||||
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 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);
|
||||
f32 fade_curve = 0.5;
|
||||
f32 spacing = 0;
|
||||
@ -520,32 +520,34 @@ INTERNAL void draw_debug_console(b32 minimized)
|
||||
opacity *= math_pow(lin, fade_curve);
|
||||
}
|
||||
if (draw_pos.y > -desired_start_pos.y && opacity > 0) {
|
||||
/* Draw background */
|
||||
u32 color_index = log->index & 1; /* Alternate colors for greater distinction between logs */
|
||||
u32 color = info_colors[color_index];
|
||||
switch (log->level) {
|
||||
default: break;
|
||||
case LOG_LEVEL_ERROR: color = error_colors[color_index]; break;
|
||||
case LOG_LEVEL_WARNING: color = warning_colors[color_index]; break;
|
||||
case LOG_LEVEL_SUCCESS: color = success_colors[color_index]; break;
|
||||
if (log->level <= level) {
|
||||
/* Draw background */
|
||||
u32 color_index = log->index & 1; /* Alternate colors for greater distinction between logs */
|
||||
u32 color = info_colors[color_index];
|
||||
switch (log->level) {
|
||||
default: break;
|
||||
case LOG_LEVEL_ERROR: color = error_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 {
|
||||
break;
|
||||
}
|
||||
@ -2006,13 +2008,17 @@ INTERNAL void user_update(void)
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
#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
|
||||
if (G.debug_draw) {
|
||||
draw_debug_console(false);
|
||||
}
|
||||
if (G.debug_draw) {
|
||||
draw_debug_console(LOG_LEVEL_INFO, false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ========================== *
|
||||
* Render
|
||||
|
||||
Loading…
Reference in New Issue
Block a user