Files
UnrealEngineUWP/Engine/Source/Runtime/UMG/Private/Components/NativeWidgetHost.cpp
Chris Gagnon 5188bf02ed [AUTOMERGE]
NativeWidgetHost no longer sets it's internal content if the content is already set to the provided widget.

#RB Dan.Hertzka
#codereview Dan.Hertzka, Nick.Darnell

--------
Integrated using branch Ue4-To-UE4-Fortnite-Simple (reversed) of change#2636075 by Chris.Gagnon on 2015/07/28 17:10:42.

[CL 2636342 by Chris Gagnon in Main branch]
2015-07-28 19:18:15 -04:00

83 lines
1.7 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "UMGPrivatePCH.h"
#define LOCTEXT_NAMESPACE "UMG"
/////////////////////////////////////////////////////
// UNativeWidgetHost
UNativeWidgetHost::UNativeWidgetHost(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
bIsVariable = false;
}
void UNativeWidgetHost::SetContent(TSharedRef<SWidget> InContent)
{
if (NativeWidget != InContent)
{
NativeWidget = InContent;
TSharedPtr<SWidget> StableMyWidget = MyWidget.Pin();
if (StableMyWidget.IsValid())
{
TSharedPtr<SBox> MyBox = StaticCastSharedPtr<SBox>(StableMyWidget);
MyBox->SetContent(InContent);
}
}
}
void UNativeWidgetHost::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
NativeWidget.Reset();
}
TSharedRef<SWidget> UNativeWidgetHost::RebuildWidget()
{
return SNew(SBox)
[
( NativeWidget.IsValid() ) ? NativeWidget.ToSharedRef() : GetDefaultContent()
];
}
TSharedRef<SWidget> UNativeWidgetHost::GetDefaultContent()
{
if ( IsDesignTime() )
{
return SNew(SBorder)
.Visibility(EVisibility::HitTestInvisible)
.BorderImage(FUMGStyle::Get().GetBrush("MarchingAnts"))
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
[
SNew(STextBlock)
.Text(LOCTEXT("NativeWidgetHostText", "Slate Widget Host"))
];
}
else
{
return SNullWidget::NullWidget;
}
}
#if WITH_EDITOR
const FSlateBrush* UNativeWidgetHost::GetEditorIcon()
{
return FUMGStyle::Get().GetBrush("Widget.NativeWidgetHost");
}
const FText UNativeWidgetHost::GetPaletteCategory()
{
return LOCTEXT("Primitive", "Primitive");
}
#endif
/////////////////////////////////////////////////////
#undef LOCTEXT_NAMESPACE