Files
UnrealEngineUWP/Engine/Source/Editor/UMGEditor/Private/Designer/SZoomPan.cpp
Patrick Boutot f5c5fbd459 Slate: Convert SCompoundWidget and SBox attributes to SlateAttribute. Mark TSupportsContentPaddingMixin::SlotPadding as deprecated to move it to private later.
#review vincent.gauthier
#preflight 60783dbd06b89e000178adb1

[CL 16025206 by Patrick Boutot in ue5-main branch]
2021-04-15 15:42:34 -04:00

52 lines
1.4 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Designer/SZoomPan.h"
#include "Layout/LayoutUtils.h"
/////////////////////////////////////////////////////
// SZoomPan
void SZoomPan::Construct(const FArguments& InArgs)
{
bHasRelativeLayoutScale = true;
ViewOffset = InArgs._ViewOffset;
ZoomAmount = InArgs._ZoomAmount;
ChildSlot
[
InArgs._Content.Widget
];
}
void SZoomPan::SetContent(const TSharedRef< SWidget >& InContent)
{
ChildSlot
[
InContent
];
}
void SZoomPan::OnArrangeChildren(const FGeometry& AllottedGeometry, FArrangedChildren& ArrangedChildren) const
{
const EVisibility ChildVisibility = ChildSlot.GetWidget()->GetVisibility();
if ( ArrangedChildren.Accepts(ChildVisibility) )
{
const FMargin SlotPadding(ChildSlot.GetPadding());
AlignmentArrangeResult XResult = AlignChild<Orient_Horizontal>(AllottedGeometry.Size.X, ChildSlot, SlotPadding, 1);
AlignmentArrangeResult YResult = AlignChild<Orient_Vertical>(AllottedGeometry.Size.Y, ChildSlot, SlotPadding, 1);
ArrangedChildren.AddWidget( ChildVisibility, AllottedGeometry.MakeChild(
ChildSlot.GetWidget(),
FVector2D(XResult.Offset, YResult.Offset) - ViewOffset.Get(),
ChildSlot.GetWidget()->GetDesiredSize(),
ZoomAmount.Get()
) );
}
}
float SZoomPan::GetRelativeLayoutScale(int32 ChildIndex, float LayoutScaleMultiplier) const
{
return ZoomAmount.Get();
}