Files
UnrealEngineUWP/Engine/Source/Programs/ZenDashboard/Private/ZenDashboardStyle.cpp
Zousar Shaker 47d2def788 Zen dashboard feature additions for:
- Service status & controls
- Version information
- GC status & control

Depends on https://p4-swarm.epicgames.net/reviews/23337377

#rb matt.peters
#preflight 638fa4a167018b14b5be45b5

[CL 23415939 by Zousar Shaker in ue5-main branch]
2022-12-06 15:38:54 -05:00

122 lines
4.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ZenDashboardStyle.h"
#include "Misc/AssertionMacros.h"
#include "Containers/UnrealString.h"
#include "Misc/Paths.h"
#include "Math/Color.h"
#include "Math/Vector2D.h"
#include "Styling/SlateStyleRegistry.h"
#include "Styling/SlateTypes.h"
#include "Styling/CoreStyle.h"
TSharedPtr< FSlateStyleSet > FZenDashboardStyle::StyleSet = nullptr;
void FZenDashboardStyle::Initialize()
{
if(!StyleSet.IsValid())
{
StyleSet = Create();
FSlateStyleRegistry::RegisterSlateStyle(*StyleSet);
}
}
void FZenDashboardStyle::Shutdown()
{
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleSet);
ensure(StyleSet.IsUnique());
StyleSet.Reset();
}
#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush(ContentFromEngine(TEXT(RelativePath), TEXT(".png")), __VA_ARGS__)
#define IMAGE_BRUSH_SVG( RelativePath, ... ) FSlateVectorImageBrush(ContentFromEngine(TEXT(RelativePath), TEXT(".svg")), __VA_ARGS__)
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush(ContentFromEngine(TEXT(RelativePath), TEXT(".png")), __VA_ARGS__)
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush(ContentFromEngine(RelativePath, TEXT(".png")), __VA_ARGS__)
#define DEFAULT_FONT(...) FCoreStyle::GetDefaultFontStyle(__VA_ARGS__)
#define EDITOR_IMAGE_BRUSH(RelativePath, ...) IMAGE_BRUSH("../Editor/Slate/" RelativePath, __VA_ARGS__)
#define EDITOR_IMAGE_BRUSH_SVG(RelativePath, ...) IMAGE_BRUSH_SVG("../Editor/Slate/" RelativePath, __VA_ARGS__)
#define EDITOR_BOX_BRUSH(RelativePath, ...) BOX_BRUSH("../Editor/Slate/" RelativePath, __VA_ARGS__)
#define EDITOR_BORDER_BRUSH(RelativePath, ...) BORDER_BRUSH("../Editor/Slate/" RelativePath, __VA_ARGS__)
namespace
{
FString ContentFromEngine(const FString& RelativePath, const TCHAR* Extension)
{
static const FString ContentDir = FPaths::EngineDir() / TEXT("Content/Slate");
return ContentDir / RelativePath + Extension;
}
}
TSharedRef< FSlateStyleSet > FZenDashboardStyle::Create()
{
TSharedRef<FSlateStyleSet> StyleRef = MakeShareable(new FSlateStyleSet("ZenDashboardStyle"));
FSlateStyleSet& Style = StyleRef.Get();
Style.SetParentStyleName("CoreStyle");
const FVector2D Icon12x12(12.0f, 12.0f);
const FVector2D Icon16x16(16.0f, 16.0f);
Style.Set( "AppIcon", new IMAGE_BRUSH( "Icons/DefaultAppIcon", FVector2D(20,20)) );
Style.Set("Icons.FolderExplore", new EDITOR_IMAGE_BRUSH_SVG("Starship/Common/ContentBrowser", Icon12x12));
Style.Set("Icons.Clipboard", new EDITOR_IMAGE_BRUSH_SVG("Starship/Common/Clipboard", Icon16x16));
const FTextBlockStyle DefaultText = FTextBlockStyle()
.SetFont(DEFAULT_FONT("Bold", 10))
.SetColorAndOpacity(FSlateColor::UseForeground())
.SetShadowOffset(FVector2D::ZeroVector)
.SetShadowColorAndOpacity(FLinearColor::Black);
// Set the client app styles
Style.Set(TEXT("Code"), FTextBlockStyle(DefaultText)
.SetFont(DEFAULT_FONT("Regular", 8))
.SetColorAndOpacity(FSlateColor(FLinearColor::White * 0.8f))
);
Style.Set(TEXT("Title"), FTextBlockStyle(DefaultText)
.SetFont(DEFAULT_FONT("Bold", 12))
);
Style.Set(TEXT("Status"), FTextBlockStyle(DefaultText)
.SetColorAndOpacity(FSlateColor::UseSubduedForeground())
);
FSlateBrush* GenericWhiteBox = new IMAGE_BRUSH( "Old/White", Icon16x16 );
// Scrollbar
const FScrollBarStyle ScrollBar = FScrollBarStyle()
.SetVerticalTopSlotImage(IMAGE_BRUSH("Common/Scrollbar_Background_Vertical", FVector2D(8, 8)))
.SetVerticalBottomSlotImage(IMAGE_BRUSH("Common/Scrollbar_Background_Vertical", FVector2D(8, 8)))
.SetHorizontalTopSlotImage(IMAGE_BRUSH("Common/Scrollbar_Background_Horizontal", FVector2D(8, 8)))
.SetHorizontalBottomSlotImage(IMAGE_BRUSH("Common/Scrollbar_Background_Horizontal", FVector2D(8, 8)))
.SetNormalThumbImage(BOX_BRUSH("Common/Scrollbar_Thumb", FMargin(4.f / 16.f)))
.SetDraggedThumbImage(BOX_BRUSH("Common/Scrollbar_Thumb", FMargin(4.f / 16.f)))
.SetHoveredThumbImage(BOX_BRUSH("Common/Scrollbar_Thumb", FMargin(4.f / 16.f)));
Style.Set("Log.TextBox", FEditableTextBoxStyle(FCoreStyle::Get().GetWidgetStyle<FEditableTextBoxStyle>("NormalEditableTextBox"))
.SetBackgroundImageNormal( BOX_BRUSH("Common/WhiteGroupBorder", FMargin(4.0f/16.0f)))
.SetBackgroundImageHovered( BOX_BRUSH("Common/WhiteGroupBorder", FMargin(4.0f/16.0f)))
.SetBackgroundImageFocused(BOX_BRUSH("Common/WhiteGroupBorder", FMargin(4.0f / 16.0f)))
.SetBackgroundImageReadOnly(BOX_BRUSH("Common/WhiteGroupBorder", FMargin(4.0f / 16.0f)))
.SetBackgroundColor( FLinearColor(0.015f, 0.015f, 0.015f) )
.SetScrollBarStyle(ScrollBar)
);
return StyleRef;
}
#undef IMAGE_BRUSH
#undef BOX_BRUSH
#undef BORDER_BRUSH
#undef DEFAULT_FONT
const ISlateStyle& FZenDashboardStyle::Get()
{
return *StyleSet;
}