Cleanup: Remove Outliner C-API headers/wrappers

Basically this removes any C <-> C++ glue code. C++ types are accessed
directly via the public C++ APIs.
Contains some related changes like, moving functions that were
previously declared in a now removed header to a different file, whose
header is the more appropriate place (and the source file as well).
But generally I tried to avoid other changes.
This commit is contained in:
Julian Eisel 2022-01-14 18:00:21 +01:00
parent 9109ea0b96
commit e9a43a3b60
34 changed files with 291 additions and 319 deletions

View File

@ -69,9 +69,8 @@ set(SRC
tree/tree_element_view_layer.cc
outliner_intern.hh
tree/tree_display.h
tree/common.hh
tree/tree_display.hh
tree/tree_element.h
tree/tree_element.hh
tree/tree_element_anim_data.hh
tree/tree_element_collection.hh

View File

@ -79,7 +79,10 @@
#include "RNA_access.h"
#include "outliner_intern.hh"
#include "tree/tree_display.h"
#include "tree/tree_display.hh"
#include "tree/tree_element.hh"
using namespace blender::ed::outliner;
/* Disable - this is far too slow - campbell. */
/* #define USE_GROUP_SELECT */
@ -3861,9 +3864,10 @@ void draw_outliner(const bContext *C)
const bool use_mode_column = (space_outliner->flag & SO_MODE_COLUMN) &&
(ELEM(space_outliner->outlinevis, SO_VIEW_LAYER, SO_SCENES));
const bool use_warning_column =
ELEM(space_outliner->outlinevis, SO_LIBRARIES, SO_OVERRIDES_LIBRARY) &&
outliner_tree_display_warnings_poll(space_outliner->runtime->tree_display);
const bool use_warning_column = ELEM(space_outliner->outlinevis,
SO_LIBRARIES,
SO_OVERRIDES_LIBRARY) &&
space_outliner->runtime->tree_display->hasWarnings();
/* Draw outliner stuff (background, hierarchy lines and names). */
const float restrict_column_width = outliner_restrict_columns_width(space_outliner);

View File

@ -47,15 +47,24 @@ struct bPoseChannel;
struct wmKeyConfig;
struct wmOperatorType;
typedef struct SpaceOutliner_Runtime {
/** Internal C++ object to create and manage the tree for a specific display type (View Layers,
* Scenes, Blender File, etc.). */
struct TreeDisplay *tree_display;
namespace blender::ed::outliner {
class AbstractTreeDisplay;
class AbstractTreeElement;
} // namespace blender::ed::outliner
struct SpaceOutliner_Runtime {
/** Object to create and manage the tree for a specific display type (View Layers, Scenes,
* Blender File, etc.). */
blender::ed::outliner::AbstractTreeDisplay *tree_display;
/** Pointers to tree-store elements, grouped by `(id, type, nr)`
* in hash-table for faster searching. */
struct GHash *treehash;
} SpaceOutliner_Runtime;
SpaceOutliner_Runtime() = default;
/** Used for copying runtime data to a duplicated space. */
SpaceOutliner_Runtime(const SpaceOutliner_Runtime &);
};
typedef enum TreeElementInsertType {
TE_INSERT_BEFORE,
@ -82,7 +91,7 @@ typedef struct TreeElement {
* #TreeElement. Step by step, data should be moved to it and operations based on the type should
* become virtual methods of the class hierarchy.
*/
struct TreeElementType *type;
blender::ed::outliner::AbstractTreeElement *type;
ListBase subtree;
int xs, ys; /* Do selection. */
@ -269,6 +278,10 @@ void outliner_build_tree(struct Main *mainvar,
struct SpaceOutliner *space_outliner,
struct ARegion *region);
struct TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
struct Collection *collection,
TreeElement *ten);
bool outliner_requires_rebuild_on_select_or_active_change(
const struct SpaceOutliner *space_outliner);
/**

View File

@ -77,13 +77,16 @@
#include "UI_resources.h"
#include "outliner_intern.hh"
#include "tree/tree_display.h"
#include "tree/tree_element.h"
#include "tree/common.hh"
#include "tree/tree_display.hh"
#include "tree/tree_element.hh"
#ifdef WIN32
# include "BLI_math_base.h" /* M_PI */
#endif
using namespace blender::ed::outliner;
/* prototypes */
static int outliner_exclude_filter_get(const SpaceOutliner *space_outliner);
@ -254,14 +257,6 @@ static void outliner_add_bone(SpaceOutliner *space_outliner,
}
}
bool outliner_animdata_test(const AnimData *adt)
{
if (adt) {
return (adt->action || adt->drivers.first || adt->nla_tracks.first);
}
return false;
}
#ifdef WITH_FREESTYLE
static void outliner_add_line_styles(SpaceOutliner *space_outliner,
ListBase *lb,
@ -815,40 +810,7 @@ static void outliner_add_id_contents(SpaceOutliner *space_outliner,
}
}
bool outliner_element_warnings_get(TreeElement *te, int *r_icon, const char **r_message)
{
TreeStoreElem *tselem = TREESTORE(te);
if (tselem->type != TSE_SOME_ID) {
return false;
}
if (te->idcode != ID_LI) {
return false;
}
Library *library = (Library *)tselem->id;
if (library->tag & LIBRARY_TAG_RESYNC_REQUIRED) {
if (r_icon) {
*r_icon = ICON_ERROR;
}
if (r_message) {
*r_message = TIP_(
"Contains linked library overrides that need to be resynced, updating the library is "
"recommended");
}
return true;
}
if (library->id.tag & LIB_TAG_MISSING) {
if (r_icon) {
*r_icon = ICON_ERROR;
}
if (r_message) {
*r_message = TIP_("Missing library");
}
return true;
}
return false;
}
namespace blender::ed::outliner {
TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
ListBase *lb,
@ -883,7 +845,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
BLI_assert(TREESTORE_ID_TYPE(id));
}
TreeElement *te = MEM_cnew<TreeElement>(__func__);
TreeElement *te = MEM_new<TreeElement>(__func__);
/* add to the visual tree */
BLI_addtail(lb, te);
/* add to the storage */
@ -898,9 +860,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
te->parent = parent;
te->index = index; /* For data arrays. */
/* New C++ based type handle (`TreeElementType` in C, `AbstractTreeElement` in C++). Only some
* support this, eventually this should replace `TreeElement` entirely. */
te->type = outliner_tree_element_type_create(type, te, idv);
/* New C++ based type handle. Only some support this, eventually this should replace
* `TreeElement` entirely. */
te->type = outliner_tree_element_type_create(type, *te, idv);
if (te->type) {
/* Element types ported to the new design are expected to have their name set at this point! */
BLI_assert(te->name != nullptr);
@ -947,14 +909,14 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
te->idcode = GS(id->name);
}
if (te->type && outliner_tree_element_type_is_expand_valid(te->type)) {
outliner_tree_element_type_expand(te->type, space_outliner);
if (te->type && te->type->isExpandValid()) {
tree_element_expand(*te->type, *space_outliner);
}
else if (type == TSE_SOME_ID) {
/* ID types not (fully) ported to new design yet. */
if (outliner_tree_element_type_expand_poll(te->type, space_outliner)) {
if (te->type->expandPoll(*space_outliner)) {
outliner_add_id_contents(space_outliner, te, tselem, id);
outliner_tree_element_type_post_expand(te->type, space_outliner);
te->type->postExpand(*space_outliner);
}
}
else if (ELEM(type,
@ -1161,6 +1123,8 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
return te;
}
} // namespace blender::ed::outliner
/* ======================================================= */
BLI_INLINE void outliner_add_collection_init(TreeElement *te, Collection *collection)
@ -1200,30 +1164,6 @@ TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
/* ======================================================= */
/* Generic Tree Building helpers - order these are called is top to bottom */
/* Hierarchy --------------------------------------------- */
void outliner_make_object_parent_hierarchy(ListBase *lb)
{
/* build hierarchy */
/* XXX also, set extents here... */
TreeElement *te = reinterpret_cast<TreeElement *>(lb->first);
while (te) {
TreeElement *ten = te->next;
TreeStoreElem *tselem = TREESTORE(te);
if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_OB) {
Object *ob = (Object *)tselem->id;
if (ob->parent && ob->parent->id.newid) {
BLI_remlink(lb, te);
TreeElement *tep = (TreeElement *)ob->parent->id.newid;
BLI_addtail(&tep->subtree, te);
te->parent = tep;
}
}
te = ten;
}
}
/* Sorting ------------------------------------------------------ */
struct tTreeSort {
@ -1942,8 +1882,8 @@ void outliner_build_tree(Main *mainvar,
outliner_storage_cleanup(space_outliner);
outliner_tree_display_destroy(&space_outliner->runtime->tree_display);
space_outliner->runtime->tree_display = outliner_tree_display_create(
(eSpaceOutliner_Mode)space_outliner->outlinevis, space_outliner);
space_outliner->runtime->tree_display = outliner_tree_display_create(space_outliner->outlinevis,
space_outliner);
/* All tree displays should be created as sub-classes of AbstractTreeDisplay. */
BLI_assert(space_outliner->runtime->tree_display != nullptr);
@ -1952,8 +1892,7 @@ void outliner_build_tree(Main *mainvar,
source_data.bmain = mainvar;
source_data.scene = scene;
source_data.view_layer = view_layer;
space_outliner->tree = outliner_tree_display_build_tree(space_outliner->runtime->tree_display,
&source_data);
space_outliner->tree = space_outliner->runtime->tree_display->buildTree(source_data);
if ((space_outliner->flag & SO_SKIP_SORT_ALPHA) == 0) {
outliner_sort(&space_outliner->tree);

View File

@ -50,7 +50,12 @@
#include "UI_view2d.h"
#include "outliner_intern.hh"
#include "tree/tree_display.h"
#include "tree/tree_display.hh"
SpaceOutliner_Runtime::SpaceOutliner_Runtime(const SpaceOutliner_Runtime & /*other*/)
: tree_display(nullptr), treehash(nullptr)
{
}
static void outliner_main_region_init(wmWindowManager *wm, ARegion *region)
{
@ -376,7 +381,7 @@ static void outliner_init(wmWindowManager *UNUSED(wm), ScrArea *area)
SpaceOutliner *space_outliner = reinterpret_cast<SpaceOutliner *>(area->spacedata.first);
if (space_outliner->runtime == nullptr) {
space_outliner->runtime = MEM_cnew<SpaceOutliner_Runtime>("SpaceOutliner_Runtime");
space_outliner->runtime = MEM_new<SpaceOutliner_Runtime>("SpaceOutliner_Runtime");
}
}
@ -391,10 +396,9 @@ static SpaceLink *outliner_duplicate(SpaceLink *sl)
space_outliner_new->sync_select_dirty = WM_OUTLINER_SYNC_SELECT_FROM_ALL;
if (space_outliner->runtime) {
/* Copy constructor handles details. */
space_outliner_new->runtime = MEM_new<SpaceOutliner_Runtime>("SpaceOutliner_runtime dup",
*space_outliner->runtime);
space_outliner_new->runtime->tree_display = nullptr;
space_outliner_new->runtime->treehash = nullptr;
}
return (SpaceLink *)space_outliner_new;

View File

@ -20,10 +20,18 @@
* Functions and helpers shared between tree-display types or other tree related code.
*/
#include "BLI_listbase.h"
#include "BKE_idtype.h"
#include "DNA_anim_types.h"
#include "DNA_object_types.h"
#include "DNA_outliner_types.h"
#include "RNA_access.h"
#include "../outliner_intern.hh"
#include "common.hh"
#include "tree_display.hh"
/* -------------------------------------------------------------------- */
@ -38,3 +46,33 @@ const char *outliner_idcode_to_plural(short idcode)
}
/** \} */
void outliner_make_object_parent_hierarchy(ListBase *lb)
{
/* build hierarchy */
/* XXX also, set extents here... */
TreeElement *te = reinterpret_cast<TreeElement *>(lb->first);
while (te) {
TreeElement *ten = te->next;
TreeStoreElem *tselem = TREESTORE(te);
if ((tselem->type == TSE_SOME_ID) && te->idcode == ID_OB) {
Object *ob = (Object *)tselem->id;
if (ob->parent && ob->parent->id.newid) {
BLI_remlink(lb, te);
TreeElement *tep = (TreeElement *)ob->parent->id.newid;
BLI_addtail(&tep->subtree, te);
te->parent = tep;
}
}
te = ten;
}
}
bool outliner_animdata_test(const AnimData *adt)
{
if (adt) {
return (adt->action || adt->drivers.first || adt->nla_tracks.first);
}
return false;
}

View File

@ -0,0 +1,28 @@
/*
* 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
*/
#pragma once
struct ListBase;
const char *outliner_idcode_to_plural(short idcode);
void outliner_make_object_parent_hierarchy(ListBase *lb);
bool outliner_animdata_test(const struct AnimData *adt);

View File

@ -19,16 +19,20 @@
*/
#include "DNA_listBase.h"
#include "DNA_space_types.h"
#include "tree_display.hh"
using namespace blender::ed::outliner;
TreeDisplay *outliner_tree_display_create(eSpaceOutliner_Mode mode, SpaceOutliner *space_outliner)
namespace blender::ed::outliner {
AbstractTreeDisplay *outliner_tree_display_create(int /*eSpaceOutliner_Mode*/ mode,
SpaceOutliner *space_outliner)
{
AbstractTreeDisplay *tree_display = nullptr;
switch (mode) {
switch ((eSpaceOutliner_Mode)mode) {
case SO_SCENES:
tree_display = new TreeDisplayScenes(*space_outliner);
break;
@ -48,28 +52,25 @@ TreeDisplay *outliner_tree_display_create(eSpaceOutliner_Mode mode, SpaceOutline
tree_display = new TreeDisplayOverrideLibrary(*space_outliner);
break;
case SO_VIEW_LAYER:
/* FIXME(Julian): this should not be the default! Return nullptr and handle that as valid
* case. */
default:
tree_display = new TreeDisplayViewLayer(*space_outliner);
break;
}
return reinterpret_cast<TreeDisplay *>(tree_display);
return tree_display;
}
void outliner_tree_display_destroy(TreeDisplay **tree_display)
void outliner_tree_display_destroy(AbstractTreeDisplay **tree_display)
{
delete reinterpret_cast<AbstractTreeDisplay *>(*tree_display);
delete *tree_display;
*tree_display = nullptr;
}
ListBase outliner_tree_display_build_tree(TreeDisplay *tree_display, TreeSourceData *source_data)
bool AbstractTreeDisplay::hasWarnings() const
{
return reinterpret_cast<AbstractTreeDisplay *>(tree_display)->buildTree(*source_data);
return has_warnings;
}
bool outliner_tree_display_warnings_poll(const TreeDisplay *tree_display)
{
const AbstractTreeDisplay *abstract_tree_display = reinterpret_cast<const AbstractTreeDisplay *>(
tree_display);
return abstract_tree_display->has_warnings;
}
} // namespace blender::ed::outliner

View File

@ -1,87 +0,0 @@
/*
* 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
*
* C-API for the Tree-Display types.
*/
#pragma once
#include "DNA_space_types.h"
struct ListBase;
#ifdef __cplusplus
extern "C" {
#endif
/** C alias for an #AbstractTreeDisplay handle. */
typedef struct TreeDisplay TreeDisplay;
/**
* \brief The data to build the tree from.
*/
typedef struct TreeSourceData {
struct Main *bmain;
struct Scene *scene;
struct ViewLayer *view_layer;
} TreeSourceData;
TreeDisplay *outliner_tree_display_create(eSpaceOutliner_Mode mode, SpaceOutliner *space_outliner);
void outliner_tree_display_destroy(TreeDisplay **tree_display);
ListBase outliner_tree_display_build_tree(TreeDisplay *tree_display, TreeSourceData *source_data);
/** Accessor to whether given tree has some warnings to display. */
bool outliner_tree_display_warnings_poll(const struct TreeDisplay *tree_display);
/** Get actual warning data of a tree element, if any.
*
* \param r_icon The icon to display as warning.
* \param r_message The message to display as warning.
* \return true if there is a warning, false otherwise.
*/
bool outliner_element_warnings_get(struct TreeElement *te, int *r_icon, const char **r_message);
/* The following functions are needed to build the tree. They are calls back into C; the way
* elements are created should be refactored and ported to C++ with a new design/API too. */
/**
* TODO: this function needs to be split up! It's getting a bit too large...
*
* \note "ID" is not always a real ID.
* \note If child items are only added to the tree if the item is open,
* the `TSE_` type _must_ be added to #outliner_element_needs_rebuild_on_open_change().
*/
struct TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
ListBase *lb,
void *idv,
struct TreeElement *parent,
short type,
short index);
/* make sure elements are correctly nested */
void outliner_make_object_parent_hierarchy(ListBase *lb);
bool outliner_animdata_test(const struct AnimData *adt);
TreeElement *outliner_add_collection_recursive(SpaceOutliner *space_outliner,
struct Collection *collection,
TreeElement *ten);
const char *outliner_idcode_to_plural(short idcode);
#ifdef __cplusplus
}
#endif

View File

@ -34,16 +34,30 @@
#pragma once
#include "tree_display.h"
#include <memory>
struct ID;
struct LayerCollection;
struct ListBase;
struct Library;
struct Main;
struct Scene;
struct Sequence;
struct SpaceOutliner;
struct TreeElement;
struct TreeSourceData;
struct ViewLayer;
namespace blender::ed::outliner {
/**
* \brief The data to build the tree from.
*/
struct TreeSourceData {
Main *bmain;
Scene *scene;
ViewLayer *view_layer;
};
/* -------------------------------------------------------------------- */
/* Tree-Display Interface */
@ -65,13 +79,20 @@ class AbstractTreeDisplay {
*/
virtual ListBase buildTree(const TreeSourceData &source_data) = 0;
bool has_warnings = false;
/** Accessor to whether given tree has some warnings to display. */
bool hasWarnings() const;
protected:
bool has_warnings = false;
/** All derived classes will need a handle to this, so storing it in the base for convenience. */
SpaceOutliner &space_outliner_;
};
AbstractTreeDisplay *outliner_tree_display_create(int /*eSpaceOutliner_Mode*/ mode,
SpaceOutliner *space_outliner);
void outliner_tree_display_destroy(AbstractTreeDisplay **tree_display);
/* -------------------------------------------------------------------- */
/* View Layer Tree-Display */

View File

@ -21,10 +21,13 @@
#include "BLI_listbase.h"
#include "BLI_mempool.h"
#include "DNA_space_types.h"
#include "RNA_access.h"
#include "../outliner_intern.hh"
#include "tree_display.hh"
#include "tree_element.hh"
namespace blender::ed::outliner {

View File

@ -25,11 +25,14 @@
#include "BKE_main.h"
#include "DNA_collection_types.h"
#include "DNA_space_types.h"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "common.hh"
#include "tree_display.hh"
#include "tree_element.hh"
namespace blender::ed::outliner {

View File

@ -19,6 +19,7 @@
*/
#include "DNA_ID.h"
#include "DNA_space_types.h"
#include "BLI_listbase.h"
#include "BLI_listbase_wrapper.hh"
@ -27,7 +28,9 @@
#include "BKE_main.h"
#include "../outliner_intern.hh"
#include "common.hh"
#include "tree_display.hh"
#include "tree_element.hh"
namespace blender::ed::outliner {

View File

@ -25,11 +25,14 @@
#include "BKE_main.h"
#include "DNA_collection_types.h"
#include "DNA_space_types.h"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "common.hh"
#include "tree_display.hh"
#include "tree_element.hh"
namespace blender::ed::outliner {

View File

@ -18,6 +18,8 @@
* \ingroup spoutliner
*/
#include "DNA_space_types.h"
#include "BLI_listbase.h"
#include "BLI_listbase_wrapper.hh"
#include "BLI_mempool.h"
@ -25,7 +27,9 @@
#include "BKE_main.h"
#include "../outliner_intern.hh"
#include "common.hh"
#include "tree_display.hh"
#include "tree_element.hh"
namespace blender::ed::outliner {

View File

@ -24,10 +24,14 @@
#include "BLI_listbase_wrapper.hh"
#include "BLI_utildefines.h"
#include "DNA_sequence_types.h"
#include "DNA_space_types.h"
#include "SEQ_sequencer.h"
#include "../outliner_intern.hh"
#include "tree_display.hh"
#include "tree_element.hh"
namespace blender::ed::outliner {

View File

@ -22,6 +22,7 @@
#include "DNA_collection_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "BKE_layer.h"
@ -33,7 +34,9 @@
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "common.hh"
#include "tree_display.hh"
#include "tree_element.hh"
namespace blender::ed::outliner {

View File

@ -20,6 +20,11 @@
#include "DNA_anim_types.h"
#include "DNA_listBase.h"
#include "DNA_space_types.h"
#include "UI_resources.h"
#include "BLT_translation.h"
#include "tree_element_anim_data.hh"
#include "tree_element_collection.hh"
@ -31,12 +36,12 @@
#include "tree_element_scene_objects.hh"
#include "tree_element_view_layer.hh"
#include "tree_element.h"
#include "../outliner_intern.hh"
#include "tree_element.hh"
namespace blender::ed::outliner {
static AbstractTreeElement *tree_element_create(int type, TreeElement &legacy_te, void *idv)
AbstractTreeElement *outliner_tree_element_type_create(int type, TreeElement &legacy_te, void *idv)
{
ID &id = *static_cast<ID *>(idv);
@ -85,14 +90,13 @@ static AbstractTreeElement *tree_element_create(int type, TreeElement &legacy_te
return nullptr;
}
static void tree_element_free(AbstractTreeElement **tree_element)
void outliner_tree_element_type_free(AbstractTreeElement **tree_element)
{
delete *tree_element;
*tree_element = nullptr;
}
static void tree_element_expand(const AbstractTreeElement &tree_element,
SpaceOutliner &space_outliner)
void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner)
{
/* Most types can just expand. IDs optionally expand (hence the poll) and do additional, common
* expanding. Could be done nicer, we could request a small "expander" helper object from the
@ -104,58 +108,39 @@ static void tree_element_expand(const AbstractTreeElement &tree_element,
tree_element.postExpand(space_outliner);
}
/**
* Needed for types that still expand in C, but need to execute the same post-expand logic. Can be
* removed once all ID types expand entirely using the new design.
*/
static void tree_element_post_expand_only(const AbstractTreeElement &tree_element,
SpaceOutliner &space_outliner)
bool outliner_element_warnings_get(TreeElement *te, int *r_icon, const char **r_message)
{
tree_element.postExpand(space_outliner);
}
/**
* Needed for types that still expand in C, to poll if they should expand in current context. Can
* be removed once all ID types expand entirely using the new design.
*/
static bool tree_element_expand_poll(const AbstractTreeElement &tree_element,
const SpaceOutliner &space_outliner)
{
return tree_element.expandPoll(space_outliner);
TreeStoreElem *tselem = te->store_elem;
if (tselem->type != TSE_SOME_ID) {
return false;
}
if (te->idcode != ID_LI) {
return false;
}
Library *library = (Library *)tselem->id;
if (library->tag & LIBRARY_TAG_RESYNC_REQUIRED) {
if (r_icon) {
*r_icon = ICON_ERROR;
}
if (r_message) {
*r_message = TIP_(
"Contains linked library overrides that need to be resynced, updating the library is "
"recommended");
}
return true;
}
if (library->id.tag & LIB_TAG_MISSING) {
if (r_icon) {
*r_icon = ICON_ERROR;
}
if (r_message) {
*r_message = TIP_("Missing library");
}
return true;
}
return false;
}
} // namespace blender::ed::outliner
namespace outliner = blender::ed::outliner;
TreeElementType *outliner_tree_element_type_create(int type, TreeElement *legacy_te, void *idv)
{
outliner::AbstractTreeElement *element = outliner::tree_element_create(type, *legacy_te, idv);
return reinterpret_cast<TreeElementType *>(element);
}
void outliner_tree_element_type_expand(TreeElementType *type, SpaceOutliner *space_outliner)
{
outliner::tree_element_expand(reinterpret_cast<outliner::AbstractTreeElement &>(*type),
*space_outliner);
}
bool outliner_tree_element_type_is_expand_valid(TreeElementType *type)
{
outliner::AbstractTreeElement &element = reinterpret_cast<outliner::AbstractTreeElement &>(
*type);
return element.isExpandValid();
}
bool outliner_tree_element_type_expand_poll(TreeElementType *type, SpaceOutliner *space_outliner)
{
return outliner::tree_element_expand_poll(
reinterpret_cast<outliner::AbstractTreeElement &>(*type), *space_outliner);
}
void outliner_tree_element_type_post_expand(TreeElementType *type, SpaceOutliner *space_outliner)
{
outliner::tree_element_post_expand_only(reinterpret_cast<outliner::AbstractTreeElement &>(*type),
*space_outliner);
}
void outliner_tree_element_type_free(TreeElementType **type)
{
outliner::tree_element_free(reinterpret_cast<outliner::AbstractTreeElement **>(type));
}

View File

@ -1,48 +0,0 @@
/*
* 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
*
* C-API for the Tree-Element types.
* This API shouldn't stay for long. All tree building should eventually be done through C++ types,
* with more type safety and an easier to reason about design.
*/
#pragma once
#include "DNA_space_types.h"
struct TreeElement;
#ifdef __cplusplus
extern "C" {
#endif
/** C alias for an #AbstractTreeElement handle. */
typedef struct TreeElementType TreeElementType;
TreeElementType *outliner_tree_element_type_create(int type, TreeElement *legacy_te, void *idv);
void outliner_tree_element_type_free(TreeElementType **type);
void outliner_tree_element_type_expand(TreeElementType *type, SpaceOutliner *space_outliner);
bool outliner_tree_element_type_is_expand_valid(TreeElementType *type);
bool outliner_tree_element_type_expand_poll(TreeElementType *type, SpaceOutliner *space_outliner);
void outliner_tree_element_type_post_expand(TreeElementType *type, SpaceOutliner *space_outliner);
#ifdef __cplusplus
}
#endif

View File

@ -20,7 +20,11 @@
#pragma once
#include "tree_element.h"
#include <memory>
struct ListBase;
struct SpaceOutliner;
struct TreeElement;
namespace blender::ed::outliner {
@ -46,12 +50,6 @@ class AbstractTreeElement {
{
return true;
}
/**
* Let the type add its own children.
*/
virtual void expand(SpaceOutliner &) const
{
}
virtual void postExpand(SpaceOutliner &) const
{
}
@ -65,11 +63,49 @@ class AbstractTreeElement {
return true;
}
friend void outliner_tree_element_type_free(AbstractTreeElement **tree_element);
friend void tree_element_expand(const AbstractTreeElement &tree_element,
SpaceOutliner &space_outliner);
protected:
/* Pseudo-abstract: Only allow creation through derived types. */
AbstractTreeElement(TreeElement &legacy_te) : legacy_te_(legacy_te)
{
}
/**
* Let the type add its own children.
*/
virtual void expand(SpaceOutliner &) const
{
}
};
/**
* TODO: this function needs to be split up! It's getting a bit too large...
*
* \note "ID" is not always a real ID.
* \note If child items are only added to the tree if the item is open,
* the `TSE_` type _must_ be added to #outliner_element_needs_rebuild_on_open_change().
*/
struct TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
ListBase *lb,
void *idv,
struct TreeElement *parent,
short type,
short index);
void tree_element_expand(const AbstractTreeElement &tree_element, SpaceOutliner &space_outliner);
AbstractTreeElement *outliner_tree_element_type_create(int type, TreeElement &legacy_te, void *idv);
void outliner_tree_element_type_free(AbstractTreeElement **tree_element);
/**
* Get actual warning data of a tree element, if any.
*
* \param r_icon The icon to display as warning.
* \param r_message The message to display as warning.
* \return true if there is a warning, false otherwise.
*/
bool outliner_element_warnings_get(struct TreeElement *te, int *r_icon, const char **r_message);
} // namespace blender::ed::outliner

View File

@ -22,11 +22,11 @@
#include "DNA_anim_types.h"
#include "DNA_listBase.h"
#include "DNA_outliner_types.h"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "tree_element_anim_data.hh"

View File

@ -19,11 +19,12 @@
*/
#include "DNA_listBase.h"
#include "DNA_outliner_types.h"
#include "DNA_scene_types.h"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "tree_element_collection.hh"

View File

@ -24,11 +24,11 @@
#include "DNA_anim_types.h"
#include "DNA_listBase.h"
#include "DNA_space_types.h"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "tree_element_driver.hh"

View File

@ -21,6 +21,7 @@
#include "BLI_utildefines.h"
#include "DNA_gpencil_types.h"
#include "DNA_space_types.h"
#include "../outliner_intern.hh"

View File

@ -19,6 +19,7 @@
*/
#include "DNA_ID.h"
#include "DNA_space_types.h"
#include "BLI_listbase_wrapper.hh"
#include "BLI_utildefines.h"
@ -30,7 +31,7 @@
#include "RNA_access.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "common.hh"
#include "tree_element_id_library.hh"
#include "tree_element_id_scene.hh"

View File

@ -24,6 +24,9 @@
#include "tree_element.hh"
struct AnimData;
struct ID;
namespace blender::ed::outliner {
class TreeElementID : public AbstractTreeElement {

View File

@ -18,6 +18,7 @@
* \ingroup spoutliner
*/
#include "DNA_ID.h"
#include "DNA_listBase.h"
#include "../outliner_intern.hh"

View File

@ -22,6 +22,8 @@
#include "tree_element_id.hh"
struct Library;
namespace blender::ed::outliner {
class TreeElementIDLibrary final : public TreeElementID {

View File

@ -19,9 +19,10 @@
*/
#include "DNA_listBase.h"
#include "DNA_outliner_types.h"
#include "DNA_scene_types.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "tree_element_id_scene.hh"

View File

@ -22,11 +22,11 @@
#include "DNA_anim_types.h"
#include "DNA_listBase.h"
#include "DNA_space_types.h"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "tree_element_nla.hh"

View File

@ -27,10 +27,11 @@
#include "BLT_translation.h"
#include "DNA_space_types.h"
#include "RNA_access.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "tree_element_overrides.hh"

View File

@ -24,8 +24,10 @@
#include "BLT_translation.h"
#include "DNA_outliner_types.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "common.hh"
#include "tree_element_scene_objects.hh"

View File

@ -22,6 +22,8 @@
#include "tree_element.hh"
struct Scene;
namespace blender::ed::outliner {
class TreeElementSceneObjectsBase final : public AbstractTreeElement {

View File

@ -19,13 +19,14 @@
*/
#include "DNA_layer_types.h"
#include "DNA_scene_types.h"
#include "DNA_space_types.h"
#include "BLI_listbase_wrapper.hh"
#include "BLT_translation.h"
#include "../outliner_intern.hh"
#include "tree_display.h"
#include "tree_element_view_layer.hh"