Lagrange
treenode.h
1/*
2 * Copyright 2021 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12#pragma once
13
14#include <lagrange/ui/api.h>
15#include <lagrange/ui/Entity.h>
16#include <lagrange/ui/components/TreeNode.h>
17
18#include <functional>
19
20namespace lagrange {
21namespace ui {
22
23
24LA_UI_API Entity create_scene_node(
25 Registry& r,
26 const std::string& name = "Unnamed Scene Node Entity",
27 Entity parent = NullEntity);
28
29
34LA_UI_API void remove(Registry& r, Entity e, bool recursive = false);
35
40LA_UI_API void set_parent(Registry& registry, Entity child, Entity new_parent);
41
47LA_UI_API Entity get_parent(const Registry& registry, Entity e);
48
54LA_UI_API std::vector<Entity> get_children(const Registry& registry, Entity e);
55
59LA_UI_API bool is_orphan(const Registry& registry, Entity child);
60
64LA_UI_API void orphan(Registry& registry, Entity child);
65
70LA_UI_API void foreach_child(
71 const Registry& registry,
72 const Entity parent,
73 const std::function<void(Entity)>& fn);
74
79LA_UI_API void foreach_child_recursive(
80 const Registry& registry,
81 const Entity parent,
82 const std::function<void(Entity)>& fn);
83
85LA_UI_API void iterate_inorder(
86 Registry& registry,
87 const std::function<bool(Entity)>& on_enter,
88 const std::function<void(Entity, bool)>& on_exit);
89
90LA_UI_API Entity group(
91 Registry& registry,
92 const std::vector<Entity>& entities,
93 const std::string& name = "NewGroup");
94
95LA_UI_API Entity group_under(Registry& registry, const std::vector<Entity>& entities, Entity parent);
96
97
99LA_UI_API Entity ungroup(Registry& registry, Entity parent, bool remove_parent = false);
100
102LA_UI_API void orphan_without_subtree(Registry& registry, Entity e);
103
104
105} // namespace ui
106} // namespace lagrange
Lagrange UI Viewer and mini 3D engine.
Definition: AcceleratedPicking.h:22
LA_UI_API void iterate_inorder(Registry &registry, const std::function< bool(Entity)> &on_enter, const std::function< void(Entity, bool)> &on_exit)
Alternative to foreach_child_recursive.
Definition: treenode.cpp:209
LA_UI_API void set_parent(Registry &registry, Entity child, Entity new_parent)
Sets new_parent as as child's new parent.
Definition: treenode.cpp:155
LA_UI_API void orphan(Registry &registry, Entity child)
Reparents child to be top-level (i.e., to have to parents).
Definition: treenode.cpp:119
LA_UI_API std::vector< Entity > get_children(const Registry &registry, Entity e)
Returns all children of e.
Definition: treenode.cpp:243
LA_UI_API void foreach_child_recursive(const Registry &registry, const Entity parent, const std::function< void(Entity)> &fn)
Calls fn(Entity) on each child of parent entity recursively.
Definition: treenode.cpp:85
LA_UI_API Entity ungroup(Registry &registry, Entity parent, bool remove_parent=false)
Returns new parent.
Definition: treenode.cpp:251
LA_UI_API void orphan_without_subtree(Registry &registry, Entity e)
Removes the node from tree and puts it as top-level node.
Definition: treenode.cpp:267
LA_UI_API void remove(Registry &r, Entity e, bool recursive=false)
Removes entity.
Definition: treenode.cpp:47
LA_UI_API void foreach_child(const Registry &registry, const Entity parent, const std::function< void(Entity)> &fn)
Calls fn(Entity) on each direct child of parent entity.
Definition: treenode.cpp:61
LA_UI_API bool is_orphan(const Registry &registry, Entity child)
Returns true if child has no parents (is at top-level in the hierarachy)
Definition: treenode.cpp:114
LA_UI_API Entity get_parent(const Registry &registry, Entity e)
Returns parent of e.
Definition: treenode.cpp:237
Main namespace for Lagrange.
Definition: AABBIGL.h:30