#pragma once #include "Widget.hpp" namespace PalUIExtension::Api { // ------------------------------------------------------------------ // UTextLayoutWidget. One UFUNCTION (SetJustification) and a handful of // protected UPROPERTYs. // // "protected" is a C++ access specifier. It is invisible to reflection: // the properties are in the class's FProperty chain either way, and // PropertyPtr reaches them fine. Do not read protected as unreachable. // // AutoWrapText is uint8 : 1 and is therefore NOT exposed as a property // read -- see the bitfield note in UnrealWrapper.hpp. UTextBlock has a // SetAutoWrapText UFUNCTION; use that. // ------------------------------------------------------------------ class TextLayoutWidget : public Widget { public: static auto ClassPath() -> const TCHAR* { return STR("/Script/UMG.TextLayoutWidget"); } static auto DebugTag() -> const TCHAR* { return STR("TextLayoutWidget"); } TextLayoutWidget() = default; explicit TextLayoutWidget(UObject* Obj) : Widget(Obj, ClassOf(), DebugTag()) {} auto SetJustification(ETextJustify_ InJustification) -> bool { struct P { ETextJustify_ InJustification; } p{ InJustification }; return Call(STR("SetJustification"), p); } // ---- property reads ------------------------------------------------- auto GetJustification() const -> std::optional { return PropertyValue(STR("Justification")); } auto GetWrappingPolicy() const -> std::optional{ return PropertyValue(STR("WrappingPolicy")); } auto GetWrapTextAt() const -> std::optional { return PropertyValue(STR("WrapTextAt")); } auto GetLineHeightPercentage()const -> std::optional { return PropertyValue(STR("LineHeightPercentage")); } auto GetMargin() const -> std::optional { return PropertyValue(STR("Margin")); } // ---- property writes ------------------------------------------------ // // These have no UFUNCTION setter, so a direct write is the only // option -- and it will NOT reach the Slate widget until something // else triggers SynchronizeProperties. Set them before the widget // is added to a panel, or accept that they take effect late. auto SetWrapTextAt(float Value) -> bool { if (float* P = PropertyPtr(STR("WrapTextAt"))) { *P = Value; return true; } return false; } auto SetLineHeightPercentage(float Value) -> bool { if (float* P = PropertyPtr(STR("LineHeightPercentage"))) { *P = Value; return true; } return false; } auto SetMargin(FMargin_ Value) -> bool { if (FMargin_* P = PropertyPtr(STR("Margin"))) { *P = Value; return true; } return false; } protected: TextLayoutWidget(UObject* Obj, UClass* Expected, const TCHAR* Tag) : Widget(Obj, Expected, Tag) {} }; }