[Bf-blender-cvs] [b49abbec5ff] blender2.8: Splash: add first time setup and templates to splash screen.

Brecht Van Lommel noreply at git.blender.org
Tue Sep 18 19:39:10 CEST 2018


Commit: b49abbec5fff29978d04572b9ac341c8a50b84cf
Author: Brecht Van Lommel
Date:   Tue Sep 18 17:44:14 2018 +0200
Branches: blender2.8
https://developer.blender.org/rBb49abbec5fff29978d04572b9ac341c8a50b84cf

Splash: add first time setup and templates to splash screen.

The first time setup screen only has the interaction preset currently, some
more work is needed to be able to set e.g. the language or compute device
here as in the mockups.

The splash screen stayed the same for now, to make room for the templates
most of the links are now in the Help menu. If there are no recent files yet
the links still show.

The splash screen buttons implementation was fully moved to Python, in the
WM_MT_splash menu.

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

M	release/scripts/startup/bl_operators/wm.py
M	release/scripts/startup/bl_ui/space_topbar.py
M	release/scripts/startup/bl_ui/space_userpref.py
M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_layout.c
M	source/blender/editors/interface/interface_templates.c
M	source/blender/makesrna/intern/rna_ui_api.c
M	source/blender/windowmanager/intern/wm_event_system.c
M	source/blender/windowmanager/intern/wm_operators.c

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

diff --git a/release/scripts/startup/bl_operators/wm.py b/release/scripts/startup/bl_operators/wm.py
index 9b09ff86c08..18104468577 100644
--- a/release/scripts/startup/bl_operators/wm.py
+++ b/release/scripts/startup/bl_operators/wm.py
@@ -20,6 +20,7 @@
 
 import bpy
 from bpy.types import (
+    Menu,
     Operator,
     OperatorFileListElement
 )
@@ -1490,33 +1491,51 @@ class WM_OT_copy_prev_settings(Operator):
     bl_idname = "wm.copy_prev_settings"
     bl_label = "Copy Previous Settings"
 
-    def execute(self, context):
-        import os
-        import shutil
+    @staticmethod
+    def previous_version():
         ver = bpy.app.version
         ver_old = ((ver[0] * 100) + ver[1]) - 1
