幕的样式
This commit is contained in:
parent
d580c945a6
commit
17c222fbf7
@ -6,6 +6,7 @@
|
||||
#include "Blueprint/WidgetBlueprintLibrary.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "Widgets/SCutMainWindow.h"
|
||||
#include "Widgets/Style/CutButtonWidgetStyle.h"
|
||||
|
||||
AMainHUD::AMainHUD()
|
||||
{
|
||||
@ -24,4 +25,11 @@ AMainHUD::AMainHUD()
|
||||
// UKismetSystemLibrary::ExecuteConsoleCommand(this, "Slate.EnableGlobalInvalidation 1");
|
||||
|
||||
}
|
||||
|
||||
FCutButtonStyle::Initialize();
|
||||
}
|
||||
|
||||
AMainHUD::~AMainHUD()
|
||||
{
|
||||
FCutButtonStyle::Shutdown();
|
||||
}
|
||||
|
@ -15,5 +15,5 @@ class CUT5_API AMainHUD : public AHUD
|
||||
GENERATED_BODY()
|
||||
|
||||
AMainHUD();
|
||||
|
||||
~AMainHUD();
|
||||
};
|
||||
|
@ -24,6 +24,10 @@ public:
|
||||
|
||||
static void TrackEncodeVideo(const FTrackData& TrackData, const FString& ExportPath);
|
||||
|
||||
static FString CurtainFullPath(const FString& GroupName)
|
||||
{
|
||||
return FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("Curtain"), GroupName + TEXT(".bin"));
|
||||
};
|
||||
static FString GroupFullPath(const FString& GroupName)
|
||||
{
|
||||
return FPaths::Combine(FGlobalData::BasePath, FGlobalData::CurrentProjectName, TEXT("FX"), GroupName + TEXT(".bin"));
|
||||
@ -49,7 +53,7 @@ public:
|
||||
}
|
||||
|
||||
inline static FButtonStyle UnSelectedButton = FButtonStyle()
|
||||
.SetNormal(FSlateImageBrush("D:\\Project\\Cut5\\Resources\\CurtainNormal.png", FVector2D(257, 32), FLinearColor(42.0f /255, 42.0f /255, 42.0f /255, 1.0f)))
|
||||
.SetNormal(FSlateImageBrush(*FUtils::GetResourcesPath("CurtainNormal.png", true), FVector2D(257, 32), FLinearColor(42.0f /255, 42.0f /255, 42.0f /255, 1.0f)))
|
||||
.SetHovered(FSlateBoxBrush(*FUtils::GetResourcesPath("CurtainHover.png", true), FMargin(1.0), FLinearColor(46.0 /255,48.0/255,54.0/255,1.0f)))
|
||||
.SetPressed(FSlateBoxBrush(*FUtils::GetResourcesPath("CurtainSelected.png", true), FMargin(1.0), FLinearColor(88.0/255,96.0/255,121.0/255,1.0f)));
|
||||
};
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "Brushes/SlateBoxBrush.h"
|
||||
#include "Brushes/SlateImageBrush.h"
|
||||
#include "Cut5/Utils/Utils.h"
|
||||
#include "Cut5/Widgets/Style/CutButtonWidgetStyle.h"
|
||||
#include "Widgets/Text/SInlineEditableTextBlock.h"
|
||||
|
||||
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
||||
@ -18,14 +19,12 @@ void SCurtain::Construct(const FArguments& InArgs)
|
||||
CurtainPanel = InArgs._CurtainPanel;
|
||||
CurtainGroup = InArgs._CurtainGroup;
|
||||
CurtainIndex = InArgs._CurtainIndex;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SelectedButtonStyle.SetNormal(FSlateBoxBrush(FUtils::GetResourcesPath("CurtainSelected.png", true), FMargin(1.0), FLinearColor(88.0/255,96.0/255,121.0/255,1.0f)));
|
||||
FTextBlockStyle TitleText = FAppStyle::GetWidgetStyle<FTextBlockStyle>("NormalText");
|
||||
TitleText.SetFontSize(15);
|
||||
|
||||
|
||||
ChildSlot
|
||||
[
|
||||
SNew(SBox)
|
||||
@ -39,10 +38,9 @@ void SCurtain::Construct(const FArguments& InArgs)
|
||||
[
|
||||
SAssignNew(CurtainButton, SButton)
|
||||
.ClickMethod(EButtonClickMethod::MouseDown)
|
||||
.ButtonStyle(FUtils::GetInstance()->GetCurtainSelectedButton())
|
||||
.ButtonStyle(FCutButtonStyle::Get(), Curtain->bIsActive ? "Curtain.CurtainButtonSelected" : "Curtain.CurtainButton")
|
||||
.OnClicked_Lambda([this]()
|
||||
{
|
||||
|
||||
CurtainPanel->DeSelectedAll();
|
||||
Curtain->bIsActive = true;
|
||||
CurtainPanel->CallRender();
|
||||
@ -53,7 +51,6 @@ void SCurtain::Construct(const FArguments& InArgs)
|
||||
CurtainDragDrop->DragDropType = FCutDragDropBase::EType::CurtainDrag;
|
||||
CurtainDragDrop->DraggingWidget = SharedThis(this);
|
||||
return FReply::Handled().DetectDrag(SharedThis(this), EKeys::LeftMouseButton).BeginDragDrop(CurtainDragDrop.ToSharedRef());
|
||||
return FReply::Handled();
|
||||
})
|
||||
]
|
||||
+ SOverlay::Slot()
|
||||
|
93
Source/Cut5/Widgets/Style/CutButtonWidgetStyle.cpp
Normal file
93
Source/Cut5/Widgets/Style/CutButtonWidgetStyle.cpp
Normal file
@ -0,0 +1,93 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "CutButtonWidgetStyle.h"
|
||||
|
||||
#include "Cut5/Utils/Utils.h"
|
||||
#include "Styling/SlateStyleRegistry.h"
|
||||
#include "Styling/SlateTypes.h"
|
||||
#include "Styling/CoreStyle.h"
|
||||
|
||||
TSharedPtr< FSlateStyleSet > FCutButtonStyle::StyleInstance = nullptr;
|
||||
|
||||
#define IMAGE_BRUSH( RelativePath, ... ) FSlateImageBrush(Style->RootToContentDir(RelativePath, TEXT(".png")), __VA_ARGS__)
|
||||
#define BOX_BRUSH( RelativePath, ... ) FSlateBoxBrush(Style->RootToContentDir(RelativePath, TEXT(".png")), __VA_ARGS__)
|
||||
#define BORDER_BRUSH( RelativePath, ... ) FSlateBorderBrush(Style->RootToContentDir(RelativePath, TEXT(".png")), __VA_ARGS__)
|
||||
#define DEFAULT_FONT(...) FCoreStyle::GetDefaultFontStyle(__VA_ARGS__)
|
||||
|
||||
|
||||
void FCutButtonStyle::Initialize()
|
||||
{
|
||||
if (!StyleInstance.IsValid())
|
||||
{
|
||||
StyleInstance = Create();
|
||||
FSlateStyleRegistry::RegisterSlateStyle(*StyleInstance);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FCutButtonStyle::Shutdown()
|
||||
{
|
||||
FSlateStyleRegistry::UnRegisterSlateStyle(*StyleInstance);
|
||||
ensure(StyleInstance.IsUnique());
|
||||
StyleInstance.Reset();
|
||||
}
|
||||
|
||||
|
||||
FName FCutButtonStyle::GetStyleSetName()
|
||||
{
|
||||
static FName StyleSetName(TEXT("SlateFileDialogsStyle"));
|
||||
return StyleSetName;
|
||||
}
|
||||
|
||||
|
||||
const FSlateStyleSet *FCutButtonStyle::Get()
|
||||
{
|
||||
return StyleInstance.Get();
|
||||
}
|
||||
|
||||
|
||||
TSharedPtr< FSlateStyleSet > FCutButtonStyle::Create()
|
||||
{
|
||||
TSharedPtr< FSlateStyleSet > Style = MakeShareable(new FSlateStyleSet(FCutButtonStyle::GetStyleSetName()));
|
||||
Style->SetContentRoot(FPaths::ConvertRelativePathToFull(FPaths::Combine(FPaths::ProjectDir(), "Resources")));
|
||||
|
||||
|
||||
|
||||
const FSlateColor InvertedForeground(FLinearColor(0.0f, 0.0f, 0.0f));
|
||||
const FSlateColor SelectionColor(FLinearColor(0.701f, 0.225f, 0.003f));
|
||||
const FSlateColor SelectionColor_Inactive(FLinearColor(0.25f, 0.25f, 0.25f));
|
||||
const FSlateColor SelectionColor_Pressed(FLinearColor(0.701f, 0.225f, 0.003f));
|
||||
|
||||
|
||||
// SButton defaults...
|
||||
const FButtonStyle Button = FButtonStyle()
|
||||
.SetNormal( BOX_BRUSH( "CurtainNormal", FVector2D(240,32), 0.25 ))
|
||||
.SetHovered( BOX_BRUSH( "CurtainHover", FVector2D(240,32), 0.25) )
|
||||
.SetPressed( BOX_BRUSH( "CurtainSelected", FVector2D(240,32), 0.25) )
|
||||
.SetDisabled( BOX_BRUSH( "CurtainSelected", FVector2D(240,32), 0.25) )
|
||||
.SetNormalPadding( FMargin( 2,2,2,2 ) )
|
||||
.SetPressedPadding( FMargin( 2,3,2,1 ) );
|
||||
{
|
||||
Style->Set( "Button", Button );
|
||||
Style->Set( "InvertedForeground", InvertedForeground );
|
||||
}
|
||||
|
||||
Style->Set("Curtain.CurtainButton", FButtonStyle(Button)
|
||||
.SetNormal( BOX_BRUSH( "CurtainNormal", FVector2D(240,32), 0.25) )
|
||||
.SetHovered( BOX_BRUSH( "CurtainHover", FVector2D(240,32), 0.25) )
|
||||
.SetPressed( BOX_BRUSH( "CurtainSelected", FVector2D(240,32), 0.25) )
|
||||
.SetDisabled( BOX_BRUSH( "CurtainSelected", FVector2D(240,32), 0.25) )
|
||||
);
|
||||
|
||||
Style->Set("Curtain.CurtainButtonSelected", FButtonStyle(Button)
|
||||
.SetNormal( BOX_BRUSH( "CurtainSelected", FVector2D(240,32), 0.25) )
|
||||
);
|
||||
|
||||
return Style;
|
||||
}
|
||||
|
||||
|
||||
#undef IMAGE_BRUSH
|
||||
#undef BOX_BRUSH
|
||||
#undef BORDER_BRUSH
|
||||
#undef DEFAULT_FONT
|
31
Source/Cut5/Widgets/Style/CutButtonWidgetStyle.h
Normal file
31
Source/Cut5/Widgets/Style/CutButtonWidgetStyle.h
Normal file
@ -0,0 +1,31 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Fonts/SlateFontInfo.h"
|
||||
#include "Styling/SlateStyle.h"
|
||||
|
||||
|
||||
class FCutButtonStyle
|
||||
{
|
||||
public:
|
||||
static void Initialize();
|
||||
static void Shutdown();
|
||||
static const FSlateStyleSet *Get();
|
||||
static FName GetStyleSetName();
|
||||
|
||||
static const FSlateBrush * GetBrush(FName PropertyName, const ANSICHAR* Specifier = NULL)
|
||||
{
|
||||
return StyleInstance->GetBrush(PropertyName, Specifier);
|
||||
}
|
||||
|
||||
static FSlateFontInfo GetFontStyle(FName PropertyName, const ANSICHAR* Specifier = NULL)
|
||||
{
|
||||
return StyleInstance->GetFontStyle(PropertyName, Specifier);
|
||||
}
|
||||
|
||||
private:
|
||||
static TSharedPtr<class FSlateStyleSet> Create();
|
||||
static TSharedPtr<class FSlateStyleSet> StyleInstance;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user