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