Plasma Engine  2.0
Loading...
Searching...
No Matches
RmlUiCanvas2DComponent.h
1#pragma once
2
3#include <Core/ResourceManager/ResourceHandle.h>
4#include <RendererCore/Components/RenderComponent.h>
5#include <RmlUiPlugin/Components/RmlUiMessages.h>
6
10class plBlackboard;
11
13
15
16class PL_RMLUIPLUGIN_DLL plRmlUiCanvas2DComponent : public plRenderComponent
17{
19
20public:
23
25
26 virtual void Initialize() override;
27 virtual void Deinitialize() override;
28
29 virtual void OnActivated() override;
30 virtual void OnDeactivated() override;
31
32 void Update();
33
34 void SetRmlFile(const char* szFile); // [ property ]
35 const char* GetRmlFile() const; // [ property ]
36
37 void SetRmlResource(const plRmlUiResourceHandle& hResource);
38 const plRmlUiResourceHandle& GetRmlResource() const { return m_hResource; }
39
40 void SetOffset(const plVec2I32& vOffset); // [ property ]
41 const plVec2I32& GetOffset() const { return m_vOffset; } // [ property ]
42
43 void SetSize(const plVec2U32& vSize); // [ property ]
44 const plVec2U32& GetSize() const { return m_vSize; } // [ property ]
45
46 void SetAnchorPoint(const plVec2& vAnchorPoint); // [ property ]
47 const plVec2& GetAnchorPoint() const { return m_vAnchorPoint; } // [ property ]
48
49 void SetPassInput(bool bPassInput); // [ property ]
50 bool GetPassInput() const { return m_bPassInput; } // [ property ]
51
53 void SetAutobindBlackboards(bool bAutobind); // [ property ]
54 bool GetAutobindBlackboards() const { return m_bAutobindBlackboards; } // [ property ]
55
56 plUInt32 AddDataBinding(plUniquePtr<plRmlUiDataBinding>&& pDataBinding);
57 void RemoveDataBinding(plUInt32 uiDataBindingIndex);
58
60 plUInt32 AddBlackboardBinding(const plSharedPtr<plBlackboard>& pBlackboard);
61 void RemoveBlackboardBinding(plUInt32 uiDataBindingIndex);
62
63 plRmlUiContext* GetOrCreateRmlContext();
64 plRmlUiContext* GetRmlContext() { return m_pContext; }
65
66 virtual void SerializeComponent(plWorldWriter& inout_stream) const override;
67 virtual void DeserializeComponent(plWorldReader& inout_stream) override;
68
69 virtual plResult GetLocalBounds(plBoundingBoxSphere& ref_bounds, bool& ref_bAlwaysVisible, plMsgUpdateLocalBounds& ref_msg) override;
70
71protected:
72 void OnMsgExtractRenderData(plMsgExtractRenderData& msg) const;
73 void OnMsgReload(plMsgRmlUiReload& msg);
74 void UpdateCachedValues();
75 void UpdateAutobinding();
76
77 plRmlUiResourceHandle m_hResource;
78 plEvent<const plResourceEvent&, plMutex>::Unsubscriber m_ResourceEventUnsubscriber;
79
80 plVec2I32 m_vOffset = plVec2I32::MakeZero();
82 plVec2 m_vAnchorPoint = plVec2::MakeZero();
83 plVec2U32 m_vReferenceResolution = plVec2U32::MakeZero();
84 bool m_bPassInput = true;
85 bool m_bAutobindBlackboards = true;
86
87 plRmlUiContext* m_pContext = nullptr;
88
90 plDynamicArray<plUInt32> m_AutoBindings;
91};
A blackboard is a key/value store that provides OnChange events to be informed when a value changes.
Definition Blackboard.h:66
virtual void SerializeComponent(plWorldWriter &inout_stream) const
Override this to save the current state of the component to the given stream.
Definition Component.cpp:54
virtual void DeserializeComponent(plWorldReader &inout_stream)
Override this to load the current state of the component from the given stream.
Definition Component.cpp:58
virtual void Initialize()
Can be overridden for basic initialization that depends on a valid hierarchy and position.
Definition Component.cpp:131
Simple component manager implementation that calls an update method on all components every frame.
Definition ComponentManager.h:142
Definition DynamicArray.h:81
Base class for objects that should be rendered.
Definition RenderComponent.h:9
virtual void OnActivated() override
This method is called when the component gets activated.
Definition RenderComponent.cpp:33
virtual void OnDeactivated() override
This method is called when the component gets deactivated.
Definition RenderComponent.cpp:38
virtual plResult GetLocalBounds(plBoundingBoxSphere &ref_bounds, bool &ref_bAlwaysVisible, plMsgUpdateLocalBounds &ref_msg)=0
Called by plRenderComponent::OnUpdateLocalBounds(). If PL_SUCCESS is returned, bounds and bAlwaysVisi...
virtual void Deinitialize() override
This method is called before the component is destroyed. A derived type can override this method to d...
Definition RenderComponent.cpp:26
Definition RmlUiCanvas2DComponent.h:17
Definition RmlUiContext.h:19
Definition RmlUiDataBinding.h:8
A Shared ptr manages a shared object and destroys that object when no one references it anymore....
Definition SharedPtr.h:10
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
static constexpr plVec2Template< plInt32 > MakeZero()
Definition Vec2.h:49
Reads a world description from a stream. Allows to instantiate that world multiple times in different...
Definition WorldReader.h:47
Stores an entire plWorld in a stream.
Definition WorldWriter.h:13
Definition RenderData.h:116
Definition RmlUiMessages.h:7
Definition UpdateLocalBoundsMessage.h:9
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54