1 #ifndef DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
2 #define DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <dali/public-api/object/property-map.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/devel-api/controls/progress-bar/progress-bar.h>
27 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
28 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
41 typedef Dali::IntrusivePtr< ProgressBar > ProgressBarPtr;
44 * @copydoc Toolkit::ProgressBar
46 class ProgressBar : public Control
51 * Create a new ProgressBar.
53 * @return A public handle to the newly allocated ProgressBar.
55 static Dali::Toolkit::ProgressBar New();
62 * Set the value of the ProgressBar
64 * @param[in] value The value to set. Will be clamped to [lowerBound .. upperBound]
67 void SetProgressValue( float value );
70 * Get the value of the ProgressBar
72 * @return The current value of the ProgressBar
74 float GetProgressValue() const;
80 * @copydoc Toolkit::ProgressBar::ValueChangedSignal()
82 Toolkit::ProgressBar::ValueChangedSignalType& ValueChangedSignal();
85 * Connects a callback function with the object's signals.
86 * @param[in] object The object providing the signal.
87 * @param[in] tracker Used to disconnect the signal.
88 * @param[in] signalName The signal to connect to.
89 * @param[in] functor A newly allocated FunctorDelegate.
90 * @return True if the signal was connected.
91 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
93 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName,
94 FunctorDelegate* functor );
99 * Called when a property of an object of this type is set.
100 * @param[in] object The object whose property is set.
101 * @param[in] index The property index.
102 * @param[in] value The new property value.
104 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
107 * Called to retrieve a property of an object of this type.
108 * @param[in] object The object whose property is to be retrieved.
109 * @param[in] index The property index.
110 * @return The current value of the property.
112 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
117 * Construct a new ProgressBar.
122 * A reference counted object may only be deleted by calling Unreference()
124 virtual ~ProgressBar();
127 * @copydoc CustomActorImpl::OnRelayout()
129 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
132 * @copydoc CustomActorImpl::GetNaturalSize()
134 virtual Vector3 GetNaturalSize();
139 * Domain is a from/to pair
149 Domain( Vector2 fromVal, Vector2 toVal )
150 : from( fromVal ), to( toVal )
158 * @copydoc Toolkit::Control::OnInitialize()
160 virtual void OnInitialize();
163 * Get the range of the valid values the ProgressBar handle can move between
165 * @param[in] currentSize The current size of the ProgressBar
166 * @return The range as a domain pair
168 Domain CalcDomain( const Vector2& currentSize );
171 * Create the track for the ProgressBar
173 * @return The track actor
175 Toolkit::ImageView CreateTrack();
178 * Create the progress track for the ProgressBar
180 * @return The track actor
182 Toolkit::ImageView CreateProgress();
185 * Create all the children
187 void CreateChildren();
190 * Set value choosing whether to fire signals or not
192 * @paramp[in] value The value to set
193 * @param[in] raiseSignals Configure signals to be raised or not.
195 void DisplayValue( float value, bool raiseSignals );
198 * Create the image for the track
200 * @param[in] filename The track image
202 void SetTrackVisual( const std::string& filename );
205 * @brief Set the track visual from an Dali::Property::Map
207 * @param[in] map The Dali::Property::Map to use for to display
209 void SetTrackVisual( Dali::Property::Map map );
212 * @brief Return the track image.
214 * @return The track image.
216 std::string GetTrackVisual();
219 * Create the image for the progress bar
221 * @param[in] filename The progress bar image
223 void SetProgressVisual( const std::string& filename );
226 * @brief Set the progress visual from an Dali::Property::Map
228 * @param[in] map The Dali::Property::Map to use for to display
230 void SetProgressVisual( Dali::Property::Map map );
233 * @brief Return the progress bar image.
235 * @return The progress bar image if it exists.
237 std::string GetProgressVisual();
242 ProgressBar( const ProgressBar& );
245 ProgressBar& operator=( const ProgressBar& rhs );
249 Domain mDomain; ///< Current domain of the handle
251 Toolkit::ImageView mTrack; ///< Track image
252 Toolkit::ImageView mProgress; ///< Progress bar
253 Toolkit::TextLabel mValueTextLabel; ///< Text value to show progress percentage
254 Toolkit::ProgressBar::ValueChangedSignalType mValueChangedSignal; ///< Signal emitted when the value is changed
256 std::string mTrackVisual; ///< Image for track image
257 std::string mProgressVisual; ///< Image for progress bar image
259 Property::Map mTrackMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
260 Property::Map mProgressMap; ///< the Property::Map if the image came from a Property::Map, empty otherwise
262 Vector2 mTrackVisualSize; ///< Size of the track image used
263 Vector2 mProgressVisualSize; ///< Size of progress image used
265 float mValue; ///< Current value of ProgressBar
268 } // namespace Internal
270 // Helpers for public-api forwarding methods
272 inline Toolkit::Internal::ProgressBar& GetImpl( Toolkit::ProgressBar& pub )
274 DALI_ASSERT_ALWAYS( pub );
276 Dali::RefObject& handle = pub.GetImplementation();
278 return static_cast< Toolkit::Internal::ProgressBar& >( handle );
281 inline const Toolkit::Internal::ProgressBar& GetImpl( const Toolkit::ProgressBar& pub )
283 DALI_ASSERT_ALWAYS( pub );
285 const Dali::RefObject& handle = pub.GetImplementation();
287 return static_cast< const Toolkit::Internal::ProgressBar& >( handle );
290 } // namespace Toolkit
294 #endif // DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H