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

Bastien Montagne noreply at git.blender.org
Fri Mar 19 10:07:43 CET 2021


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

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/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_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/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..9f604ae296b 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
@@ -353,7 +353,7 @@ class OUTLINER_PT_filter(Panel):
         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 not in {'VIEW_LAYER', 'LIBRARY_OVERRIDES'}:
             return
 
         layout.separator()
@@ -405,10 +405,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 +421,16 @@ class OUTLINER_PT_filter(Panel):
             row.label(icon='BLANK1')
             row.prop(space, "use_filter_object_others", text="Others")
 
+        if bpy.data.libraries:
+            sub.separator()
+            row = sub.row()
+            row.label(icon='LIBRARY_DATA_OVERRIDE')
+            row.prop(space, "use_filter_lib_override", text="Library Overrides")
+            row = sub.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_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 278162c4338..b10ae0440a2 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -1754,6 +1754,98 @@ 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: {
+        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");
+          }
+        }
+#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:
+        break;
+      case TSE_LIBRARY_OVERRIDE:
+        break;
+      default:
+        break;
+    }
+
+    const bool have_children_warnings = outliner_draw_overrides_buts(
+        block,
+        region,
+        space_outliner,
+        &te->subtree,
+        is_open && TSELEM_OPEN(tselem, space_outliner));
+
+    if (do_draw &&
+        (has_warnings || (have_children_warnings && !TSELEM_OPEN(tselem, space_outliner)))) {
+      but_flag |= UI_BUT_REDALERT;
+      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);
+    }
+    parent_has_warnings = parent_has_warnings || has_warnings || have_children_warnings;
+  }
+
+  return parent_has_warnings;
+}
+
 static void outliner_draw_rnacols(ARegion *region, int sizex)
 {
   View2D *v2d = &region->v2d;
@@ -2875,7 +2967,19 @@ 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_ID_BASE,
+                TSE_SOME_ID,
+                TSE_LAYER_COLLECTION,
+                TSE_R_LAYER,
+                TSE_GP_LAYER,
+                TSE_LIBRARY_OVERRIDE_BASE,
+                TSE_LIBRARY_OVERRIDE,
+                TSE_BONE,
+                TSE_EBONE,
+                TSE_POSE_CHANNEL,
+                TSE_POSEGRP,
+                TSE_DEFGROUP)) {
         outliner_draw_iconrow_doit(block, te, fstyle, xmax, offsx, ys, alpha_fac, active, 1);
       }
       else {
@@ -3635,7 +3739,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);
   }
@@ -3682,6 +3790,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/s

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list