You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#rb vincent.gauthier #preflight 621cc32a9a5676d19a301114 #ROBOMERGE-OWNER: patrick.boutot #ROBOMERGE-AUTHOR: patrick.boutot #ROBOMERGE-SOURCE: CL 19172743 via CL 19172838 via CL 19172865 via CL 19173039 via CL 19173047 via CL 19173891 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v921-19075845) [CL 19174092 by patrick boutot in ue5-main branch]
134 lines
3.0 KiB
C++
134 lines
3.0 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Components/ScrollBar.h"
|
|
#include "UObject/EditorObjectVersion.h"
|
|
#include "Styling/UMGCoreStyle.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UMG"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UScrollBar
|
|
|
|
namespace
|
|
{
|
|
static FScrollBarStyle* DefaultScrollBarStyle = nullptr;
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
static FScrollBarStyle* EditorScrollBarStyle = nullptr;
|
|
#endif
|
|
|
|
UScrollBar::UScrollBar(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
bIsVariable = false;
|
|
|
|
bAlwaysShowScrollbar = true;
|
|
bAlwaysShowScrollbarTrack = true;
|
|
Orientation = Orient_Vertical;
|
|
Thickness = FVector2D(16.0f, 16.0f);
|
|
Padding = FMargin(2.0f);
|
|
|
|
if (DefaultScrollBarStyle == nullptr)
|
|
{
|
|
DefaultScrollBarStyle = new FScrollBarStyle(FUMGCoreStyle::Get().GetWidgetStyle<FScrollBarStyle>("Scrollbar"));
|
|
|
|
// Unlink UMG default colors.
|
|
DefaultScrollBarStyle->UnlinkColors();
|
|
}
|
|
|
|
WidgetStyle = *DefaultScrollBarStyle;
|
|
|
|
#if WITH_EDITOR
|
|
if (EditorScrollBarStyle == nullptr)
|
|
{
|
|
EditorScrollBarStyle = new FScrollBarStyle(FCoreStyle::Get().GetWidgetStyle<FScrollBarStyle>("Scrollbar"));
|
|
|
|
// Unlink UMG Editor colors from the editor settings colors.
|
|
EditorScrollBarStyle->UnlinkColors();
|
|
}
|
|
|
|
if (IsEditorWidget())
|
|
{
|
|
WidgetStyle = *EditorScrollBarStyle;
|
|
|
|
// The CDO isn't an editor widget and thus won't use the editor style, call post edit change to mark difference from CDO
|
|
PostEditChange();
|
|
}
|
|
#endif // WITH_EDITOR
|
|
}
|
|
|
|
void UScrollBar::ReleaseSlateResources(bool bReleaseChildren)
|
|
{
|
|
Super::ReleaseSlateResources(bReleaseChildren);
|
|
|
|
MyScrollBar.Reset();
|
|
}
|
|
|
|
TSharedRef<SWidget> UScrollBar::RebuildWidget()
|
|
{
|
|
MyScrollBar = SNew(SScrollBar)
|
|
.Style(&WidgetStyle)
|
|
.AlwaysShowScrollbar(bAlwaysShowScrollbar)
|
|
.AlwaysShowScrollbarTrack(bAlwaysShowScrollbarTrack)
|
|
.Orientation(Orientation)
|
|
.Thickness(Thickness)
|
|
.Padding(Padding);
|
|
|
|
//SLATE_EVENT(FOnUserScrolled, OnUserScrolled)
|
|
|
|
return MyScrollBar.ToSharedRef();
|
|
}
|
|
|
|
void UScrollBar::SynchronizeProperties()
|
|
{
|
|
Super::SynchronizeProperties();
|
|
|
|
//MyScrollBar->SetScrollOffset(DesiredScrollOffset);
|
|
}
|
|
|
|
void UScrollBar::SetState(float InOffsetFraction, float InThumbSizeFraction)
|
|
{
|
|
if ( MyScrollBar.IsValid() )
|
|
{
|
|
MyScrollBar->SetState(InOffsetFraction, InThumbSizeFraction);
|
|
}
|
|
}
|
|
|
|
#if WITH_EDITORONLY_DATA
|
|
|
|
void UScrollBar::Serialize(FArchive& Ar)
|
|
{
|
|
Ar.UsingCustomVersion(FEditorObjectVersion::GUID);
|
|
|
|
const bool bDeprecateThickness = Ar.IsLoading() && Ar.CustomVer(FEditorObjectVersion::GUID) < FEditorObjectVersion::ScrollBarThicknessChange;
|
|
if (bDeprecateThickness)
|
|
{
|
|
// Set Thickness property to previous default value.
|
|
Thickness.Set(12.0f, 12.0f);
|
|
}
|
|
|
|
Super::Serialize(Ar);
|
|
|
|
if (bDeprecateThickness)
|
|
{
|
|
// Implicit padding of 2 was removed, so Thickness value must be incremented by 4.
|
|
Thickness += FVector2D(4.0f, 4.0f);
|
|
}
|
|
}
|
|
|
|
#endif // if WITH_EDITORONLY_DATA
|
|
|
|
#if WITH_EDITOR
|
|
|
|
const FText UScrollBar::GetPaletteCategory()
|
|
{
|
|
return LOCTEXT("Primitive", "Primitive");
|
|
}
|
|
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|