From 9ed7d7cb035fa196b04d93bed576f33fab16f346 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 20 Sep 2023 15:11:18 +1000 Subject: [PATCH] UI: add extensions section (shown when extension repos are enabled) This is a place-holder by default, the work-in-progress extensions add-on makes use of this. --- scripts/startup/bl_ui/space_userpref.py | 33 +++++++++++++++++++ source/blender/makesdna/DNA_userdef_types.h | 1 + source/blender/makesrna/intern/rna_userdef.cc | 18 ++++++++-- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 3d5f8f74502..f89c04b6b1f 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -1994,6 +1994,36 @@ class USERPREF_PT_keymap(KeymapPanel, Panel): # print("runtime", time.time() - start) +# ----------------------------------------------------------------------------- +# Extension Panels + +class ExtensionsPanel: + bl_space_type = 'PREFERENCES' + bl_region_type = 'WINDOW' + bl_context = "extensions" + + +class USERPREF_PT_extensions(ExtensionsPanel, Panel): + bl_label = "Extensions" + bl_options = {'HIDE_HEADER'} + + # NOTE: currently disabled by an add-on when used. + unused = True + + @classmethod + def poll(cls, _context): + return cls.unused + + def draw(self, context): + layout = self.layout + + row = layout.row() + row.label(text="The add-on to use extensions is disabled! See:") + row.operator( + "wm.url_open", text="Extension Add-on Repo", icon='URL', + ).url = "https://projects.blender.org/ideasman42/bl_ext" + + # ----------------------------------------------------------------------------- # Add-On Panels @@ -2272,6 +2302,7 @@ class USERPREF_PT_addons(AddOnPanel, Panel): # ----------------------------------------------------------------------------- # Studio Light Panels + class StudioLightPanel: bl_space_type = 'PREFERENCES' bl_region_type = 'WINDOW' @@ -2633,6 +2664,8 @@ classes = ( USERPREF_PT_navigation_fly_walk_gravity, USERPREF_PT_keymap, + + USERPREF_PT_extensions, USERPREF_PT_addons, USERPREF_PT_studiolight_lights, diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index d3064c1b736..bce18ad25b5 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -1070,6 +1070,7 @@ typedef enum eUserPref_Section { USER_SECTION_NAVIGATION = 14, USER_SECTION_FILE_PATHS = 15, USER_SECTION_EXPERIMENTAL = 16, + USER_SECTION_EXTENSIONS = 17, } eUserPref_Section; /** #UserDef_SpaceData.flag (State of the user preferences UI). */ diff --git a/source/blender/makesrna/intern/rna_userdef.cc b/source/blender/makesrna/intern/rna_userdef.cc index 75e6a1e4875..1f88897c26f 100644 --- a/source/blender/makesrna/intern/rna_userdef.cc +++ b/source/blender/makesrna/intern/rna_userdef.cc @@ -56,6 +56,7 @@ const EnumPropertyItem rna_enum_preference_section_items[] = { {USER_SECTION_EDITING, "EDITING", 0, "Editing", ""}, {USER_SECTION_ANIMATION, "ANIMATION", 0, "Animation", ""}, RNA_ENUM_ITEM_SEPR, + {USER_SECTION_EXTENSIONS, "EXTENSIONS", 0, "Extensions", ""}, {USER_SECTION_ADDONS, "ADDONS", 0, "Add-ons", ""}, #if 0 /* def WITH_USERDEF_WORKSPACES */ RNA_ENUM_ITEM_SEPR, @@ -302,6 +303,9 @@ static void rna_PreferencesExperimental_use_extension_repos_set(PointerRNA * /*p U.experimental.use_extension_repos = value; BKE_callback_exec_null(bmain, BKE_CB_EVT_EXTENSION_REPOS_UPDATE_POST); } + + /* Needed to redraw the preferences window. */ + WM_main_add_notifier(NC_WINDOW, nullptr); } static void rna_userdef_font_update(Main * /*bmain*/, Scene * /*scene*/, PointerRNA * /*ptr*/) @@ -601,7 +605,10 @@ static const EnumPropertyItem *rna_UseDef_active_section_itemf(bContext * /*C*/, { UserDef *userdef = static_cast(ptr->data); - if ((userdef->flag & USER_DEVELOPER_UI) != 0) { + const bool use_developer_ui = (userdef->flag & USER_DEVELOPER_UI) != 0; + const bool use_extension_repos = use_developer_ui && U.experimental.use_extension_repos; + + if (use_developer_ui && use_extension_repos) { *r_free = false; return rna_enum_preference_section_items; } @@ -613,7 +620,14 @@ static const EnumPropertyItem *rna_UseDef_active_section_itemf(bContext * /*C*/, it++) { if (it->value == USER_SECTION_EXPERIMENTAL) { - continue; + if (use_developer_ui == false) { + continue; + } + } + else if (it->value == USER_SECTION_EXTENSIONS) { + if (use_extension_repos == false) { + continue; + } } RNA_enum_item_add(&items, &totitem, it); }