[AT-SPI] Remove SetAccessibilityConstructor()
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / progress-bar / progress-bar-impl.h
old mode 100755 (executable)
new mode 100644 (file)
index f5f7e91..13c9cb3
@@ -2,7 +2,7 @@
 #define DALI_TOOLKIT_INTERNAL_PROGRESS_BAR_H
 
 /*
- * Copyright (c) 2016 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
  */
 
 // EXTERNAL INCLUDES
-#include <dali/public-api/object/property-map.h>
+#include <dali/devel-api/atspi-interfaces/value.h>
 
 // INTERNAL INCLUDES
+#include <dali-toolkit/devel-api/controls/control-devel.h>
+#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar-devel.h>
+#include <dali-toolkit/devel-api/visual-factory/transition-data.h>
+#include <dali-toolkit/internal/controls/control/control-data-impl.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
-#include <dali-toolkit/devel-api/controls/progress-bar/progress-bar.h>
-#include <dali-toolkit/public-api/controls/image-view/image-view.h>
-#include <dali-toolkit/public-api/controls/text-controls/text-label.h>
+#include <dali-toolkit/public-api/controls/progress-bar/progress-bar.h>
+#include <dali/public-api/animation/animation.h>
 
 namespace Dali
 {
-
 namespace Toolkit
 {
-
 namespace Internal
 {
-
 class ProgressBar;
 
-typedef Dali::IntrusivePtr< ProgressBar > ProgressBarPtr;
+typedef Dali::IntrusivePtr<ProgressBar> ProgressBarPtr;
 
 /**
  * @copydoc Toolkit::ProgressBar
@@ -46,16 +46,14 @@ typedef Dali::IntrusivePtr< ProgressBar > ProgressBarPtr;
 class ProgressBar : public Control
 {
 public:
-
   /**
-   * Create a new ProgressBar.
-   *
+   * Create a new ProgressBar with predefined style.
+   * @param[in] progressBarStyle A style value that determines the shape of the progress bar.
    * @return A public handle to the newly allocated ProgressBar.
    */
-  static Dali::Toolkit::ProgressBar New();
+  static Dali::Toolkit::ProgressBar New(DevelProgressBar::Style progressBarStyle = DevelProgressBar::Style::LINEAR);
 
 public:
-
   // Properties
 
   /**
@@ -63,8 +61,7 @@ public:
    *
    * @param[in] value The value to set. Will be clamped to [lowerBound .. upperBound]
    */
-
-  void SetProgressValue( float value );
+  void SetProgressValue(float value);
 
   /**
    * Get the value of the ProgressBar
@@ -73,11 +70,58 @@ public:
    */
   float GetProgressValue() const;
 
+  /**
+   * Set the secondary progress value of the ProgressBar
+   *
+   * @param[in] value The secondary progress value to set. Will be clamped to [lowerBound .. upperBound]
+   */
+  void SetSecondaryProgressValue(float value);
+
+  /**
+   * Get the secondary progress value of the ProgressBar
+   *
+   * @return The current secondary progress value of the ProgressBar
+   */
+  float GetSecondaryProgressValue() const;
+
+  /**
+   * Set the indeterminate state of the ProgressBar
+   *
+   * @param[in] value The value to set.
+   */
+  void SetIndeterminate(bool value);
+
+  /**
+   * Get the indeterminate state value of the ProgressBar
+   *
+   * @return The current determined state of the ProgressBar
+   */
+  bool GetIndeterminate() const;
+
+  /**
+   * Set the indeterminate visual transition of the ProgressBar
+   *
+   * @param[in] Transition data map to set.
+   */
+  void SetIndeterminateVisualTransition(Property::Map transtion);
+
+  /**
+   * Get the indeterminate visual transition data map of the ProgressBar
+   *
+   * @return The current indeterminate visual transition data map of the ProgressBar
+   */
+  Property::Map GetIndeterminateVisualTransition() const;
+
+  /**
+   * Play the indeterminate visual transition
+   */
+  void PlayIndeterminateVisualTransition();
+
 public:
   //Signals
 
   /**
-   * @copydoc Toolkit::ProgressBar::ValueChangedSignal()
+   * @copydoc toolkit::progressbar::valuechangedsignal()
    */
   Toolkit::ProgressBar::ValueChangedSignalType& ValueChangedSignal();
 
@@ -90,8 +134,7 @@ public:
    * @return True if the signal was connected.
    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
    */
-  static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName,
-                               FunctorDelegate* functor );
+  static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
 
   // Properties
 
@@ -101,7 +144,7 @@ public:
    * @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 );
+  static void SetProperty(BaseObject* object, Property::Index index, const Property::Value& value);
 
   /**
    * Called to retrieve a property of an object of this type.
@@ -109,10 +152,9 @@ public:
    * @param[in] index The property index.
    * @return The current value of the property.
    */
-  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
+  static Property::Value GetProperty(BaseObject* object, Property::Index propertyIndex);
 
 protected:
-
   /**
    * Construct a new ProgressBar.
    */
@@ -126,15 +168,14 @@ protected:
   /**
    * @copydoc CustomActorImpl::OnRelayout()
    */
-  virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
+  void OnRelayout(const Vector2& size, RelayoutContainer& container) override;
 
   /**
    * @copydoc CustomActorImpl::GetNaturalSize()
    */
-  virtual Vector3 GetNaturalSize();
+  Vector3 GetNaturalSize() override;
 
 private:
-
   /**
    * Domain is a from/to pair
    */
@@ -146,145 +187,142 @@ private:
     Domain()
     {
     }
-    Domain( Vector2 fromVal, Vector2 toVal )
-        : from( fromVal ), to( toVal )
+    Domain(Vector2 fromVal, Vector2 toVal)
+    : from(fromVal),
+      to(toVal)
     {
     }
   };
 
 private:
