[Bf-blender-cvs] [8a5bae0e9f9] override-outliner-view: Initial raw liboverride-dedicated view in the Outliner.

Bastien Montagne noreply at git.blender.org
Fri Mar 26 09:13:07 CET 2021


Commit: 8a5bae0e9f96e0c791f62fd5c6202c8af196af4d
Author: Bastien Montagne
Date:   Fri Feb 26 17:32:02 2021 +0100
Branches: override-outliner-view
https://developer.blender.org/rB8a5bae0e9f96e0c791f62fd5c6202c8af196af4d

Initial raw liboverride-dedicated view in the Outliner.

Disclaimer: this is merely a copy of the Libraries (aka blend file)
view, with some minor tweaking.

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

M	release/scripts/startup/bl_ui/space_outliner.py
M	source/blender/blenkernel/intern/lib_override.c
M	source/blender/editors/space_outliner/CMakeLists.txt
M	source/blender/editors/space_outliner/outliner_collections.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/editors/space_outliner/outliner_intern.h
M	source/blender/editors/space_outliner/outliner_sync.c
M	source/blender/editors/space_outliner/outliner_tree.c
M	source/blender/editors/space_outliner/outliner_utils.c
M	source/blender/editors/space_outliner/space_outliner.c
M	source/blender/editors/space_outliner/tree/tree_display.cc
M	source/blender/editors/space_outliner/tree/tree_display.hh
A	source/blender/editors/space_outliner/tree/tree_display_override_library.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.cc
M	source/blender/editors/space_outliner/tree/tree_element_overrides.hh
M	source/blender/makesdna/DNA_ID.h
M	source/blender/makesdna/DNA_space_types.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_outliner.py b/release/scripts/startup/bl_ui/space_outliner.py
index 5c5a78f3942..1e799379543 100644
--- a/release/scripts/startup/bl_ui/space_outliner.py
+++ b/release/scripts/startup/bl_ui/space_outliner.py
@@ -51,13 +51,13 @@ class OUTLINER_HT_header(Header):
             row.prop(space, "use_sync_select", icon='UV_SYNC_SELECT', text="")
 
         row = layout.row(align=True)
-        if display_mode in {'SCENES', 'VIEW_LAYER'}:
+        if display_mode in {'SCENES', 'VIEW_LAYER', 'LIBRARY_OVERRIDES'}:
             row.popover(
                 panel="OUTLINER_PT_filter",
                 text="",
                 icon='FILTER',
             )
-        elif display_mode in {'LIBRARIES', 'ORPHAN_DATA'}:
+        if display_mode in {'LIBRARIES', 'LIBRARY_OVERRIDES', 'ORPHAN_DATA'}:
             row.prop(space, "use_filter_id_type", text="", icon='FILTER')
             sub = row.row(align=True)
             sub.active = space.use_filter_id_type
@@ -341,19 +341,26 @@ class OUTLINER_PT_filter(Panel):
             col = layout.column(align=True)
             col.prop(space, "use_sort_alpha")
 
-        row = layout.row(align=True)
-        row.prop(space, "use_sync_select", text="Sync Selection")
+        if display_mode not in {'LIBRARY_OVERRIDES'}:
+            row = layout.row(align=True)
+            row.prop(space, "use_sync_select", text="Sync Selection")
 
-        row = layout.row(align=True)
-        row.prop(space, "show_mode_column", text="Show Mode Column")
-        layout.separator()
+            row = layout.row(align=True)
+            row.prop(space, "show_mode_column", text="Show Mode Column")
+            layout.separator()
 
         col = layout.column(align=True)
         col.label(text="Search")
         col.prop(space, "use_filter_complete", text="Exact Match")
         col.prop(space, "use_filter_case_sensitive", text="Case Sensitive")
 
-        if display_mode != 'VIEW_LAYER':
+        if display_mode in {'LIBRARY_OVERRIDES'} and bpy.data.libraries:
+            col.separator()
+            row = col.row()
+            row.label(icon='LIBRARY_DATA_OVERRIDE')
+            row.prop(space, "use_filter_lib_override_system", text="System Overrides")
+
+        if display_mode not in {'VIEW_LAYER'}:
             return
 
         layout.separator()
