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

93 lines
2.1 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Components/WrapBoxSlot.h"
#include "Components/Widget.h"
/////////////////////////////////////////////////////
// UWrapBoxSlot
UWrapBoxSlot::UWrapBoxSlot(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, Slot(NULL)
{
HorizontalAlignment = HAlign_Fill;
VerticalAlignment = VAlign_Fill;
bFillEmptySpace = false;
FillSpanWhenLessThan = 0;
}
void UWrapBoxSlot::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
Slot = NULL;
}
void UWrapBoxSlot::BuildSlot(TSharedRef<SWrapBox> WrapBox)
{
Slot = &WrapBox->AddSlot()
.Padding(Padding)
.HAlign(HorizontalAlignment)
.VAlign(VerticalAlignment)
.FillEmptySpace(bFillEmptySpace)
.FillLineWhenWidthLessThan(FillSpanWhenLessThan == 0 ? TOptional<float>() : TOptional<float>(FillSpanWhenLessThan))
[
Content == NULL ? SNullWidget::NullWidget : Content->TakeWidget()
];
}
void UWrapBoxSlot::SetPadding(FMargin InPadding)
{
Padding = InPadding;
if ( Slot )
{
Slot->Padding(InPadding);
}
}
void UWrapBoxSlot::SetFillEmptySpace(bool InbFillEmptySpace)
{
bFillEmptySpace = InbFillEmptySpace;
if ( Slot )
{
Slot->FillEmptySpace(InbFillEmptySpace);
}
}
void UWrapBoxSlot::SetFillSpanWhenLessThan(float InFillSpanWhenLessThan)
{
FillSpanWhenLessThan = InFillSpanWhenLessThan;
if ( Slot )
{
Slot->FillLineWhenWidthLessThan(InFillSpanWhenLessThan == 0 ? TOptional<float>() : TOptional<float>(InFillSpanWhenLessThan));
}
}
void UWrapBoxSlot::SetHorizontalAlignment(EHorizontalAlignment InHorizontalAlignment)
{
HorizontalAlignment = InHorizontalAlignment;
if ( Slot )
{
Slot->HAlign(InHorizontalAlignment);
}
}
void UWrapBoxSlot::SetVerticalAlignment(EVerticalAlignment InVerticalAlignment)
{
VerticalAlignment = InVerticalAlignment;
if ( Slot )
{
Slot->VAlign(InVerticalAlignment);
}
}
void UWrapBoxSlot::SynchronizeProperties()
{
SetPadding(Padding);
SetFillEmptySpace(bFillEmptySpace);
SetFillSpanWhenLessThan(FillSpanWhenLessThan);
SetHorizontalAlignment(HorizontalAlignment);
SetVerticalAlignment(VerticalAlignment);
}