-
   /**
    * @copydoc Toolkit::Control::OnInitialize()
    */
-  virtual void OnInitialize();
-
-  /**
-   * Get the range of the valid values the ProgressBar handle can move between
-   *
-   * @param[in] currentSize The current size of the ProgressBar
-   * @return The range as a domain pair
-   */
-  Domain CalcDomain( const Vector2& currentSize );
+  void OnInitialize() override;
 
   /**
-   * Create the track for the ProgressBar
-   *
-   * @return The track actor
+   * @copydoc Toolkit::Internal::Control::CreateAccessibleObject()
    */
-  Toolkit::ImageView CreateTrack();
+  DevelControl::ControlAccessible* CreateAccessibleObject() override;
 
   /**
-   * Create the progress track for the ProgressBar
+   * Get the range of the valid values the ProgressBar handle can move between
    *
-   * @return The track actor
-   */
-  Toolkit::ImageView CreateProgress();
-
-  /**
-   * Create all the children
+   * @param[in] currentSize The current size of the ProgressBar
+   * @return The range as a domain pair
    */
-  void CreateChildren();
+  Domain CalcDomain(const Vector2& currentSize);
 
   /**
-   * Set value choosing whether to fire signals or not
-   *
-   * @paramp[in] value The value to set
-   * @param[in] raiseSignals Configure signals to be raised or not.
+   * Set indeterminate visual transition animation
    */
-  void DisplayValue( float value, bool raiseSignals );
+  void SetIndeterminateVisualTransition(Toolkit::TransitionData transtion);
 
   /**
-   * Create the image for the track
-   *
-   * @param[in] filename The track image
+   * Convert value to transition data
    */
-  void SetTrackVisual( const std::string& filename );
+  Toolkit::TransitionData ConvertPropertyToTransition(const Property::Value& value);
 
   /**
-   * @brief Set the track visual from an Dali::Property::Map
-   *
-   * @param[in] map The Dali::Property::Map to use for to display
+   * Update progress bar label when progress value is changed
    */
-  void SetTrackVisual( Dali::Property::Map map );
+  void CreateVisualsForComponent(Property::Index index, const Property::Value& value, const int visualDepth);
 
   /**
-   * @brief Return the track image.
-   *
-   * @return The track image.
+   * Update progress bar label when progress value is changed
    */
-  std::string GetTrackVisual();
+  bool GetPropertyMapForVisual(Property::Index visualIndex, Property::Map& retreivedMap) const;
 
   /**
-   * Create the image for the progress bar
-   *
-   * @param[in] filename The progress bar image
+   * Apply progress value to visual
    */
-  void SetProgressVisual( const std::string& filename );
+  void ApplyProgressToVisual(float progress, Property::Index index, int depth);
 
   /**
-   * @brief Set the progress visual from an Dali::Property::Map
-   *
-   * @param[in] map The Dali::Property::Map to use for to display
+   * Apply progress value to visual transform
    */
-  void SetProgressVisual( Dali::Property::Map map );
+  void ApplyProgressToVisualTransform(float progress, Vector2 trackSize, Property::Index index);
 
   /**
-   * @brief Return the progress bar image.
-   *
-   * @return The progress bar image if it exists.
+   * Check if we should start animating
    */
