diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-18 13:15:59 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-05-18 13:19:27 +0300 |
commit | 396558b36fb32e2a8b6d5fc641d434351179afce (patch) | |
tree | 5343dd4136537e53863200c770c4e48b4d3331b4 /source/blender/windowmanager/intern/wm_files.c | |
parent | 7fd015bb70b2fe690d06a97ef8df54eed511d1ba (diff) |
Windows: use more standard button layout in quit dialog
macOS and Linux remain the same as before. Ref D3118.
Diffstat (limited to 'source/blender/windowmanager/intern/wm_files.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_files.c | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 96b97f67cda..9e9619c698d 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -2900,6 +2900,31 @@ static void wm_block_file_close_save(bContext *C, void *arg_block, void *arg_dat wm_generic_callback_free(callback); } +static void wm_block_file_close_cancel_button(uiBlock *block, GenericCallback *post_action) +{ + uiBut *but = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, 0, IFACE_("Cancel"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, ""); + UI_but_func_set(but, wm_block_file_close_cancel, block, post_action); + UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); +} + +static void wm_block_file_close_discard_button(uiBlock *block, GenericCallback *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, ""); + UI_but_func_set(but, wm_block_file_close_discard, block, post_action); + UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); +} + +static void wm_block_file_close_save_button(uiBlock *block, GenericCallback *post_action) +{ + uiBut *but = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, 0, IFACE_("Save"), 0, 0, 0, UI_UNIT_Y, 0, 0, 0, 0, 0, ""); + UI_but_func_set(but, wm_block_file_close_save, block, post_action); + UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); + UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); +} + static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegion *ar, void *arg1) { GenericCallback *post_action = (GenericCallback *)arg1; @@ -2923,6 +2948,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi 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); @@ -2931,6 +2957,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi uiItemL(layout, "This file has not been saved yet.", ICON_INFO); } + /* Image Saving */ ReportList reports; BKE_reports_init(&reports, RPT_STORE); uint modified_images_count = ED_image_save_all_modified_info(C, &reports); @@ -2967,70 +2994,43 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, struct ARegi uiItemL(layout, "", ICON_NONE); - uiBut *but; + /* Buttons */ +#ifdef _WIN32 + const bool windows_layout = true; +#else + const bool windows_layout = false; +#endif + uiLayout *split = uiLayoutSplit(layout, 0.0f, true); - uiLayout *col = uiLayoutColumn(split, false); - but = uiDefIconTextBut(block, - UI_BTYPE_BUT, - 0, - 0, - IFACE_("Cancel"), - 0, - 0, - 0, - UI_UNIT_Y, - NULL, - 0, - 0, - 0, - 0, - ""); - UI_but_func_set(but, wm_block_file_close_cancel, block, post_action); - UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); + if (windows_layout) { + /* Windows standard layout. */ + uiLayout *col = uiLayoutColumn(split, false); + uiItemS(col); - /* empty space between buttons */ - col = uiLayoutColumn(split, false); - uiItemS(col); + col = uiLayoutColumn(split, false); + wm_block_file_close_save_button(block, post_action); - col = uiLayoutColumn(split, false); - but = uiDefIconTextBut(block, - UI_BTYPE_BUT, - 0, - 0, - IFACE_("Discard Changes"), - 0, - 0, - 50, - UI_UNIT_Y, - NULL, - 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); + col = uiLayoutColumn(split, false); + wm_block_file_close_discard_button(block, post_action); - col = uiLayoutColumn(split, false); - but = uiDefIconTextBut(block, - UI_BTYPE_BUT, - 0, - 0, - IFACE_("Save"), - 0, - 0, - 50, - UI_UNIT_Y, - NULL, - 0, - 0, - 0, - 0, - ""); - UI_but_func_set(but, wm_block_file_close_save, block, post_action); - UI_but_drawflag_disable(but, UI_BUT_TEXT_LEFT); - UI_but_flag_enable(but, UI_BUT_ACTIVE_DEFAULT); + col = uiLayoutColumn(split, false); + wm_block_file_close_cancel_button(block, post_action); + } + else { + /* macOS and Linux standard layout. */ + uiLayout *col = uiLayoutColumn(split, false); + wm_block_file_close_cancel_button(block, post_action); + + col = uiLayoutColumn(split, false); + uiItemS(col); + + col = uiLayoutColumn(split, false); + wm_block_file_close_discard_button(block, post_action); + + col = uiLayoutColumn(split, false); + wm_block_file_close_save_button(block, post_action); + } UI_block_bounds_set_centered(block, 10); return block; |