You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
[FYI] vincent.gauthier #ROBOMERGE-AUTHOR: patrick.boutot #ROBOMERGE-SOURCE: CL 20142060 via CL 20143142 via CL 20143633 #ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690) [CL 20148091 by patrick boutot in ue5-main branch]
174 lines
3.7 KiB
C++
174 lines
3.7 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "Components/ScaleBox.h"
|
|
#include "Components/ScaleBoxSlot.h"
|
|
#include "UObject/EditorObjectVersion.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "UMG"
|
|
|
|
/////////////////////////////////////////////////////
|
|
// UScaleBox
|
|
|
|
UScaleBox::UScaleBox(const FObjectInitializer& ObjectInitializer)
|
|
: Super(ObjectInitializer)
|
|
{
|
|
bIsVariable = false;
|
|
SetVisibilityInternal(ESlateVisibility::SelfHitTestInvisible);
|
|
|
|
StretchDirection = EStretchDirection::Both;
|
|
Stretch = EStretch::ScaleToFit;
|
|
UserSpecifiedScale = 1.0f;
|
|
IgnoreInheritedScale = false;
|
|
}
|
|
|
|
void UScaleBox::ReleaseSlateResources(bool bReleaseChildren)
|
|
{
|
|
Super::ReleaseSlateResources(bReleaseChildren);
|
|
|
|
MyScaleBox.Reset();
|
|
}
|
|
|
|
TSharedRef<SWidget> UScaleBox::RebuildWidget()
|
|
{
|
|
MyScaleBox = SNew(SScaleBox)
|
|
#if WITH_EDITOR
|
|
.OverrideScreenSize(DesignerSize)
|
|
#endif
|
|
;
|
|
|
|
if ( GetChildrenCount() > 0 )
|
|
{
|
|
CastChecked<UScaleBoxSlot>(GetContentSlot())->BuildSlot(MyScaleBox.ToSharedRef());
|
|
}
|
|
|
|
return MyScaleBox.ToSharedRef();
|
|
}
|
|
|
|
void UScaleBox::SetStretch(EStretch::Type InStretch)
|
|
{
|
|
Stretch = InStretch;
|
|
if(MyScaleBox.IsValid())
|
|
{
|
|
MyScaleBox->SetStretch(InStretch);
|
|
}
|
|
}
|
|
|
|
void UScaleBox::SetStretchDirection(EStretchDirection::Type InStretchDirection)
|
|
{
|
|
StretchDirection = InStretchDirection;
|
|
if (MyScaleBox.IsValid())
|
|
{
|
|
MyScaleBox->SetStretchDirection(InStretchDirection);
|
|
}
|
|
}
|
|
|
|
void UScaleBox::SetUserSpecifiedScale(float InUserSpecifiedScale)
|
|
{
|
|
UserSpecifiedScale = InUserSpecifiedScale;
|
|
if (MyScaleBox.IsValid())
|
|
{
|
|
MyScaleBox->SetUserSpecifiedScale(InUserSpecifiedScale);
|
|
}
|
|
}
|
|
|
|
void UScaleBox::SetIgnoreInheritedScale(bool bInIgnoreInheritedScale)
|
|
{
|
|
IgnoreInheritedScale = bInIgnoreInheritedScale;
|
|
if (MyScaleBox.IsValid())
|
|
{
|
|
MyScaleBox->SetIgnoreInheritedScale(bInIgnoreInheritedScale);
|
|
}
|
|
}
|
|
|
|
void UScaleBox::SynchronizeProperties()
|
|
{
|
|
Super::SynchronizeProperties();
|
|
|
|
MyScaleBox->SetStretchDirection(StretchDirection);
|
|
MyScaleBox->SetStretch(Stretch);
|
|
MyScaleBox->SetUserSpecifiedScale(UserSpecifiedScale);
|
|
MyScaleBox->SetIgnoreInheritedScale(IgnoreInheritedScale);
|
|
}
|
|
|
|
UClass* UScaleBox::GetSlotClass() const
|
|
{
|
|
return UScaleBoxSlot::StaticClass();
|
|
}
|
|
|
|
void UScaleBox::OnSlotAdded(UPanelSlot* InSlot)
|
|
{
|
|
// Add the child to the live slot if it already exists
|
|
if ( MyScaleBox.IsValid() )
|
|
{
|
|
CastChecked<UScaleBoxSlot>(InSlot)->BuildSlot(MyScaleBox.ToSharedRef());
|
|
}
|
|
}
|
|
|
|
void UScaleBox::OnSlotRemoved(UPanelSlot* InSlot)
|
|
{
|
|
// Remove the widget from the live slot if it exists.
|
|
if ( MyScaleBox.IsValid() )
|
|
{
|
|
MyScaleBox->SetContent(SNullWidget::NullWidget);
|
|
}
|
|
}
|
|
|
|
void UScaleBox::Serialize(FArchive& Ar)
|
|
{
|
|
Super::Serialize(Ar);
|
|
|
|
Ar.UsingCustomVersion(FEditorObjectVersion::GUID);
|
|
}
|
|
|
|
#if WITH_EDITOR
|
|
|
|
const FText UScaleBox::GetPaletteCategory()
|
|
{
|
|
return LOCTEXT("Panel", "Panel");
|
|
}
|
|
|
|
bool UScaleBox::CanEditChange(const FProperty* InProperty) const
|
|
{
|
|
bool bIsEditable = Super::CanEditChange(InProperty);
|
|
if (bIsEditable && InProperty)
|
|
{
|
|
const FName PropertyName = InProperty->GetFName();
|
|
|
|
if (PropertyName == GET_MEMBER_NAME_CHECKED(UScaleBox, StretchDirection))
|
|
{
|
|
return Stretch != EStretch::None && Stretch != EStretch::ScaleBySafeZone && Stretch != EStretch::UserSpecified;
|
|
}
|
|
|
|
if (PropertyName == GET_MEMBER_NAME_CHECKED(UScaleBox, UserSpecifiedScale))
|
|
{
|
|
return Stretch == EStretch::UserSpecified;
|
|
}
|
|
}
|
|
|
|
return bIsEditable;
|
|
}
|
|
|
|
|
|
void UScaleBox::OnDesignerChanged(const FDesignerChangedEventArgs& EventArgs)
|
|
{
|
|
if (EventArgs.bScreenPreview)
|
|
{
|
|
DesignerSize = EventArgs.Size;
|
|
}
|
|
else
|
|
{
|
|
DesignerSize = FVector2D(0, 0);
|
|
}
|
|
|
|
if (MyScaleBox.IsValid())
|
|
{
|
|
MyScaleBox->SetOverrideScreenInformation(DesignerSize);
|
|
}
|
|
}
|
|
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////
|
|
|
|
#undef LOCTEXT_NAMESPACE
|