RealtimeStyleTransferRuntime/Source/LyraEditor/Private/GameEditorStyle.cpp

68 lines
2.3 KiB
C++
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#include "GameEditorStyle.h"
#include "Styling/SlateTypes.h"
#include "Styling/SlateStyleRegistry.h"
#include "Engine/Texture2D.h"
TSharedPtr< FSlateStyleSet > FGameEditorStyle::StyleInstance = nullptr;
void FGameEditorStyle::Initialize()
{
if ( !StyleInstance.IsValid() )
{
StyleInstance = Create();
FSlateStyleRegistry::RegisterSlateStyle( *StyleInstance );
}
}
void FGameEditorStyle::Shutdown()
{
FSlateStyleRegistry::UnRegisterSlateStyle( *StyleInstance );
ensure( StyleInstance.IsUnique() );
StyleInstance.Reset();
}
FName FGameEditorStyle::GetStyleSetName()
{
static FName StyleSetName(TEXT("GameEditorStyle"));
return StyleSetName;
}
#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( FPaths::EngineContentDir() / "Editor/Slate"/ RelativePath + TEXT(".png"), __VA_ARGS__ )
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush( FPaths::EngineContentDir() / "Editor/Slate"/ RelativePath + TEXT(".png"), __VA_ARGS__ )
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush( FPaths::EngineContentDir() / "Editor/Slate"/ RelativePath + TEXT(".png"), __VA_ARGS__ )
#define GAME_IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush( FPaths::ProjectContentDir() / "Editor/Slate"/ RelativePath + TEXT(".png"), __VA_ARGS__ )
#define GAME_IMAGE_BRUSH_SVG( RelativePath, ... ) FSlateVectorImageBrush( FPaths::ProjectContentDir() / "Editor/Slate"/ RelativePath + TEXT(".svg"), __VA_ARGS__ )
TSharedRef< FSlateStyleSet > FGameEditorStyle::Create()
{
TSharedRef<FSlateStyleSet> StyleRef = MakeShareable(new FSlateStyleSet(FGameEditorStyle::GetStyleSetName()));
StyleRef->SetContentRoot(FPaths::EngineContentDir() / TEXT("Editor/Slate"));
StyleRef->SetCoreContentRoot(FPaths::EngineContentDir() / TEXT("Slate"));
FSlateStyleSet& Style = StyleRef.Get();
const FVector2D Icon16x16(16.0f, 16.0f);
const FVector2D Icon20x20(20.0f, 20.0f);
const FVector2D Icon40x40(40.0f, 40.0f);
const FVector2D Icon64x64(64.0f, 64.0f);
// Toolbar
{
Style.Set("GameEditor.CheckContent", new GAME_IMAGE_BRUSH_SVG("Icons/CheckContent", Icon20x20));
}
return StyleRef;
}
#undef IMAGE_BRUSH
#undef BOX_BRUSH
#undef BORDER_BRUSH
const ISlateStyle& FGameEditorStyle::Get()
{
return *StyleInstance;
}