File size: 2,359 Bytes
b315adb | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | // Copyright Epic Games, Inc. All Rights Reserved.
#include "GameResponsivePanel.h"
#include "GameResponsivePanelSlot.h"
#include "Widgets/Responsive/SGameResponsivePanel.h"
#include UE_INLINE_GENERATED_CPP_BY_NAME(GameResponsivePanel)
#define LOCTEXT_NAMESPACE "GameSetting"
/////////////////////////////////////////////////////
// UGameResponsivePanel
UGameResponsivePanel::UGameResponsivePanel(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bIsVariable = false;
SetVisibility(ESlateVisibility::SelfHitTestInvisible);
}
void UGameResponsivePanel::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
MyGameResponsivePanel.Reset();
}
UClass* UGameResponsivePanel::GetSlotClass() const
{
return UGameResponsivePanelSlot::StaticClass();
}
void UGameResponsivePanel::OnSlotAdded(UPanelSlot* InSlot)
{
// Add the child to the live canvas if it already exists
if ( MyGameResponsivePanel.IsValid() )
{
CastChecked<UGameResponsivePanelSlot>(InSlot)->BuildSlot(MyGameResponsivePanel.ToSharedRef());
}
}
void UGameResponsivePanel::OnSlotRemoved(UPanelSlot* InSlot)
{
// Remove the widget from the live slot if it exists.
if ( MyGameResponsivePanel.IsValid() && InSlot->Content)
{
TSharedPtr<SWidget> Widget = InSlot->Content->GetCachedWidget();
if ( Widget.IsValid() )
{
MyGameResponsivePanel->RemoveSlot(Widget.ToSharedRef());
}
}
}
UGameResponsivePanelSlot* UGameResponsivePanel::AddChildToGameResponsivePanel(UWidget* Content)
{
return Cast<UGameResponsivePanelSlot>( Super::AddChild(Content) );
}
TSharedRef<SWidget> UGameResponsivePanel::RebuildWidget()
{
MyGameResponsivePanel = SNew(SGameResponsivePanel);
MyGameResponsivePanel->EnableVerticalStacking(bCanStackVertically);
for ( UPanelSlot* PanelSlot : Slots )
{
if ( UGameResponsivePanelSlot* TypedSlot = Cast<UGameResponsivePanelSlot>(PanelSlot) )
{
TypedSlot->Parent = this;
TypedSlot->BuildSlot(MyGameResponsivePanel.ToSharedRef());
}
}
return MyGameResponsivePanel.ToSharedRef();
}
#if WITH_EDITOR
const FText UGameResponsivePanel::GetPaletteCategory()
{
return LOCTEXT("Panel", "Panel");
}
#endif
/////////////////////////////////////////////////////
#undef LOCTEXT_NAMESPACE
|