Fix compile errors after removing boost function include from dali-core
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / slider / slider-impl.cpp
index d5d1596..4c1b2fa 100755 (executable)
@@ -19,7 +19,9 @@
 #include <dali-toolkit/internal/controls/slider/slider-impl.h>
 
 // EXTERNAL INCLUDES
+#include <cstring> // for strcmp
 #include <sstream>
+#include <limits>
 #include <dali/public-api/events/touch-event.h>
 #include <dali/public-api/object/type-registry.h>
 #include <dali/public-api/object/type-registry-helper.h>
@@ -348,7 +350,14 @@ void Slider::DisplayValue( float value, bool raiseSignals )
     }
   }
 
-  // TODO
+  if( mHandleValueTextLabel )
+  {
+    std::stringstream ss;
+    ss.precision( GetValuePrecision() );
+    ss << std::fixed << clampledValue;
+
+    mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, ss.str() );
+  }
 }
 
 void Slider::SetMarks( const MarkList& marks )
@@ -516,9 +525,16 @@ ImageActor Slider::CreatePopupArrow()
   return arrow;
 }
 
-//Toolkit::TextView Slider::CreatePopupText()
-//{
-//}
+Toolkit::TextLabel Slider::CreatePopupText()
+{
+  Toolkit::TextLabel textLabel = Toolkit::TextLabel::New();
+  textLabel.SetParentOrigin( ParentOrigin::CENTER );
+  textLabel.SetAnchorPoint( AnchorPoint::CENTER );
+  textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+  textLabel.SetZ( VALUE_DISPLAY_TEXT_Z );
+  return textLabel;
+}
 
 ImageActor Slider::CreatePopup()
 {
@@ -527,6 +543,9 @@ ImageActor Slider::CreatePopup()
   popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
   popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
 
+  mValueTextLabel = CreatePopupText();
+  popup.Add( mValueTextLabel );
+
   return popup;
 }
 
@@ -559,10 +578,21 @@ void Slider::ResizeHandleRegion( const Vector2& region )
 
 void Slider::CreateHandleValueDisplay()
 {
+  if( mHandle && !mHandleValueTextLabel )
+  {
+    mHandleValueTextLabel = Toolkit::TextLabel::New();
+    mHandleValueTextLabel.SetParentOrigin( ParentOrigin::CENTER );
+    mHandleValueTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
+    mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+    mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+    mHandleValueTextLabel.SetDrawMode( DrawMode::OVERLAY );
+    mHandle.Add( mHandleValueTextLabel );
+  }
 }
 
 void Slider::DestroyHandleValueDisplay()
 {
+  UnparentAndReset(mHandleValueTextLabel);
 }
 
 void Slider::SetPopupTextColor( const Vector4& color )
@@ -988,6 +1018,21 @@ bool Slider::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tr
 
 void Slider::DisplayPopup( float value )
 {
+  // Value displayDoConnectSignal
+  if( mValueTextLabel )
+  {
+    std::stringstream ss;
+    ss.precision( GetValuePrecision() );
+    ss << std::fixed << value;
+    mValueTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, ss.str() );
+
+    if( mValueDisplay )
+    {
+      mValueDisplay.SetVisible( true );
+
+      mValueTimer.SetInterval( VALUE_VIEW_SHOW_DURATION );
+    }
+  }
 }
 
 void Slider::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value )