// Copyright Epic Games, Inc. All Rights Reserved. #include "Binding/CheckedStateBinding.h" #include "Styling/SlateTypes.h" #include UE_INLINE_GENERATED_CPP_BY_NAME(CheckedStateBinding) #define LOCTEXT_NAMESPACE "UMG" UCheckedStateBinding::UCheckedStateBinding() { } bool UCheckedStateBinding::IsSupportedSource(FProperty* Property) const { return IsSupportedDestination(Property) || IsConcreteTypeCompatibleWithReflectedType(Property); } bool UCheckedStateBinding::IsSupportedDestination(FProperty* Property) const { static const FName CheckBoxStateEnum(TEXT("ECheckBoxState")); if ( FEnumProperty* EnumProperty = CastField(Property) ) { return EnumProperty->GetEnum()->GetFName() == CheckBoxStateEnum; } else if ( FByteProperty* ByteProperty = CastField(Property) ) { if ( ByteProperty->IsEnum() ) { return ByteProperty->Enum->GetFName() == CheckBoxStateEnum; } } return false; } ECheckBoxState UCheckedStateBinding::GetValue() const { //SCOPE_CYCLE_COUNTER(STAT_UMGBinding); if ( UObject* Source = SourceObject.Get() ) { if ( bConversion.Get(EConversion::None) == EConversion::None ) { uint8 Value = 0; if ( SourcePath.GetValue(Source, Value) ) { bConversion = EConversion::None; return static_cast(Value); } } if ( bConversion.Get(EConversion::Bool) == EConversion::Bool ) { bool Value = false; if ( SourcePath.GetValue(Source, Value) ) { bConversion = EConversion::Bool; return Value ? ECheckBoxState::Checked : ECheckBoxState::Unchecked; } } } return ECheckBoxState::Unchecked; } #undef LOCTEXT_NAMESPACE