[Bf-blender-cvs] [0c62906a414] master: UI: Correct the text alignment in the quick setup (splash screen) dialog

Yevgeny Makarov noreply at git.blender.org
Sun Feb 21 17:32:45 CET 2021


Commit: 0c62906a4145b242d5ed772209038f65d7b493a8
Author: Yevgeny Makarov
Date:   Sun Feb 21 17:26:55 2021 +0100
Branches: master
https://developer.blender.org/rB0c62906a4145b242d5ed772209038f65d7b493a8

UI: Correct the text alignment in the quick setup (splash screen) dialog

The "quick setup" dialog is actually a 'menu', and the "splash screen" block
contains the UI_BLOCK_LOOP flag which causes the buttons' text to align
to the left, however, usually regular buttons have centered text.

As a workaround, add the UI_BLOCK_QUICK_SETUP flag which prevents
the text from being left-aligned.

Differential Revision: https://developer.blender.org/D10486

Reviewed by: Julian Eisel

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

M	release/scripts/startup/bl_operators/wm.py
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/windowmanager/intern/wm_splash_screen.c

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

diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index db15f4597bf..3b94a964148 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -2479,10 +2479,10 @@ class WM_OT_batch_rename(Operator):
         return wm.invoke_props_dialog(self, width=400)
 
 
-class WM_MT_splash(Menu):
-    bl_label = "Splash"
+class WM_MT_splash_quick_setup(Menu):
+    bl_label = "Quick Setup"
 
-    def draw_setup(self, context):
+    def draw(self, context):
         wm = context.window_manager
         # prefs = context.preferences
 
@@ -2570,18 +2570,11 @@ class WM_MT_splash(Menu):
         layout.separator()
         layout.separator()
 
-    def draw(self, context):
-        # Draw setup screen if no preferences have been saved yet.
-        import os
 
-        userconfig_path = bpy.utils.user_resource('CONFIG')
-        userdef_path = os.path.join(userconfig_path, "userpref.blend")
-
-        if not os.path.isfile(userdef_path):
-            self.draw_setup(context)
-            return
+class WM_MT_splash(Menu):
+    bl_label = "Splash"
 
-        # Pass
+    def draw(self, context):
         layout = self.layout
         layout.operator_context = 'EXEC_DEFAULT'
         layout.emboss = 'PULLDOWN_MENU'
@@ -2730,6 +2723,7 @@ classes = (
     WM_OT_toolbar_prompt,
     BatchRenameAction,
     WM_OT_batch_rename,
+    WM_MT_splash_quick_setup,
     WM_MT_splash,
     WM_MT_splash_about,
 )
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index bc013953b1e..81641239c6a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -166,6 +166,8 @@ enum {
   /** The block is only used during the search process and will not be drawn.
    * Currently just for the case of a closed panel's sub-panel (and its sub-panels). */
   UI_BLOCK_SEARCH_ONLY = 1 << 25,
+  /** Hack for quick setup (splash screen) to draw text centered. */
+  UI_BLOCK_QUICK_SETUP = 1 << 26,
 };
 
 /** #uiPopupBlockHandle.menuretval */
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 3fec88810c9..1aff68871e4 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -4060,7 +4060,8 @@ static uiBut *ui_def_but(uiBlock *block,
       but->drawflag |= UI_BUT_ICON_LEFT;
     }
   }
-  else if (((block->flag & UI_BLOCK_LOOP) && !ui_block_is_popover(block)) ||
+  else if (((block->flag & UI_BLOCK_LOOP) && !ui_block_is_popover(block) &&
+            !(block->flag & UI_BLOCK_QUICK_SETUP)) ||
            ELEM(but->type,
                 UI_BTYPE_MENU,
                 UI_BTYPE_TEXT,
diff --git a/source/blender/windowmanager/intern/wm_splash_screen.c b/source/blender/windowmanager/intern/wm_splash_screen.c
index a3619a69152..ae726e73fe7 100644
--- a/source/blender/windowmanager/intern/wm_splash_screen.c
+++ b/source/blender/windowmanager/intern/wm_splash_screen.c
@@ -226,7 +226,26 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *region, void *UNUSE
                                      0,
                                      style);
 
-  MenuType *mt = WM_menutype_find("WM_MT_splash", true);
+  MenuType *mt;
+  char userpref[FILE_MAX];
+  const char *const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL);
+
+  if (cfgdir) {
+    BLI_path_join(userpref, sizeof(userpref), cfgdir, BLENDER_USERPREF_FILE, NULL);
+  }
+
+  /* Draw setup screen if no preferences have been saved yet. */
+  if (!BLI_exists(userpref)) {
+    mt = WM_menutype_find("WM_MT_splash_quick_setup", true);
+
+    /* The UI_BLOCK_QUICK_SETUP flag prevents the button text from being left-aligned,
+       as it is for all menus due to the UI_BLOCK_LOOP flag, see in 'ui_def_but'. */
+    UI_block_flag_enable(block, UI_BLOCK_QUICK_SETUP);
+  }
+  else {
+    mt = WM_menutype_find("WM_MT_splash", true);
+  }
+
   if (mt) {
     UI_menutype_draw(C, mt, layout);
   }



More information about the Bf-blender-cvs mailing list