3#include "../../UI/Components/CHLayout.hpp"
4#include "../../UI/Components/CVLayout.hpp"
5#include "IXUIElement.hpp"
6#include "IXUIBindable.hpp"
7#include "IXUIElementReady.hpp"
14 template<
class t_Base,
class t_Component>
19 public std::enable_shared_from_this<t_Base>
29 std::shared_ptr<t_Base> AsShared() {
return std::enable_shared_from_this<t_Base>::shared_from_this(); }
45 _XUIHOrVSpacer(std::u16string_view p_Name, IXUIElement::ETypeID p_TypeID,
float p_Spacing)
56 virtual void BuildUI(_u::Transform* p_Parent)
override
58 if constexpr (std::is_same_v<t_Component, _v::CHLayout>)
63 try { m_OnReady(m_Element.Ptr()); m_OnReady.Clear(); }
64 catch (
const std::exception& l_Exception)
66 ChatPlexSDK::Logger()->Error(u
"[CP_SDK.XUI][_XUIHOrVSpacer<{typeof(t_Component).Name}>.BuildUI] Error OnReady:");
76 if (m_Element) p_Functor(m_Element.Ptr());
77 else m_OnReady += p_Functor;
78 return reinterpret_cast<t_Base*
>(
this);
82 virtual t_Base*
Bind(std::shared_ptr<t_Base>* p_Target)
override
84 *p_Target = std::enable_shared_from_this<t_Base>::shared_from_this();
85 return reinterpret_cast<t_Base*
>(
this);
91 t_Base*
SetActive(
bool p_Active) XUI_PROXY_IMPL_EX(t_Component, { x->get_gameObject()->
SetActive(p_Active); })
96 t_Base*
SetSpacing(float p_Spacing) XUI_PROXY_IMPL_EX(t_Component, {
97 if constexpr (std::is_same_v<t_Component, _v::CHLayout>)
98 { x->SetMinWidth(p_Spacing); x->SetWidth(p_Spacing); }
100 { x->SetMinHeight(p_Spacing); x->SetHeight(p_Spacing); }
static Logging::ILogger * Logger()
Logger instance.
IHOrVLayout abstract XUI Element.
virtual ~_XUIHOrVSpacer()=default
Destructor.
virtual void BuildUI(_u::Transform *p_Parent) override
BuildUI for this element into p_Parent transform.
virtual t_Base * Bind(std::shared_ptr< t_Base > *p_Target) override
On ready, bind.
_XUIHOrVSpacer(std::u16string_view p_Name, IXUIElement::ETypeID p_TypeID, float p_Spacing)
Constructor.
t_Base * SetActive(bool p_Active) XUI_PROXY_IMPL_EX(t_Component
Set game object active state.
virtual t_Base * OnReady(_v::CActionRef< t_Component * > p_Functor) override
IXUIElement OnReady functor interface.
t_Base * SetSpacing(float p_Spacing) XUI_PROXY_IMPL_EX(t_Component
Set spacing between elements.
IXUIElement Bind interface.
std::u16string_view GetInitialName()
Get initial name.
IXUIElement OnReady functor interface.
Tree like syntax CP_SDK::UI builder.