X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fslider%2Fslider-impl.h;h=c078271e84026ba0f06f97f0c29bc832bc07d77f;hp=3f4b8c8c63f951151da41659a8162407424f2662;hb=8a647e87a01c5c78451653c1264a9eea81ac9b20;hpb=e2eda444afbe82e9591fe198eef339227f90a616 diff --git a/dali-toolkit/internal/controls/slider/slider-impl.h b/dali-toolkit/internal/controls/slider/slider-impl.h old mode 100755 new mode 100644 index 3f4b8c8..c078271 --- a/dali-toolkit/internal/controls/slider/slider-impl.h +++ b/dali-toolkit/internal/controls/slider/slider-impl.h @@ -1,27 +1,34 @@ -#ifndef __DALI_TOOLKIT_INTERNAL_SLIDER_H__ -#define __DALI_TOOLKIT_INTERNAL_SLIDER_H__ - -// -// Copyright (c) 2014 Samsung Electronics Co., Ltd. -// -// Licensed under the Flora License, Version 1.0 (the License); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://floralicense.org/license/ -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an AS IS BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// +#ifndef DALI_TOOLKIT_INTERNAL_SLIDER_H +#define DALI_TOOLKIT_INTERNAL_SLIDER_H + +/* + * Copyright (c) 2020 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +// EXTERNAL INCLUDES +#include +#include +#include // INTERNAL INCLUDES -#include #include #include -#include +#include +#include +#include namespace Dali { @@ -41,7 +48,7 @@ typedef Dali::IntrusivePtr< Slider > SliderPtr; /** * @copydoc Toolkit::Slider */ -class Slider : public ControlImpl +class Slider : public Control { public: @@ -112,49 +119,42 @@ public: * * @return The hit region */ - Vector2 GetHitRegion() const; - - /** - * Set backing region - * - * @param[in] region The backing region - */ - void SetBackingRegion( const Vector2& region ); + const Vector2& GetHitRegion() const; /** - * Get backing region + * Set the track region * - * @return The backing region + * @param[in] region The track region */ - Vector2 GetBackingRegion() const; + void SetTrackRegion( const Vector2& region ); /** - * Get backing scale9 border + * Get the track region * - * @return The backing scale9 border + * @return The track region */ - Vector4 GetBackingScale9Border() const; + const Vector2& GetTrackRegion() const; /** - * Get popup scale9 border + * @brief Set the disabled color. * - * @return The popup scale9 border + * @param[in] color The disabled color. */ - Vector4 GetPopupScale9Border() const; + void SetDisabledColor( const Vector4& color ); /** - * Get disable color + * @brief Get disabled color * - * @return The disable color + * @return The disabled color */ - Vector4 GetDisableColor() const; + Vector4 GetDisabledColor() const; /** - * Get popup text color + * Set the value precision to be used for numbers in the slider * - * @return The popup text color + * @param[in] precision The number of decimal places to use for printing numbers */ - Vector4 GetPopupTextColor() const; + void SetValuePrecision( int precision ); /** * Get 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 @@ -221,9 +231,14 @@ public: Toolkit::Slider::ValueChangedSignalType& ValueChangedSignal(); /** - * @copydoc Toolkit::Slider::MarkSignal() + * copydoc Toolkit::Slider::SlidingFinishedSignal() */ - Toolkit::Slider::MarkSignalType& MarkSignal(); + Toolkit::Slider::ValueChangedSignalType& SlidingFinishedSignal(); + + /** + * @copydoc Toolkit::Slider::MarkReachedSignal() + */ + Toolkit::Slider::MarkReachedSignalType& MarkReachedSignal(); /** * Connects a callback function with the object's signals. @@ -237,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: /** @@ -250,9 +283,10 @@ protected: virtual ~Slider(); /** - * @copydoc Toolkit::ControlImpl::OnControlSizeSet( const Vector3& size ) + * @copydoc CustomActorImpl::OnRelayout */ - virtual void OnControlSizeSet( const Vector3& size ); + void OnRelayout( const Vector2& size, RelayoutContainer& container ) override; + private: @@ -289,16 +323,16 @@ private: /** * @copydoc Toolkit::Control::OnInitialize() */ - virtual void OnInitialize(); + void OnInitialize() override; /** - * Hit region touch event + * Hit region touch * * @param[in] actor The actor the event is raised for - * @param[in] event The touch event info - * @return If the event is handled or not + * @param[in] touch The touch info + * @return If touch is handled or not */ - bool OnTouchEvent( Actor actor, const TouchEvent& event ); + bool OnTouch( Actor actor, const TouchEvent& touch ); /** * Pan gesture event @@ -306,7 +340,7 @@ private: * @param[in] actor The actor the event is raised for * @param[in] gesture The pan event info */ - void OnPan( Actor actor, PanGesture gestur ); + void OnPan( Actor actor, const PanGesture& gesture ); /** * Map a position onto a domain and return the result as a percentage @@ -358,46 +392,46 @@ private: Actor CreateHitRegion(); /** - * Create the backing for the slider + * Create the track for the slider * - * @return The backing actor + * @return The track actor */ - ImageActor CreateBacking(); + Toolkit::ImageView CreateTrack(); /** - * Create the progress backing for the slider + * Create the progress track for the slider * - * @return The backing actor + * @return The track actor */ - ImageActor CreateProgress(); + Toolkit::ImageView CreateProgress(); /** * Create the handle for the slider * * @return The created image handle */ - ImageActor CreateHandle(); + Toolkit::ImageView CreateHandle(); /** * Create the popup arrow * * @return The created image handle */ - ImageActor CreatePopupArrow(); + Toolkit::ImageView CreatePopupArrow(); /** * Create the popup * * @return The created image handle */ - ImageActor CreatePopup(); + Toolkit::ImageView CreatePopup(); /** * Create the textview for the popup * * @return The textview created for the popup */ - Toolkit::TextView CreatePopupText(); + Toolkit::TextLabel CreatePopupText(); /** * Create the value display for the slider @@ -417,13 +451,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(); @@ -481,67 +508,102 @@ private: void DisplayValue( float value, bool raiseSignals ); /** - * Create the image for the backing + * Create the image for the track * - * @param[in] imageName The name of the image to load and set + * @param[in] filename The track image */ - void CreateBackingImage( const std::string& imageName ); + void SetTrackVisual( const std::string& filename ); /** - * Set the backing image to be a scale-9 image + * @brief Set the track visual from an Dali::Property::Map * - * @param[in] border The scale-9 border to use + * @param[in] map The Dali::Property::Map to use for to display */ - void SetBackingScale9( const Vector4& border ); + void SetTrackVisual( Dali::Property::Map map ); /** - * Resize the backing region + * @brief Return the track image. * - * @param[in] region The size of the region to set + * @return The track image. */ - void ResizeBackingRegion( const Vector2& region ); + std::string GetTrackVisual(); /** - * Size the backing region + * Create the image for the progress bar * - * @param[in] region The size of the region to set + * @param[in] filename The progress bar image */ - void SetBackingRegionSize( const Vector2& region ); + void SetProgressVisual( const std::string& filename ); /** - * Create the image for the progress bar + * @brief Set the progress visual from an Dali::Property::Map * - * @param[in] imageName The name of the image to load and set + * @param[in] map The Dali::Property::Map to use for to display */ - void CreateProgressImage( const std::string& imageName ); + void SetProgressVisual( Dali::Property::Map map ); /** - * Create the image for the popup + * @brief Return the progress bar image. * - * @param[in] imageName The name of the image to load and set + * @return The progress bar image if it exists. */ - void CreatePopupImage( const std::string& imageName ); + std::string GetProgressVisual(); /** - * Create the image for the popup arrow + * @brief Create the image for the popup + * + * @param[in] filename The popup image + */ + void CreatePopupImage( const std::string& filename ); + + /** + * @brief Set the popup image + * + * @param[in] filename The popup image to set + */ + void SetPopupVisual( const std::string& filename ); + + /** + * @brief Set the popup from an Dali::Property::Map + * + * @param[in] map The Dali::Property::Map to use for to display + */ + void SetPopupVisual( Dali::Property::Map map ); + + /** + * @brief Return the popup image. + * + * @return The popup image if it exists. + */ + std::string GetPopupVisual(); + + /** + * @brief Set the popup arrow image * - * @param[in] imageName The name of the image to load and set + * @param[in] filename The popup arrow image to set */ - void CreatePopupArrowImage( const std::string& imageName ); + void SetPopupArrowVisual( const std::string& filename ); /** - * Set the progress image to be a scale-9 image + * @brief Set the popup arrow from an Dali::Property::Map * - * @param[in] border The scale-9 border to use + * @param[in] map The Dali::Property::Map to use for to display */ - void SetProgressScale9( const Vector4& border ); + void SetPopupArrowVisual( Dali::Property::Map map ); /** - * Set the popup image to be a scale-9 image + * @brief Return the popup arrow image. * - * @param[in] border The scale-9 border to use + * @return The popup arrow image if it exists. */ - void SetPopupScale9( const Vector4& border ); + std::string GetPopupArrowVisual(); + + /** + * Create the image for the popup arrow + * + * @param[in] filename The popup arrow image to load and set + */ + void CreatePopupArrowImage( const std::string& filename ); /** * Set the size of the progress bar region @@ -553,16 +615,30 @@ private: /** * Create the image for the handle * - * @param[in] imageName The name of the image to load and set + * @param[in] filename The handle image */ - void CreateHandleImage( const std::string& imageName ); + void SetHandleVisual( const std::string& filename ); /** - * Set the size of the handle region + * @brief Set the handle visual from an Dali::Property::Map * - * @param[in] region The size of the region to set + * @param[in] map The Dali::Property::Map to use for to display + */ + void SetHandleVisual( Property::Map map ); + + /** + * @brief Return the handle image. + * + * @return The handle image if it exists. + */ + std::string GetHandleVisual(); + + /** + * Reset the size of the handle + * + * @param[in] size The size of the handle to set */ - void ResizeHandleRegion( const Vector2& region ); + void ResizeHandleSize( const Vector2& size ); /** * Create and display the value on the handle @@ -575,32 +651,25 @@ private: void DestroyHandleValueDisplay(); /** - * Update the color of the popup text + * Set the size of the handle * - * @param[in] color The new color + * @param[in] size The handle size */ - void UpdatePopupTextColor( const Vector4& color ); + void SetHandleSize( const Vector2& size ); /** - * Set handle region + * Get the size of the handle * - * @param[in] region The handle region + * @return The handle size */ - void UpdateHandleRegion( const Vector2& region ); - - /** - * Get handle region - * - * @return The handle region - */ - Vector2 GetHandleRegion() const; + const Vector2& GetHandleSize() 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 @@ -614,7 +683,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 @@ -624,14 +693,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& ); @@ -644,20 +705,21 @@ private: Domain mDomain; ///< Current domain of the handle Actor mHitArea; ///< The input handler - ImageActor mBacking; ///< Backing image - ImageActor mHandle; ///< Slider handle - ImageActor mProgress; ///< Progress backing Actor mValueDisplay; ///< Display of the value - ImageActor mPopup; ///< Popup backing - ImageActor mPopupArrow; ///< Popup arrow backing - - Toolkit::TextView mValueTextView; //< The text value in popup - Toolkit::TextView mHandleValueTextView; ///< The text value on handle + Toolkit::ImageView mTrack; ///< Track image + Toolkit::ImageView mHandle; ///< Slider handle + Toolkit::ImageView mProgress; ///< Progress bar + Toolkit::ImageView mPopup; ///< Popup backing + Toolkit::ImageView mPopupArrow; ///< Popup arrow backing + + Toolkit::TextLabel mValueTextLabel; //< The text value in popup + Toolkit::TextLabel mHandleValueTextLabel; ///< The text value on handle Vector2 mHandleLastTouchPoint; ///< The last touch point for the handle Timer mValueTimer; ///< Timer used to hide value view - Toolkit::Slider::ValueChangedSignalType mValueChangedSignal; ///< Signal emitted when the value is changed - Toolkit::Slider::MarkSignalType mMarkSignal; ///< Signal emitted when a mark is reached + Toolkit::Slider::ValueChangedSignalType mValueChangedSignal; ///< Signal emitted when the value is changed + Toolkit::Slider::ValueChangedSignalType mSlidingFinishedSignal; ///< Signal emitted when a sliding is finished + Toolkit::Slider::MarkReachedSignalType mMarkReachedSignal; ///< Signal emitted when a mark is reached SliderState mState; ///< The state of the slider @@ -665,38 +727,47 @@ 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; + std::string mPopupVisual; ///< Image for popup image + std::string mPopupArrowVisual; ///< Image for popup arrow image + std::string mTrackVisual; ///< Image for track image + std::string mHandleVisual; ///< Image for handle image + std::string mProgressVisual; ///< Image for progress bar image - Property::Index mPropertyBackingImageName; - Property::Index mPropertyHandleImageName; - Property::Index mPropertyProgressImageName; - Property::Index mPropertyPopupImageName; - Property::Index mPropertyPopupArrowImageName; + Property::Map mPopupMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise + Property::Map mTrackMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise + Property::Map mHandleMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise + Property::Map mProgressMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise + Property::Map mPopupArrowMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise - Property::Index mPropertyBackingScale9Border; - Property::Index mPropertyProgressScale9Border; - Property::Index mPropertyPopupScale9Border; + Vector4 mDisabledColor; ///< The color to tint the slider when disabled - Property::Index mPropertyDisableColor; - Property::Index mPropertyPopupTextColor; + Vector2 mHitRegion; ///< Size of hit region + Vector2 mTrackRegion; ///< Size of track region + Vector2 mHandleSize; ///< Size of the handle - Property::Index mPropertyValuePrecision; + float mLowerBound = 0.0f; ///< Lower bound on value + float mUpperBound = 1.0f; ///< Upper bound on value + float mValue = 0.0f; ///< Current value of slider - Property::Index mPropertyShowPopup; - Property::Index mPropertyShowValue; + float mMarkTolerance = 0.05f; ///< Tolerance in percentage of slider width for which to snap to marks - Property::Index mPropertyEnabled; + int mValuePrecision; ///< The precision to use for outputting the value - Property::Index mPropertyMarks; - Property::Index mPropertySnapToMarks; - Property::Index mPropertyMarkTolerance; + 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 +protected: + struct AccessibleImpl : public Control::Impl::AccessibleImpl, + public virtual Dali::Accessibility::Value + { + using Control::Impl::AccessibleImpl::AccessibleImpl; + double GetMinimum() override; + double GetCurrent() override; + double GetMaximum() override; + bool SetCurrent( double ) override; + double GetMinimumIncrement() override; + }; }; } // namespace Internal @@ -725,4 +796,4 @@ inline const Toolkit::Internal::Slider& GetImpl( const Toolkit::Slider& pub ) } // namespace Dali -#endif // __DALI_TOOLKIT_INTERNAL_SLIDER_H__ +#endif // DALI_TOOLKIT_INTERNAL_SLIDER_H