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

86 lines
2.2 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Components/RichTextBlock.h"
#include "UObject/ConstructorHelpers.h"
#include "Engine/Font.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/Text/SRichTextBlock.h"
#include "Components/RichTextBlockDecorator.h"
#define LOCTEXT_NAMESPACE "UMG"
/////////////////////////////////////////////////////
// URichTextBlock
URichTextBlock::URichTextBlock(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
{
if (!IsRunningDedicatedServer())
{
static ConstructorHelpers::FObjectFinder<UFont> RobotoFontObj(TEXT("/Engine/EngineFonts/Roboto"));
Font = FSlateFontInfo(RobotoFontObj.Object, 12, FName("Regular"));
}
Color = FLinearColor::White;
Decorators.Add(ObjectInitializer.CreateOptionalDefaultSubobject<URichTextBlockDecorator>(this, FName("DefaultDecorator")));
}
void URichTextBlock::ReleaseSlateResources(bool bReleaseChildren)
{
Super::ReleaseSlateResources(bReleaseChildren);
MyRichTextBlock.Reset();
}
TSharedRef<SWidget> URichTextBlock::RebuildWidget()
{
//+ OnHyperlinkClicked = FSlateHyperlinkRun::FOnClick::CreateStatic(&RichTextHelper::OnBrowserLinkClicked, AsShared());
//+ FHyperlinkDecorator::Create(TEXT("browser"), OnHyperlinkClicked))
//+MakeShareable(new FDefaultRichTextDecorator(Font, Color));
DefaultStyle.SetFont(Font);
DefaultStyle.SetColorAndOpacity(Color);
TArray< TSharedRef< class ITextDecorator > > CreatedDecorators;
for ( URichTextBlockDecorator* Decorator : Decorators )
{
if ( Decorator )
{
CreatedDecorators.Add(Decorator->CreateDecorator(Font, Color));
}
}
MyRichTextBlock =
SNew(SRichTextBlock)
.TextStyle(&DefaultStyle)
.Decorators(CreatedDecorators);
return MyRichTextBlock.ToSharedRef();
}
void URichTextBlock::SynchronizeProperties()
{
Super::SynchronizeProperties();
TAttribute<FText> TextBinding = OPTIONAL_BINDING(FText, Text);
MyRichTextBlock->SetText(TextBinding);
Super::SynchronizeTextLayoutProperties( *MyRichTextBlock );
}
#if WITH_EDITOR
const FText URichTextBlock::GetPaletteCategory()
{
return LOCTEXT("Common", "Common");
}
#endif
/////////////////////////////////////////////////////
#undef LOCTEXT_NAMESPACE