Files
UnrealEngineUWP/Engine/Source/Editor/UMGEditor/Private/Customizations/TextJustifyCustomization.cpp
Ben Marsh 149375b14b Update copyright notices to 2015.
[CL 2379638 by Ben Marsh in Main branch]
2014-12-07 19:09:38 -05:00

100 lines
3.1 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "UMGEditorPrivatePCH.h"
#include "PropertyEditing.h"
#include "ObjectEditorUtils.h"
#include "WidgetGraphSchema.h"
#include "ScopedTransaction.h"
#include "BlueprintEditorUtils.h"
#include "TextJustifyCustomization.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("HAlignLeft", "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("HAlignCenter", "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("HAlignRight", "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(ESlateCheckBoxState::Type InCheckboxState, TSharedRef<IPropertyHandle> PropertyHandle, ETextJustify::Type ToAlignment)
{
PropertyHandle->SetValue((uint8)ToAlignment);
}
ESlateCheckBoxState::Type FTextJustifyCustomization::GetCheckState(TSharedRef<IPropertyHandle> PropertyHandle, ETextJustify::Type ForAlignment) const
{
uint8 Value;
if ( PropertyHandle->GetValue(Value) )
{
return Value == ForAlignment ? ESlateCheckBoxState::Checked : ESlateCheckBoxState::Unchecked;
}
return ESlateCheckBoxState::Unchecked;
}
#undef LOCTEXT_NAMESPACE