Files
UnrealEngineUWP/Engine/Source/Runtime/UMG/Private/Components/UniformGridPanel.cpp
Ben Marsh 20bf0eb6a1 Updating copyright notices to 2017 (copying from //Tasks/UE4/Dev-Copyright-2017).
#rb none
#lockdown Nick.Penwarden

[CL 3226823 by Ben Marsh in Main branch]
2016-12-08 08:52:44 -05:00

125 lines
3.1 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Components/UniformGridPanel.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/Layout/SUniformGridPanel.h"
#include "Components/UniformGridSlot.h"
#define LOCTEXT_NAMESPACE "UMG"
/////////////////////////////////////////////////////
// UUniformGridPanel
UUniformGridPanel::UUniformGridPanel(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bIsVariable = false;
SUniformGridPanel::FArguments Defaults;
Visiblity_DEPRECATED = Visibility = UWidget::ConvertRuntimeToSerializedVisibility(Defaults._Visibility.Get());
}
void UUniformGridPanel::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
MyUniformGridPanel.Reset();
}
UClass* UUniformGridPanel::GetSlotClass() const
{
return UUniformGridSlot::StaticClass();
}
void UUniformGridPanel::OnSlotAdded(UPanelSlot* InSlot)
{
// Add the child to the live canvas if it already exists
if ( MyUniformGridPanel.IsValid() )
{
CastChecked<UUniformGridSlot>(InSlot)->BuildSlot(MyUniformGridPanel.ToSharedRef());
}
}
void UUniformGridPanel::OnSlotRemoved(UPanelSlot* InSlot)
{
// Remove the widget from the live slot if it exists.
if ( MyUniformGridPanel.IsValid() )
{
TSharedPtr<SWidget> Widget = InSlot->Content->GetCachedWidget();
if ( Widget.IsValid() )
{
MyUniformGridPanel->RemoveSlot(Widget.ToSharedRef());
}
}
}
TSharedRef<SWidget> UUniformGridPanel::RebuildWidget()
{
MyUniformGridPanel = SNew(SUniformGridPanel);
for ( UPanelSlot* PanelSlot : Slots )
{
if ( UUniformGridSlot* TypedSlot = Cast<UUniformGridSlot>(PanelSlot) )
{
TypedSlot->Parent = this;
TypedSlot->BuildSlot(MyUniformGridPanel.ToSharedRef());
}
}
return BuildDesignTimeWidget( MyUniformGridPanel.ToSharedRef() );
}
UUniformGridSlot* UUniformGridPanel::AddChildToUniformGrid(UWidget* Content)
{
return Cast<UUniformGridSlot>(Super::AddChild(Content));
}
void UUniformGridPanel::SetSlotPadding(FMargin InSlotPadding)
{
SlotPadding = InSlotPadding;
if ( MyUniformGridPanel.IsValid() )
{
MyUniformGridPanel->SetSlotPadding(InSlotPadding);
}
}
void UUniformGridPanel::SetMinDesiredSlotWidth(float InMinDesiredSlotWidth)
{
MinDesiredSlotWidth = InMinDesiredSlotWidth;
if ( MyUniformGridPanel.IsValid() )
{
MyUniformGridPanel->SetMinDesiredSlotWidth(InMinDesiredSlotWidth);
}
}
void UUniformGridPanel::SetMinDesiredSlotHeight(float InMinDesiredSlotHeight)
{
MinDesiredSlotHeight = InMinDesiredSlotHeight;
if ( MyUniformGridPanel.IsValid() )
{
MyUniformGridPanel->SetMinDesiredSlotHeight(InMinDesiredSlotHeight);
}
}
void UUniformGridPanel::SynchronizeProperties()
{
Super::SynchronizeProperties();
MyUniformGridPanel->SetSlotPadding(SlotPadding);
MyUniformGridPanel->SetMinDesiredSlotWidth(MinDesiredSlotWidth);
MyUniformGridPanel->SetMinDesiredSlotHeight(MinDesiredSlotHeight);
}
#if WITH_EDITOR
const FText UUniformGridPanel::GetPaletteCategory()
{
return LOCTEXT("Panel", "Panel");
}
#endif
/////////////////////////////////////////////////////
#undef LOCTEXT_NAMESPACE