#pragma once #include "PanelWidget.hpp" #include "CanvasPanelSlot.hpp" namespace PalUIExtension::Api { // UCanvasPanel adds exactly one function of its own. Everything else // it offers comes from UPanelWidget and UWidget, which is now inherited // rather than re-declared. class CanvasPanel : public PanelWidget { public: static auto ClassPath() -> const TCHAR* { return STR("/Script/UMG.CanvasPanel"); } static auto DebugTag() -> const TCHAR* { return STR("Canvas"); } CanvasPanel() = default; explicit CanvasPanel(UObject* Obj) : PanelWidget(Obj, ClassOf(), DebugTag()) {} // Returns an invalid CanvasPanelSlot if the call failed or the // engine handed back null. Check it before using it -- the wrapper // will refuse to dispatch and log, but silently doing nothing is // not what you want out of a layout call. auto AddChildToCanvas(UObject* Content) -> CanvasPanelSlot { struct P { UObject* Content; UObject* ReturnValue; } p{ Content, nullptr }; auto Result = CallForReturn(STR("AddChildToCanvas"), p, &P::ReturnValue); return (Result && *Result) ? CanvasPanelSlot{ *Result } : CanvasPanelSlot{}; } }; }