Commit: d2a30abff09b5403e72541860935c593602153b2 Author: Julian Eisel Date: Thu Aug 4 15:52:51 2022 +0200 Branches: blender-v3.3-release https://developer.blender.org/rBd2a30abff09b5403e72541860935c593602153b2
Outliner: Use UI names and grouping for library overrides properties NOTE: This is committed to the 3.3 branch as decided by Bastien, Dalai and me. That is because these are important usability fixes/improvements to have for the LTS release. Part of T95802. Showing properties with an RNA path in the UI isn't very user friendly. Instead, represent the RNA path as a tree, merging together parts of the RNA path that are shared by multiple properties. Properties and "groups" (RNA structs/pointers) are now shown with their UI name and an icon if any. The actually overridden properties still show the Library Overrides icon. See the patch for screenshots. Also: When a RNA collection item, like a modifier or constraint was added via a library override, indicate that item and show all collection items in the list, since the complete list of items and their orders may be important context. Differential Revision: https://developer.blender.org/D15606 =================================================================== M source/blender/editors/space_outliner/outliner_draw.cc M source/blender/editors/space_outliner/outliner_tree.cc M source/blender/editors/space_outliner/tree/tree_element.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_outliner_types.h M source/blender/makesrna/intern/rna_path.cc =================================================================== diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index fd38bcfc5e2..ae9ffffd145 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -1806,18 +1806,17 @@ static void outliner_draw_overrides_rna_buts(uiBlock *block, if (!outliner_is_element_in_view(te, ®ion->v2d)) { continue; } - if (tselem->type != TSE_LIBRARY_OVERRIDE) { + TreeElementOverridesProperty *override_elem = tree_element_cast<TreeElementOverridesProperty>( + te); + if (!override_elem) { continue; } - TreeElementOverridesProperty &override_elem = *tree_element_cast<TreeElementOverridesProperty>( - te); - - if (!override_elem.is_rna_path_valid) { + if (!override_elem->is_rna_path_valid) { uiBut *but = uiDefBut(block, UI_BTYPE_LABEL, 0, - override_elem.rna_path.c_str(), + override_elem->rna_path.c_str(), x + pad_x, te->ys + pad_y, item_max_width, @@ -1832,8 +1831,28 @@ static void outliner_draw_overrides_rna_buts(uiBlock *block, continue; } - PointerRNA *ptr = &override_elem.override_rna_ptr; - PropertyRNA *prop = &override_elem.override_rna_prop; + if (const TreeElementOverridesPropertyOperation *override_op_elem = + tree_element_cast<TreeElementOverridesPropertyOperation>(te)) { + StringRefNull op_label = override_op_elem->getOverrideOperationLabel(); + uiDefBut(block, + UI_BTYPE_LABEL, + 0, + op_label.c_str(), + x + pad_x, + te->ys + pad_y, + item_max_width, + item_height, + nullptr, + 0, + 0, + 0, + 0, + ""); + continue; + } + + PointerRNA *ptr = &override_elem->override_rna_ptr; + PropertyRNA *prop = &override_elem->override_rna_prop; const PropertyType prop_type = RNA_property_type(prop); uiBut *auto_but = uiDefAutoButR(block, @@ -3104,6 +3123,7 @@ static void outliner_draw_iconrow(bContext *C, TSE_GP_LAYER, TSE_LIBRARY_OVERRIDE_BASE, TSE_LIBRARY_OVERRIDE, + TSE_LIBRARY_OVERRIDE_OPERATION, TSE_BONE, TSE_EBONE, TSE_POSE_CHANNEL, diff --git a/source/blender/editors/space_outliner/outliner_tree.cc b/source/blender/editors/space_outliner/outliner_tree.cc index b2199f18b7b..3357a456e30 100644 --- a/source/blender/editors/space_outliner/outliner_tree.cc +++ b/source/blender/editors/space_outliner/outliner_tree.cc @@ -880,7 +880,10 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner, BLI_assert_msg(0, "Expected this ID type to be ported to new Outliner tree-element design"); } } - else if (ELEM(type, TSE_LIBRARY_OVERRIDE_BASE, TSE_LIBRARY_OVERRIDE)) { + else if (ELEM(type, + TSE_LIBRARY_OVERRIDE_BASE, + TSE_LIBRARY_OVERRIDE, + TSE_LIBRARY_OVERRIDE_OPERATION)) { if (!te->abstract_element) { BLI_assert_msg(0, "Expected override types to be ported to new Outliner tree-element design"); diff --git a/source/blender/editors/space_outliner/tree/tree_element.cc b/source/blender/editors/space_outliner/tree/tree_element.cc index 9bc65ce572b..a401662297a 100644 --- a/source/blender/editors/space_outliner/tree/tree_element.cc +++ b/source/blender/editors/space_outliner/tree/tree_element.cc @@ -79,6 +79,9 @@ std::unique_ptr<AbstractTreeElement> AbstractTreeElement::createFromType(const i case TSE_LIBRARY_OVERRIDE: return std::make_unique<TreeElementOverridesProperty>( legacy_te, *static_cast<TreeElementOverridesData *>(idv)); + case TSE_LIBRARY_OVERRIDE_OPERATION: + return std::make_unique<TreeElementOverridesPropertyOperation>( + legacy_te, *static_cast<TreeElementOverridesData *>(idv)); case TSE_RNA_STRUCT: return std::make_unique<TreeElementRNAStruct>(legacy_te, *reinterpret_cast<PointerRNA *>(idv)); diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc index d1babda642e..7db6b9635ee 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_overrides.cc +++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.cc @@ -7,30 +7,60 @@ #include "BKE_collection.h" #include "BKE_lib_override.h" -#include "BLI_utildefines.h" - +#include "BLI_function_ref.hh" #include "BLI_listbase_wrapper.hh" +#include "BLI_map.hh" +#include "BLI_utildefines.h" #include "BLT_translation.h" #include "DNA_space_types.h" #include "RNA_access.h" +#include "RNA_path.h" #include "../outliner_intern.hh" +#include "tree_element_label.hh" #include "tree_element_overrides.hh" namespace blender::ed::outliner { +class OverrideRNAPathTreeBuilder { + SpaceOutliner &space_outliner_; + Map<std::string, TreeElement *> path_te_map; + + public: + OverrideRNAPathTreeBuilder(SpaceOutliner &space_outliner); + void build_path(TreeElement &parent, TreeElementOverridesData &override_data, short &index); + + private: + TreeElement &ensure_label_element_for_prop( + TreeElement &parent, StringRef elem_path, PointerRNA &ptr, PropertyRNA &prop, short &index); + TreeElement &ensure_label_element_for_ptr(TreeElement &parent, + StringRef elem_path, + PointerRNA &ptr, + short &index); + void ensure_entire_collection(TreeElement &te_to_expand, + const TreeElementOverridesData &override_data, + const char *coll_prop_path, + short &index); +}; + +/* -------------------------------------------------------------------- */ +/** \name Base Element + * + * Represents an ID that has overridden properties. The expanding will invoke building of tree + * elements for the full RNA path of the property. + * + * \{ */ + TreeElementOverridesBase::TreeElementOverridesBase(TreeElement &legacy_te, ID &id) : AbstractTreeElement(legacy_te), id(id) { BLI_assert(legacy_te.store_elem->type == TSE_LIBRARY_OVERRIDE_BASE); if (legacy_te.parent != nullptr && - ELEM(legacy_te.parent->store_elem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) - - { + ELEM(legacy_te.parent->store_elem->type, TSE_SOME_ID, TSE_LAYER_COLLECTION)) { legacy_te.name = IFACE_("Library Overrides"); } else { @@ -51,21 +81,17 @@ StringRefNull TreeElementOverridesBase::getWarning() const return {}; } -void TreeElementOverridesBase::expand(SpaceOutliner &space_outliner) const +static void iterate_properties_to_display(ID &id, + const bool show_system_overrides, + FunctionRef<void(TreeElementOverridesData &data)> fn) { - BLI_assert(id.override_library != nullptr); + PointerRNA override_rna_ptr; + PropertyRNA *override_rna_prop; - const bool show_system_overrides = (SUPPORT_FILTER_OUTLINER(&space_outliner) && - (space_outliner.filter & SO_FILTER_SHOW_SYSTEM_OVERRIDES) != - 0); PointerRNA idpoin; RNA_id_pointer_create(&id, &idpoin); - PointerRNA override_rna_ptr; - PropertyRNA *override_rna_prop; - short index = 0; - - for (auto *override_prop : + for (IDOverrideLibraryProperty *override_prop : ListBaseWrapper<IDOverrideLibraryProperty>(id.override_library->properties)) { int rnaprop_index = 0; const bool is_rna_path_valid = BKE_lib_override_rna_property_find( @@ -80,7 +106,7 @@ void TreeElementOverridesBase::expand(SpaceOutliner &space_outliner) const /* Matching ID pointers are considered as system overrides. */ if (ELEM(override_prop->rna_prop_type, PROP_POINTER, PROP_COLLECTION) && RNA_struct_is_ID(RNA_property_pointer_type(&override_rna_ptr, override_rna_prop))) { - for (auto *override_prop_op : + for (IDOverrideLibraryPropertyOperation *override_prop_op : ListBaseWrapper<IDOverrideLibraryPropertyOperation>(override_prop->operations)) { if ((override_prop_op->flag & IDOVERRIDE_LIBRARY_FLAG_IDPOINTER_MATCH_REFERENCE) == 0) { do_skip = false; @@ -103,11 +129,36 @@ void TreeElementOverridesBase::expand(SpaceOutliner &space_outliner) const TreeElementOverridesData data = { id, *override_prop, override_rna_ptr, *override_rna_prop, is_rna_path_valid}; - outliner_add_element( - &space_outliner, &legacy_te_.subtree, &data, &legacy_te_, TSE_LIBRARY_OVERRIDE, index++); + + fn(data); } } +void TreeElementOverridesBase::expand(SpaceOutliner &space_outliner) const +{ + BLI_assert(id.override_library != nullptr); + + const bool show_system_overrides = (SUPPORT_FILTER_OUTLINER(&space_outliner) && + (space_outliner.filter & SO_FILTER_SHOW_SYSTEM_OVERRIDES) != + 0); + + OverrideRNAPathTreeBuilder path_builder(space_outliner); + short index = 0; + + iterate_properties_to_display(id, show_system_overrides, [&](TreeElementOverridesData &data) { + path_builder.build_path(legacy_te_, data, index); + }); +} + +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Overriden Property + * + * Represents an RNA property that was overridden. + * + * \{ */ + TreeElementOverridesProperty::TreeElementOverridesProperty(TreeElement &legacy_te, TreeElementOverridesData &override_data) : AbstractTreeElement(legacy_te), @@ -116,9 +167,10 @@ TreeE @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list [email protected] List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs
