Remove non-public APIs of Animation
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / push-button-impl.h
index b463513..cee57f6 100644 (file)
@@ -1,27 +1,29 @@
 #ifndef __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_H__
 #define __DALI_TOOLKIT_INTERNAL_PUSH_BUTTON_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.
-//
+/*
+ * Copyright (c) 2014 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.
+ *
+ */
 
-// INTERNAL INCLUDES
+// EXTERNAL INCLUDES
 #include <dali/public-api/common/dali-vector.h>
+#include <dali/public-api/animation/animation.h>
 
+// INTERNAL INCLUDES
 #include <dali-toolkit/public-api/controls/buttons/push-button.h>
-
 #include "button-impl.h"
 
 namespace Dali
@@ -48,313 +50,180 @@ public:
    */
   static Dali::Toolkit::PushButton New();
 
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetAutoRepeating( bool autoRepeating )
-   */
-  void SetAutoRepeating( bool autoRepeating );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::IsAutoRepeating() const
-   */
-  bool IsAutoRepeating() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
-   */
-  void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetInitialAutoRepeatingDelay() const
-   */
-  float GetInitialAutoRepeatingDelay() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
-   */
-  void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetNextAutoRepeatingDelay() const
-   */
-  float GetNextAutoRepeatingDelay() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetToggleButton( bool toggle )
-   */
-  void SetToggleButton( bool toggle );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::IsToggleButton() const
-   */
-  bool IsToggleButton() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetToggled( bool toggle )
-   */
-  void SetToggled( bool toggle );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::IsToggled() const
-   */
-  bool IsToggled() const;
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( const Image image )
-   */
-  void SetButtonImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetButtonImage( Actor image )
-   */
-  void SetButtonImage( Actor image );
-
-  /**
-   * Used by the painter only.
-   * @return A reference to the button image.
-   */
-  Actor& GetButtonImage();
+protected:
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::
+   * Construct a new PushButton.
    */
-  Actor GetButtonImage() const;
+  PushButton();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( const Image image )
+   * A reference counted object may only be deleted by calling Unreference()
    */
-  void SetBackgroundImage( Image image );
+  virtual ~PushButton();
 
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetBackgroundImage( Actor image )
-   */
-  void SetBackgroundImage( Actor image );
+public: // From Button
 
   /**
-   * Used by the painter only.
-   * @return A reference to the background image.
+   * @copydoc Toolkit::Internal::Button::SetButtonImage( Actor image )
    */
-  Actor& GetBackgroundImage();
+  virtual void SetButtonImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetBackgroundImage()
+   * @copydoc Toolkit::Internal::Button::SetSelectedImage( Actor image )
    */
-  Actor GetBackgroundImage() const;
+  virtual void SetSelectedImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetPressedImage( const Image image )
+   * @copydoc Toolkit::Internal::Button::SetBackgroundImage( Actor image )
    */
-  void SetPressedImage( Image image );
+  virtual void SetBackgroundImage( Actor image );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetPressedImage( Actor image )
+   * @copydoc Toolkit::Internal::Button::SetDisabledImage( Actor image )
    */
-  void SetPressedImage( Actor image );
+  virtual void SetDisabledImage( Actor image );
 
   /**
-   * Used by the painter only.
-   * @return A reference to the pressed image.
+   * @copydoc Toolkit::Internal::Button::SetDisabledBackgroundImage( Actor image )
    */
-  Actor& GetPressedImage();
+  virtual void SetDisabledBackgroundImage( Actor image );
 
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetPressedImage()
-   */
-  Actor GetPressedImage() const;
+private: // From Button
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDimmedBackgroundImage( Image image )
+   * @copydoc Toolkit::Internal::Button::OnButtonInitialize()
    */
-  void SetDimmedBackgroundImage( Image image );
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetDimmedBackgroundImage( Actor image )
-   */
-  void SetDimmedBackgroundImage( Actor image );
+  virtual void OnButtonInitialize();
 
   /**
-   * Used by the painter only.
-   * @return A reference to the dimmed background image.
+   * @copydoc Toolkit::Internal::Button::OnLabelSet()
    */
-  Actor& GetDimmedBackgroundImage();
+  virtual void OnLabelSet();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDimmedBackgroundImage()
+   * @copydoc Toolkit::Internal::Button::OnSelected()
    */
-  Actor GetDimmedBackgroundImage() const;
+  virtual void OnSelected( bool selected );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDimmedImage( Image image )
+   * @copydoc Toolkit::Internal::Button::OnDisabled( bool disabled )
    */
-  void SetDimmedImage( Image image );
+  virtual void OnDisabled( bool disabled );
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetDimmedImage( Actor image )
+   * @copydoc Toolkit::Internal::Button::OnPressed()
    */
