Files
UnrealEngineUWP/Engine/Source/Runtime/UMG/Private/Components/BorderSlot.cpp
ryan durand 0f0464a30e Updating copyright for Engine Runtime.
#rnx
#rb none


#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870549 by ryan durand in Main branch]
2019-12-26 14:45:42 -05:00

106 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Components/BorderSlot.h"
#include "Widgets/SNullWidget.h"
#include "Widgets/Layout/SBorder.h"
#include "Components/Border.h"
#include "ObjectEditorUtils.h"
/////////////////////////////////////////////////////
// UBorderSlot
UBorderSlot::UBorderSlot(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
Padding = FMargin(4, 2);
HorizontalAlignment = HAlign_Fill;
VerticalAlignment = VAlign_Fill;
}
void UBorderSlot::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
Border.Reset();
}
void UBorderSlot::BuildSlot(TSharedRef<SBorder> InBorder)
{
Border = InBorder;
Border.Pin()->SetPadding(Padding);
Border.Pin()->SetHAlign(HorizontalAlignment);
Border.Pin()->SetVAlign(VerticalAlignment);
Border.Pin()->SetContent(Content ? Content->TakeWidget() : SNullWidget::NullWidget);
}
void UBorderSlot::SetPadding(FMargin InPadding)
{
CastChecked<UBorder>(Parent)->SetPadding(InPadding);
}
void UBorderSlot::SetHorizontalAlignment(EHorizontalAlignment InHorizontalAlignment)
{
CastChecked<UBorder>(Parent)->SetHorizontalAlignment(InHorizontalAlignment);
}
void UBorderSlot::SetVerticalAlignment(EVerticalAlignment InVerticalAlignment)
{
CastChecked<UBorder>(Parent)->SetVerticalAlignment(InVerticalAlignment);
}
void UBorderSlot::SynchronizeProperties()
{
if ( Border.IsValid() )
{
SetPadding(Padding);
SetHorizontalAlignment(HorizontalAlignment);
SetVerticalAlignment(VerticalAlignment);
}
}
#if WITH_EDITOR
void UBorderSlot::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
static bool IsReentrant = false;
if ( !IsReentrant )
{
IsReentrant = true;
if ( PropertyChangedEvent.Property )
{
static const FName PaddingName("Padding");
static const FName HorizontalAlignmentName("HorizontalAlignment");
static const FName VerticalAlignmentName("VerticalAlignment");
FName PropertyName = PropertyChangedEvent.Property->GetFName();
if ( UBorder* ParentBorder = CastChecked<UBorder>(Parent) )
{
if ( PropertyName == PaddingName)
{
FObjectEditorUtils::MigratePropertyValue(this, PaddingName, ParentBorder, PaddingName);
}
else if ( PropertyName == HorizontalAlignmentName)
{
FObjectEditorUtils::MigratePropertyValue(this, HorizontalAlignmentName, ParentBorder, HorizontalAlignmentName);
}
else if ( PropertyName == VerticalAlignmentName)
{
FObjectEditorUtils::MigratePropertyValue(this, VerticalAlignmentName, ParentBorder, VerticalAlignmentName);
}
}
}
IsReentrant = false;
}
}
#endif