1 #ifndef DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
2 #define DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
5 * Copyright (c) 2017 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.
23 #include <dali-toolkit/public-api/controls/control-impl.h>
24 #include <dali/public-api/animation/animation.h>
25 #include <dali-toolkit/public-api/controls/progress-bar/progress-bar.h>
26 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
39 typedef Dali::IntrusivePtr< ProgressBar > ProgressBarPtr;
42 * @copydoc Toolkit::ProgressBar
44 class ProgressBar : public Control
49 * Create a new ProgressBar.
51 * @return A public handle to the newly allocated ProgressBar.
53 static Dali::Toolkit::ProgressBar New();
60 * Set the value of the ProgressBar
62 * @param[in] value The value to set. Will be clamped to [lowerBound .. upperBound]
64 void SetProgressValue( float value );
67 * Get the value of the ProgressBar
69 * @return The current value of the ProgressBar
71 float GetProgressValue() const;
74 * Set the secondary progress value of the ProgressBar
76 * @param[in] value The secondary progress value to set. Will be clamped to [lowerBound .. upperBound]
78 void SetSecondaryProgressValue( float value );
81 * Get the secondary progress value of the ProgressBar
83 * @return The current secondary progress value of the ProgressBar
85 float GetSecondaryProgressValue() const;
88 * Set the indeterminate state of the ProgressBar
90 * @param[in] value The value to set.
92 void SetIndeterminate( bool value );
95 * Get the indeterminate state value of the ProgressBar
97 * @return The current determined state of the ProgressBar
99 bool GetIndeterminate() const;
102 * Set the indeterminate visual transition of the ProgressBar
104 * @param[in] Transition data map to set.
106 void SetIndeterminateVisualTransition( Property::Map transtion );
109 * Get the indeterminate visual transition data map of the ProgressBar
111 * @return The current indeterminate visual transition data map of the ProgressBar
113 Property::Map GetIndeterminateVisualTransition() const;
116 * Play the indeterminate visual transition
118 void PlayIndeterminateVisualTransition();
124 * @copydoc toolkit::progressbar::valuechangedsignal()
126 Toolkit::ProgressBar::ValueChangedSignalType& ValueChangedSignal();
130 * Connects a callback function with the object's signals.
131 * @param[in] object The object providing the signal.
132 * @param[in] tracker Used to disconnect the signal.
133 * @param[in] signalName The signal to connect to.
134 * @param[in] functor A newly allocated FunctorDelegate.
135 * @return True if the signal was connected.
136 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
138 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName,
139 FunctorDelegate* functor );
144 * Called when a property of an object of this type is set.
145 * @param[in] object The object whose property is set.
146 * @param[in] index The property index.
147 * @param[in] value The new property value.
149 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
152 * Called to retrieve a property of an object of this type.
153 * @param[in] object The object whose property is to be retrieved.
154 * @param[in] index The property index.
155 * @return The current value of the property.
157 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
162 * Construct a new ProgressBar.
167 * A reference counted object may only be deleted by calling Unreference()
169 virtual ~ProgressBar();
172 * @copydoc CustomActorImpl::OnRelayout()
174 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
177 * @copydoc CustomActorImpl::GetNaturalSize()
179 virtual Vector3 GetNaturalSize();
184 * Domain is a from/to pair
194 Domain( Vector2 fromVal, Vector2 toVal )
195 : from( fromVal ), to( toVal )
203 * @copydoc Toolkit::Control::OnInitialize()
205 virtual void OnInitialize();
208 * Get the range of the valid values the ProgressBar handle can move between
210 * @param[in] currentSize The current size of the ProgressBar
211 * @return The range as a domain pair
213 Domain CalcDomain( const Vector2& currentSize );
216 * Set indeterminate visual transition animation
218 void SetIndeterminateVisualTransition( Toolkit::TransitionData transtion );
221 * Convert value to transition data
223 Toolkit::TransitionData ConvertPropertyToTransition( const Property::Value& value );
226 * Update progress bar label when progress value is changed
228 void CreateVisualsForComponent( Property::Index index, const Property::Value& value, const int visualDepth );
231 * Update progress bar label when progress value is changed
233 bool GetPropertyMapForVisual( Property::Index visualIndex, Property::Map& retreivedMap ) const;
236 * Check if we should start animating
238 virtual void OnStageConnection( int depth );
243 ProgressBar( const ProgressBar& );
246 ProgressBar& operator=( const ProgressBar& rhs );
250 Domain mDomain; ///< Current domain of the handle
252 Animation mIndeterminateVisualAni; ///< Animation for indetrminate visual. Transition animation.
253 Toolkit::ProgressBar::ValueChangedSignalType mValueChangedSignal; ///< Signal emitted when the value is changed
255 Toolkit::TransitionData mIndeterminateVisualTransition; ///< Transition data map for mIndeterminateVisualAni
256 float mProgressValue; ///< Current value of ProgressBar
257 float mSecondaryProgressValue; ///< Current loading value of ProgressBar
258 bool mIndeterminate; ///< Whether the progress state is determined or not
261 } // namespace Internal
263 // Helpers for public-api forwarding methods
265 inline Toolkit::Internal::ProgressBar& GetImpl( Toolkit::ProgressBar& pub )
267 DALI_ASSERT_ALWAYS( pub );
269 Dali::RefObject& handle = pub.GetImplementation();
271 return static_cast< Toolkit::Internal::ProgressBar& >( handle );
274 inline const Toolkit::Internal::ProgressBar& GetImpl( const Toolkit::ProgressBar& pub )
276 DALI_ASSERT_ALWAYS( pub );
278 const Dali::RefObject& handle = pub.GetImplementation();
280 return static_cast< const Toolkit::Internal::ProgressBar& >( handle );
283 } // namespace Toolkit
287 #endif // DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H