From: Kingsley Stephens Date: Fri, 2 May 2014 12:48:31 +0000 (+0100) Subject: (Slider) Update slider properties to new property system X-Git-Tag: dali-2014-wk20-release~14 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=23374ab802a79da0a932f825021e66d069b4442e (Slider) Update slider properties to new property system [Issue#] N/A [Problem] The property system has been updated [Cause] New properties [Solution] Move over to using new property registration sytem Change-Id: Id067026c88edc97a26573fa5fe205c7106906756 --- diff --git a/automated-tests/TET/dali-test-suite/slider/utc-Dali-Slider.cpp b/automated-tests/TET/dali-test-suite/slider/utc-Dali-Slider.cpp index 13cd708..6028669 100644 --- a/automated-tests/TET/dali-test-suite/slider/utc-Dali-Slider.cpp +++ b/automated-tests/TET/dali-test-suite/slider/utc-Dali-Slider.cpp @@ -161,8 +161,8 @@ static void UtcDaliSliderSignals() { marks.push_back( MIN_BOUND + ( static_cast(i) / ( NUM_MARKS - 1) ) * ( MAX_BOUND - MIN_BOUND ) ); } - slider.SetProperty( slider.GetPropertyIndex( Slider::MARKS_PROPERTY_NAME ), marks ); - slider.SetProperty( slider.GetPropertyIndex( Slider::MARK_TOLERANCE_PROPERTY_NAME ), 0.1f ); + slider.SetProperty( Slider::MARKS_PROPERTY, marks ); + slider.SetProperty( Slider::MARK_TOLERANCE_PROPERTY, 0.1f ); slider.ValueChangedSignal().Connect( &OnSliderValueChanged ); slider.MarkSignal().Connect( &OnSliderMark ); diff --git a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-Slider.cpp b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-Slider.cpp index ea611ac..5f675de 100644 --- a/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-Slider.cpp +++ b/automated-tests/src/dali-toolkit-unmanaged/utc-Dali-Slider.cpp @@ -135,8 +135,8 @@ int UtcDaliSliderSignals(void) { marks.push_back( MIN_BOUND + ( static_cast(i) / ( NUM_MARKS - 1) ) * ( MAX_BOUND - MIN_BOUND ) ); } - slider.SetProperty( slider.GetPropertyIndex( Slider::MARKS_PROPERTY_NAME ), marks ); - slider.SetProperty( slider.GetPropertyIndex( Slider::MARK_TOLERANCE_PROPERTY_NAME ), 0.1f ); + slider.SetProperty( Slider::MARKS_PROPERTY, marks ); + slider.SetProperty( Slider::MARK_TOLERANCE_PROPERTY, 0.1f ); slider.ValueChangedSignal().Connect( &OnSliderValueChanged ); slider.MarkSignal().Connect( &OnSliderMark ); diff --git a/optional/dali-toolkit/images/slider-popup.9.png b/optional/dali-toolkit/images/slider-popup.9.png new file mode 100644 index 0000000..010cce7 Binary files /dev/null and b/optional/dali-toolkit/images/slider-popup.9.png differ diff --git a/optional/dali-toolkit/images/slider-skin-progress.9.png b/optional/dali-toolkit/images/slider-skin-progress.9.png new file mode 100644 index 0000000..4663335 Binary files /dev/null and b/optional/dali-toolkit/images/slider-skin-progress.9.png differ diff --git a/optional/dali-toolkit/images/slider-skin.9.png b/optional/dali-toolkit/images/slider-skin.9.png new file mode 100644 index 0000000..e1c2ca0 Binary files /dev/null and b/optional/dali-toolkit/images/slider-skin.9.png differ diff --git a/optional/dali-toolkit/internal/controls/slider/slider-impl.cpp b/optional/dali-toolkit/internal/controls/slider/slider-impl.cpp index 37650e4..d27eed4 100755 --- a/optional/dali-toolkit/internal/controls/slider/slider-impl.cpp +++ b/optional/dali-toolkit/internal/controls/slider/slider-impl.cpp @@ -28,6 +28,35 @@ namespace Dali namespace Toolkit { +// Properties +const Property::Index Slider::LOWER_BOUND_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 1; +const Property::Index Slider::UPPER_BOUND_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 2; + +const Property::Index Slider::VALUE_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 3; +const Property::Index Slider::HIT_REGION_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 4; +const Property::Index Slider::BACKING_REGION_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 5; +const Property::Index Slider::HANDLE_REGION_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 6; + +const Property::Index Slider::BACKING_IMAGE_NAME_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 7; +const Property::Index Slider::HANDLE_IMAGE_NAME_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 8; +const Property::Index Slider::PROGRESS_IMAGE_NAME_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 9; +const Property::Index Slider::POPUP_IMAGE_NAME_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 10; +const Property::Index Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 11; + +const Property::Index Slider::DISABLE_COLOR_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 12; +const Property::Index Slider::POPUP_TEXT_COLOR_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 13; + +const Property::Index Slider::VALUE_PRECISION_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 14; + +const Property::Index Slider::SHOW_POPUP_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 15; +const Property::Index Slider::SHOW_VALUE_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 16; + +const Property::Index Slider::ENABLED_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 17; + +const Property::Index Slider::MARKS_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 18; +const Property::Index Slider::SNAP_TO_MARKS_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 19; +const Property::Index Slider::MARK_TOLERANCE_PROPERTY = ControlImpl::CONTROL_PROPERTY_END_INDEX + 20; + namespace Internal { @@ -52,16 +81,12 @@ const float DEFAULT_HEIGHT = 27.0f; const float DEFAULT_HIT_HEIGHT = 72.0f; const float DEFAULT_HANDLE_HEIGHT = DEFAULT_HIT_HEIGHT; -const char* SKINNED_BACKING_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin.png"; +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";; -const char* SKINNED_PROGRESS_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin-progress.png"; -const char* SKINNED_POPUP_IMAGE_NAME = DALI_IMAGE_DIR "slider-popup.png"; +const char* SKINNED_PROGRESS_IMAGE_NAME = DALI_IMAGE_DIR "slider-skin-progress.9.png"; +const char* SKINNED_POPUP_IMAGE_NAME = DALI_IMAGE_DIR "slider-popup.9.png"; const char* SKINNED_POPUP_ARROW_IMAGE_NAME = DALI_IMAGE_DIR "slider-popup-arrow.png"; -const Vector4 SKINNED_BACKING_SCALE9_BORDER( 12.0f, 0.0f, 12.0f, 0.0f ); -const Vector4 SKINNED_PROGRESS_SCALE9_BORDER( 14.0f, 0.0f, 0.0f, 0.0f ); -const Vector4 SKINNED_POPUP_SCALE9_BORDER( 10.0f, 10.0f, 10.0f, 10.0f ); - const Vector2 DEFAULT_HIT_REGION( DEFAULT_WIDTH, DEFAULT_HIT_HEIGHT ); const Vector2 DEFAULT_BACKING_REGION( DEFAULT_WIDTH, DEFAULT_HEIGHT ); const Vector2 DEFAULT_HANDLE_REGION( DEFAULT_HANDLE_HEIGHT, DEFAULT_HANDLE_HEIGHT ); @@ -81,7 +106,7 @@ const int DEFAULT_VALUE_PRECISION = 0; const bool DEFAULT_SHOW_POPUP = false; const bool DEFAULT_SHOW_VALUE = true; const bool DEFAULT_ENABLED = true; - +const bool DEFAULT_SNAP_TO_MARKS = false; BaseHandle Create() { @@ -93,6 +118,34 @@ TypeRegistration typeRegistration( typeid(Dali::Toolkit::Slider), typeid(Dali::T SignalConnectorType signalConnector1( typeRegistration, Toolkit::Slider::SIGNAL_VALUE_CHANGED, &Toolkit::Internal::Slider::DoConnectSignal ); SignalConnectorType signalConnector2( typeRegistration, Toolkit::Slider::SIGNAL_MARK, &Toolkit::Internal::Slider::DoConnectSignal ); +PropertyRegistration property1( typeRegistration, "lower-bound", Toolkit::Slider::LOWER_BOUND_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property2( typeRegistration, "upper-bound", Toolkit::Slider::UPPER_BOUND_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property3( typeRegistration, "value", Toolkit::Slider::VALUE_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty ); + +PropertyRegistration property4( typeRegistration, "hit-region", Toolkit::Slider::HIT_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property5( typeRegistration, "backing-region", Toolkit::Slider::BACKING_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property6( typeRegistration, "handle-region", Toolkit::Slider::HANDLE_REGION_PROPERTY, Property::VECTOR2, &Slider::SetProperty, &Slider::GetProperty ); + +PropertyRegistration property7( typeRegistration, "backing-image-name", Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property8( typeRegistration, "handle-image-name", Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property9( typeRegistration, "progress-image-name", Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property10( typeRegistration, "popup-image-name", Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property11( typeRegistration, "popup-arrow-image-name", Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY, Property::STRING, &Slider::SetProperty, &Slider::GetProperty ); + +PropertyRegistration property12( typeRegistration, "disable-color", Toolkit::Slider::DISABLE_COLOR_PROPERTY, Property::VECTOR4, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property13( typeRegistration, "popup-text-color", Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY, Property::VECTOR4, &Slider::SetProperty, &Slider::GetProperty ); + +PropertyRegistration property14( typeRegistration, "value-precision", Toolkit::Slider::VALUE_PRECISION_PROPERTY, Property::INTEGER, &Slider::SetProperty, &Slider::GetProperty ); + +PropertyRegistration property15( typeRegistration, "show-popup", Toolkit::Slider::SHOW_POPUP_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property16( typeRegistration, "show-value", Toolkit::Slider::SHOW_VALUE_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty ); + +PropertyRegistration property17( typeRegistration, "enabled", Toolkit::Slider::ENABLED_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty ); + +PropertyRegistration property18( typeRegistration, "marks", Toolkit::Slider::MARKS_PROPERTY, Property::ARRAY, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property19( typeRegistration, "snap-to-marks", Toolkit::Slider::SNAP_TO_MARKS_PROPERTY, Property::BOOLEAN, &Slider::SetProperty, &Slider::GetProperty ); +PropertyRegistration property20( typeRegistration, "mark-tolerance", Toolkit::Slider::MARK_TOLERANCE_PROPERTY, Property::FLOAT, &Slider::SetProperty, &Slider::GetProperty ); + } // namespace /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -116,7 +169,20 @@ Dali::Toolkit::Slider Slider::New() Slider::Slider() : ControlImpl( true ), - mState( NORMAL ) + mState( NORMAL ), + mDisableColor( 0.0f, 0.0f, 0.0f, 0.0f ), + mPopupTextColor( 0.0f, 0.0f, 0.0f, 0.0f ), + mHitRegion( 0.0f, 0.0f ), + mBackingRegion( 0.0f, 0.0f ), + mHandleRegionSize( 0.0f, 0.0f ), + mLowerBound( 0.0f ), + mUpperBound( 0.0f ), + mValue( 0.0f ), + mMarkTolerance( 0.0f ), + mValuePrecision( 0 ), + mShowPopup( false ), + mShowValue( false ), + mSnapToMarks( false ) { } @@ -132,58 +198,33 @@ void Slider::OnInitialize() // Properties Actor self = Self(); - // Register properties in a block so the properties are ready for the update functions - mPropertyHitRegion = self.RegisterProperty( Dali::Toolkit::Slider::HIT_REGION_PROPERTY_NAME, DEFAULT_HIT_REGION, Property::READ_WRITE ); - mPropertyBackingRegion = self.RegisterProperty( Dali::Toolkit::Slider::BACKING_REGION_PROPERTY_NAME, DEFAULT_BACKING_REGION, Property::READ_WRITE ); - mPropertyHandleRegion = self.RegisterProperty( Dali::Toolkit::Slider::HANDLE_REGION_PROPERTY_NAME, DEFAULT_HANDLE_REGION, Property::READ_WRITE ); - - mPropertyBackingImageName = self.RegisterProperty( Dali::Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY_NAME, SKINNED_BACKING_IMAGE_NAME, Property::READ_WRITE ); - mPropertyHandleImageName = self.RegisterProperty( Dali::Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY_NAME, SKINNED_HANDLE_IMAGE_NAME, Property::READ_WRITE ); - - mPropertyProgressImageName = self.RegisterProperty( Dali::Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY_NAME, SKINNED_PROGRESS_IMAGE_NAME, Property::READ_WRITE ); - mPropertyPopupImageName = self.RegisterProperty( Dali::Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY_NAME, SKINNED_POPUP_IMAGE_NAME, Property::READ_WRITE ); - mPropertyPopupArrowImageName = self.RegisterProperty( Dali::Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY_NAME, SKINNED_POPUP_ARROW_IMAGE_NAME, Property::READ_WRITE ); - - mPropertyBackingScale9Border = self.RegisterProperty( Dali::Toolkit::Slider::BACKING_SCALE9_BORDER_PROPERTY_NAME, SKINNED_BACKING_SCALE9_BORDER, Property::READ_WRITE ); - mPropertyProgressScale9Border = self.RegisterProperty( Dali::Toolkit::Slider::PROGRESS_SCALE9_BORDER_PROPERTY_NAME, SKINNED_PROGRESS_SCALE9_BORDER, Property::READ_WRITE ); - mPropertyPopupScale9Border = self.RegisterProperty( Dali::Toolkit::Slider::POPUP_SCALE9_BORDER_PROPERTY_NAME, SKINNED_POPUP_SCALE9_BORDER, Property::READ_WRITE ); + SetHitRegion( DEFAULT_HIT_REGION ); + SetBackingRegion( DEFAULT_BACKING_REGION ); + SetHandleRegion( DEFAULT_HANDLE_REGION ); - mPropertyDisableColor = self.RegisterProperty( Dali::Toolkit::Slider::DISABLE_COLOR_PROPERTY_NAME, DEFAULT_DISABLE_COLOR, Property::READ_WRITE ); - mPropertyPopupTextColor = self.RegisterProperty( Dali::Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY_NAME, DEFAULT_POPUP_TEXT_COLOR, Property::READ_WRITE ); + SetBackingImageName( SKINNED_BACKING_IMAGE_NAME ); + SetHandleImageName( SKINNED_HANDLE_IMAGE_NAME ); + SetProgressImageName( SKINNED_PROGRESS_IMAGE_NAME ); + SetPopupImageName( SKINNED_POPUP_IMAGE_NAME ); + SetPopupArrowImageName( SKINNED_POPUP_ARROW_IMAGE_NAME ); - mPropertyValuePrecision = self.RegisterProperty( Dali::Toolkit::Slider::VALUE_PRECISION_PROPERTY_NAME, DEFAULT_VALUE_PRECISION, Property::READ_WRITE ); - mPropertyShowPopup = self.RegisterProperty( Dali::Toolkit::Slider::SHOW_POPUP_PROPERTY_NAME, DEFAULT_SHOW_POPUP, Property::READ_WRITE ); - mPropertyShowValue = self.RegisterProperty( Dali::Toolkit::Slider::SHOW_VALUE_PROPERTY_NAME, DEFAULT_SHOW_VALUE, Property::READ_WRITE ); + SetPopupTextColor( DEFAULT_POPUP_TEXT_COLOR ); - mPropertyEnabled = self.RegisterProperty( Dali::Toolkit::Slider::ENABLED_PROPERTY_NAME, DEFAULT_ENABLED, Property::READ_WRITE ); + SetShowPopup( DEFAULT_SHOW_POPUP ); + SetShowValue( DEFAULT_SHOW_VALUE ); - mPropertyMarks = self.RegisterProperty( Dali::Toolkit::Slider::MARKS_PROPERTY_NAME, mMarks, Property::READ_WRITE ); - mPropertySnapToMarks = self.RegisterProperty( Dali::Toolkit::Slider::SNAP_TO_MARKS_PROPERTY_NAME, false, Property::READ_WRITE ); - mPropertyMarkTolerance = self.RegisterProperty( Dali::Toolkit::Slider::MARK_TOLERANCE_PROPERTY_NAME, MARK_SNAP_TOLERANCE, Property::READ_WRITE ); + SetEnabled( DEFAULT_ENABLED ); + SetDisableColor( DEFAULT_DISABLE_COLOR ); - mPropertyLowerBound = self.RegisterProperty( Dali::Toolkit::Slider::LOWER_BOUND_PROPERTY_NAME, DEFAULT_LOWER_BOUND, Property::READ_WRITE ); - mPropertyUpperBound = self.RegisterProperty( Dali::Toolkit::Slider::UPPER_BOUND_PROPERTY_NAME, DEFAULT_UPPER_BOUND, Property::READ_WRITE ); - mPropertyValue = self.RegisterProperty( Dali::Toolkit::Slider::VALUE_PROPERTY_NAME, DEFAULT_VALUE, Property::READ_WRITE ); + SetSnapToMarks( DEFAULT_SNAP_TO_MARKS ); + SetMarkTolerance( MARK_SNAP_TOLERANCE ); - ResizeHitRegion( DEFAULT_HIT_REGION ); - SetBackingRegion( DEFAULT_BACKING_REGION ); - UpdateHandleRegion( DEFAULT_HANDLE_REGION ); - CreateBackingImage( SKINNED_BACKING_IMAGE_NAME ); - CreateHandleImage( SKINNED_HANDLE_IMAGE_NAME ); - CreateProgressImage( SKINNED_PROGRESS_IMAGE_NAME ); - CreatePopupImage( SKINNED_POPUP_IMAGE_NAME ); - CreatePopupArrowImage( SKINNED_POPUP_ARROW_IMAGE_NAME ); - SetBackingScale9( SKINNED_BACKING_SCALE9_BORDER ); - SetProgressScale9( SKINNED_PROGRESS_SCALE9_BORDER ); - SetPopupScale9( SKINNED_POPUP_SCALE9_BORDER ); - UpdatePopupTextColor( DEFAULT_POPUP_TEXT_COLOR ); - ShowPopup( DEFAULT_SHOW_POPUP ); - ShowValue( DEFAULT_SHOW_VALUE ); - SetEnabled( DEFAULT_ENABLED ); - UpdateLowerBound( DEFAULT_LOWER_BOUND ); - UpdateUpperBound( DEFAULT_UPPER_BOUND ); + SetLowerBound( DEFAULT_LOWER_BOUND ); + SetUpperBound( DEFAULT_UPPER_BOUND ); UpdateSkin(); - DisplayValue( DEFAULT_VALUE, false ); // Run this last to display the correct value + SetValuePrecision( DEFAULT_VALUE_PRECISION ); + mValue = DEFAULT_VALUE; + DisplayValue( mValue, false ); // Run this last to display the correct value // Size the Slider actor to a default self.SetSize( DEFAULT_HIT_REGION.x, DEFAULT_HIT_REGION.y ); @@ -216,7 +257,7 @@ bool Slider::OnTouchEvent(Actor actor, const TouchEvent& event) if( mState == PRESSED ) { mState = NORMAL; - mSlidingFinishedSignal.Emit( Toolkit::Slider::DownCast( Self() ), Self().GetProperty( mPropertyValue ).Get()); + mSlidingFinishedSignal.Emit( Toolkit::Slider::DownCast( Self() ), GetValue() ); } } } @@ -251,7 +292,7 @@ void Slider::OnPan( Actor actor, PanGesture gesture ) SetValue( value ); DisplayPopup( value ); } - mSlidingFinishedSignal.Emit( Toolkit::Slider::DownCast( Self() ), Self().GetProperty( mPropertyValue ).Get()); + mSlidingFinishedSignal.Emit( Toolkit::Slider::DownCast( Self() ), GetValue() ); } mState = NORMAL; @@ -357,9 +398,14 @@ const Slider::MarkList& Slider::GetMarks() const return mMarks; } +void Slider::SetSnapToMarks( bool snap ) +{ + mSnapToMarks = snap; +} + bool Slider::GetSnapToMarks() const { - return Self().GetProperty( mPropertySnapToMarks ); + return mSnapToMarks; } Actor Slider::CreateHitRegion() @@ -382,7 +428,7 @@ ImageActor Slider::CreateBacking() return backing; } -void Slider::CreateBackingImage( const std::string& imageName ) +void Slider::SetBackingImageName( const std::string& imageName ) { if( mBacking && imageName != String::EMPTY ) { @@ -391,21 +437,14 @@ void Slider::CreateBackingImage( const std::string& imageName ) } } -void Slider::SetBackingScale9( const Vector4& border ) +std::string Slider::GetBackingImageName() { if( mBacking ) { - mBacking.SetStyle( ImageActor::STYLE_NINE_PATCH ); - mBacking.SetNinePatchBorder( border ); + return mBacking.GetImage().GetFilename(); } -} -void Slider::SetBackingRegionSize( const Vector2& region ) -{ - if( mBacking ) - { - mBacking.SetSize( region ); - } + return std::string( "" ); } ImageActor Slider::CreateProgress() @@ -418,7 +457,7 @@ ImageActor Slider::CreateProgress() return progress; } -void Slider::CreateProgressImage( const std::string& imageName ) +void Slider::SetProgressImageName( const std::string& imageName ) { if( mProgress && imageName != String::EMPTY ) { @@ -427,6 +466,26 @@ void Slider::CreateProgressImage( const std::string& imageName ) } } +std::string Slider::GetProgressImageName() +{ + if( mProgress ) + { + return mProgress.GetImage().GetFilename(); + } + + return std::string( "" ); +} + +void Slider::SetPopupImageName( const std::string& imageName ) +{ + mPopupImageName = imageName; +} + +std::string Slider::GetPopupImageName() +{ + return mPopupImageName; +} + void Slider::CreatePopupImage( const std::string& imageName ) { if( mPopup && imageName != String::EMPTY ) @@ -436,30 +495,22 @@ void Slider::CreatePopupImage( const std::string& imageName ) } } -void Slider::CreatePopupArrowImage( const std::string& imageName ) +void Slider::SetPopupArrowImageName( const std::string& imageName ) { - if( mPopupArrow && imageName != String::EMPTY ) - { - Image image = Image::New( imageName ); - mPopupArrow.SetImage( image ); - } + mPopupArrowImageName = imageName; } -void Slider::SetProgressScale9( const Vector4& border ) +std::string Slider::GetPopupArrowImageName() { - if( mProgress ) - { - mProgress.SetStyle( ImageActor::STYLE_NINE_PATCH ); - mProgress.SetNinePatchBorder( border ); - } + return mPopupArrowImageName; } -void Slider::SetPopupScale9( const Vector4& border ) +void Slider::CreatePopupArrowImage( const std::string& imageName ) { - if( mPopup ) + if( mPopupArrow && imageName != String::EMPTY ) { - mPopup.SetStyle( ImageActor::STYLE_NINE_PATCH ); - mPopup.SetNinePatchBorder( border ); + Image image = Image::New( imageName ); + mPopupArrow.SetImage( image ); } } @@ -513,7 +564,7 @@ ImageActor Slider::CreatePopup() return popup; } -void Slider::CreateHandleImage( const std::string& imageName ) +void Slider::SetHandleImageName( const std::string& imageName ) { if( mHandle && imageName != String::EMPTY ) { @@ -522,6 +573,16 @@ void Slider::CreateHandleImage( const std::string& imageName ) } } +std::string Slider::GetHandleImageName() +{ + if( mHandle ) + { + return mHandle.GetImage().GetFilename(); + } + + return std::string( "" ); +} + void Slider::ResizeHandleRegion( const Vector2& region ) { if( mHandle ) @@ -552,12 +613,9 @@ void Slider::DestroyHandleValueDisplay() } } -void Slider::UpdatePopupTextColor( const Vector4& color ) +void Slider::SetPopupTextColor( const Vector4& color ) { - if( mValueTextView ) - { - mValueTextView.SetColor( color ); - } + mPopupTextColor = color; } Actor Slider::CreateValueDisplay() @@ -645,14 +703,21 @@ void Slider::CreateChildren() mBacking.Add( mHandle ); } -void Slider::ResizeHitRegion( const Vector2& size ) +void Slider::SetHitRegion( const Vector2& size ) { + mHitRegion = size; + if( mHitArea ) { - mHitArea.SetSize( size ); + mHitArea.SetSize( mHitRegion ); } } +const Vector2& Slider::GetHitRegion() const +{ + return mHitRegion; +} + void Slider::AddPopup() { if( !mValueDisplay ) @@ -661,10 +726,8 @@ void Slider::AddPopup() mValueDisplay.SetVisible( false ); mHandle.Add( mValueDisplay ); - Actor self = Self(); - CreatePopupImage( self.GetProperty( mPropertyPopupImageName ) ); - SetPopupScale9( GetPopupScale9Border() ); - CreatePopupArrowImage( self.GetProperty( mPropertyPopupArrowImageName ) ); + CreatePopupImage( GetPopupImageName() ); + CreatePopupArrowImage( GetPopupArrowImageName() ); mValueTimer = Timer::New( VALUE_VIEW_SHOW_DURATION ); mValueTimer.TickSignal().Connect( this, &Slider::HideValueView ); @@ -783,205 +846,109 @@ bool Slider::HideValueView() return false; } -void Slider::OnPropertySet( Property::Index index, Property::Value propertyValue ) -{ - if( index == mPropertyLowerBound ) - { - UpdateLowerBound( propertyValue.Get() ); - } - else if( index == mPropertyUpperBound ) - { - UpdateUpperBound( propertyValue.Get() ); - } - else if( index == mPropertyValue ) - { - DisplayValue( propertyValue.Get(), true ); - } - else if( index == mPropertyHitRegion ) - { - ResizeHitRegion( propertyValue.Get() ); - } - else if( index == mPropertyBackingRegion ) - { - ResizeBackingRegion( propertyValue.Get() ); - } - else if( index == mPropertyHandleRegion ) - { - UpdateHandleRegion( propertyValue.Get() ); - } - else if( index == mPropertyBackingImageName ) - { - CreateBackingImage( propertyValue.Get() ); - } - else if( index == mPropertyHandleImageName ) - { - CreateHandleImage( propertyValue.Get() ); - } - else if( index == mPropertyProgressImageName ) - { - CreateProgressImage( propertyValue.Get() ); - } - else if( index == mPropertyPopupImageName ) - { - CreatePopupImage( propertyValue.Get() ); - } - else if( index == mPropertyPopupArrowImageName ) - { - CreatePopupArrowImage( propertyValue.Get() ); - } - else if( index == mPropertyBackingScale9Border ) - { - SetBackingScale9( propertyValue.Get() ); - } - else if( index == mPropertyProgressScale9Border ) - { - SetProgressScale9( propertyValue.Get() ); - } - else if( index == mPropertyPopupScale9Border ) - { - SetPopupScale9( propertyValue.Get() ); - } - else if( index == mPropertyDisableColor ) - { - UpdateSkin(); - } - else if( index == mPropertyPopupTextColor ) - { - UpdatePopupTextColor( propertyValue.Get() ); - } - else if( index == mPropertyValuePrecision ) - { - DisplayValue( GetValue(), false ); - } - else if( index == mPropertyShowPopup ) - { - ShowPopup( propertyValue.Get() ); - } - else if( index == mPropertyShowValue ) - { - ShowValue( propertyValue.Get() ); - } - else if( index == mPropertyEnabled ) - { - SetEnabled( propertyValue.Get() ); - } - else if( index == mPropertyMarks ) - { - SetMarks( propertyValue.Get() ); - } - else if( index == mPropertySnapToMarks ) - { - // Nothing - } - else if( index == mPropertyMarkTolerance ) - { - // Nothing - } -} - -void Slider::UpdateLowerBound( float bound ) +void Slider::SetLowerBound( float bound ) { + mLowerBound = bound; DisplayValue( GetValue(), false ); } float Slider::GetLowerBound() const { - return Self().GetProperty( mPropertyLowerBound ); + return mLowerBound; } -void Slider::UpdateUpperBound( float bound ) +void Slider::SetUpperBound( float bound ) { + mUpperBound = bound; DisplayValue( GetValue(), false ); } float Slider::GetUpperBound() const { - return Self().GetProperty( mPropertyUpperBound ); + return mUpperBound; } void Slider::SetValue( float value ) { - Self().SetProperty( mPropertyValue, value ); + mValue = value; + DisplayValue( mValue, true ); } float Slider::GetValue() const { - return Self().GetProperty( mPropertyValue ); -} - -void Slider::SetHitRegion( const Vector2& region ) -{ - Self().SetProperty( mPropertyHitRegion, region ); -} - -Vector2 Slider::GetHitRegion() const -{ - return Self().GetProperty( mPropertyHitRegion ); + return mValue; } void Slider::SetBackingRegion( const Vector2& region ) { - Self().SetProperty( mPropertyBackingRegion, region ); -} + mBackingRegion = region; -void Slider::ResizeBackingRegion( const Vector2& region ) -{ - SetBackingRegionSize( region ); - ResizeProgressRegion( Vector2( 0.0f, region.y ) ); + if( mBacking ) + { + mBacking.SetSize( mBackingRegion ); + } - mDomain = CalcDomain( region ); + ResizeProgressRegion( Vector2( 0.0f, mBackingRegion.y ) ); + + mDomain = CalcDomain( mBackingRegion ); DisplayValue( GetValue(), false ); // Set the progress bar to correct width } -Vector2 Slider::GetBackingRegion() const +const Vector2& Slider::GetBackingRegion() const { - return Self().GetProperty( mPropertyBackingRegion ); + return mBackingRegion; } -void Slider::UpdateHandleRegion( const Vector2& region ) +void Slider::SetHandleRegion( const Vector2& region ) { - ResizeHandleRegion( region ); + mHandleRegionSize = region; + + ResizeHandleRegion( mHandleRegionSize ); Vector2 hitRegion = GetHitRegion(); - hitRegion.x += region.x; + hitRegion.x += mHandleRegionSize.x; SetHitRegion( hitRegion ); } -Vector2 Slider::GetHandleRegion() const +const Vector2& Slider::GetHandleRegion() const { - return Self().GetProperty( mPropertyHandleRegion ); + return mHandleRegionSize; } -Vector4 Slider::GetBackingScale9Border() const +void Slider::SetDisableColor( const Vector4& color ) { - return Self().GetProperty( mPropertyBackingScale9Border ); -} + mDisableColor = color; -Vector4 Slider::GetPopupScale9Border() const -{ - return Self().GetProperty( mPropertyPopupScale9Border ); + UpdateSkin(); } Vector4 Slider::GetDisableColor() const { - return Self().GetProperty( mPropertyDisableColor ); + return mDisableColor; } Vector4 Slider::GetPopupTextColor() const { - return Self().GetProperty( mPropertyPopupTextColor ); + return mPopupTextColor; +} + +void Slider::SetValuePrecision( int precision ) +{ + mValuePrecision = precision; } int Slider::GetValuePrecision() const { - return Self().GetProperty( mPropertyValuePrecision ); + return mValuePrecision; } -void Slider::ShowPopup( bool showPopup ) +void Slider::SetShowPopup( bool showPopup ) { + mShowPopup = showPopup; + // Value display - if( showPopup ) + if( mShowPopup ) { AddPopup(); } @@ -993,12 +960,14 @@ void Slider::ShowPopup( bool showPopup ) bool Slider::GetShowPopup() const { - return Self().GetProperty( mPropertyShowPopup ); + return mShowPopup; } -void Slider::ShowValue( bool showValue ) +void Slider::SetShowValue( bool showValue ) { - if( showValue ) + mShowValue = showValue; + + if( mShowValue ) { CreateHandleValueDisplay(); } @@ -1010,7 +979,7 @@ void Slider::ShowValue( bool showValue ) bool Slider::GetShowValue() const { - return Self().GetProperty( mPropertyShowValue ); + return mShowValue; } void Slider::SetEnabled( bool enabled ) @@ -1032,9 +1001,14 @@ bool Slider::IsEnabled() const return mState != DISABLED; } +void Slider::SetMarkTolerance( float tolerance ) +{ + mMarkTolerance = tolerance; +} + float Slider::GetMarkTolerance() const { - return Self().GetProperty( mPropertyMarkTolerance ); + return mMarkTolerance; } // static class method to support script connecting signals @@ -1054,7 +1028,7 @@ bool Slider::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tr { slider.MarkSignal().Connect( tracker, functor ); } - else + else { // signalName does not match any signal connected = false; @@ -1065,7 +1039,7 @@ bool Slider::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tr void Slider::DisplayPopup( float value ) { - // Value display + // Value displayDoConnectSignal if( mValueTextView ) { std::stringstream ss; @@ -1093,6 +1067,276 @@ void Slider::DisplayPopup( float value ) } } +void Slider::SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value ) +{ + Toolkit::Slider slider = Toolkit::Slider::DownCast( Dali::BaseHandle( object ) ); + + if ( slider ) + { + Slider& sliderImpl( GetImpl( slider ) ); + + switch ( propertyIndex ) + { + case Toolkit::Slider::LOWER_BOUND_PROPERTY: + { + sliderImpl.SetLowerBound( value.Get< float >() ); + break; + } + + case Toolkit::Slider::UPPER_BOUND_PROPERTY: + { + sliderImpl.SetUpperBound( value.Get< float >() ); + break; + } + + case Toolkit::Slider::VALUE_PROPERTY: + { + sliderImpl.SetValue( value.Get< float >() ); + break; + } + + case Toolkit::Slider::HIT_REGION_PROPERTY: + { + sliderImpl.SetHitRegion( value.Get< Vector2 >() ); + break; + } + + case Toolkit::Slider::BACKING_REGION_PROPERTY: + { + sliderImpl.SetBackingRegion( value.Get< Vector2 >() ); + break; + } + + case Toolkit::Slider::HANDLE_REGION_PROPERTY: + { + sliderImpl.SetHandleRegion( value.Get< Vector2 >() ); + break; + } + + case Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY: + { + sliderImpl.SetBackingImageName( value.Get< std::string >() ); + break; + } + + case Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY: + { + sliderImpl.SetHandleImageName( value.Get< std::string >() ); + break; + } + + case Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY: + { + sliderImpl.SetProgressImageName( value.Get< std::string >() ); + break; + } + + case Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY: + { + sliderImpl.SetPopupImageName( value.Get< std::string >() ); + break; + } + + case Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY: + { + sliderImpl.SetPopupArrowImageName( value.Get< std::string >() ); + break; + } + + case Toolkit::Slider::DISABLE_COLOR_PROPERTY: + { + sliderImpl.SetDisableColor( value.Get< Vector4 >() ); + break; + } + + case Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY: + { + sliderImpl.SetPopupTextColor( value.Get< Vector4 >() ); + break; + } + + case Toolkit::Slider::VALUE_PRECISION_PROPERTY: + { + sliderImpl.SetValuePrecision( value.Get< int >() ); + break; + } + + case Toolkit::Slider::SHOW_POPUP_PROPERTY: + { + sliderImpl.SetShowPopup( value.Get< bool >() ); + break; + } + + case Toolkit::Slider::SHOW_VALUE_PROPERTY: + { + sliderImpl.SetShowValue( value.Get< bool >() ); + break; + } + + case Toolkit::Slider::ENABLED_PROPERTY: + { + sliderImpl.SetEnabled( value.Get< bool >() ); + break; + } + + case Toolkit::Slider::MARKS_PROPERTY: + { + sliderImpl.SetMarks( value.Get< Property::Array >() ); + break; + } + + case Toolkit::Slider::SNAP_TO_MARKS_PROPERTY: + { + sliderImpl.SetSnapToMarks( value.Get< bool >() ); + break; + } + + case Toolkit::Slider::MARK_TOLERANCE_PROPERTY: + { + sliderImpl.SetMarkTolerance( value.Get< float >() ); + break; + } + } + } +} + +Property::Value Slider::GetProperty( BaseObject* object, Property::Index propertyIndex ) +{ + Property::Value value; + + Toolkit::Slider slider = Toolkit::Slider::DownCast( Dali::BaseHandle( object ) ); + + if ( slider ) + { + Slider& sliderImpl( GetImpl( slider ) ); + + switch ( propertyIndex ) + { + case Toolkit::Slider::LOWER_BOUND_PROPERTY: + { + value = sliderImpl.GetLowerBound(); + break; + } + + case Toolkit::Slider::UPPER_BOUND_PROPERTY: + { + value = sliderImpl.GetUpperBound(); + break; + } + + case Toolkit::Slider::VALUE_PROPERTY: + { + value = sliderImpl.GetValue(); + break; + } + + case Toolkit::Slider::HIT_REGION_PROPERTY: + { + value = sliderImpl.GetHitRegion(); + break; + } + + case Toolkit::Slider::BACKING_REGION_PROPERTY: + { + value = sliderImpl.GetBackingRegion(); + break; + } + + case Toolkit::Slider::HANDLE_REGION_PROPERTY: + { + value = sliderImpl.GetHandleRegion(); + break; + } + + case Toolkit::Slider::BACKING_IMAGE_NAME_PROPERTY: + { + value = sliderImpl.GetBackingImageName(); + break; + } + + case Toolkit::Slider::HANDLE_IMAGE_NAME_PROPERTY: + { + value = sliderImpl.GetHandleImageName(); + break; + } + + case Toolkit::Slider::PROGRESS_IMAGE_NAME_PROPERTY: + { + value = sliderImpl.GetProgressImageName(); + break; + } + + case Toolkit::Slider::POPUP_IMAGE_NAME_PROPERTY: + { + value = sliderImpl.GetPopupImageName(); + break; + } + + case Toolkit::Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY: + { + value = sliderImpl.GetPopupArrowImageName(); + break; + } + + case Toolkit::Slider::DISABLE_COLOR_PROPERTY: + { + value = sliderImpl.GetDisableColor(); + break; + } + + case Toolkit::Slider::POPUP_TEXT_COLOR_PROPERTY: + { + value = sliderImpl.GetPopupTextColor(); + break; + } + + case Toolkit::Slider::VALUE_PRECISION_PROPERTY: + { + value = sliderImpl.GetValuePrecision(); + break; + } + + case Toolkit::Slider::SHOW_POPUP_PROPERTY: + { + value = sliderImpl.GetShowPopup(); + break; + } + + case Toolkit::Slider::SHOW_VALUE_PROPERTY: + { + value = sliderImpl.GetShowValue(); + break; + } + + case Toolkit::Slider::ENABLED_PROPERTY: + { + value = sliderImpl.IsEnabled(); + break; + } + + case Toolkit::Slider::MARKS_PROPERTY: + { + // TODO: Need to be able to return a PropertyArray + // value = sliderImpl.GetMarks(); + break; + } + + case Toolkit::Slider::SNAP_TO_MARKS_PROPERTY: + { + value = sliderImpl.GetSnapToMarks(); + break; + } + + case Toolkit::Slider::MARK_TOLERANCE_PROPERTY: + { + value = sliderImpl.GetMarkTolerance(); + break; + } + } + } + + return value; +} } // namespace Internal diff --git a/optional/dali-toolkit/internal/controls/slider/slider-impl.h b/optional/dali-toolkit/internal/controls/slider/slider-impl.h index d97da67..8da4de1 100755 --- a/optional/dali-toolkit/internal/controls/slider/slider-impl.h +++ b/optional/dali-toolkit/internal/controls/slider/slider-impl.h @@ -112,7 +112,7 @@ public: * * @return The hit region */ - Vector2 GetHitRegion() const; + const Vector2& GetHitRegion() const; /** * Set backing region @@ -126,24 +126,17 @@ public: * * @return The backing region */ - Vector2 GetBackingRegion() const; + const Vector2& GetBackingRegion() const; /** - * Get backing scale9 border + * @brief Set the disable color. * - * @return The backing scale9 border + * @param[in] color The disable color. */ - Vector4 GetBackingScale9Border() const; + void SetDisableColor( const Vector4& color ); /** - * Get popup scale9 border - * - * @return The popup scale9 border - */ - Vector4 GetPopupScale9Border() const; - - /** - * Get disable color + * @brief Get disable color * * @return The disable color */ @@ -157,6 +150,13 @@ public: Vector4 GetPopupTextColor() const; /** + * Set the value precision to be used for numbers in the slider + * + * @param[in] precision The number of decimal places to use for printing numbers + */ + void SetValuePrecision( int precision ); + + /** * Get value precision * * @return The value precision @@ -168,7 +168,7 @@ public: * * @param[in] showPopup The show popup flag */ - void ShowPopup( bool showPopup ); + void SetShowPopup( bool showPopup ); /** * Get show value in popup @@ -182,7 +182,7 @@ public: * * @param[in] showValue The show value flag */ - void ShowValue( bool showValue ); + void SetShowValue( bool showValue ); /** * Get show value on handle @@ -206,6 +206,16 @@ public: bool IsEnabled() const; /** + * @brief Set the mark tolerance + * + * The tolerance is the percentage of the slider width for which snapping to + * marks occurs + * + * @param[in] tolerance The percentage of width for which to snap + */ + void SetMarkTolerance( float tolerance ); + + /** * Return the mark tolerance * * @return The tolerance set for snapping to marks @@ -242,6 +252,24 @@ public: static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor ); + // Properties + + /** + * Called when a property of an object of this type is set. + * @param[in] object The object whose property is set. + * @param[in] index The property index. + * @param[in] value The new property value. + */ + static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value ); + + /** + * Called to retrieve a property of an object of this type. + * @param[in] object The object whose property is to be retrieved. + * @param[in] index The property index. + * @return The current value of the property. + */ + static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex ); + protected: /** @@ -422,13 +450,6 @@ private: void CreateChildren(); /** - * Resize the hit area - * - * @param[in] size The new size of the hit area - */ - void ResizeHitRegion( const Vector2& size ); - - /** * Create value popup */ void AddPopup(); @@ -490,63 +511,70 @@ private: * * @param[in] imageName The name of the image to load and set */ - void CreateBackingImage( const std::string& imageName ); + void SetBackingImageName( const std::string& imageName ); /** - * Set the backing image to be a scale-9 image + * @brief Return the backing image file name. * - * @param[in] border The scale-9 border to use + * @return The backing image file name. */ - void SetBackingScale9( const Vector4& border ); + std::string GetBackingImageName(); /** - * Resize the backing region + * Create the image for the progress bar * - * @param[in] region The size of the region to set + * @param[in] imageName The name of the image to load and set */ - void ResizeBackingRegion( const Vector2& region ); + void SetProgressImageName( const std::string& imageName ); /** - * Size the backing region + * @brief Return the progress image name. * - * @param[in] region The size of the region to set + * @return The progress image name if it exists. */ - void SetBackingRegionSize( const Vector2& region ); + std::string GetProgressImageName(); /** - * Create the image for the progress bar + * @brief Create the image for the popup * * @param[in] imageName The name of the image to load and set */ - void CreateProgressImage( const std::string& imageName ); + void CreatePopupImage( const std::string& imageName ); /** - * Create the image for the popup + * @brief Set the popup name * - * @param[in] imageName The name of the image to load and set + * @param[in] imageName The name of the image to set */ - void CreatePopupImage( const std::string& imageName ); + void SetPopupImageName( const std::string& imageName ); /** - * Create the image for the popup arrow + * @brief Return the popup image name. * - * @param[in] imageName The name of the image to load and set + * @return The name of the popup image if it exists. */ - void CreatePopupArrowImage( const std::string& imageName ); + std::string GetPopupImageName(); /** - * Set the progress image to be a scale-9 image + * @brief Set the popup arrow image name * - * @param[in] border The scale-9 border to use + * @param[in] imageName The name of the image to set */ - void SetProgressScale9( const Vector4& border ); + void SetPopupArrowImageName( const std::string& imageName ); /** - * Set the popup image to be a scale-9 image + * @brief Return the popup arrow image name. * - * @param[in] border The scale-9 border to use + * @return The name of the popup image if it exists. */ - void SetPopupScale9( const Vector4& border ); + std::string GetPopupArrowImageName(); + + /** + * Create the image for the popup arrow + * + * @param[in] imageName The name of the image to load and set + */ + void CreatePopupArrowImage( const std::string& imageName ); /** * Set the size of the progress bar region @@ -560,7 +588,14 @@ private: * * @param[in] imageName The name of the image to load and set */ - void CreateHandleImage( const std::string& imageName ); + void SetHandleImageName( const std::string& imageName ); + + /** + * @brief Return the handle image name. + * + * @return The name of the image handle if it exists. + */ + std::string GetHandleImageName(); /** * Set the size of the handle region @@ -584,28 +619,28 @@ private: * * @param[in] color The new color */ - void UpdatePopupTextColor( const Vector4& color ); + void SetPopupTextColor( const Vector4& color ); /** * Set handle region * * @param[in] region The handle region */ - void UpdateHandleRegion( const Vector2& region ); + void SetHandleRegion( const Vector2& region ); /** * Get handle region * * @return The handle region */ - Vector2 GetHandleRegion() const; + const Vector2& GetHandleRegion() const; /** * Set the lower bound of the slider's value * * @param[in] bound The value to set for the lower bound */ - void UpdateLowerBound( float bound ); + void SetLowerBound( float bound ); /** * Get the lower bound of the slider's value @@ -619,7 +654,7 @@ private: * * @param[in] bound The value to set for the upper bound */ - void UpdateUpperBound( float bound ); + void SetUpperBound( float bound ); /** * Get the upper bound of the slider's value @@ -629,14 +664,6 @@ private: float GetUpperBound() const; private: - // From ControlImpl - - /** - * @copydoc Dali::CustomActorImpl::OnPropertySet() - */ - virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ); - -private: // Undefined Slider( const Slider& ); @@ -671,38 +698,27 @@ private: MarkList mMarks; ///< List of discreet marks - // Properties - Property::Index mPropertyLowerBound; - Property::Index mPropertyUpperBound; - Property::Index mPropertyValue; - Property::Index mPropertyHitRegion; - Property::Index mPropertyBackingRegion; - Property::Index mPropertyHandleRegion; - - Property::Index mPropertyBackingImageName; - Property::Index mPropertyHandleImageName; - Property::Index mPropertyProgressImageName; - Property::Index mPropertyPopupImageName; - Property::Index mPropertyPopupArrowImageName; - - Property::Index mPropertyBackingScale9Border; - Property::Index mPropertyProgressScale9Border; - Property::Index mPropertyPopupScale9Border; + std::string mPopupImageName; ///< Image name for popup image + std::string mPopupArrowImageName; ///< Image name for popup arrow - Property::Index mPropertyDisableColor; - Property::Index mPropertyPopupTextColor; + Vector4 mDisableColor; ///< The color to tint the slider when disabled + Vector4 mPopupTextColor; ///< The color of the popup text - Property::Index mPropertyValuePrecision; + Vector2 mHitRegion; ///< Size of hit region + Vector2 mBackingRegion; ///< Size of backing region + Vector2 mHandleRegionSize; ///< Size of the handle region - Property::Index mPropertyShowPopup; - Property::Index mPropertyShowValue; + float mLowerBound; ///< Lower bound on value + float mUpperBound; ///< Upper bound on value + float mValue; ///< Current value of slider - Property::Index mPropertyEnabled; + float mMarkTolerance; ///< Tolerance in percentage of slider width for which to snap to marks - Property::Index mPropertyMarks; - Property::Index mPropertySnapToMarks; - Property::Index mPropertyMarkTolerance; + int mValuePrecision; ///< The precision to use for outputting the value + bool mShowPopup : 1, ///< Show the popup or not + mShowValue : 1, ///< Whether to display the value number or not on the handle + mSnapToMarks : 1; ///< Turn on or off snapping to marks }; } // namespace Internal diff --git a/optional/dali-toolkit/public-api/controls/slider/slider.cpp b/optional/dali-toolkit/public-api/controls/slider/slider.cpp index a72792e..6ada0ec 100644 --- a/optional/dali-toolkit/public-api/controls/slider/slider.cpp +++ b/optional/dali-toolkit/public-api/controls/slider/slider.cpp @@ -33,38 +33,6 @@ namespace Toolkit const char* const Slider::SIGNAL_VALUE_CHANGED = "value-changed"; const char* const Slider::SIGNAL_MARK = "mark"; -// Properties -const std::string Slider::LOWER_BOUND_PROPERTY_NAME( "lower-bound" ); -const std::string Slider::UPPER_BOUND_PROPERTY_NAME( "upper-bound" ); -const std::string Slider::VALUE_PROPERTY_NAME( "value" ); -const std::string Slider::HIT_REGION_PROPERTY_NAME( "hit-region" ); -const std::string Slider::BACKING_REGION_PROPERTY_NAME( "backing-region" ); -const std::string Slider::HANDLE_REGION_PROPERTY_NAME( "handle-region" ); - -const std::string Slider::BACKING_IMAGE_NAME_PROPERTY_NAME( "backing-image-name" ); -const std::string Slider::HANDLE_IMAGE_NAME_PROPERTY_NAME( "handle-image-name" ); -const std::string Slider::PROGRESS_IMAGE_NAME_PROPERTY_NAME( "progress-image-name" ); -const std::string Slider::POPUP_IMAGE_NAME_PROPERTY_NAME( "popup-image-name" ); -const std::string Slider::POPUP_ARROW_IMAGE_NAME_PROPERTY_NAME( "popup-arrow-image-name" ); - -const std::string Slider::BACKING_SCALE9_BORDER_PROPERTY_NAME( "backing-scale9-border" ); -const std::string Slider::PROGRESS_SCALE9_BORDER_PROPERTY_NAME( "progress-scale9-border" ); -const std::string Slider::POPUP_SCALE9_BORDER_PROPERTY_NAME( "popup-scale9-border" ); - -const std::string Slider::DISABLE_COLOR_PROPERTY_NAME( "disable-color" ); -const std::string Slider::POPUP_TEXT_COLOR_PROPERTY_NAME( "popup-text-color" ); - -const std::string Slider::VALUE_PRECISION_PROPERTY_NAME( "value-precision" ); - -const std::string Slider::SHOW_POPUP_PROPERTY_NAME( "show-popup" ); -const std::string Slider::SHOW_VALUE_PROPERTY_NAME( "show-value" ); - -const std::string Slider::ENABLED_PROPERTY_NAME( "enabled" ); - -const std::string Slider::MARKS_PROPERTY_NAME( "marks" ); -const std::string Slider::SNAP_TO_MARKS_PROPERTY_NAME( "snap-to-marks" ); -const std::string Slider::MARK_TOLERANCE_PROPERTY_NAME( "mark-tolerance" ); - Slider::Slider() { } diff --git a/optional/dali-toolkit/public-api/controls/slider/slider.h b/optional/dali-toolkit/public-api/controls/slider/slider.h index c5dc76f..a87bf2f 100644 --- a/optional/dali-toolkit/public-api/controls/slider/slider.h +++ b/optional/dali-toolkit/public-api/controls/slider/slider.h @@ -43,37 +43,33 @@ public: static const char* const SIGNAL_MARK; // Properties - static const std::string LOWER_BOUND_PROPERTY_NAME; ///< Property, name "lower-bound", type FLOAT - static const std::string UPPER_BOUND_PROPERTY_NAME; ///< Property, name "upper-bound", type FLOAT - static const std::string VALUE_PROPERTY_NAME; ///< Property, name "value", type FLOAT + static const Property::Index LOWER_BOUND_PROPERTY; ///< Property, name "lower-bound", type FLOAT + static const Property::Index UPPER_BOUND_PROPERTY; ///< Property, name "upper-bound", type FLOAT + static const Property::Index VALUE_PROPERTY; ///< Property, name "value", type FLOAT - static const std::string HIT_REGION_PROPERTY_NAME; ///< Property, name "hit-region", type VECTOR2 - static const std::string BACKING_REGION_PROPERTY_NAME; ///< Property, name "backing-region", type VECTOR2 - static const std::string HANDLE_REGION_PROPERTY_NAME; ///< Property, name "handle-region", type VECTOR2 + static const Property::Index HIT_REGION_PROPERTY; ///< Property, name "hit-region", type VECTOR2 + static const Property::Index BACKING_REGION_PROPERTY; ///< Property, name "backing-region", type VECTOR2 + static const Property::Index HANDLE_REGION_PROPERTY; ///< Property, name "handle-region", type VECTOR2 - static const std::string BACKING_IMAGE_NAME_PROPERTY_NAME; ///< Property, name "backing-image-name", type std::string - static const std::string HANDLE_IMAGE_NAME_PROPERTY_NAME; ///< Property, name "handle-image-name", type std::string - static const std::string PROGRESS_IMAGE_NAME_PROPERTY_NAME; ///< Property, name "progress-image-name", type std::string - static const std::string POPUP_IMAGE_NAME_PROPERTY_NAME; ///< Property, name "popup-image-name", type std::string - static const std::string POPUP_ARROW_IMAGE_NAME_PROPERTY_NAME; ///< Property, name "popup-arrow-image-name", type std::string + static const Property::Index BACKING_IMAGE_NAME_PROPERTY; ///< Property, name "backing-image-name", type STRING + static const Property::Index HANDLE_IMAGE_NAME_PROPERTY; ///< Property, name "handle-image-name", type STRING + static const Property::Index PROGRESS_IMAGE_NAME_PROPERTY; ///< Property, name "progress-image-name", type STRING + static const Property::Index POPUP_IMAGE_NAME_PROPERTY; ///< Property, name "popup-image-name", type STRING + static const Property::Index POPUP_ARROW_IMAGE_NAME_PROPERTY; ///< Property, name "popup-arrow-image-name", type STRING - static const std::string BACKING_SCALE9_BORDER_PROPERTY_NAME; ///< Property, name "backing-scale9-border", type VECTOR4 - static const std::string PROGRESS_SCALE9_BORDER_PROPERTY_NAME; ///< Property, name "progress-scale9-border", type VECTOR4 - static const std::string POPUP_SCALE9_BORDER_PROPERTY_NAME; ///< Property, name "popup-scale9-border", type VECTOR4 + static const Property::Index DISABLE_COLOR_PROPERTY; ///< Property, name "disable-color", type VECTOR4 + static const Property::Index POPUP_TEXT_COLOR_PROPERTY; ///< Property, name "popup-text-color", type VECTOR4 - static const std::string DISABLE_COLOR_PROPERTY_NAME; ///< Property, name "disable-color", type VECTOR4 - static const std::string POPUP_TEXT_COLOR_PROPERTY_NAME; ///< Property, name "popup-text-color", type VECTOR4 + static const Property::Index VALUE_PRECISION_PROPERTY; ///< Property, name "value-precision", type INT - static const std::string VALUE_PRECISION_PROPERTY_NAME; ///< Property, name "value-precision", type INT + static const Property::Index SHOW_POPUP_PROPERTY; ///< Property, name "show-popup", type BOOLEAN + static const Property::Index SHOW_VALUE_PROPERTY; ///< Property, name "show-value", type BOOLEAN - static const std::string SHOW_POPUP_PROPERTY_NAME; ///< Property, name "show-popup", type BOOLEAN - static const std::string SHOW_VALUE_PROPERTY_NAME; ///< Property, name "show-value", type BOOLEAN + static const Property::Index ENABLED_PROPERTY; ///< Property, name "enabled", type BOOLEAN - static const std::string ENABLED_PROPERTY_NAME; ///< Property, name "enabled", type BOOLEAN - - static const std::string MARKS_PROPERTY_NAME; ///< Property, name "marks", type Property::Array - static const std::string SNAP_TO_MARKS_PROPERTY_NAME; ///< Property, name "snap-to-marks", type BOOLEAN - static const std::string MARK_TOLERANCE_PROPERTY_NAME; ///< Property, name "mark-tolerance", type FLOAT + static const Property::Index MARKS_PROPERTY; ///< Property, name "marks", type Property::Array + static const Property::Index SNAP_TO_MARKS_PROPERTY; ///< Property, name "snap-to-marks", type BOOLEAN + static const Property::Index MARK_TOLERANCE_PROPERTY; ///< Property, name "mark-tolerance", type FLOAT public: