Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
DesignerObject.ipp
Go to the documentation of this file.
1#pragma once
2
5
6#include <Utility/traits.h>
7
8#include <utility>
9
10namespace ph::editor
11{
12
13template<typename ChildType>
14inline ChildType* DesignerObject::newChild(
15 const bool shouldInit,
16 const bool shouldSetToDefault)
17{
18 static_assert(CDerived<ChildType, DesignerObject>,
19 "Child type must be a designer object.");
20
21 if(!canHaveChildren())
22 {
23 return nullptr;
24 }
25
26 ChildType* childObj = newChild(
27 ChildType::getSdlClass(),
28 shouldInit,
29 shouldSetToDefault);
30
31 // We know the exact type
32 return static_cast<ChildType*>(childObj);
33}
34
35inline bool DesignerObject::isSelected() const
36{
37 return getState().has(EObjectState::Selected);
38}
39
40inline bool DesignerObject::isVisible() const
41{
42 return getState().hasNo(EObjectState::Hidden);
43}
44
45inline void DesignerObject::setParentObject(DesignerObject* const object)
46{
47 PH_ASSERT(object != nullptr);
48 PH_ASSERT(object != this);
49
50 // Only root object can have a scene as parent
51 PH_ASSERT(getState().hasNo(EObjectState::Root));
52
53 m_parent.u_object = object;
54}
55
56inline void DesignerObject::setParentScene(DesignerScene* const scene)
57{
58 PH_ASSERT(scene != nullptr);
59
60 // Only root object can have a scene as parent
61 PH_ASSERT(getState().has(EObjectState::Root));
62
63 m_parent.u_scene = scene;
64}
65
66inline const std::string& DesignerObject::getName() const
67{
68 return m_name;
69}
70
72{
73 return getChildren().size() > 0;
74}
75
76}// end namespace ph::editor
const TEnumFlags< EObjectState > & getState() const
Definition AbstractDesignerObject.ipp:10
Definition DesignerObject.h:31
bool isVisible() const
Definition DesignerObject.ipp:40
bool isSelected() const
Definition DesignerObject.ipp:35
ChildType * newChild(bool shouldInit=true, bool shouldSetToDefault=true)
Create and add the new object as a child.
Definition DesignerObject.ipp:14
bool haveChildren() const
Definition DesignerObject.ipp:71
virtual bool canHaveChildren() const =0
const std::string & getName() const
Definition DesignerObject.ipp:66
virtual TSpanView< DesignerObject * > getChildren() const =0
Definition ph_editor.h:10