-  std::string GetProgressVisual();
+  void OnSceneConnection(int depth) override;
 
 private:
-
   // Undefined
-  ProgressBar( const ProgressBar& );
+  ProgressBar(const ProgressBar&);
 
   // Undefined
-  ProgressBar& operator=( const ProgressBar& rhs );
+  ProgressBar& operator=(const ProgressBar& rhs);
 
 private:
+  Domain mDomain; ///< Current domain of the handle
 
-  Domain mDomain;                           ///< Current domain of the handle
-
-  Toolkit::ImageView mTrack;                ///< Track image
-  Toolkit::ImageView mProgress;             ///< Progress bar
-  Toolkit::TextLabel mValueTextLabel;       ///< Text value to show progress percentage
-  Toolkit::ProgressBar::ValueChangedSignalType mValueChangedSignal;       ///< Signal emitted when the value is changed
-
-  std::string mTrackVisual;           ///< Image for track image
-  std::string mProgressVisual;        ///< Image for progress bar image
+  Animation                                    mIndeterminateVisualAni; ///< Animation for indetrminate visual. Transition animation.
+  Toolkit::ProgressBar::ValueChangedSignalType mValueChangedSignal;     ///< Signal emitted when the value is changed
 
-  Property::Map mTrackMap;         ///< 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
+  Toolkit::TransitionData mIndeterminateVisualTransition; ///< Transition data map for mIndeterminateVisualAni
+  float                   mProgressValue;                 ///< Current value of ProgressBar
+  float                   mSecondaryProgressValue;        ///< Current loading value of ProgressBar
+  bool                    mIndeterminate;                 ///< Whether the progress state is determined or not
+  Property::Map           mTrackVisualMap;                ///< To backup visual properties when switching determinate/indeterminate.
+  Property::Map           mProgressVisualMap;             ///< To backup visual properties when switching determinate/indeterminate.
+  Property::Map           mSecondaryProgressVisualMap;    ///< To backup visual properties when switching determinate/indeterminate.
 
-  Vector2 mTrackVisualSize;      ///< Size of the track image used
-  Vector2 mProgressVisualSize;   ///< Size of progress image used
-
-  float mValue;             ///< Current value of ProgressBar
+protected:
+  class ProgressBarAccessible : public DevelControl::ControlAccessible,
+                                public virtual Dali::Accessibility::Value
+  {
+  public:
+    using DevelControl::ControlAccessible::ControlAccessible;
+
+    /**
+     * @copydoc Dali::Accessibility::Value::GetMinimum()
+     */
+    double GetMinimum() const override;
+
+    /**
+     * @copydoc Dali::Accessibility::Value::GetCurrent()
+     */
+    double GetCurrent() const override;
+
+    /**
+     * @copydoc Dali::Accessibility::Value::GetMaximum()
+     */
+    double GetMaximum() const override;
+
+    /**
+     * @copydoc Dali::Accessibility::Value::SetCurrent()
+     */
+    bool SetCurrent(double) override;
+
+    /**
+     * @copydoc Dali::Accessibility::Value::GetMinimumIncrement()
+     */
+    double GetMinimumIncrement() const override;
+  };
 };
 
 } // namespace Internal
 
 // Helpers for public-api forwarding methods
 
-inline Toolkit::Internal::ProgressBar& GetImpl( Toolkit::ProgressBar& pub )
+inline Toolkit::Internal::ProgressBar& GetImpl(Toolkit::ProgressBar& pub)
 {
-  DALI_ASSERT_ALWAYS( pub );
+  DALI_ASSERT_ALWAYS(pub);
 
   Dali::RefObject& handle = pub.GetImplementation();
 
-  return static_cast< Toolkit::Internal::ProgressBar& >( handle );
+  return static_cast<Toolkit::Internal::ProgressBar&>(handle);
 }
 
-inline const Toolkit::Internal::ProgressBar& GetImpl( const Toolkit::ProgressBar& pub )
+inline const Toolkit::Internal::ProgressBar& GetImpl(const Toolkit::ProgressBar& pub)
 {
-  DALI_ASSERT_ALWAYS( pub );
+  DALI_ASSERT_ALWAYS(pub);
 
   const Dali::RefObject& handle = pub.GetImplementation();
 
-  return static_cast< const Toolkit::Internal::ProgressBar& >( handle );
+  return static_cast<const Toolkit::Internal::ProgressBar&>(handle);
 }
 
 } // namespace Toolkit