-  void SetDimmedImage( Actor image );
+  virtual void OnPressed();
 
   /**
-   * Used by the painter only.
-   * @return A reference to the dimmed button image.
+   * @copydoc Toolkit::Internal::Button::OnReleased()
    */
-  Actor& GetDimmedImage();
+  virtual void OnReleased();
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::GetDimmedImage()
+   * @copydoc Toolkit::Internal::Button::OnClicked()
    */
-  Actor GetDimmedImage() const;
+  virtual void OnClicked();
 
-  /**
-   * @copydoc Dali::Toolkit::PushButton::SetLabelText( const std::string& text )
-   */
-  void SetLabelText( const std::string& text );
+private: // From Control
 
   /**
-   * @copydoc Dali::Toolkit::PushButton::SetLabelText( Actor text )
+   * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
    */
-  void SetLabelText( Actor text );
+  virtual void OnControlSizeSet( const Vector3& targetSize );
 
   /**
-   * Used by the painter only.
-   * @return A reference to the label actor.
+   * @copydoc Toolkit::Control::GetNaturalSize()
    */
-  Actor& GetLabel();
+  virtual Vector3 GetNaturalSize();
 
-  /**
-   * @copydoc Dali::Toolkit::PushButton::GetLabelText()
-   */
-  Actor GetLabelText() const;
+private:
 
   /**
-   * Used by the painter only.
-   * @return A reference to the background image that is fading out.
+   * Used in the FadeOut functions.
    */
-  Actor& GetFadeOutBackgroundImage();
+  enum ImageLayer
+  {
+    Background, ///< Fade out the background.
+    Foreground  ///< Fade out the foreground.
+  };
 
   /**
-   * Used by the painter only.
+   * Gets the button image that is fading out.
    * @return A reference to the button image that is fading out.
    */
   Actor& GetFadeOutButtonImage();
 
-public:
-
-  // Signals
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::ToggledSignal()
-   */
-  Toolkit::PushButton::ToggledSignalV2& ToggledSignal();
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::PressedSignal()
-   */
-  Toolkit::PushButton::PressedSignalV2& PressedSignal();
-
-  /**
-   * @copydoc Dali::Toolkit::PushButton::ReleasedSignal()
-   */
-  Toolkit::PushButton::ReleasedSignalV2& ReleasedSignal();
-
-  /**
-   * Connects a callback function with the object's signals.
-   * @param[in] object The object providing the signal.
-   * @param[in] tracker Used to disconnect the signal.
-   * @param[in] signalName The signal to connect to.
-   * @param[in] functor A newly allocated FunctorDelegate.
-   * @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 );
-
-  // Properties
-
-  /**
-   * @copydoc Button::SetProperty
-   */
-  static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value );
-
   /**
-   * @copydoc Button::GetProperty
-   */
-  static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
-
-protected: // From Button
-
-  /**
-   * Sets the Leave signal.
+   * Gets the background image that is fading out.
+   * @return A reference to the background image that is fading out.
    */
-  virtual void OnButtonInitialize();
+  Actor& GetFadeOutBackgroundImage();
 
   /**
-   * Emits signals and notifies the painter accordingly with the set button
-   * properties when the button is pressed.
+   * Adds the actor to the fade in animation. It creates a fade in animation if needed.
+   * @param[in] actor The actor.
    */
-  virtual void OnButtonDown();
+  void AddToFadeInAnimation( Actor& actor );
 
   /**
-   * Emits signals and notifies the painter accordingly with the set button
-   * properties when the button is released.
+   * Starts the fade in animation.
+   * PushButton::FadeInAnimationFinished slot is called when the animation finishes.
    */
-  virtual void OnButtonUp();
+  void StartFadeInAnimation();
 
   /**
-   * Emits signals and notifies the painter accordingly with the set button
-   * properties when the touch point leaves the boundary of the button.
+   * Stops the fade in animation.
    */
-  virtual void OnTouchPointLeave();
+  void StopFadeInAnimation();
 
   /**
-   * Currently it doesn't need different behaviour than @see OnTouchPointLeave()
+   * Adds the actor to the fade out animation. It creates a fade out animation if needed.
    */
-  virtual void OnTouchPointInterrupted();
+  void AddToFadeOutAnimation( Actor& actor );
 
   /**
-   * Sets the push button animation time.
-   * @param animationTime The animation time in seconds.
+   * Starts the fade out animation.
+   * PushButton::FadeOutAnimationFinished slot is called when the animation finishes.
    */
-  virtual void OnAnimationTimeSet( float animationTime );
+  void StartFadeOutAnimation();
 
   /**
-   * Retrieves the animation time.
-   * @return The animation time in seconds.
+   * Stops the fade out animation.
+   * It removes the actor stored in PushButton::mFadeOutBackgroundImage and PushButton::mFadeOutCheckedImage.
+   * @param[in] remove If true, removes the fadeout actor from root.
    */
