/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <dali/public-api/events/touch-data.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
-#include <dali/public-api/images/resource-image.h>
+#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
// INTERNAL INCLUDES
#include <dali-toolkit/public-api/controls/control-impl.h>
const float VALUE_POPUP_MARGIN = 10.0f;
const float VALUE_POPUP_HEIGHT = 81.0f;
const float VALUE_POPUP_MIN_WIDTH = 54.0f;
-const Vector2 VALUE_POPUP_ARROW_SIZE( 18.0f, 18.0f );
const float DEFAULT_LOWER_BOUND = 0.0f;
const float DEFAULT_UPPER_BOUND = 1.0f;
}
Slider::Slider()
-: Control( ControlBehaviour( REQUIRES_STYLE_CHANGE_SIGNALS ) ),
+: Control( ControlBehaviour( CONTROL_BEHAVIOUR_DEFAULT ) ),
mState( NORMAL ),
mPopupVisual(""),
mPopupArrowVisual(""),
self.TouchSignal().Connect( this, &Slider::OnTouch );
}
-void Slider::OnSizeSet( const Vector3& size )
+void Slider::OnRelayout( const Vector2& size, RelayoutContainer& container )
{
- // Factor in handle overshoot into size of track
SetHitRegion( Vector2( size.x, GetHitRegion().y ) );
+ // Factor in handle overshoot into size of backing
SetTrackRegion( Vector2( size.x - GetHandleSize().x, GetTrackRegion().y ) );
+ Control::OnRelayout( size, container );
}
bool Slider::OnTouch(Actor actor, const TouchData& touch)
void Slider::DisplayValue( float value, bool raiseSignals )
{
- float clampledValue = Clamp( value, GetLowerBound(), GetUpperBound() );
+ float clampedValue = Clamp( value, GetLowerBound(), GetUpperBound() );
- float percent = MapValuePercentage( clampledValue );
+ float percent = MapValuePercentage( clampedValue );
float x = mDomain.from.x + percent * ( mDomain.to.x - mDomain.from.x );
if( raiseSignals )
{
Toolkit::Slider self = Toolkit::Slider::DownCast( Self() );
- mValueChangedSignal.Emit( self, clampledValue );
+ mValueChangedSignal.Emit( self, clampedValue );
int markIndex;
if( MarkReached( percent, markIndex ) )
{
std::stringstream ss;
ss.precision( GetValuePrecision() );
- ss << std::fixed << clampledValue;
+ ss << std::fixed << clampedValue;
- mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, ss.str() );
+ std::string label = mHandleValueTextLabel.GetProperty<std::string>( Toolkit::TextLabel::Property::TEXT );
+ if( label.compare(ss.str()) )
+ {
+ mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::TEXT, ss.str() );
+ }
}
}
Toolkit::ImageView Slider::CreateTrack()
{
Toolkit::ImageView track = Toolkit::ImageView::New();
+ track.SetName("SliderTrack");
track.SetParentOrigin( ParentOrigin::CENTER );
track.SetAnchorPoint( AnchorPoint::CENTER );
-
return track;
}
Toolkit::ImageView Slider::CreateProgress()
{
Toolkit::ImageView progress = Toolkit::ImageView::New();
+ progress.SetName("SliderProgress");
progress.SetParentOrigin( ParentOrigin::CENTER_LEFT );
progress.SetAnchorPoint( AnchorPoint::CENTER_LEFT );
{
if( mPopup && ( filename.size() > 0 ) )
{
- Image image = ResourceImage::New( filename );
- mPopup.SetImage( image );
+ Property::Map map;
+ map[Toolkit::ImageVisual::Property::URL] = filename;
+ mPopup.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
}
}
{
if( mPopupArrow && ( filename.size() > 0 ) )
{
- Image image = ResourceImage::New( filename );
- mPopupArrow.SetImage( image );
+ Property::Map map;
+ map[Toolkit::ImageVisual::Property::URL] = filename;
+ mPopupArrow.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
}
}
Toolkit::ImageView Slider::CreateHandle()
{
Toolkit::ImageView handle = Toolkit::ImageView::New();
+ handle.SetName("SliderHandle");
handle.SetParentOrigin( ParentOrigin::CENTER_LEFT );
handle.SetAnchorPoint( AnchorPoint::CENTER );
Toolkit::ImageView Slider::CreatePopupArrow()
{
Toolkit::ImageView arrow = Toolkit::ImageView::New();
+ arrow.SetStyleName("SliderPopupArrow");
+ arrow.SetName("SliderPopupArrow");
arrow.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
arrow.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
Toolkit::TextLabel Slider::CreatePopupText()
{
Toolkit::TextLabel textLabel = Toolkit::TextLabel::New();
+ textLabel.SetName( "SliderPopupTextLabel" );
+ textLabel.SetStyleName( "SliderPopupTextLabel" );
textLabel.SetParentOrigin( ParentOrigin::CENTER );
textLabel.SetAnchorPoint( AnchorPoint::CENTER );
textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
Toolkit::ImageView Slider::CreatePopup()
{
Toolkit::ImageView popup = Toolkit::ImageView::New();
+ popup.SetName( "SliderPopup" );
popup.SetParentOrigin( ParentOrigin::TOP_CENTER );
popup.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
popup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::WIDTH );
if( mHandle && !mHandleValueTextLabel )
{
mHandleValueTextLabel = Toolkit::TextLabel::New();
+ mHandleValueTextLabel.SetName("SliderHandleTextLabel");
+ mHandleValueTextLabel.SetStyleName("SliderHandleTextLabel");
mHandleValueTextLabel.SetParentOrigin( ParentOrigin::CENTER );
mHandleValueTextLabel.SetAnchorPoint( AnchorPoint::CENTER );
mHandleValueTextLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
case Toolkit::Slider::Property::MARKS:
{
- // TODO: Need to be able to return a PropertyArray
- // value = sliderImpl.GetMarks();
+ Property::Value value1( Property::ARRAY );
+ Property::Array* markArray = value1.GetArray();
+
+ if( markArray )
+ {
+ *markArray = sliderImpl.GetMarks();
+ }
+
+ value = value1;
break;
}