initial commit; cv 0.0.3
This commit is contained in:
68
Api/TextLayoutWidget.hpp
Normal file
68
Api/TextLayoutWidget.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#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<TextLayoutWidget>(), DebugTag()) {}
|
||||
|
||||
auto SetJustification(ETextJustify_ InJustification) -> bool
|
||||
{
|
||||
struct P { ETextJustify_ InJustification; } p{ InJustification };
|
||||
return Call(STR("SetJustification"), p);
|
||||
}
|
||||
|
||||
// ---- property reads -------------------------------------------------
|
||||
auto GetJustification() const -> std::optional<ETextJustify_> { return PropertyValue<ETextJustify_>(STR("Justification")); }
|
||||
auto GetWrappingPolicy() const -> std::optional<ETextWrappingPolicy_>{ return PropertyValue<ETextWrappingPolicy_>(STR("WrappingPolicy")); }
|
||||
auto GetWrapTextAt() const -> std::optional<float> { return PropertyValue<float>(STR("WrapTextAt")); }
|
||||
auto GetLineHeightPercentage()const -> std::optional<float> { return PropertyValue<float>(STR("LineHeightPercentage")); }
|
||||
auto GetMargin() const -> std::optional<FMargin_> { return PropertyValue<FMargin_>(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<float>(STR("WrapTextAt"))) { *P = Value; return true; }
|
||||
return false;
|
||||
}
|
||||
auto SetLineHeightPercentage(float Value) -> bool
|
||||
{
|
||||
if (float* P = PropertyPtr<float>(STR("LineHeightPercentage"))) { *P = Value; return true; }
|
||||
return false;
|
||||
}
|
||||
auto SetMargin(FMargin_ Value) -> bool
|
||||
{
|
||||
if (FMargin_* P = PropertyPtr<FMargin_>(STR("Margin"))) { *P = Value; return true; }
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
TextLayoutWidget(UObject* Obj, UClass* Expected, const TCHAR* Tag)
|
||||
: Widget(Obj, Expected, Tag) {}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user