Outliner: Port view layer elements to new tree-element code design
No user visible changes expected. Part of #96713, continuation of work started in249e4df110and2e221de4ce. Refer to these for a motivation and design overview. Adds a new class for view layer elements. Pull Request: https://projects.blender.org/blender/blender/pulls/110920
This commit is contained in:
committed by
Julian Eisel
parent
d9de0a4725
commit
d5c7608b39
@@ -315,6 +315,11 @@ struct ParticleSystemElementCreateData {
|
|||||||
ParticleSystem *psys;
|
ParticleSystem *psys;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct ViewLayerElementCreateData {
|
||||||
|
Scene *scene;
|
||||||
|
ViewLayer *view_layer;
|
||||||
|
};
|
||||||
|
|
||||||
TreeTraversalAction outliner_collect_selected_collections(TreeElement *te, void *customdata);
|
TreeTraversalAction outliner_collect_selected_collections(TreeElement *te, void *customdata);
|
||||||
TreeTraversalAction outliner_collect_selected_objects(TreeElement *te, void *customdata);
|
TreeTraversalAction outliner_collect_selected_objects(TreeElement *te, void *customdata);
|
||||||
|
|
||||||
|
|||||||
@@ -258,6 +258,9 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
|||||||
else if (type == TSE_LINKED_PSYS) {
|
else if (type == TSE_LINKED_PSYS) {
|
||||||
id = &static_cast<ParticleSystemElementCreateData *>(idv)->object->id;
|
id = &static_cast<ParticleSystemElementCreateData *>(idv)->object->id;
|
||||||
}
|
}
|
||||||
|
else if (type == TSE_R_LAYER) {
|
||||||
|
id = &static_cast<ViewLayerElementCreateData *>(idv)->scene->id;
|
||||||
|
}
|
||||||
|
|
||||||
/* exceptions */
|
/* exceptions */
|
||||||
if (ELEM(type, TSE_ID_BASE, TSE_GENERIC_LABEL)) {
|
if (ELEM(type, TSE_ID_BASE, TSE_GENERIC_LABEL)) {
|
||||||
@@ -325,7 +328,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
|||||||
else if (type == TSE_LINKED_PSYS) {
|
else if (type == TSE_LINKED_PSYS) {
|
||||||
/* pass */
|
/* pass */
|
||||||
}
|
}
|
||||||
else if (ELEM(type, TSE_R_LAYER_BASE)) {
|
else if (ELEM(type, TSE_R_LAYER, TSE_R_LAYER_BASE)) {
|
||||||
/* pass */
|
/* pass */
|
||||||
}
|
}
|
||||||
else if (type == TSE_SOME_ID) {
|
else if (type == TSE_SOME_ID) {
|
||||||
@@ -383,6 +386,7 @@ TreeElement *outliner_add_element(SpaceOutliner *space_outliner,
|
|||||||
TSE_DEFGROUP_BASE,
|
TSE_DEFGROUP_BASE,
|
||||||
TSE_GPENCIL_EFFECT,
|
TSE_GPENCIL_EFFECT,
|
||||||
TSE_GPENCIL_EFFECT_BASE,
|
TSE_GPENCIL_EFFECT_BASE,
|
||||||
|
TSE_R_LAYER,
|
||||||
TSE_R_LAYER_BASE))
|
TSE_R_LAYER_BASE))
|
||||||
{
|
{
|
||||||
BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design");
|
BLI_assert_msg(false, "Element type should already use new AbstractTreeElement design");
|
||||||
|
|||||||
@@ -80,6 +80,11 @@ std::unique_ptr<AbstractTreeElement> AbstractTreeElement::createFromType(const i
|
|||||||
return std::make_unique<TreeElementGPencilLayer>(legacy_te, *static_cast<bGPDlayer *>(idv));
|
return std::make_unique<TreeElementGPencilLayer>(legacy_te, *static_cast<bGPDlayer *>(idv));
|
||||||
case TSE_R_LAYER_BASE:
|
case TSE_R_LAYER_BASE:
|
||||||
return std::make_unique<TreeElementViewLayerBase>(legacy_te, *static_cast<Scene *>(idv));
|
return std::make_unique<TreeElementViewLayerBase>(legacy_te, *static_cast<Scene *>(idv));
|
||||||
|
case TSE_R_LAYER: {
|
||||||
|
ViewLayerElementCreateData *view_layer_data = static_cast<ViewLayerElementCreateData *>(idv);
|
||||||
|
return std::make_unique<TreeElementViewLayer>(
|
||||||
|
legacy_te, *view_layer_data->scene, *view_layer_data->view_layer);
|
||||||
|
}
|
||||||
case TSE_SCENE_COLLECTION_BASE:
|
case TSE_SCENE_COLLECTION_BASE:
|
||||||
return std::make_unique<TreeElementCollectionBase>(legacy_te, *static_cast<Scene *>(idv));
|
return std::make_unique<TreeElementCollectionBase>(legacy_te, *static_cast<Scene *>(idv));
|
||||||
case TSE_SCENE_OBJECTS_BASE:
|
case TSE_SCENE_OBJECTS_BASE:
|
||||||
|
|||||||
@@ -30,11 +30,21 @@ TreeElementViewLayerBase::TreeElementViewLayerBase(TreeElement &legacy_te, Scene
|
|||||||
void TreeElementViewLayerBase::expand(SpaceOutliner &space_outliner) const
|
void TreeElementViewLayerBase::expand(SpaceOutliner &space_outliner) const
|
||||||
{
|
{
|
||||||
for (auto *view_layer : ListBaseWrapper<ViewLayer>(scene_.view_layers)) {
|
for (auto *view_layer : ListBaseWrapper<ViewLayer>(scene_.view_layers)) {
|
||||||
TreeElement *tenlay = outliner_add_element(
|
ViewLayerElementCreateData view_layer_data = {&scene_, view_layer};
|
||||||
&space_outliner, &legacy_te_.subtree, &scene_, &legacy_te_, TSE_R_LAYER, 0);
|
|
||||||
tenlay->name = view_layer->name;
|
outliner_add_element(
|
||||||
tenlay->directdata = view_layer;
|
&space_outliner, &legacy_te_.subtree, &view_layer_data, &legacy_te_, TSE_R_LAYER, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TreeElementViewLayer::TreeElementViewLayer(TreeElement &legacy_te,
|
||||||
|
Scene & /* scene */,
|
||||||
|
ViewLayer &view_layer)
|
||||||
|
: AbstractTreeElement(legacy_te), /* scene_(scene), */ view_layer_(view_layer)
|
||||||
|
{
|
||||||
|
BLI_assert(legacy_te.store_elem->type == TSE_R_LAYER);
|
||||||
|
legacy_te.name = view_layer_.name;
|
||||||
|
legacy_te.directdata = &view_layer_;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace blender::ed::outliner
|
} // namespace blender::ed::outliner
|
||||||
|
|||||||
@@ -21,4 +21,13 @@ class TreeElementViewLayerBase final : public AbstractTreeElement {
|
|||||||
void expand(SpaceOutliner &) const override;
|
void expand(SpaceOutliner &) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TreeElementViewLayer final : public AbstractTreeElement {
|
||||||
|
/* Not needed right now, avoid unused member variable warning. */
|
||||||
|
// Scene &scene_;
|
||||||
|
ViewLayer &view_layer_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TreeElementViewLayer(TreeElement &legacy_te, Scene &scene, ViewLayer &view_layer);
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace blender::ed::outliner
|
} // namespace blender::ed::outliner
|
||||||
|
|||||||
Reference in New Issue
Block a user