You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
130 lines
2.9 KiB
C++
130 lines
2.9 KiB
C++
// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Components/RetainerBox.h"
|
|
#include "Widgets/SNullWidget.h"
|
|
#include "Widgets/DeclarativeSyntaxSupport.h"
|
|
|
|
#include "Slate/SRetainerWidget.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UMG"
|
|
|
|
static FName DefaultTextureParameterName("Texture");
|
|
|
|
/////////////////////////////////////////////////////
|
|
// URetainerBox
|
|
|
|
URetainerBox::URetainerBox(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
Visibility = ESlateVisibility::Visible;
|
|
Phase = 0;
|
|
PhaseCount = 1;
|
|
TextureParameter = DefaultTextureParameterName;
|
|
}
|
|
|
|
UMaterialInstanceDynamic* URetainerBox::GetEffectMaterial() const
|
|
{
|
|
if ( MyRetainerWidget.IsValid() )
|
|
{
|
|
return MyRetainerWidget->GetEffectMaterial();
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
void URetainerBox::SetEffectMaterial(UMaterialInterface* InEffectMaterial)
|
|
{
|
|
EffectMaterial = InEffectMaterial;
|
|
if ( MyRetainerWidget.IsValid() )
|
|
{
|
|
MyRetainerWidget->SetEffectMaterial(EffectMaterial);
|
|
}
|
|
}
|
|
|
|
void URetainerBox::SetTextureParameter(FName InTextureParameter)
|
|
{
|
|
TextureParameter = InTextureParameter;
|
|
if ( MyRetainerWidget.IsValid() )
|
|
{
|
|
MyRetainerWidget->SetTextureParameter(TextureParameter);
|
|
}
|
|
}
|
|
|
|
void URetainerBox::ReleaseSlateResources(bool bReleaseChildren)
|
|
{
|
|
Super::ReleaseSlateResources(bReleaseChildren);
|
|
|
|
MyRetainerWidget.Reset();
|
|
}
|
|
|
|
TSharedRef<SWidget> URetainerBox::RebuildWidget()
|
|
{
|
|
MyRetainerWidget =
|
|
SNew(SRetainerWidget)
|
|
.Phase(Phase)
|
|
.PhaseCount(PhaseCount)
|
|
#if STATS
|
|
.StatId( FName( *FString::Printf(TEXT("%s [%s]"), *GetFName().ToString(), *GetClass()->GetName() ) ) )
|
|
#endif//STATS
|
|
;
|
|
|
|
MyRetainerWidget->SetRetainedRendering(IsDesignTime() ? false : true);
|
|
|
|
if ( GetChildrenCount() > 0 )
|
|
{
|
|
MyRetainerWidget->SetContent(GetContentSlot()->Content ? GetContentSlot()->Content->TakeWidget() : SNullWidget::NullWidget);
|
|
}
|
|
|
|
return BuildDesignTimeWidget(MyRetainerWidget.ToSharedRef());
|
|
}
|
|
|
|
void URetainerBox::SynchronizeProperties()
|
|
{
|
|
Super::SynchronizeProperties();
|
|
|
|
MyRetainerWidget->SetEffectMaterial(EffectMaterial);
|
|
MyRetainerWidget->SetTextureParameter(TextureParameter);
|
|
}
|
|
|
|
void URetainerBox::OnSlotAdded(UPanelSlot* InSlot)
|
|
{
|
|
// Add the child to the live slot if it already exists
|
|
if ( MyRetainerWidget.IsValid() )
|
|
{
|
|
MyRetainerWidget->SetContent(InSlot->Content ? InSlot->Content->TakeWidget() : SNullWidget::NullWidget);
|
|
}
|
|
}
|
|
|
|
void URetainerBox::OnSlotRemoved(UPanelSlot* InSlot)
|
|
{
|
|
// Remove the widget from the live slot if it exists.
|
|
if ( MyRetainerWidget.IsValid() )
|
|
{
|
|
MyRetainerWidget->SetContent(SNullWidget::NullWidget);
|
|
}
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
|
|
const FText URetainerBox::GetPaletteCategory()
|
|
{
|
|
return LOCTEXT("Optimization", "Optimization");
|
|
}
|
|
|
|
#endif
|
|
|
|
const FGeometry& URetainerBox::GetCachedAllottedGeometry() const
|
|
{
|
|
if (MyRetainerWidget.IsValid())
|
|
{
|
|
return MyRetainerWidget->GetCachedAllottedGeometry();
|
|
}
|
|
|
|
static const FGeometry TempGeo;
|
|
return TempGeo;
|
|
}
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|