UI: layout and text changes for unsaved changes dialog
Patch by Harley Acheson, with additional changes by Yevgeny Makarov. Differential Revision: https://developer.blender.org/D5133
This commit is contained in:
committed by
Brecht Van Lommel
parent
77f01748e7
commit
c3e4a26816
@@ -3002,7 +3002,7 @@ static void wm_block_file_close_cancel_button(uiBlock *block, wmGenericCallback
|
||||
static void wm_block_file_close_discard_button(uiBlock *block, wmGenericCallback *post_action)
|
||||
{
|
||||
uiBut *but = uiDefIconTextBut(
|
||||
block, UI_BTYPE_BUT, 0, 0, IFACE_("Discard Changes"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, "");
|
||||
block, UI_BTYPE_BUT, 0, 0, IFACE_("Don't Save"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, "");
|
||||
UI_but_func_set(but, wm_block_file_close_discard, block, post_action);
|
||||
UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT);
|
||||
}
|
||||
@@ -3022,8 +3022,28 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi
|
||||
{
|
||||
wmGenericCallback *post_action = (wmGenericCallback *)arg1;
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
uiStyle *style = UI_style_get();
|
||||
uiFontStyle *fs = &style->widgetlabel;
|
||||
|
||||
/* Filename */
|
||||
const char *blendfile_pathpath = BKE_main_blendfile_path(bmain);
|
||||
char filename[FILE_MAX];
|
||||
if (blendfile_pathpath[0] != '\0') {
|
||||
BLI_split_file_part(blendfile_pathpath, filename, sizeof(filename));
|
||||
BLI_path_extension_replace(filename, sizeof(filename), "");
|
||||
}
|
||||
else {
|
||||
BLI_snprintf(filename, sizeof(filename), IFACE_("Untitled"));
|
||||
}
|
||||
|
||||
/* Title */
|
||||
char title[FILE_MAX + 100];
|
||||
UI_text_clip_middle_ex(
|
||||
fs, filename, U.widget_unit * 9, U.widget_unit * 2, sizeof(filename), '\0');
|
||||
BLI_snprintf(title, sizeof(title), TIP_("Save changes to \"%s\" before closing?"), filename);
|
||||
int title_width = MAX2(UI_fontstyle_string_width(fs, title), U.widget_unit * 22);
|
||||
|
||||
/* Create dialog */
|
||||
uiBlock *block = UI_block_begin(C, ar, close_file_dialog_name, UI_EMBOSS);
|
||||
|
||||
UI_block_flag_enable(
|
||||
@@ -3036,19 +3056,13 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi
|
||||
UI_LAYOUT_PANEL,
|
||||
10,
|
||||
2,
|
||||
U.widget_unit * 24,
|
||||
U.widget_unit * 2 + title_width,
|
||||
U.widget_unit * 6,
|
||||
0,
|
||||
style);
|
||||
|
||||
/* Title */
|
||||
bool blend_file_is_saved = BKE_main_blendfile_path(bmain)[0] != '\0';
|
||||
if (blend_file_is_saved) {
|
||||
uiItemL(layout, "This file has unsaved changes.", ICON_INFO);
|
||||
}
|
||||
else {
|
||||
uiItemL(layout, "This file has not been saved yet.", ICON_INFO);
|
||||
}
|
||||
uiItemL(layout, title, ICON_ERROR);
|
||||
|
||||
/* Image Saving */
|
||||
ReportList reports;
|
||||
@@ -3062,6 +3076,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi
|
||||
(modified_images_count == 1) ? "Save %u modified image" :
|
||||
"Save %u modified images",
|
||||
modified_images_count);
|
||||
uiItemS(layout);
|
||||
uiDefButBitC(block,
|
||||
UI_BTYPE_CHECKBOX,
|
||||
1,
|
||||
@@ -3094,10 +3109,12 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi
|
||||
const bool windows_layout = false;
|
||||
#endif
|
||||
|
||||
uiLayout *split = uiLayoutSplit(layout, 0.0f, true);
|
||||
|
||||
if (windows_layout) {
|
||||
/* Windows standard layout. */
|
||||
|
||||
uiLayout *split = uiLayoutSplit(layout, 0.18f, true);
|
||||
uiLayoutSetScaleY(split, 1.2f);
|
||||
|
||||
uiLayout *col = uiLayoutColumn(split, false);
|
||||
uiItemS(col);
|
||||
|
||||
@@ -3112,20 +3129,24 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi
|
||||
}
|
||||
else {
|
||||
/* macOS and Linux standard layout. */
|
||||
uiLayout *col = uiLayoutColumn(split, false);
|
||||
|
||||
uiLayout *split = uiLayoutSplit(layout, 0.0f, true);
|
||||
uiLayoutSetScaleY(split, 1.2f);
|
||||
|
||||
uiLayout *col = uiLayoutColumn(split, true);
|
||||
wm_block_file_close_discard_button(block, post_action);
|
||||
|
||||
col = uiLayoutColumn(split, false);
|
||||
col = uiLayoutColumn(split, true);
|
||||
uiItemS(col);
|
||||
|
||||
col = uiLayoutColumn(split, false);
|
||||
col = uiLayoutColumn(split, true);
|
||||
wm_block_file_close_cancel_button(block, post_action);
|
||||
|
||||
col = uiLayoutColumn(split, false);
|
||||
wm_block_file_close_save_button(block, post_action);
|
||||
}
|
||||
|
||||
UI_block_bounds_set_centered(block, 10);
|
||||
UI_block_bounds_set_centered(block, 14 * U.dpi_fac);
|
||||
return block;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user