Files
UnrealEngineUWP/Engine/Source/Editor/UMGEditor/Private/Customizations/TextJustifyCustomization.cpp
Ben Marsh 20bf0eb6a1 Updating copyright notices to 2017 (copying from //Tasks/UE4/Dev-Copyright-2017).
#rb none
#lockdown Nick.Penwarden

[CL 3226823 by Ben Marsh in Main branch]
2016-12-08 08:52:44 -05:00

96 lines
3.0 KiB
C++

// Copyright 1998-2017 Epic Games, Inc. All Rights Reserved.
#include "Customizations/TextJustifyCustomization.h"
#include "Widgets/Images/SImage.h"
#include "Widgets/Input/SCheckBox.h"
#include "DetailWidgetRow.h"
#define LOCTEXT_NAMESPACE "UMG"
void FTextJustifyCustomization::CustomizeHeader(TSharedRef<IPropertyHandle> PropertyHandle, FDetailWidgetRow& HeaderRow, IPropertyTypeCustomizationUtils& CustomizationUtils)
{
const FMargin OuterPadding(2);
const FMargin ContentPadding(2);
HeaderRow
.NameContent()
[
PropertyHandle->CreatePropertyNameWidget()
]
.ValueContent()
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.AutoWidth()
.Padding(OuterPadding)
[
SNew( SCheckBox )
.Style(FEditorStyle::Get(), "ToggleButtonCheckbox")
.ToolTipText(LOCTEXT("AlignTextLeft", "Align Text Left"))
.Padding(ContentPadding)
.OnCheckStateChanged(this, &FTextJustifyCustomization::HandleCheckStateChanged, PropertyHandle, ETextJustify::Left)
.IsChecked(this, &FTextJustifyCustomization::GetCheckState, PropertyHandle, ETextJustify::Left)
[
SNew(SImage)
.Image(FEditorStyle::GetBrush("HorizontalAlignment_Left"))
]
]
+ SHorizontalBox::Slot()
.AutoWidth()
.Padding(OuterPadding)
[
SNew(SCheckBox)
.Style(FEditorStyle::Get(), "ToggleButtonCheckbox")
.ToolTipText(LOCTEXT("AlignTextCenter", "Align Text Center"))
.Padding(ContentPadding)
.OnCheckStateChanged(this, &FTextJustifyCustomization::HandleCheckStateChanged, PropertyHandle, ETextJustify::Center)
.IsChecked(this, &FTextJustifyCustomization::GetCheckState, PropertyHandle, ETextJustify::Center)
[
SNew(SImage)
.Image(FEditorStyle::GetBrush("HorizontalAlignment_Center"))
]
]
+ SHorizontalBox::Slot()
.AutoWidth()
.Padding(OuterPadding)
[
SNew(SCheckBox)
.Style(FEditorStyle::Get(), "ToggleButtonCheckbox")
.ToolTipText(LOCTEXT("AlignTextRight", "Align Text Right"))
.Padding(ContentPadding)
.OnCheckStateChanged(this, &FTextJustifyCustomization::HandleCheckStateChanged, PropertyHandle, ETextJustify::Right)
.IsChecked(this, &FTextJustifyCustomization::GetCheckState, PropertyHandle, ETextJustify::Right)
[
SNew(SImage)
.Image(FEditorStyle::GetBrush("HorizontalAlignment_Right"))
]
]
];
}
void FTextJustifyCustomization::CustomizeChildren(TSharedRef<IPropertyHandle> PropertyHandle, IDetailChildrenBuilder& ChildBuilder, IPropertyTypeCustomizationUtils& CustomizationUtils)
{
}
void FTextJustifyCustomization::HandleCheckStateChanged(ECheckBoxState InCheckboxState, TSharedRef<IPropertyHandle> PropertyHandle, ETextJustify::Type ToAlignment)
{
PropertyHandle->SetValue((uint8)ToAlignment);
}
ECheckBoxState FTextJustifyCustomization::GetCheckState(TSharedRef<IPropertyHandle> PropertyHandle, ETextJustify::Type ForAlignment) const
{
uint8 Value;
if ( PropertyHandle->GetValue(Value) )
{
return Value == ForAlignment ? ECheckBoxState::Checked : ECheckBoxState::Unchecked;
}
return ECheckBoxState::Unchecked;
}
#undef LOCTEXT_NAMESPACE