Blender  V3.3
tree_element.hh
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
7 #pragma once
8 
9 #include <memory>
10 #include <optional>
11 
12 #include "BLI_string_ref.hh"
13 #include "UI_resources.h"
14 
15 struct ListBase;
16 struct SpaceOutliner;
17 struct TreeElement;
18 
19 namespace blender::ed::outliner {
20 
21 /* -------------------------------------------------------------------- */
22 /* Tree-Display Interface */
23 
25  protected:
32 
33  public:
34  virtual ~AbstractTreeElement() = default;
35 
36  static std::unique_ptr<AbstractTreeElement> createFromType(int type,
37  TreeElement &legacy_te,
38  void *idv);
39 
43  virtual bool expandPoll(const SpaceOutliner &) const
44  {
45  return true;
46  }
47 
52  virtual bool isExpandValid() const
53  {
54  return true;
55  }
56 
58  {
59  return legacy_te_;
60  }
61 
66  virtual StringRefNull getWarning() const;
67 
75  virtual std::optional<BIFIconID> getIcon() const;
76 
83  static void uncollapse_by_default(TreeElement *legacy_te);
84 
85  friend void tree_element_expand(const AbstractTreeElement &tree_element,
86  SpaceOutliner &space_outliner);
87 
88  protected:
89  /* Pseudo-abstract: Only allow creation through derived types. */
90  AbstractTreeElement(TreeElement &legacy_te) : legacy_te_(legacy_te)
91  {
92  }
93 
97  virtual void expand(SpaceOutliner &) const
98  {
99  }
100 };
101 
114 struct TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
115  ListBase *lb,
116  void *idv,
117  struct TreeElement *parent,
118  short type,
119  short index,
120  const bool expand = true);
121 
122 void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner);
123 
124 } // namespace blender::ed::outliner
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
AbstractTreeElement(TreeElement &legacy_te)
Definition: tree_element.hh:90
friend void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner)
virtual std::optional< BIFIconID > getIcon() const
static std::unique_ptr< AbstractTreeElement > createFromType(int type, TreeElement &legacy_te, void *idv)
Definition: tree_element.cc:33
virtual bool expandPoll(const SpaceOutliner &) const
Definition: tree_element.hh:43
static void uncollapse_by_default(TreeElement *legacy_te)
virtual void expand(SpaceOutliner &) const
Definition: tree_element.hh:97
virtual StringRefNull getWarning() const
TreeElement * outliner_add_element(SpaceOutliner *space_outliner, ListBase *lb, void *idv, TreeElement *parent, short type, short index, const bool expand)
void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner)
struct TreeElement * parent