Files
UnrealEngineUWP/Engine/Source/Editor/UMGEditor/Private/Customizations/VerticalAlignmentCustomization.cpp
Lauren Barnes 6248f8d412 Replacing legacy EditorStyle calls with AppStyle
#preflight 6272a74d2f6d177be3c6fdda
#rb Matt.Kuhlenschmidt

#ROBOMERGE-OWNER: Lauren.Barnes
#ROBOMERGE-AUTHOR: lauren.barnes
#ROBOMERGE-SOURCE: CL 20057269 via CL 20070159 via CL 20072035 via CL 20072203
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v943-19904690)
#ROBOMERGE-CONFLICT from-shelf

[CL 20105363 by Lauren Barnes in ue5-main branch]
2022-05-09 13:12:28 -04:00

70 lines
2.6 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "Customizations/VerticalAlignmentCustomization.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Engine/GameViewportClient.h"
#include "Widgets/SBoxPanel.h"
#include "Styling/SlateTypes.h"
#include "Widgets/Images/SImage.h"
#include "Widgets/Input/SCheckBox.h"
#include "PropertyHandle.h"
#include "DetailWidgetRow.h"
#include "Framework/Application/SlateApplication.h"
#include "Widgets/Input/SSegmentedControl.h"
#define LOCTEXT_NAMESPACE "UMG"
void FVerticalAlignmentCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> PropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& CustomizationUtils)
{
const FMargin OuterPadding(2);
const FMargin ContentPadding(2);
HeaderRow
.NameContent()
[
PropertyHandle->CreatePropertyNameWidget()
]
.ValueContent()
.MaxDesiredWidth(0)
[
SNew(SSegmentedControl<EVerticalAlignment>)
.Value(this, &FVerticalAlignmentCustomization::GetCurrentAlignment, PropertyHandle)
.OnValueChanged(this, &FVerticalAlignmentCustomization::OnCurrentAlignmentChanged, PropertyHandle)
+ SSegmentedControl<EVerticalAlignment>::Slot(EVerticalAlignment::VAlign_Top)
.Icon(FAppStyle::GetBrush("VerticalAlignment_Top"))
.ToolTip(LOCTEXT("VAlignTop", "Top Align Vertically"))
+ SSegmentedControl<EVerticalAlignment>::Slot(EVerticalAlignment::VAlign_Center)
.Icon(FAppStyle::GetBrush("VerticalAlignment_Center"))
.ToolTip(LOCTEXT("VAlignCenter", "Center Align Vertically"))
+ SSegmentedControl<EVerticalAlignment>::Slot(EVerticalAlignment::VAlign_Bottom)
.Icon(FAppStyle::GetBrush("VerticalAlignment_Bottom"))
.ToolTip(LOCTEXT("VAlignBottom", "Bottom Align Vertically"))
+ SSegmentedControl<EVerticalAlignment>::Slot(EVerticalAlignment::VAlign_Fill)
.Icon(FAppStyle::GetBrush("VerticalAlignment_Fill"))
.ToolTip(LOCTEXT("VAlignFill", "Fill Vertically"))
];
}
void FVerticalAlignmentCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> PropertyHandle, IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& CustomizationUtils)
{
}
EVerticalAlignment FVerticalAlignmentCustomization::GetCurrentAlignment(TSharedRef<IPropertyHandle> PropertyHandle) const
{
uint8 Value;
if (PropertyHandle->GetValue(Value) == FPropertyAccess::Result::Success)
{
return (EVerticalAlignment)Value;
}
return VAlign_Fill;
}
void FVerticalAlignmentCustomization::OnCurrentAlignmentChanged(EVerticalAlignment NewAlignment, TSharedRef<IPropertyHandle> PropertyHandle)
{
PropertyHandle->SetValue((uint8)NewAlignment);
}
#undef LOCTEXT_NAMESPACE