[Bf-blender-cvs] [5cc304b9a7c] blender-projects-basics: Add most bolierplate code & some buttons for Project Settings editor

Julian Eisel noreply at git.blender.org
Mon Oct 3 21:46:01 CEST 2022


Commit: 5cc304b9a7c6f0c83800b664970d0160174199dd
Author: Julian Eisel
Date:   Mon Oct 3 21:28:35 2022 +0200
Branches: blender-projects-basics
https://developer.blender.org/rB5cc304b9a7c6f0c83800b664970d0160174199dd

Add most bolierplate code & some buttons for Project Settings editor

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

M	release/scripts/startup/bl_ui/__init__.py
A	release/scripts/startup/bl_ui/space_project_settings.py
M	source/blender/blenkernel/BKE_context.h
M	source/blender/blenkernel/intern/context.c
M	source/blender/editors/CMakeLists.txt
M	source/blender/editors/include/ED_space_api.h
M	source/blender/editors/interface/interface_template_search_menu.cc
M	source/blender/editors/space_api/CMakeLists.txt
M	source/blender/editors/space_api/spacetypes.c
A	source/blender/editors/space_project_settings/CMakeLists.txt
A	source/blender/editors/space_project_settings/space_project_settings.cc
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c
M	source/blender/python/intern/bpy_rna_callback.c
M	source/blender/windowmanager/intern/wm_draw.c

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

diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index eaf61b58e6d..bd5e4983834 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -69,6 +69,7 @@ _modules = [
     "space_nla",
     "space_node",
     "space_outliner",
+    "space_project_settings",
     "space_properties",
     "space_sequencer",
     "space_spreadsheet",
diff --git a/release/scripts/startup/bl_ui/space_project_settings.py b/release/scripts/startup/bl_ui/space_project_settings.py
new file mode 100644
index 00000000000..cd30d5bbe26
--- /dev/null
+++ b/release/scripts/startup/bl_ui/space_project_settings.py
@@ -0,0 +1,112 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+import bpy
+from bpy.types import Header, Menu, Panel
+from bpy.app.translations import pgettext_iface as iface_
+
+
+# -----------------------------------------------------------------------------
+# Main Header
+
+class PROJECTSETTINGS_HT_header(Header):
+    bl_space_type = 'PROJECT_SETTINGS'
+
+    @staticmethod
+    def draw_buttons(layout, context):
+        layout.operator_context = 'EXEC_AREA'
+        is_dirty = True
+
+        # Show '*' to let users know the settings have been modified.
+        # TODO, wrong operator
+        layout.operator(
+            "wm.save_userpref",
+            text=iface_("Save Project") + (" *" if is_dirty else ""),
+            translate=False,
+        )
+
+    def draw(self, context):
+        layout = self.layout
+        layout.operator_context = 'EXEC_AREA'
+
+        layout.template_header()
+
+        PROJECTSETTINGS_MT_editor_menus.draw_collapsible(context, layout)
+
+        layout.separator_spacer()
+
+        self.draw_buttons(layout, context)
+
+
+# -----------------------------------------------------------------------------
+# Main Navigation Bar
+
+class PROJECTSETTINGS_PT_navigation_bar(Panel):
+    bl_label = "Project Settings Navigation"
+    bl_space_type = 'PROJECT_SETTINGS'
+    bl_region_type = 'NAVIGATION_BAR'
+    bl_options = {'HIDE_HEADER'}
+
+    def draw(self, context):
+        layout = self.layout
+
+        # prefs = context.preferences
+
+        col = layout.column()
+
+        col.scale_x = 1.3
+        col.scale_y = 1.3
+        col.label(text="Test")
+        # col.prop(prefs, "active_section", expand=True)
+
+
+class PROJECTSETTINGS_MT_editor_menus(Menu):
+    bl_idname = "PROJECTSETTINGS_MT_editor_menus"
+    bl_label = ""
+
+    def draw(self, _context):
+        layout = self.layout
+        layout.menu("PROJECTSETTINGS_MT_view")
+
+
+class PROJECTSETTINGS_MT_view(Menu):
+    bl_label = "View"
+
+    def draw(self, _context):
+        layout = self.layout
+
+        layout.menu("INFO_MT_area")
+
+
+class PROJECTSETTINGS_PT_save_project_settings(Panel):
+    bl_label = "Save Project Settings"
+    bl_space_type = 'PROJECT_SETTINGS'
+    bl_region_type = 'EXECUTE'
+    bl_options = {'HIDE_HEADER'}
+
+    @classmethod
+    def poll(cls, context):
+        # Hide when header is visible
+        for region in context.area.regions:
+            if region.type == 'HEADER' and region.height <= 1:
+                return True
+
+        return False
+
+    def draw(self, context):
+        layout = self.layout.row()
+        layout.operator_context = 'EXEC_AREA'
+
+        PROJECTSETTINGS_HT_header.draw_buttons(layout, context)
+
+
+classes = (
+    PROJECTSETTINGS_HT_header,
+    PROJECTSETTINGS_MT_editor_menus,
+    PROJECTSETTINGS_MT_view,
+    PROJECTSETTINGS_PT_navigation_bar,
+    PROJECTSETTINGS_PT_save_project_settings,
+)
+
+if __name__ == "__main__":  # only for live edit.
+    from bpy.utils import register_class
+    for cls in classes:
+        register_class(cls)
diff --git a/source/blender/blenkernel/BKE_context.h b/source/blender/blenkernel/BKE_context.h
index f3edce7709c..4b9d78e45ec 100644
--- a/source/blender/blenkernel/BKE_context.h
+++ b/source/blender/blenkernel/BKE_context.h
@@ -194,6 +194,7 @@ struct SpaceUserPref *CTX_wm_space_userpref(const bContext *C);
 struct SpaceClip *CTX_wm_space_clip(const bContext *C);
 struct SpaceTopBar *CTX_wm_space_topbar(const bContext *C);
 struct SpaceSpreadsheet *CTX_wm_space_spreadsheet(const bContext *C);
+struct SpaceProjectSettings *CTX_wm_space_project_settings(const bContext *C);
 
 void CTX_wm_manager_set(bContext *C, struct wmWindowManager *wm);
 void CTX_wm_window_set(bContext *C, struct wmWindow *win);
diff --git a/source/blender/blenkernel/intern/context.c b/source/blender/blenkernel/intern/context.c
index 1061b106727..25f347ccbe6 100644
--- a/source/blender/blenkernel/intern/context.c
+++ b/source/blender/blenkernel/intern/context.c
@@ -954,6 +954,15 @@ struct SpaceSpreadsheet *CTX_wm_space_spreadsheet(const bContext *C)
   return NULL;
 }
 
