Files
UnrealEngineUWP/Engine/Source/Runtime/UMG/Private/Components/GridPanel.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

106 lines
2.3 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Components/GridPanel.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/Layout/SGridPanel.h"
#include "Components/GridSlot.h"
#define LOCTEXT_NAMESPACE "UMG"
/////////////////////////////////////////////////////
// UGridPanel
UGridPanel::UGridPanel(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bIsVariable = false;
SGridPanel::FArguments Defaults;
Visiblity_DEPRECATED = Visibility = UWidget::ConvertRuntimeToSerializedVisibility(Defaults._Visibility.Get());
}
void UGridPanel::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
MyGridPanel.Reset();
}
UClass* UGridPanel::GetSlotClass() const
{
return UGridSlot::StaticClass();
}
void UGridPanel::OnSlotAdded(UPanelSlot* InSlot)
{
// Add the child to the live canvas if it already exists
if ( MyGridPanel.IsValid() )
{
CastChecked<UGridSlot>(InSlot)->BuildSlot(MyGridPanel.ToSharedRef());
}
}
void UGridPanel::OnSlotRemoved(UPanelSlot* InSlot)
{
// Remove the widget from the live slot if it exists.
if ( MyGridPanel.IsValid() )
{
TSharedPtr<SWidget> Widget = InSlot->Content->GetCachedWidget();
if ( Widget.IsValid() )
{
MyGridPanel->RemoveSlot(Widget.ToSharedRef());
}
}
}
TSharedRef<SWidget> UGridPanel::RebuildWidget()
{
MyGridPanel = SNew(SGridPanel);
for ( UPanelSlot* PanelSlot : Slots )
{
if ( UGridSlot* TypedSlot = Cast<UGridSlot>(PanelSlot) )
{
TypedSlot->Parent = this;
TypedSlot->BuildSlot( MyGridPanel.ToSharedRef() );
}
}
return BuildDesignTimeWidget( MyGridPanel.ToSharedRef() );
}
UGridSlot* UGridPanel::AddChildToGrid(UWidget* Content)
{
return Cast<UGridSlot>(Super::AddChild(Content));
}
void UGridPanel::SynchronizeProperties()
{
Super::SynchronizeProperties();
MyGridPanel->ClearFill();
for ( int ColumnIndex = 0; ColumnIndex < ColumnFill.Num(); ColumnIndex++ )
{
MyGridPanel->SetColumnFill(ColumnIndex, ColumnFill[ColumnIndex]);
}
for ( int RowIndex = 0; RowIndex < RowFill.Num(); RowIndex++ )
{
MyGridPanel->SetRowFill(RowIndex, RowFill[RowIndex]);
}
}
#if WITH_EDITOR
const FText UGridPanel::GetPaletteCategory()
{
return LOCTEXT("Panel", "Panel");
}
#endif
/////////////////////////////////////////////////////
#undef LOCTEXT_NAMESPACE