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

100 lines
2.3 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Components/InvalidationBox.h"
#include "Widgets/SNullWidget.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/SInvalidationPanel.h"
#define LOCTEXT_NAMESPACE "UMG"
/////////////////////////////////////////////////////
// UInvalidationBox
UInvalidationBox::UInvalidationBox(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bCanCache = true;
Visibility = ESlateVisibility::SelfHitTestInvisible;
}
void UInvalidationBox::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
MyInvalidationPanel.Reset();
}
TSharedRef<SWidget> UInvalidationBox::RebuildWidget()
{
MyInvalidationPanel =
SNew(SInvalidationPanel)
.CacheRelativeTransforms(CacheRelativeTransforms);
MyInvalidationPanel->SetCanCache(IsDesignTime() ? false : bCanCache);
if ( GetChildrenCount() > 0 )
{
MyInvalidationPanel->SetContent(GetContentSlot()->Content ? GetContentSlot()->Content->TakeWidget() : SNullWidget::NullWidget);
}
return BuildDesignTimeWidget(MyInvalidationPanel.ToSharedRef());
}
void UInvalidationBox::OnSlotAdded(UPanelSlot* InSlot)
{
// Add the child to the live slot if it already exists
if ( MyInvalidationPanel.IsValid() )
{
MyInvalidationPanel->SetContent(InSlot->Content ? InSlot->Content->TakeWidget() : SNullWidget::NullWidget);
}
}
void UInvalidationBox::OnSlotRemoved(UPanelSlot* InSlot)
{
// Remove the widget from the live slot if it exists.
if ( MyInvalidationPanel.IsValid() )
{
MyInvalidationPanel->SetContent(SNullWidget::NullWidget);
}
}
void UInvalidationBox::InvalidateCache()
{
if ( MyInvalidationPanel.IsValid() )
{
return MyInvalidationPanel->InvalidateCache();
}
}
bool UInvalidationBox::GetCanCache() const
{
if ( MyInvalidationPanel.IsValid() )
{
return MyInvalidationPanel->GetCanCache();
}
return bCanCache;
}
void UInvalidationBox::SetCanCache(bool CanCache)
{
bCanCache = CanCache;
if ( MyInvalidationPanel.IsValid() )
{
return MyInvalidationPanel->SetCanCache(bCanCache);
}
}
#if WITH_EDITOR
const FText UInvalidationBox::GetPaletteCategory()
{
return LOCTEXT("Optimization", "Optimization");
}
#endif
/////////////////////////////////////////////////////
#undef LOCTEXT_NAMESPACE