+SpaceProjectSettings *CTX_wm_space_project_settings(const bContext *C)
+{
+  ScrArea *area = CTX_wm_area(C);
+  if (area && area->spacetype == SPACE_PROJECT_SETTINGS) {
+    return area->spacedata.first;
+  }
+  return NULL;
+}
+
 void CTX_wm_manager_set(bContext *C, wmWindowManager *wm)
 {
   C->wm.manager = wm;
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index 9fff8bf861c..f230e3213d6 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -37,6 +37,7 @@ if(WITH_BLENDER)
   add_subdirectory(space_nla)
   add_subdirectory(space_node)
   add_subdirectory(space_outliner)
+  add_subdirectory(space_project_settings)
   add_subdirectory(space_script)
   add_subdirectory(space_sequencer)
   add_subdirectory(space_spreadsheet)
diff --git a/source/blender/editors/include/ED_space_api.h b/source/blender/editors/include/ED_space_api.h
index 07d4f43bb2b..e36cbd25e74 100644
--- a/source/blender/editors/include/ED_space_api.h
+++ b/source/blender/editors/include/ED_space_api.h
@@ -46,6 +46,7 @@ void ED_spacetype_clip(void);
 void ED_spacetype_statusbar(void);
 void ED_spacetype_topbar(void);
 void ED_spacetype_spreadsheet(void);
+void ED_spacetype_project_settings(void);
 
 /** \} */
 
diff --git a/source/blender/editors/interface/interface_template_search_menu.cc b/source/blender/editors/interface/interface_template_search_menu.cc
index f61baf65b58..9f0ec844ba1 100644
--- a/source/blender/editors/interface/interface_template_search_menu.cc
+++ b/source/blender/editors/interface/interface_template_search_menu.cc
@@ -635,6 +635,7 @@ static MenuSearch_Data *menu_items_from_ui_create(
           SPACE_MENU_MAP(SPACE_NODE, "NODE_MT_editor_menus");
           SPACE_MENU_MAP(SPACE_CONSOLE, "CONSOLE_MT_editor_menus");
           SPACE_MENU_MAP(SPACE_USERPREF, "USERPREF_MT_editor_menus");
+          SPACE_MENU_MAP(SPACE_PROJECT_SETTINGS, "PROJECTSETTINGS_MT_editor_menus");
           SPACE_MENU_MAP(SPACE_CLIP,
                          (((const SpaceClip *)sl)->mode == SC_MODE_TRACKING) ?
                              "CLIP_MT_tracking_editor_menus" :
diff --git a/source/blender/editors/space_api/CMakeLists.txt b/source/blender/editors/space_api/CMakeLists.txt
index 0024e7935d8..4eff8a5732f 100644
--- a/source/blender/editors/space_api/CMakeLists.txt
+++ b/source/blender/editors/space_api/CMakeLists.txt
@@ -33,6 +33,7 @@ set(LIB
   bf_editor_space_nla
   bf_editor_space_node
   bf_editor_space_outliner
+  bf_editor_space_project_settings
   bf_editor_space_script
   bf_editor_space_sequencer
   bf_editor_space_spreadsheet
diff --git a/source/blender/editors/space_api/spacetypes.c b/source/blender/editors/space_api/spacetypes.c
index 3d964a95bc0..22ce421e443 100644
--- a/source/blender/editors/space_api/spacetypes.c
+++ b/source/blender/editors/space_api/spacetypes.c
@@ -82,6 +82,7 @@ void ED_spacetypes_init(void)
   ED_spacetype_statusbar();
   ED_spacetype_topbar();
   ED_spacetype_spreadsheet();
+  ED_spacetype_project_settings();
 
   /* Register operator types for screen and all spaces. */
   ED_operatortypes_userpref();
diff --git a/source/blender/editors/space_project_settings/CMakeLists.txt b/source/blender/editors/space_project_settings/CMakeLists.txt
new file mode 100644
index 00000000000..b5492a6ee6a
--- /dev/null
+++ b/source/blender/editors/space_project_settings/CMakeLists.txt
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+set(INC
+  ../include
+  ../../blenfont
+  ../../blenkernel
+  ../../blenlib
+  ../../blenloader
+  ../../blentranslation
+  ../../depsgraph
+  ../../makesdna
+  ../../makesrna
+  ../../windowmanager
+  ../../../../intern/guardedalloc
+
+  # dna_type_offsets.h
+  ${CMAKE_CURRENT_BINARY_DIR}/../../makesdna/intern
+  # RNA_prototypes.h
+  ${CMAKE_BINARY_DIR}/source/blender/makesrna
+)
+
+set(SRC
+  space_project_settings.cc
+)
+
+set(LIB
+)
+
+blender_add_lib(bf_editor_space_project_settings "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
+
+# RNA_prototypes.h dna_type_offsets.h
+# add_dependencies(bf_editor_space_project_settings bf_rna)
diff --git a/source/blender/editors/space_project_settings/space_project_settings.cc b/source/blender/editors/space_project_settings/space_project_settings.cc
new file mode 100644
index 00000000000..9c2d64d2204
--- /dev/null
+++ b/source/blender/editors/space_project_settings/space_project_settings.cc
@@ -0,0 +1,217 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#include "BKE_screen.h"
+
+#include "BLI_string.h"
+
+#include "BLO_read_write.h"
+
+#include "DNA_screen_types.h"
+#include "DNA_space_types.h"
+
+#include "ED_screen.h"
+#include "ED_space_api.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "UI_interface.h"
+
+static SpaceLink *project_settings_create(const ScrArea *area, const Scene *UNUSED(scene))
+{
+  SpaceProjectSettings *project_settings_space = MEM_cnew<SpaceProjectSettings>(
+      "project settings space");
+  project_settings_space->spacetype = SPACE_PROJECT_SETTINGS;
+
+  {
+    /* Header. */
+    ARegion *region = MEM_cnew<ARegion>("project settings header");
+    BLI_addtail(&project_settings_space->regionbase, region);
+    region->regiontype = RGN_TYPE_HEADER;
+    /* Ignore preference "USER_HEADER_BOTTOM" here (always show bottom for new types). */
+    region->alignment = RGN_ALIGN_BOTTOM;
+  }
+
+  {
+    /* navigation region */
+    ARegion *region = M

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list