-  virtual float OnAnimationTimeRequested() const;
-
-protected: // From ControlImpl
+  void StopFadeOutAnimation( bool remove = true );
 
   /**
-   * Respond the activate notification.
+   * It adds the actor to the root actor and to the fade in animation.
+   * @param[inout] image The actor.
+   * @param[in] opacity The initial opacity.
    */
-  virtual void OnActivated();
-
-private:
+  void FadeInImage( Actor& image, float opacity = 0.f, int priority = -1 );
 
   /**
-   * Perform the click action to click the button.
-   * @param[in] attributes The attributes to perfrom this action.
+   * It adds the actor fade out animation and stores it to be removed when the animation finishes.
+   * @param[in] layer Defines if the actor is going to be stored in the mFadeOutBackgroundImage or mFadeOutCheckedImage member.
+   * @param[inout] image The actor.
+   * @param[in] opacity The initial opacity.
    */
-  void DoClickAction(const PropertyValueContainer& attributes);
+  void FadeOutImage( ImageLayer layer, Actor& image, float opacity = 1.f );
 
-public:
+  // slots
 
   /**
-   * Performs actions as requested using the action name.
-   * @param[in] object The object on which to perform the action.
-   * @param[in] actionName The action to perform.
-   * @param[in] attributes The attributes with which to perfrom this action.
-   * @return true if action has been accepted by this control
+   * Called when the fade out animation finishes.
+   * It changes the check button paint state and removes actors from the root.
    */
-  static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
+  void FadeOutAnimationFinished( Dali::Animation& source );
 
   /**
-   * Construct a new PushButton.
+   * Called when the fade in animation finishes.
+   * It changes the check button paint state.
    */
-  PushButton();
-
-  /**
-   * A reference counted object may only be deleted by calling Unreference()
-   */
-  virtual ~PushButton();
+  void FadeInAnimationFinished( Dali::Animation& source );
 
 private:
 
@@ -364,47 +233,17 @@ private:
   // Undefined
   PushButton& operator=( const PushButton& );
 
-  /**
-   * Sets up the autorepeating timer.
-   * @param[in] delay The delay time in seconds.
-   */
-  void SetUpTimer( float delay );
-
-  /**
-   * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
-   */
-  bool AutoRepeatingSlot();
-
 private:
-  bool  mAutoRepeating;             ///< Stores the autorepeating property.
-  float mInitialAutoRepeatingDelay; ///< Stores the initial autorepeating delay in seconds.
-  float mNextAutoRepeatingDelay;    ///< Stores the next autorepeating delay in seconds.
-  bool  mToggleButton;              ///< Stores the toggle property.
-
-  // AutoRepeating
-  Timer mAutoRepeatingTimer;        ///< Timer used to implement the autorepeating property.
-
-  // Toggle
-  bool  mToggled;                   ///< Stores the toggle state.
-
-  // Signals
-  Toolkit::PushButton::ToggledSignalV2 mToggledSignalV2;   ///< Signal emitted when the button is toggled.
-  Toolkit::PushButton::PressedSignalV2 mPressedSignalV2;   ///< Signal emitted when the button is pressed.
-  Toolkit::PushButton::ReleasedSignalV2 mReleasedSignalV2; ///< Signal emitted when the button is released.
 
-  Actor mButtonImage;               ///< Stores the released image.
-  Actor mBackgroundImage;           ///< Stores the background image.
-  Actor mPressedImage;              ///< Stores the pressed image.
-  Actor mDimmedImage;               ///< Stores the dimmed image.
-  Actor mDimmedBackgroundImage;     ///< Stores the dimmed background image.
+  Animation             mFadeInAnimation;           ///< Animation used in the state transitions.
+  Animation             mFadeOutAnimation;          ///< Animation used in the state transitions.
 
-  Actor mLabel;                     ///< Stores the text label.
+  Actor                 mFadeOutButtonContent;      ///< Stores a foreground content, which is in a fade out animation, to be removed when the animation finishes.
+  Actor                 mFadeOutBackgroundContent;  ///< Stores a background content, which is in a fade out animation, to be removed when the animation finishes.
 
-  Actor mFadeOutBackgroundImage;    ///< Stores a background image, which is in a fade out animation, to be removed when the animation finishes.
-  Actor mFadeOutButtonImage;        ///< Stores a foreground image, which is in a fade out animation, to be removed when the animation finishes.
+  Vector3               mSize;                      ///< The button's size.
 
-  // Actions
-  bool mClickActionPerforming;
+  PaintState            mPaintState;                ///< The paint state.
 };
 
 } // namespace Internal