fix: fix UI issues in Files app dialogs

This commit is contained in:
2026-06-07 10:56:43 +02:00
parent 9715cd608d
commit dff5a4a4b1
3 changed files with 36 additions and 8 deletions
+1 -1
View File
@@ -12,4 +12,4 @@
#pragma once
#define MONTAUK_BUILD_NUMBER 1
#define MONTAUK_BUILD_NUMBER 3
@@ -285,7 +285,17 @@ static void fileop_dialog_on_close(Window* win) {
static bool fileop_show_dialog(FileOpJob* job) {
DesktopState* ds = job->desktop;
int w = 380, h = 150;
// Size the window to the content laid out top-down in fileop_dialog_on_draw
// (title, current-item line, progress bar) plus the bottom-anchored Cancel
// button. With a fixed height the bottom button collided with the bar at
// the current font height, so derive the height from the layout instead.
int fh = system_font_height();
int bar_bottom = 18 + (fh + 10) + (fh + 12) + 10; // mirrors on_draw layout
int btn_h = 28;
int content_h = bar_bottom + 16 /*gap*/ + btn_h + 14 /*bottom margin*/;
int w = 380;
int h = content_h + gui::TITLEBAR_HEIGHT + gui::BORDER_WIDTH;
int wx = 0, wy = 0;
props_center_dialog(ds, job->owner, w, h, &wx, &wy);
@@ -407,6 +407,24 @@ static void props_on_close(Window* win) {
win->app_data = nullptr;
}
// Subtitle wording, shared between the width calculation at creation time and
// the draw path so the two never drift out of sync.
static const char* const kDeleteSubMulti =
"This will delete all selected items and their contents.";
static const char* const kDeleteSubSingle =
"This will delete all of its contents.";
// Pick a dialog width wide enough that the subtitle (drawn at x=80 with a 16px
// right margin) fits without being clipped. Falls back to the original 380px
// minimum and is capped so an absurd subtitle cannot create a huge window.
static int delete_confirm_dialog_width(const char* sub) {
int needed = 80 + text_width(sub) + 16;
int w = 380;
if (needed > w) w = needed;
if (w > 560) w = 560;
return w;
}
static void delete_confirm_button_rects(int content_w,
int content_h,
Rect* delete_btn,
@@ -505,10 +523,10 @@ static void delete_confirm_on_draw(Window* win, Framebuffer& fb) {
props_fit_text(title, title_fit, sizeof(title_fit), c.w - 88);
c.text(80, 22, title_fit, theme.text);
const char* sub = (st->count > 1)
? "This will delete all selected items and their contents."
: "This will delete all of its contents.";
c.text(80, 22 + fh + 8, sub, theme.text_muted);
const char* sub = (st->count > 1) ? kDeleteSubMulti : kDeleteSubSingle;
char sub_fit[160];
props_fit_text(sub, sub_fit, sizeof(sub_fit), c.w - 96);
c.text(80, 22 + fh + 8, sub_fit, theme.text_muted);
if (st->count <= 1) {
char path_fit[512];
@@ -623,7 +641,7 @@ void filemanager_show_directory_delete_confirmation(FileManagerState* fm, int ta
st->icon = ds->icon_folder_lg;
}
int w = 380;
int w = delete_confirm_dialog_width(kDeleteSubSingle);
int h = 180;
int wx = 0;
int wy = 0;
@@ -702,7 +720,7 @@ void filemanager_show_bulk_delete_confirmation(FileManagerState* fm,
if (ds->icon_folder_lg.pixels) st->icon = ds->icon_folder_lg;
int w = 380;
int w = delete_confirm_dialog_width(out > 1 ? kDeleteSubMulti : kDeleteSubSingle);
int h = 180;
int wx = 0;
int wy = 0;