@@ -405,10 +412,6 @@ class OUTLINER_PT_filter(Panel):
         row = sub.row()
         row.label(icon='EMPTY_DATA')
         row.prop(space, "use_filter_object_empty", text="Empties")
-        row = sub.row()
-        if bpy.data.libraries:
-            row.label(icon='LIBRARY_DATA_OVERRIDE')
-            row.prop(space, "use_filter_lib_override", text="Library Overrides")
 
         if (
                 bpy.data.curves or
@@ -425,6 +428,16 @@ class OUTLINER_PT_filter(Panel):
             row.label(icon='BLANK1')
             row.prop(space, "use_filter_object_others", text="Others")
 
+        if bpy.data.libraries:
+            col.separator()
+            row = col.row()
+            row.label(icon='LIBRARY_DATA_OVERRIDE')
+            row.prop(space, "use_filter_lib_override", text="Library Overrides")
+            row = col.row()
+            row.label(icon='LIBRARY_DATA_OVERRIDE')
+            row.prop(space, "use_filter_lib_override_system", text="System Overrides")
+
+
 
 classes = (
     OUTLINER_HT_header,
diff --git a/source/blender/blenkernel/intern/lib_override.c b/source/blender/blenkernel/intern/lib_override.c
index c755d153100..aed3af3927d 100644
--- a/source/blender/blenkernel/intern/lib_override.c
+++ b/source/blender/blenkernel/intern/lib_override.c
@@ -702,6 +702,9 @@ static void lib_override_library_create_post_process(Main *bmain,
                 base = BKE_view_layer_base_find(view_layer, ob_new);
                 DEG_id_tag_update_ex(
                     bmain, &ob_new->id, ID_RECALC_TRANSFORM | ID_RECALC_BASE_FLAGS);
+                if (is_resync) {
+                  ob_new->id.flag |= LIB_LIB_OVERRIDE_RESYNC_LEFTOVER;
+                }
               }
 
               if (ob_new == (Object *)ob_reference->id.newid && base != NULL) {
@@ -713,6 +716,9 @@ static void lib_override_library_create_post_process(Main *bmain,
                          view_layer, ob_new, is_resync)) {
               BKE_collection_object_add(bmain, collection_new, ob_new);
               DEG_id_tag_update_ex(bmain, &ob_new->id, ID_RECALC_TRANSFORM | ID_RECALC_BASE_FLAGS);
+              if (is_resync) {
+                ob_new->id.flag |= LIB_LIB_OVERRIDE_RESYNC_LEFTOVER;
+              }
             }
           }
         }
@@ -729,6 +735,9 @@ static void lib_override_library_create_post_process(Main *bmain,
           else {
             BKE_collection_object_add_from(bmain, scene, (Object *)id_root, ob_new);
           }
+          if (is_resync) {
+            ob_new->id.flag |= LIB_LIB_OVERRIDE_RESYNC_LEFTOVER;
+          }
         }
         break;
       }
@@ -1071,6 +1080,7 @@ bool BKE_lib_override_library_resync(Main *bmain,
         /* Otherwise, keep them, user needs to decide whether what to do with them. */
         BLI_assert((id->tag & LIB_TAG_DOIT) == 0);
         id_fake_user_set(id);
+        id->flag |= LIB_LIB_OVERRIDE_RESYNC_LEFTOVER;
         CLOG_INFO(&LOG, 2, "Old override %s is being kept around as it was user-edited", id->name);
       }
     }
