Welcome to mirror list, hosted at ThFree Co, Russian Federation.

tree_view.hh « tree « space_outliner « editors « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a4ce0ce6e782c4864bcc306b8754f1fdd7af47a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/*
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

/** \file
 * \ingroup spoutliner
 *
 * For now all sub-class declarations of #AbstractTreeView are in this file. They could be moved
 * into own headers of course.
 */

#pragma once

#include "DNA_space_types.h"

struct ListBase;
struct SpaceOutliner;
struct TreeElement;
struct TreeSourceData;

#ifdef __cplusplus

namespace blender {
namespace ed {
namespace outliner {

using Tree = ListBase;

/* -------------------------------------------------------------------- */
/* Tree-View Interface */

/**
 * \brief Base Class For Tree-Views
 *
 * Abstract base class defining the interface for tree-view variants. For each Outliner display
 * type (e.g View Layer, Scenes, Blender File), a derived class implements a #buildTree() function,
 * that based on Blender data (#TreeSourceData), builds a custom tree of whatever data it wants to
 * visualize.
 */
class AbstractTreeView {
 public:
  AbstractTreeView(SpaceOutliner &space_outliner) : _space_outliner(space_outliner)
  {
  }
  virtual ~AbstractTreeView() = default;

  /**
   * Build a tree for this view with the Blender context data given in \a source_data and the view
   * settings in \a space_outliner.
   */
  virtual Tree buildTree(const TreeSourceData &source_data) = 0;

 protected:
  /** All derived classes will need a handle to this, so storing it in the base for convenience. */
  SpaceOutliner &_space_outliner;
};

/* -------------------------------------------------------------------- */
/* View Layer Tree-View */

/**
 * \brief Tree-View for the View Layer display mode.
 */
class TreeViewViewLayer final : public AbstractTreeView {
  ViewLayer *_view_layer = nullptr;
  bool _show_objects = true;

 public:
  TreeViewViewLayer(SpaceOutliner &space_outliner);

  Tree buildTree(const TreeSourceData &source_data) override;

 private:
  void add_view_layer(ListBase &, TreeElement &);
  void add_layer_collections_recursive(ListBase &, ListBase &, TreeElement &);
  void add_layer_collection_objects(ListBase &, LayerCollection &, TreeElement &);
  void add_layer_collection_objects_children(TreeElement &);
};

}  // namespace outliner
}  // namespace ed
}  // namespace blender

extern "C" {
#endif

/* -------------------------------------------------------------------- */
/* C-API */

/** There is no actual implementation of this, it's the C name for an #AbstractTreeView handle. */
typedef struct TreeView TreeView;

/**
 * \brief The data to build the tree from.
 */
typedef struct TreeSourceData {
  struct Main *bmain;
  struct Scene *scene;
  struct ViewLayer *view_layer;
} TreeSourceData;

TreeView *outliner_tree_view_create(eSpaceOutliner_Mode mode, SpaceOutliner *space_outliner);
void outliner_tree_view_destroy(TreeView **tree_view);

ListBase outliner_tree_view_build_tree(TreeView *tree_view, TreeSourceData *source_data);

/* The following functions are needed to build the tree. These are calls back into C; the way
 * elements are created should be refactored and ported to C++ with a new design/API too. */
struct TreeElement *outliner_add_element(struct SpaceOutliner *space_outliner,
                                         ListBase *lb,
                                         void *idv,
                                         struct TreeElement *parent,
                                         short type,
                                         short index);
void outliner_make_object_parent_hierarchy(ListBase *lb);

#ifdef __cplusplus
}
#endif