3#include "../../UI/Components/CHLayout.hpp"
4#include "../../UI/Components/CVLayout.hpp"
5#include "IXUIElementWithChilds.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 _XUIHOrVLayout(std::u16string_view p_Name, IXUIElement::ETypeID p_TypeID,
const std::vector<std::shared_ptr<IXUIElement>>& p_Childs)
45 _XUIHOrVLayout(std::u16string_view p_Name, IXUIElement::ETypeID p_TypeID,
const std::vector<std::shared_ptr<IXUIElement>>& p_Childs) {
…}
54 virtual void BuildUI(_u::Transform* p_Parent)
override
56 if constexpr (std::is_same_v<t_Component, _v::CHLayout>)
61 m_Element->SetSpacing(2.0f);
62 m_Element->SetPadding(_u::RectOffset::New_ctor(2, 2, 2, 2));
66 try { m_OnReady(m_Element.Ptr()); m_OnReady.Clear(); }
67 catch (
const std::exception& l_Exception)
69 if constexpr (std::is_same_v<t_Component, _v::CHLayout>)
70 ChatPlexSDK::Logger()->Error(u
"[CP_SDK.XUI][_XUIHOrVLayout<CHLayout>.BuildUI] Error OnReady:");
72 ChatPlexSDK::Logger()->Error(u
"[CP_SDK.XUI][_XUIHOrVLayout<CVLayout}>.BuildUI] Error OnReady:");
54 virtual void BuildUI(_u::Transform* p_Parent)
override {
…}
82 if (m_Element) p_Functor(m_Element.Ptr());
83 else m_OnReady += p_Functor;
84 return reinterpret_cast<t_Base*
>(
this);
88 virtual t_Base*
Bind(std::shared_ptr<t_Base>* p_Target)
override
90 *p_Target = std::enable_shared_from_this<t_Base>::shared_from_this();
91 return reinterpret_cast<t_Base*
>(
this);
88 virtual t_Base*
Bind(std::shared_ptr<t_Base>* p_Target)
override {
…}
97 t_Base*
SetActive(
bool p_Active) XUI_PROXY_IMPL_EX(t_Component, { x->get_gameObject()->
SetActive(p_Active); })
104 t_Base*
SetBackground(bool p_Enabled, std::optional<_u::Color> p_Color = std::nullopt, bool p_RaycastTarget = false) XUI_PROXY_IMPL_EX(t_Component, { x->SetBackground(p_Enabled, p_Color, p_RaycastTarget); })
107 t_Base*
SetBackgroundColor(
float p_Color) XUI_PROXY_IMPL_EX(t_Component, { x->SetBackgroundColor(p_Color); })
111 t_Base*
SetBackgroundFillMethod(_u::Image::FillMethod p_FillMethod) XUI_PROXY_IMPL_EX(t_Component, { x->SetBackgroundFillMethod(p_FillMethod); })
114 t_Base*
SetBackgroundFillAmount(
float p_FillAmount) XUI_PROXY_IMPL_EX(t_Component, { x->SetBackgroundFillAmount(p_FillAmount); })
118 t_Base*
SetBackgroundSprite(_u::Sprite* p_Sprite, _u::Image::Type p_Type = _u::Image::Type::Simple) XUI_PROXY_IMPL_EX(t_Component, { x->SetBackgroundSprite(p_Sprite, p_Type); })
123 t_Base*
SetWidth(float p_Width) XUI_PROXY_IMPL_EX(t_Component, { x->SetWidth(p_Width); })
126 t_Base*
SetHeight(
float p_Height) XUI_PROXY_IMPL_EX(t_Component, { x->SetHeight(p_Height); })
131 t_Base*
SetMinWidth(float p_Width) XUI_PROXY_IMPL_EX(t_Component, { x->SetMinWidth(p_Width); })
134 t_Base*
SetMinHeight(
float p_Height) XUI_PROXY_IMPL_EX(t_Component, { x->SetMinHeight(p_Height); })
139 t_Base*
SetPadding(_u::RectOffset* p_Padding) XUI_PROXY_IMPL_EX(t_Component, { x->SetPadding(p_Padding); })
145 t_Base*
SetPadding(
int p_Top,
int p_Right,
int p_Bottom,
int p_Left) XUI_PROXY_IMPL_EX(t_Component, { x->SetPadding(p_Top, p_Right, p_Bottom, p_Left); })
148 t_Base*
SetPadding(
int p_Padding) XUI_PROXY_IMPL_EX(t_Component, { x->SetPadding(p_Padding); })
153 t_Base*
SetSpacing(float p_Spacing) XUI_PROXY_IMPL_EX(t_Component, { x->SetSpacing(p_Spacing); })
static Logging::ILogger * Logger()
Logger instance.
CHOrVLayout abstract XUI Element.
t_Base t_Base t_Base t_Base * SetBackgroundFillAmount(float p_FillAmount) XUI_PROXY_IMPL_EX(t_Component
Set background fill amount.
t_Base * SetSpacing(float p_Spacing) XUI_PROXY_IMPL_EX(t_Component
Set spacing between elements.
virtual t_Base * OnReady(_v::CActionRef< t_Component * > p_Functor) override
IXUIElement OnReady functor interface.
virtual t_Base * Bind(std::shared_ptr< t_Base > *p_Target) override
On ready, bind.
virtual ~_XUIHOrVLayout()=default
Destructor.
t_Base * SetActive(bool p_Active) XUI_PROXY_IMPL_EX(t_Component
Set game object active state.
t_Base t_Base t_Base * SetPadding(int p_Padding) XUI_PROXY_IMPL_EX(t_Component
Set padding.
t_Base t_Base * SetPadding(int p_Top, int p_Right, int p_Bottom, int p_Left) XUI_PROXY_IMPL_EX(t_Component
Set padding.
_XUIHOrVLayout(std::u16string_view p_Name, IXUIElement::ETypeID p_TypeID, const std::vector< std::shared_ptr< IXUIElement > > &p_Childs)
Constructor.
t_Base t_Base * SetBackgroundColor(float p_Color) XUI_PROXY_IMPL_EX(t_Component
Set background color.
t_Base * SetPadding(_u::RectOffset *p_Padding) XUI_PROXY_IMPL_EX(t_Component
Set padding.
t_Base t_Base * SetMinHeight(float p_Height) XUI_PROXY_IMPL_EX(t_Component
Set min height.
t_Base t_Base t_Base * SetBackgroundFillMethod(_u::Image::FillMethod p_FillMethod) XUI_PROXY_IMPL_EX(t_Component
Set background fill method.
t_Base t_Base * SetHeight(float p_Height) XUI_PROXY_IMPL_EX(t_Component
Set preferred height.
t_Base t_Base t_Base t_Base t_Base * SetBackgroundSprite(_u::Sprite *p_Sprite, _u::Image::Type p_Type=_u::Image::Type::Simple) XUI_PROXY_IMPL_EX(t_Component
Set background sprite.
virtual void BuildUI(_u::Transform *p_Parent) override
BuildUI for this element into p_Parent transform.
t_Base * SetWidth(float p_Width) XUI_PROXY_IMPL_EX(t_Component
Set preferred width.
t_Base * SetMinWidth(float p_Width) XUI_PROXY_IMPL_EX(t_Component
Set min width.
t_Base * SetBackground(bool p_Enabled, std::optional< _u::Color > p_Color=std::nullopt, bool p_RaycastTarget=false) XUI_PROXY_IMPL_EX(t_Component
IXUIElement Bind interface.
std::u16string_view GetInitialName()
Get initial name.
IXUIElement OnReady functor interface.
IXUIElement with children abstract class.
void BuildUIChilds(_u::Transform *p_Parent)
BuildUI for children into p_Parent transform.
Tree like syntax CP_SDK::UI builder.