[Bf-blender-cvs] [396558b36fb] master: Windows: use more standard button layout in quit dialog

Brecht Van Lommel noreply at git.blender.org
Sat May 18 12:21:06 CEST 2019


Commit: 396558b36fb32e2a8b6d5fc641d434351179afce
Author: Brecht Van Lommel
Date:   Sat May 18 12:15:59 2019 +0200
Branches: master
https://developer.blender.org/rB396558b36fb32e2a8b6d5fc641d434351179afce

Windows: use more standard button layout in quit dialog

macOS and Linux remain the same as before. Ref D3118.

===================================================================

M	source/blender/windowmanager/intern/wm_files.c

===================================================================

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;



More information about the Bf-blender-cvs mailing list