-        path_src = bpy.utils.resource_path('USER', ver_old // 100, ver_old % 100)
-        path_dst = bpy.utils.resource_path('USER')
+        return ver_old // 100, ver_old % 100
 
-        if os.path.isdir(path_dst):
-            self.report({'ERROR'}, "Target path %r exists" % path_dst)
-        elif not os.path.isdir(path_src):
-            self.report({'ERROR'}, "Source path %r does not exist" % path_src)
-        else:
-            shutil.copytree(path_src, path_dst, symlinks=True)
+    @staticmethod
+    def _old_path():
+        ver = bpy.app.version
+        ver_old = ((ver[0] * 100) + ver[1]) - 1
+        return bpy.utils.resource_path('USER', ver_old // 100, ver_old % 100)
 
-            # reload recent-files.txt
-            bpy.ops.wm.read_history()
+    @staticmethod
+    def _new_path():
+        return bpy.utils.resource_path('USER')
 
-            # don't loose users work if they open the splash later.
-            if bpy.data.is_saved is bpy.data.is_dirty is False:
-                bpy.ops.wm.read_homefile()
-            else:
-                self.report({'INFO'}, "Reload Start-Up file to restore settings")
+    @classmethod
+    def poll(cls, context):
+        import os
 
-            return {'FINISHED'}
+        old = cls._old_path()
+        new = cls._new_path()
+        if os.path.isdir(old) and not os.path.isdir(new):
+            return True
 
-        return {'CANCELLED'}
+        old_userpref = os.path.join(old, "config", "userpref.blend")
+        new_userpref = os.path.join(new, "config", "userpref.blend")
+        return os.path.isfile(old_userpref) and not os.path.isfile(new_userpref)
+
+    def execute(self, context):
+        import os
+        import shutil
+
+        shutil.copytree(self._old_path(), self._new_path(), symlinks=True)
+
+        # reload recent-files.txt
+        bpy.ops.wm.read_history()
+
+        # don't loose users work if they open the splash later.
+        if bpy.data.is_saved is bpy.data.is_dirty is False:
+            bpy.ops.wm.read_homefile()
+        else:
+            self.report({'INFO'}, "Reload Start-Up file to restore settings")
+
+        return {'FINISHED'}
 
 
 class WM_OT_keyconfig_test(Operator):
@@ -2525,6 +2544,134 @@ class WM_OT_studiolight_userpref_show(Operator):
         return {'FINISHED'}
 
 
+class WM_MT_splash(Menu):
+    bl_label = "Splash"
+
+    def draw_setup(self, context):
+        layout = self.layout
+        layout.operator_context = 'EXEC_DEFAULT'
+
+        layout.label(text="Quick Setup")
+
+        split = layout.split(factor=0.25)
+        split.label()
+        split = split.split(factor=2.0/3.0)
+
+        col = split.column()
+
+        col.label()
+
+        sub = col.column(align=True)
+        sub.label(text="Input and Shortcuts:")
+        text = bpy.path.display_name(context.window_manager.keyconfigs.active.name)
+        if not text:
+            text = "Blender (default)"
+        sub.menu("USERPREF_MT_appconfigs", text=text)
+
+        col.separator()
+
+        # We need to make switching to a language easier first
+        #sub = col.column(align=False)
+        #sub.label(text="Language:")
+        #userpref = context.user_preferences
+        #sub.prop(userpref.system, "language", text="")
+
+        col.label()
+
+        layout.label()
+
+        row = layout.row()
+
+        sub = row.row()
+        if bpy.types.WM_OT_copy_prev_settings.poll(context):
+            old_version = bpy.types.WM_OT_copy_prev_settings.previous_version()
+            sub.operator("wm.copy_prev_settings", text="Load %d.%d Settings" % old_version)
+            sub.operator("wm.save_userpref", text="Save New Settings")
+        else:
+            sub.label()
+            sub.label()
+            sub.operator("wm.save_userpref", text="Next")
+
+        layout.separator()
+
+    def draw(self, context):
+        # Draw setup screen if no user preferences have been saved yet.
+        import os
+
+        user_path = bpy.utils.resource_path('USER')
+        userdef_path = os.path.join(user_path, "config", "userpref.blend")
+
+        if not os.path.isfile(userdef_path):
+            self.draw_setup(context)
+            return
+
+        # Pass
+        layout = self.layout
+        layout.operator_context = 'EXEC_DEFAULT'
+        layout.emboss = 'PULLDOWN_MENU'
+
+        split = layout.split()
+
+        # Templates
+        col1 = split.column()
+        col1.label(text="New File")
+
+        bpy.types.TOPBAR_MT_file_new.draw_ex(col1, context, use_splash=True)
+
+        # Recent
+        col2 = split.column()
+        col2_title = col2.row()
+
+        found_recent = col2.template_recent_files()
+
+        if found_recent:
+            col2_title.label(text="Recent Files")
+        else:
+            # Links if no recent files
+            col2_title.label(text="Getting Started")
+
+            col2.operator(
+                "wm.url_open", text="Manual", icon='URL'
+            ).url = "https://docs.blender.org/manual/en/dev/"
+            col2.operator(
+                "wm.url_open", text="Release Notes", icon='URL',
+            ).url = "https://www.blender.org/download/releases/%d-%d/" % bpy.app.version[:2]
+            col2.operator(
+                "wm.url_open", text="Blender Website", icon='URL',
+            ).url = "https://www.blender.org"
+            col2.operator(
+                "wm.url_open", text="Credits", icon='URL',
+            ).url = "https://www.blender.org/about/credits/"
+
+        layout.separator()
+
+        split = layout.split()
+
+        col1 = split.column()
+        sub = col1.row()
+        sub.operator_context = 'INVOKE_DEFAULT'
+        sub.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
+        col1.operator("wm.recover_last_session", icon='RECOVER_LAST')
+
+        col2 = split.column()
+        if found_recent:
+            col2.operator(
+                "wm.url_open", text="Release Notes", icon='URL',
+            ).url = "https://www.blender.org/download/releases/%d-%d/" % bpy.app.version[:2]
+            col2.operator(
+                "wm.url_open", text="Development Fund", icon='URL'
+            ).url = "https://www.blender.org/foundation/development-fund/"
+        else:
+            col2.operator(
+                "wm.url_open", text="Development Fund", icon='URL'
+            ).url = "https://www.blender.org/foundation/development-fund/"
+            col2.operator(
+                "wm.url_open", text="Donate", icon='URL'
+            ).url = "https://www.blender.org/foundation/donation-payment/"
+
+        layout.separator()
+
+
 classes = (
     BRUSH_OT_active_index_set,
     WM_OT_addon_disable,
@@ -2584,4 +2731,5 @@ classes = (
     WM_OT_studiolight_userpref_show,
     WM_OT_tool_set_by_name,
     WM_OT_toolbar,
+    WM_MT_splash,
 )
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 80a7215f90b..563bd0afcca 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -287,7 +287,7 @@ class TOPBAR_MT_file(Menu):
         layout = self.layout
 
         layout.operator_context = 'INVOKE_AREA'
-        layout.menu("TOPBAR_MT_file_new", text="New", icon='NEW')
+        layout.menu("TOPBAR_MT_file_new", text="New", icon='FILE')
         layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
         layout.menu("TOPBAR_MT_file_open_recent")
         layout.operator("wm.revert_mainfile")
@@ -373,25 +373,51 @@ class TOPBAR_MT_file_new(Menu):
 
         return sorted(app_templates)
 
-    def draw_ex(self, context, *, use_splash=False, use_default=False):
-        layout = self.layout
-
-        # now draw the presets
+    def draw_ex(layout, context, *, use_splash=False, use_more=False):
         layout.operator_context = 'EXEC_DEFAULT'
 
-        if use_default:
-            props = layout.operator("wm.read_homefile", text="General")
+        # Limit number of templates in splash screen, spill over into more menu.
+        paths = TOPBAR_MT_file_new.app_template_paths()
+        splash_limit = 5
+
+        if use_splash:
+            icon = 'FILE'
+            show_more = len(paths) > (splash_limit - 1)
+            if show_more:
+                paths = paths[:splash_limit - 2]
+        elif use_more:
+            icon = 'FILE'
+            paths = paths[splash_limit - 2:]
+            show_more = False
+        else:
+            icon = 'NONE'
+            show_more = False
+
+        # Draw application templates.
+        if not use_more:
+            props = layout.operator("wm.read_homefile", text="General", icon=icon)
             props.app_template = ""
 
-        for d in TOPBAR_MT_file_new.app_template_paths():
+        for d in paths:
             props = layout.operator(
                 "wm.read_homefile",
                 text=bpy.path.display_name(d),
+                icon=icon,
             )
             props.app_template = d
 
+        if show_more:
+            layout.menu("TOPBAR_MT_templates_more", text="...")
+
     def draw(self, context):
-        self.draw_ex(context, use_splash=False, use_default=True)
+        TOPBAR_MT_file_new.draw_ex(self.layout, context)
+
+
+class TOPBAR_MT_templates_more(Menu):
+    bl_label = "Templates"
+
+    def draw(self, context):
+        bpy.types.TOPBAR_MT_file_new.draw_ex(self.layout, context, use_more=True)
 
 
 class TOPBAR_MT_file_import(Menu):
@@ -591,13 +617,24 @@ class TOPBAR_MT_help(Menu):
      

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list