fix: fix UI issues in Files app dialogs
This commit is contained in:
@@ -12,4 +12,4 @@
|
|||||||
|
|
||||||
#pragma once
|
#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) {
|
static bool fileop_show_dialog(FileOpJob* job) {
|
||||||
DesktopState* ds = job->desktop;
|
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;
|
int wx = 0, wy = 0;
|
||||||
props_center_dialog(ds, job->owner, w, h, &wx, &wy);
|
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;
|
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,
|
static void delete_confirm_button_rects(int content_w,
|
||||||
int content_h,
|
int content_h,
|
||||||
Rect* delete_btn,
|
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);
|
props_fit_text(title, title_fit, sizeof(title_fit), c.w - 88);
|
||||||
c.text(80, 22, title_fit, theme.text);
|
c.text(80, 22, title_fit, theme.text);
|
||||||
|
|
||||||
const char* sub = (st->count > 1)
|
const char* sub = (st->count > 1) ? kDeleteSubMulti : kDeleteSubSingle;
|
||||||
? "This will delete all selected items and their contents."
|
char sub_fit[160];
|
||||||
: "This will delete all of its contents.";
|
props_fit_text(sub, sub_fit, sizeof(sub_fit), c.w - 96);
|
||||||
c.text(80, 22 + fh + 8, sub, theme.text_muted);
|
c.text(80, 22 + fh + 8, sub_fit, theme.text_muted);
|
||||||
|
|
||||||
if (st->count <= 1) {
|
if (st->count <= 1) {
|
||||||
char path_fit[512];
|
char path_fit[512];
|
||||||
@@ -623,7 +641,7 @@ void filemanager_show_directory_delete_confirmation(FileManagerState* fm, int ta
|
|||||||
st->icon = ds->icon_folder_lg;
|
st->icon = ds->icon_folder_lg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w = 380;
|
int w = delete_confirm_dialog_width(kDeleteSubSingle);
|
||||||
int h = 180;
|
int h = 180;
|
||||||
int wx = 0;
|
int wx = 0;
|
||||||
int wy = 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;
|
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 h = 180;
|
||||||
int wx = 0;
|
int wx = 0;
|
||||||
int wy = 0;
|
int wy = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user