Make the volume dialog's close button functional

This commit is contained in:
kichikuou
2026-06-29 11:44:21 +09:00
parent c119c2f969
commit 63886d7d00
2 changed files with 15 additions and 1 deletions
+12
View File
@@ -182,6 +182,18 @@ static void render_icon(int id, mu_Rect rect, mu_Color color) {
draw_thick_line(bx, by, cx, cy, thickness);
break;
}
case MU_ICON_CLOSE: {
// An X mark: two crossing diagonal strokes.
float x = rect.x, y = rect.y, w = rect.w, h = rect.h;
float lx = x + w * 0.32f, rx = x + w * 0.68f;
float ty = y + h * 0.32f, by = y + h * 0.68f;
int thickness = rect.w / 16;
if (thickness < 1)
thickness = 1;
draw_thick_line(lx, ty, rx, by, thickness);
draw_thick_line(lx, by, rx, ty, thickness);
break;
}
default: {
SDL_Rect r = { rect.x + rect.w / 2 - 2, rect.y + rect.h / 2 - 2, 4, 4 };
SDL_RenderFillRect(gfx_renderer, &r);
+3 -1
View File
@@ -166,7 +166,7 @@ static bool volume_build(mu_Context *ctx, modal *modal) {
mu_Rect r = mu_rect((view_w - w) / 2, (view_h - h) / 2, w, h);
if (mu_begin_window_ex(ctx, _("Volume"), r,
MU_OPT_NORESIZE | MU_OPT_NOCLOSE | MU_OPT_NOSCROLL)) {
MU_OPT_NORESIZE | MU_OPT_NOSCROLL)) {
for (int i = 0; i < count; i++) {
if (!ch[i].label)
continue;
@@ -193,6 +193,8 @@ static bool volume_build(mu_Context *ctx, modal *modal) {
if (mu_button(ctx, _("Close")))
keep_open = false;
mu_end_window(ctx);
} else {
keep_open = false; // The title-bar close button was clicked.
}
if (st->base.cancelled) // Esc