[Bf-blender-cvs] [e1ae5bd45fd] master: LibOverride: Add a dedicated view in the Outliner.

Bastien Montagne noreply at git.blender.org
Thu Apr 8 11:48:23 CEST 2021


Commit: e1ae5bd45fd0a8c0073039fa3b46835fe20f530e
Author: Bastien Montagne
Date:   Wed Apr 7 15:58:34 2021 +0200
Branches: master
https://developer.blender.org/rBe1ae5bd45fd0a8c0073039fa3b46835fe20f530e

LibOverride: Add a dedicated view in the Outliner.

This is a minimal, information-only view currently, listing by default
all the override data-blocks, with their user-edited override
properties.

System-generated overrides (like the overrides of pointers to other
override data-blocks) can be shown through a filter option.

Finally, potential info or warning messages from (auto-)resync propcess
are also shown, as an icon + tooltip next to the affected items.

Part of D10855.

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

M	release/scripts/startup/bl_ui/space_outliner.py
M	source/blender/editors/space_outliner/CMakeLists.txt
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_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/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_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index 0916e106abf..99bc23ad246 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1775,6 +1775,88 @@ 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 any_item_has_warnings = false;
+
+  LISTBASE_FOREACH (TreeElement *, te, lb) {
+    bool item_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_LIBRARY_OVERRIDE_BASE: {
+        ID *id = tselem->id;
+
+        if (ID_IS_OVERRIDE_LIBRARY_REAL(id) && ID_REAL_USERS(id) == 0) {
+          item_has_warnings = true;
+          if (do_draw) {
+            tip = TIP_("This override data-block is unused");
+          }
+        }
+
+        else if (id->flag & LIB_LIB_OVERRIDE_RESYNC_LEFTOVER) {
+          item_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) {
+          item_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 any_child_has_warnings = outliner_draw_overrides_buts(
+        block,
+        region,
+        space_outliner,
+        &te->subtree,
+        is_open && TSELEM_OPEN(tselem, space_outliner));
+
+    if (do_draw &&
+        (item_has_warnings || (any_child_has_warnings && !TSELEM_OPEN(tselem, space_outliner)))) {
+      if (tip == NULL) {
+        tip = TIP_("Some sub-items require attention");
+      }
+      uiBut *bt = uiDefIconBlockBut(block,
+                                    NULL,
+                                    NULL,
+                                    1,
+                                    ICON_ERROR,
+                                    (int)(region->v2d.cur.xmax - OL_TOG_USER_BUTS_STATUS),
+                                    te->ys,
+                                    UI_UNIT_X,
+                                    UI_UNIT_Y,
+                                    tip);
+      UI_but_flag_enable(bt, but_flag);
+    }
+    any_item_has_warnings = any_item_has_warnings || item_has_warnings || any_child_has_warnings;
+  }
+
+  return any_item_has_warnings;
+}
+
 static void outliner_draw_rnacols(ARegion *region, int sizex)
 {
   View2D *v2d = &region->v2d;
@@ -2896,7 +2978,13 @@ static void outliner_draw_iconrow(bContext *C,
         active = tree_element_type_active_state_get(C, tvc, te, tselem);
       }
 
-      if (!ELEM(tselem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION, TSE_R_LAYER, TSE_GP_LAYER)) {
+      if (!ELEM(tselem->type,
+                TSE_SOME_ID,
+                TSE_LAYER_COLLECTION,
+                TSE_R_LAYER,
+                TSE_GP_LAYER,
+                TSE_LIBRARY_OVERRIDE_BASE,
+                TSE_LIBRARY_OVERRIDE)) {
         outliner_draw_iconrow_doit(block, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1);
       }
       else {
@@ -3656,7 +3744,11 @@ void draw_outliner(const bContext *C)
   }
 
   /* Sync selection state from view layer. */
-  if (!ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS) &&
+  if (!ELEM(space_outliner->outlinevis,
+            SO_LIBRARIES,
+            SO_OVERRIDES_LIBRARY,
+            SO_DATA_API,
+            SO_ID_ORPHANS) &&
       space_outliner->flag & SO_SYNC_SELECT) {
     outliner_sync_selection(C, space_outliner);
   }
@@ -3703,6 +3795,10 @@ void draw_outliner(const bContext *C)
     /* draw user toggle columns */
     outliner_draw_userbuts(block, region, space_outliner, &space_outliner->tree);
   }
+  else if (space_outliner->outlinevis == SO_OVERRIDES_LIBRARY) {
+    /* Draw overrides status columns. */
+    outliner_draw_overrides_buts(block, region, space_outliner, &space_outliner->tree, true);
+  }
   else if (restrict_column_width > 0.0f) {
     /* draw restriction columns */
     RestrictPropertiesActive props_active;
diff --git a/source/blender/editors/space_outliner/outliner_intern.h b/source/blender/editors/space_outliner/outliner_intern.h
index f65e273c1b5..fea5ddae16b 100644
--- a/source/blender/editors/space_outliner/outliner_intern.h
+++ b/source/blender/editors/space_outliner/outliner_intern.h
@@ -193,7 +193,7 @@ typedef enum {
 /* The outliner display modes that support the filter system.
  * Note: keep it synced with space_outliner.py */
 #define SUPPORT_FILTER_OUTLINER(space_outliner_) \
-  (ELEM((space_outliner_)->outlinevis, SO_VIEW_LAYER))
+  (ELEM((space_outliner_)->outlinevis, SO_VIEW_LAYER, SO_OVERRIDES_LIBRARY))
 
 /* Outliner Searching --
  *
diff --git a/source/blender/editors/space_outliner/outliner_sync.c b/source/blender/editors/space_outliner/outliner_sync.c
index 6543a909a41..d78767019b5 100644
--- a/source/blender/editors/space_outliner/outliner_sync.c
+++ b/source/blender/editors/space_outliner/outliner_sync.c
@@ -356,8 +356,11 @@ static void outliner_sync_selection_from_outliner(Scene *scene,
 void ED_outliner_select_sync_from_outliner(bContext *C, SpaceOutliner *space_outliner)
 {
   /* Don't sync if not checked or in certain outliner display modes */
-  if (!(space_outliner->flag & SO_SYNC_SELECT) ||
-      ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_DATA_API, SO_ID_ORPHANS)) {
+  if (!(space_outliner->flag & SO_

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list