text: // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
  
  #include "UMGPrivatePCH.h"
  
  #define LOCTEXT_NAMESPACE "UMG"
  
  /////////////////////////////////////////////////////
  // USlider
  
  USlider::USlider(const FObjectInitializer& ObjectInitializer)
  	: Super(ObjectInitializer)
  {
  	Orientation = EOrientation::Orient_Horizontal;
  	SliderBarColor = FLinearColor::White;
  	SliderHandleColor = FLinearColor::White;
  
  	SSlider::FArguments Defaults;
  	WidgetStyle = *Defaults._Style;
  }
  
  TSharedRef<SWidget> USlider::RebuildWidget()
  {
  	MySlider = SNew(SSlider)
  		.Style(&WidgetStyle)
  		.OnMouseCaptureBegin(BIND_UOBJECT_DELEGATE(FSimpleDelegate, HandleOnMouseCaptureBegin))
  		.OnMouseCaptureEnd(BIND_UOBJECT_DELEGATE(FSimpleDelegate, HandleOnMouseCaptureEnd))
  		.OnValueChanged(BIND_UOBJECT_DELEGATE(FOnFloatValueChanged, HandleOnValueChanged));
  
  	return MySlider.ToSharedRef();
  }
  
  void USlider::SynchronizeProperties()
  {
  	Super::SynchronizeProperties();
  
  	TAttribute<float> ValueBinding = OPTIONAL_BINDING(float, Value);
  	
  	MySlider->SetOrientation(Orientation);
  	MySlider->SetSliderBarColor(SliderBarColor);
  	MySlider->SetSliderHandleColor(SliderHandleColor);
  	MySlider->SetValue(ValueBinding);
  }
  
  void USlider::HandleOnValueChanged(float InValue)
  {
  	OnValueChanged.Broadcast(InValue);
  }
  
  void USlider::HandleOnMouseCaptureBegin()
  {
  	OnMouseCaptureBegin.Broadcast();
  }
  
  void USlider::HandleOnMouseCaptureEnd()
  {
  	OnMouseCaptureEnd.Broadcast();
  }
  
  float USlider::GetValue() const
  {
  	if ( MySlider.IsValid() )
  	{
  		return MySlider->GetValue();
  	}
  
  	return Value;
  }
  
  void USlider::SetValue(float InValue)
  {
  	Value = InValue;
  	if ( MySlider.IsValid() )
  	{
  		MySlider->SetValue(InValue);
  	}
  }
  
  #if WITH_EDITOR
  
  const FSlateBrush* USlider::GetEditorIcon()
  {
  	return FUMGStyle::Get().GetBrush("Widget.Slider");
  }
  
  const FText USlider::GetPaletteCategory()
  {
  	return LOCTEXT("Common", "Common");
  }
  
  #endif
  
  /////////////////////////////////////////////////////
  
  #undef LOCTEXT_NAMESPACE
  