You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#jira none #rb none #preflight 629607c6be0ae0b33a3908a2 [CL 20435923 by George Rolfe in ue5-main branch]
68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "EditorWidgetsStyle.h"
|
|
#include "Styling/AppStyle.h"
|
|
#include "Styling/SlateStyleRegistry.h"
|
|
#include "Styling/SlateTypes.h"
|
|
|
|
TSharedPtr<FSlateStyleSet> FEditorWidgetsStyle::StyleSet = nullptr;
|
|
|
|
#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( StyleSet->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
|
|
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( StyleSet->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
|
|
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( StyleSet->RootToContentDir( RelativePath, TEXT(".png") ), __VA_ARGS__ )
|
|
#define DEFAULT_FONT(...) FCoreStyle::GetDefaultFontStyle(__VA_ARGS__)
|
|
|
|
void FEditorWidgetsStyle::Initialize()
|
|
{
|
|
// Only register once
|
|
if(StyleSet.IsValid())
|
|
{
|
|
return;
|
|
}
|
|
|
|
StyleSet = MakeShareable(new FSlateStyleSet("EditorWidgets"));
|
|
|
|
const FEditableTextBoxStyle& NormalEditableTextBoxStyle = FAppStyle::GetWidgetStyle<FEditableTextBoxStyle>("NormalEditableTextBox");
|
|
|
|
const FTextBlockStyle NormalText = FTextBlockStyle()
|
|
.SetColorAndOpacity(NormalEditableTextBoxStyle.ForegroundColor)
|
|
.SetHighlightColor(NormalEditableTextBoxStyle.FocusedForegroundColor)
|
|
.SetFont(NormalEditableTextBoxStyle.Font)
|
|
.SetFontSize(NormalEditableTextBoxStyle.Font.Size);
|
|
|
|
// Text editor
|
|
{
|
|
StyleSet->Set("TextEditor.NormalText", NormalText);
|
|
|
|
StyleSet->Set("SyntaxHighlight.Template.Normal", NormalText);
|
|
StyleSet->Set("SyntaxHighlight.Template.Argument", FAppStyle::GetWidgetStyle<FTextBlockStyle>("RichTextBlock.BoldHighlight"));
|
|
}
|
|
|
|
FSlateStyleRegistry::RegisterSlateStyle( *StyleSet.Get() );
|
|
}
|
|
|
|
#undef IMAGE_BRUSH
|
|
#undef BOX_BRUSH
|
|
#undef BORDER_BRUSH
|
|
#undef DEFAULT_FONT
|
|
|
|
void FEditorWidgetsStyle::Shutdown()
|
|
{
|
|
if(StyleSet.IsValid())
|
|
{
|
|
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet.Get());
|
|
ensure(StyleSet.IsUnique());
|
|
StyleSet.Reset();
|
|
}
|
|
}
|
|
|
|
const ISlateStyle& FEditorWidgetsStyle::Get()
|
|
{
|
|
return *(StyleSet.Get());
|
|
}
|
|
|
|
const FName& FEditorWidgetsStyle::GetStyleSetName()
|
|
{
|
|
return StyleSet->GetStyleSetName();
|
|
}
|