Size negotiation patch 4: Remove SetRelayoutEnabled
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / slider / slider-impl.cpp
index af62846..8acd72c 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>
@@ -94,6 +96,7 @@ const float DEFAULT_WIDTH = 0.0f;
 const float DEFAULT_HEIGHT = 27.0f;
 const float DEFAULT_HIT_HEIGHT = 72.0f;
 const float DEFAULT_HANDLE_HEIGHT = DEFAULT_HIT_HEIGHT;
+const float POPUP_TEXT_PADDING = 10.0f;
 
 const char* SKINNED_BACKING_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin.9.png";
 const char* SKINNED_HANDLE_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin-handle.png";;
@@ -347,6 +350,15 @@ void Slider::DisplayValue( float value, bool raiseSignals )
       mMarkSignal.Emit( self, markIndex );
     }
   }
+
+  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 )
@@ -510,15 +522,29 @@ 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.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
+  textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+  textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+  textLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, DEFAULT_POPUP_TEXT_COLOR );
+  textLabel.SetZ( VALUE_DISPLAY_TEXT_Z );
+  textLabel.SetPadding( Padding( POPUP_TEXT_PADDING, POPUP_TEXT_PADDING, 0.0f, 0.0f ) );
+  return textLabel;
+}
 
 ImageActor Slider::CreatePopup()
 {
   ImageActor popup = ImageActor::New();
   popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
   popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
+  popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH );
+
+  mValueTextLabel = CreatePopupText();
+  popup.Add( mValueTextLabel );
 
   return popup;
 }
@@ -552,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 )
@@ -981,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 )