diff --git a/source/blender/editors/space_outliner/CMakeLists.txt b/source/blender/editors/space_outliner/CMakeLists.txt
index 4a1e5c1a12c..c31239f0e9c 100644
--- a/source/blender/editors/space_outliner/CMakeLists.txt
+++ b/source/blender/editors/space_outliner/CMakeLists.txt
@@ -51,6 +51,7 @@ set(SRC
   tree/tree_display_data.cc
   tree/tree_display_libraries.cc
   tree/tree_display_orphaned.cc
+  tree/tree_display_override_library.cc
   tree/tree_display_scenes.cc
   tree/tree_display_sequencer.cc
   tree/tree_display_view_layer.cc
diff --git a/source/blender/editors/space_outliner/outliner_collections.c b/source/blender/editors/space_outliner/outliner_collections.c
index 062d2e2b5d1..bb89d7dc3b2 100644
--- a/source/blender/editors/space_outliner/outliner_collections.c
+++ b/source/blender/editors/space_outliner/outliner_collections.c
@@ -166,8 +166,11 @@ void ED_outliner_selected_objects_get(const bContext *C, ListBase *objects)
 bool ED_outliner_collections_editor_poll(bContext *C)
 {
   SpaceOutliner *space_outliner = CTX_wm_space_outliner(C);
-  return (space_outliner != NULL) &&
-         ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES, SO_LIBRARIES);
+  return (space_outliner != NULL) && ELEM(space_outliner->outlinevis,
+                                          SO_VIEW_LAYER,
+                                          SO_SCENES,
+                                          SO_LIBRARIES,
+                                          SO_OVERRIDES_LIBRARY);
 }
 
 static bool outliner_view_layer_collections_editor_poll(bContext *C)
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 0916e106abf..c000cbf9d31 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1775,6 +1775,117 @@ static void outliner_draw_userbuts(uiBlock *block,
   }
 }
 
+static bool outliner_draw_overrides_buts(uiBlock *block,
+                                         ARegion *region,
+                                         SpaceOutliner *space_outliner,
+                                         ListBase *lb,
+                                         const bool is_open)
+{
+  bool parent_has_warnings = false;
+
+  LISTBASE_FOREACH (TreeElement *, te, lb) {
+    bool has_warnings = false;
+    const bool do_draw = (te->ys + 2 * UI_UNIT_Y >= region->v2d.cur.ymin &&
+                          te->ys <= region->v2d.cur.ymax);
+    int but_flag = UI_BUT_DRAG_LOCK;
+    const char *tip = NULL;
+
+    TreeStoreElem *tselem = TREESTORE(te);
+    switch (tselem->type) {
+      case TSE_SOME_ID: {
+#if 0
+        if (id->flag & LIB_FAKEUSER) {
+          tip = TIP_("Data-block will be retained using a fake user");
+        }
+        else {
+          tip = TIP_("Data-block has no users and will be deleted");
+        }
+        bt = uiDefIconButBitS(block,
+                              UI_BTYPE_ICON_TOGGLE,
+                              LIB_FAKEUSER,
+                              1,
+                              ICON_FAKE_USER_OFF,
+                              (int)(region->v2d.cur.xmax - OL_TOG_USER_BUTS_STATUS),
+                              te->ys,
+                              UI_UNIT_X,
+                              UI_UNIT_Y,
+                              &id->flag,
+                              0,
+                              0,
+                              0,
+                              0,
+                              tip);
+        UI_but_func_set(bt, restrictbutton_id_user_toggle, id, NULL);
+        UI_but_flag_enable(bt, but_flag);
+#endif
+        break;
+      }
+      case TSE_LIBRARY_OVERRIDE_BASE: {
+        ID *id = tselem->id;
+
+        if (ID_IS_OVERRIDE_LIBRARY_REAL(id) && ID_REAL_USERS(id) == 0) {
+          has_warnings = true;
+          if (do_draw) {
+            tip = TIP_("This override data-block is unused");
+          }
+        }
+
+        else if (id->flag & LIB_LIB_OVERRIDE_RESYNC_LEFTOVER) {
+          has_warnings = true;
+          if (do_draw) {
+            tip = TIP_(
+                "This override data-block is not needed anymore, but was detected as user-edited");
+          }
+        }
+        break;
+      }
+      case TSE_LIBRARY_OVERRIDE: {
+        const bool is_rna_path_valid = (bool)(POINTER_AS_UINT(te->directdata));
+        if (!is_rna_path_valid) {
+          has_warnings = true;
+          if (do_draw) {
+            tip = TIP_(
+                "This override property does not exist in current data, it will be removed on "
+                "next .blend file save");
+          }
+        }
+        break;
+      }
+      default:
+        break;
+    }
+
+    const bool have_children_warnings = outliner_draw_overrides_buts(
+        block,
+        region,
+

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list