Files
UnrealEngineUWP/Engine/Source/Runtime/UMG/Private/Components/HorizontalBox.cpp
Nick Darnell 3da7a67f2d UMG - General cleanup of the horizontal box.
[CL 2253333 by Nick Darnell in Main branch]
2014-08-12 14:34:49 -04:00

85 lines
1.9 KiB
C++

// Copyright 1998-2014 Epic Games, Inc. All Rights Reserved.
#include "UMGPrivatePCH.h"
/////////////////////////////////////////////////////
// UHorizontalBox
UHorizontalBox::UHorizontalBox(const FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{
bIsVariable = false;
SHorizontalBox::FArguments Defaults;
Visiblity = UWidget::ConvertRuntimeToSerializedVisiblity(Defaults._Visibility.Get());
}
void UHorizontalBox::ReleaseNativeWidget()
{
Super::ReleaseNativeWidget();
MyHorizontalBox.Reset();
}
UClass* UHorizontalBox::GetSlotClass() const
{
return UHorizontalBoxSlot::StaticClass();
}
void UHorizontalBox::OnSlotAdded(UPanelSlot* Slot)
{
// Add the child to the live canvas if it already exists
if ( MyHorizontalBox.IsValid() )
{
Cast<UHorizontalBoxSlot>(Slot)->BuildSlot(MyHorizontalBox.ToSharedRef());
}
}
void UHorizontalBox::OnSlotRemoved(UPanelSlot* Slot)
{
// Remove the widget from the live slot if it exists.
if ( MyHorizontalBox.IsValid() )
{
TSharedPtr<SWidget> Widget = Slot->Content->GetCachedWidget();
if ( Widget.IsValid() )
{
MyHorizontalBox->RemoveSlot(Widget.ToSharedRef());
}
}
}
UHorizontalBoxSlot* UHorizontalBox::AddSlot(UWidget* Content)
{
return Cast<UHorizontalBoxSlot>( Super::AddChild(Content) );
}
UHorizontalBoxSlot* UHorizontalBox::HorizontalBoxSlot(UWidget* Child)
{
return Cast<UHorizontalBoxSlot>(Child->Slot);
}
TSharedRef<SWidget> UHorizontalBox::RebuildWidget()
{
MyHorizontalBox = SNew(SHorizontalBox);
for ( UPanelSlot* Slot : Slots )
{
if ( UHorizontalBoxSlot* TypedSlot = Cast<UHorizontalBoxSlot>(Slot) )
{
TypedSlot->Parent = this;
TypedSlot->BuildSlot(MyHorizontalBox.ToSharedRef());
}
}
return BuildDesignTimeWidget( MyHorizontalBox.ToSharedRef() );
}
#if WITH_EDITOR
const FSlateBrush* UHorizontalBox::GetEditorIcon()
{
return FUMGStyle::Get().GetBrush("Widget.HorizontalBox");
}
#endif