diff options
Diffstat (limited to 'source/blender/editors/space_outliner/tree/tree_element_overrides.hh')
-rw-r--r-- | source/blender/editors/space_outliner/tree/tree_element_overrides.hh | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh index 1db46d9af1d..f8ca146a4ea 100644 --- a/source/blender/editors/space_outliner/tree/tree_element_overrides.hh +++ b/source/blender/editors/space_outliner/tree/tree_element_overrides.hh @@ -14,6 +14,7 @@ struct ID; struct IDOverrideLibraryProperty; +struct IDOverrideLibraryPropertyOperation; namespace blender::ed::outliner { @@ -24,6 +25,11 @@ struct TreeElementOverridesData { PropertyRNA &override_rna_prop; bool is_rna_path_valid; + + /* In case the property references a specific operation. Only used for collection overrides + * currently, where a single override may add/remove multiple collection items (only add + * currently). */ + IDOverrideLibraryPropertyOperation *operation = nullptr; }; class TreeElementOverridesBase final : public AbstractTreeElement { @@ -38,7 +44,12 @@ class TreeElementOverridesBase final : public AbstractTreeElement { StringRefNull getWarning() const override; }; -class TreeElementOverridesProperty final : public AbstractTreeElement { +/** + * Represent a single overridden property. Collection properties may support multiple override + * operations, e.g. to insert/remove multiple collection items. For these multiple operation cases, + * use #TreeElementOverridesPropertyOperation. + */ +class TreeElementOverridesProperty : public AbstractTreeElement { public: PointerRNA override_rna_ptr; PropertyRNA &override_rna_prop; @@ -50,6 +61,33 @@ class TreeElementOverridesProperty final : public AbstractTreeElement { TreeElementOverridesProperty(TreeElement &legacy_te, TreeElementOverridesData &override_data); StringRefNull getWarning() const override; + + bool isCollectionOperation() const; +}; + +/** + * Represent a single operation within an overridden property. While usually a single override + * property represents a single operation (changing the value), a single overridden collection + * property may have multiple operations, e.g. to insert or remove collection items. + * + * Inherits from the override property class since it should look/behave mostly the same. + */ +class TreeElementOverridesPropertyOperation final : public TreeElementOverridesProperty { + /** See #TreeElementOverridesData::operation. Operations are recreated as part of the diffing + * (e.g. on undo pushes) so store a copy of the data here. */ + std::unique_ptr<IDOverrideLibraryPropertyOperation> operation_; + + public: + TreeElementOverridesPropertyOperation(TreeElement &legacy_te, + TreeElementOverridesData &override_data); + + /** Return a short string to display in the right column of the properties mode, indicating what + * the override operation did (e.g. added or removed a collection item). */ + StringRefNull getOverrideOperationLabel() const; + std::optional<BIFIconID> getIcon() const override; + + private: + std::optional<PointerRNA> get_collection_ptr() const; }; } // namespace blender::ed::outliner |