Blender V4.3
tree_element.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
11#include <memory>
12#include <optional>
13
14#include "BLI_string_ref.hh"
15#include "UI_resources.hh"
16
17struct ID;
18struct ListBase;
19struct SpaceOutliner;
20
21namespace blender::ed::outliner {
22
23class AbstractTreeDisplay;
24struct TreeElement;
25
26/* -------------------------------------------------------------------- */
27/* Tree-Display Interface */
28
30 protected:
41
42 friend class AbstractTreeDisplay;
43
44 public:
45 virtual ~AbstractTreeElement() = default;
46
47 static std::unique_ptr<AbstractTreeElement> create_from_type(int type,
48 TreeElement &legacy_te,
49 ID *owner_id,
50 void *create_data);
51
55 virtual bool expand_poll(const SpaceOutliner &) const
56 {
57 return true;
58 }
59
61 {
62 return legacy_te_;
63 }
64
69 virtual StringRefNull get_warning() const;
70
78 virtual std::optional<BIFIconID> get_icon() const;
79
88 void print_path();
89
96 static void uncollapse_by_default(TreeElement *legacy_te);
97
98 friend void tree_element_expand(const AbstractTreeElement &tree_element,
99 SpaceOutliner &space_outliner);
100
101 protected:
102 /* Pseudo-abstract: Only allow creation through derived types. */
103 AbstractTreeElement(TreeElement &legacy_te) : legacy_te_(legacy_te) {}
104
108 virtual void expand(SpaceOutliner &) const {}
109
112 ID *owner_id,
113 void *create_data,
114 TreeElement *parent,
115 short type,
116 short index,
117 const bool expand = true) const;
118};
119
120void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner);
121
122} // namespace blender::ed::outliner
Base Class For Tree-Displays.
virtual StringRefNull get_warning() const
friend void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner)
static std::unique_ptr< AbstractTreeElement > create_from_type(int type, TreeElement &legacy_te, ID *owner_id, void *create_data)
TreeElement * add_element(ListBase *lb, ID *owner_id, void *create_data, TreeElement *parent, short type, short index, const bool expand=true) const
static void uncollapse_by_default(TreeElement *legacy_te)
virtual bool expand_poll(const SpaceOutliner &) const
virtual void expand(SpaceOutliner &) const
virtual std::optional< BIFIconID > get_icon() const
void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner)
Definition DNA_ID.h:413