You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
[FYI] vincent.gauthier #ROBOMERGE-AUTHOR: patrick.boutot #ROBOMERGE-SOURCE: CL 20142060 via CL 20143142 via CL 20143633 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690) [CL 20148091 by patrick boutot in ue5-main branch]
185 lines
4.1 KiB
C++
185 lines
4.1 KiB
C++
// Copyright 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)
|
|
{
|
|
SetVisibilityInternal(ESlateVisibility::Visible);
|
|
Phase = 0;
|
|
PhaseCount = 1;
|
|
RenderOnPhase = true;
|
|
RenderOnInvalidation = false;
|
|
TextureParameter = DefaultTextureParameterName;
|
|
}
|
|
|
|
void URetainerBox::SetRenderingPhase(int32 PhaseToRenderOn, int32 TotalRenderingPhases)
|
|
{
|
|
Phase = PhaseToRenderOn;
|
|
PhaseCount = TotalRenderingPhases;
|
|
|
|
if ( PhaseCount < 1 )
|
|
{
|
|
PhaseCount = 1;
|
|
}
|
|
|
|
if (MyRetainerWidget.IsValid())
|
|
{
|
|
MyRetainerWidget->SetRenderingPhase(Phase, PhaseCount);
|
|
}
|
|
}
|
|
|
|
void URetainerBox::RequestRender()
|
|
{
|
|
if ( MyRetainerWidget.IsValid() )
|
|
{
|
|
MyRetainerWidget->RequestRender();
|
|
}
|
|
}
|
|
|
|
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::SetRetainRendering(bool bInRetainRendering)
|
|
{
|
|
bRetainRender = bInRetainRendering;
|
|
|
|
if (MyRetainerWidget.IsValid())
|
|
{
|
|
MyRetainerWidget->SetRetainedRendering(bRetainRender);
|
|
}
|
|
}
|
|
|
|
void URetainerBox::ReleaseSlateResources(bool bReleaseChildren)
|
|
{
|
|
Super::ReleaseSlateResources(bReleaseChildren);
|
|
|
|
MyRetainerWidget.Reset();
|
|
}
|
|
|
|
TSharedRef<SWidget> URetainerBox::RebuildWidget()
|
|
{
|
|
MyRetainerWidget =
|
|
SNew(SRetainerWidget)
|
|
.RenderOnInvalidation(RenderOnInvalidation)
|
|
.RenderOnPhase(RenderOnPhase)
|
|
.Phase(Phase)
|
|
.PhaseCount(PhaseCount)
|
|
#if STATS
|
|
.StatId( FName( *FString::Printf(TEXT("%s [%s]"), *GetFName().ToString(), *GetClass()->GetName() ) ) )
|
|
#endif//STATS
|
|
;
|
|
|
|
if ( GetChildrenCount() > 0 )
|
|
{
|
|
MyRetainerWidget->SetContent(GetContentSlot()->Content ? GetContentSlot()->Content->TakeWidget() : SNullWidget::NullWidget);
|
|
}
|
|
|
|
return MyRetainerWidget.ToSharedRef();
|
|
}
|
|
|
|
void URetainerBox::SynchronizeProperties()
|
|
{
|
|
Super::SynchronizeProperties();
|
|
|
|
MyRetainerWidget->SetRetainedRendering(IsDesignTime() ? false : bRetainRender);
|
|
MyRetainerWidget->SetEffectMaterial(EffectMaterial);
|
|
MyRetainerWidget->SetTextureParameter(TextureParameter);
|
|
MyRetainerWidget->SetWorld(GetWorld());
|
|
}
|
|
|
|
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
|
|
|
|
FGeometry URetainerBox::GetCachedAllottedGeometry() const
|
|
{
|
|
if (MyRetainerWidget.IsValid())
|
|
{
|
|
return MyRetainerWidget->GetTickSpaceGeometry();
|
|
}
|
|
|
|
static const FGeometry TempGeo;
|
|
return TempGeo;
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
bool URetainerBox::CanEditChange(const FProperty* InProperty) const
|
|
{
|
|
if (!Super::CanEditChange(InProperty))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(URetainerBox, Phase)
|
|
|| InProperty->GetFName() == GET_MEMBER_NAME_CHECKED(URetainerBox, PhaseCount))
|
|
{
|
|
return RenderOnPhase && bRetainRender;
|
|
}
|
|
return true;
|
|
}
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|