Buttons to use Visuals
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / button-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_BUTTON_H
2 #define DALI_TOOLKIT_INTERNAL_BUTTON_H
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/adaptor-framework/timer.h>
23 #include <dali/public-api/animation/animation.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/devel-api/visual-factory/visual-base.h>
27 #include <dali-toolkit/public-api/controls/buttons/button.h>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29
30 //#if defined(DEBUG_ENABLED)
31 //  Debug::Filter* gLogButtonFilter = Debug::Filter::New(Debug::NoLogging, true, "LOG_BUTTON_CONTROL");
32 //#endif
33
34 namespace Dali
35 {
36
37 namespace Toolkit
38 {
39
40 class Button;
41
42 namespace Internal
43 {
44
45 /**
46  * @copydoc Toolkit::Button
47  *
48  * Button is the base class implementation for all buttons.
49  *
50  * @note
51  *
52  * All Foreground/Icon visuals expected to be the same size.
53  * Background visuals will take the size of the control.
54  * Padding and struts take size precedence over visuals when available space is limited.
55  * Icon/Foreground visuals take size precedence over Labels when available space is limited.
56  */
57 class Button : public Control
58 {
59
60 public:
61
62   /**
63    * Enum describing the position the text label can be in relation to the control (and foreground/icon)
64    */
65   enum Align
66   {
67     BEGIN,  // At the start of the control before the foreground/icon
68     END,    // At the end of the control after the foreground/icon
69     TOP,    // At the top of the control above the foreground/icon
70     BOTTOM  // At the bottom of the control below the foreground/icon
71   };
72
73 public:
74
75   /**
76    * @copydoc Dali::Toolkit::Button::SetDisabled
77    */
78   void SetDisabled( bool disabled );
79
80   /**
81    * @copydoc Dali::Toolkit::Button::IsDisabled
82    */
83   bool IsDisabled() const;
84
85   /**
86    * @copydoc Dali::Toolkit::Button::SetAutoRepeating
87    */
88   void SetAutoRepeating( bool autoRepeating );
89
90   /**
91    * @copydoc Dali::Toolkit::Button::IsAutoRepeating
92    */
93   bool IsAutoRepeating() const;
94
95   /**
96    * @copydoc Dali::Toolkit::Button::SetInitialAutoRepeatingDelay
97    */
98   void SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay );
99
100   /**
101    * @copydoc Dali::Toolkit::Button::GetInitialAutoRepeatingDelay
102    */
103   float GetInitialAutoRepeatingDelay() const;
104
105   /**
106    * @copydoc Dali::Toolkit::Button::SetNextAutoRepeatingDelay
107    */
108   void SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay );
109
110   /**
111    * @copydoc Dali::Toolkit::Button::GetNextAutoRepeatingDelay
112    */
113   float GetNextAutoRepeatingDelay() const;
114
115   /**
116    * @copydoc Dali::Toolkit::Button::SetTogglableButton
117    */
118   void SetTogglableButton( bool togglable );
119
120   /**
121    * @copydoc Dali::Toolkit::Button::IsTogglableButton
122    */
123   bool IsTogglableButton() const;
124
125   /**
126    * @copydoc Dali::Toolkit::Button::SetSelected
127    */
128   void SetSelected( bool selected );
129
130   /**
131    * @copydoc Dali::Toolkit::Button::IsSelected
132    */
133   bool IsSelected() const;
134
135   /**
136    * @copydoc Dali::Toolkit::Button::SetAnimationTime
137    */
138   void SetAnimationTime( float animationTime );
139
140   /**
141    * @copydoc Dali::Toolkit::Button::GetAnimationTime
142    */
143   float GetAnimationTime() const;
144
145   /**
146    * @copydoc Dali::Toolkit::Button::SetLabelText
147    */
148   void SetLabelText( const std::string& label );
149
150   /**
151    * @copydoc Dali::Toolkit::Button::GetLabelText
152    */
153   std::string GetLabelText() const;
154
155   /**
156    * @brief Sets the specified properties on the button label.
157    * If the label does not exist yet, it is created.
158    * The derived buttons are notified if any properties are changed.
159    * @param[in] properties A Property::Map of key-value pairs of properties to set.
160    */
161   void SetupLabel( const Property::Map& properties );
162
163   /**
164    * Performs actions as requested using the action name.
165    * @param[in] object The object on which to perform the action.
166    * @param[in] actionName The action to perform.
167    * @param[in] attributes The attributes with which to perfrom this action.
168    * @return true if action has been accepted by this control
169    */
170   static bool DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes );
171
172 public: // Deprecated API
173
174   /**
175    * @copydoc Dali::Toolkit::Button::SetLabel( Actor label )
176    */
177   void SetLabel( Actor label );
178
179   /**
180    * @deprecated Sets the unselected image with an url.
181    * @param[in] image The Actor to use.
182    */
183   void SetUnselectedImage( const std::string& filename );
184
185   /**
186    * @deprecated Sets the selected image with an url.
187    * @param[in] filename The url of the image to use to use.
188    */
189   void SetSelectedImage( const std::string& filename );
190
191   /**
192    * @deprecated Sets the selected background image with an url.
193    * @param[in] filename The url of the image to use to use.
194    */
195   void SetSelectedBackgroundImage( const std::string& filename );
196
197   /**
198    * @deprecated Sets the background image with an url.
199    * @param[in] filename The url of the image to use to use.
200    */
201   void SetBackgroundImage( const std::string& filename );
202
203   /**
204    * @deprecated Sets the disabled unselected background image with an url.
205    * @param[in] filename The url of the image to use to use.
206    */
207   void SetDisabledBackgroundImage( const std::string& filename );
208
209   /**
210    * @deprecated Sets the disabled unselected image with an url.
211    * @param[in] filename The url of the image to use to use.
212    */
213   void SetDisabledImage( const std::string& filename );
214
215   /**
216    * @deprecated Sets the disabled selected image with an url.
217    * @param[in] filename The url of the image to use to use.
218    */
219   void SetDisabledSelectedImage( const std::string& filename );
220
221   /**
222    * @deprecated Sets the unselected image with an Actor.
223    * @param[in] image The Actor to use.
224    */
225   void SetUnselectedImage( Actor image );
226
227   /**
228    * @deprecated Sets the selected image with an Actor.
229    * @param[in] image The Actor to use.
230    */
231   void SetSelectedImage( Actor image );
232
233   /**
234    * @deprecated Sets the selected background image with an Actor.
235    * @param[in] image The Actor to use.
236    */
237   void SetSelectedBackgroundImage( Actor image );
238
239   /**
240    * @deprecated Sets the disabled image with an Actor.
241    * @param[in] image The Actor to use.
242    */
243   void SetDisabledImage( Actor image );
244
245   /**
246    * @deprecated Sets the disabled selected image with an Actor.
247    * @param[in] image The Actor to use.
248    */
249   void SetDisabledSelectedImage( Actor image );
250
251   /**
252    * @deprecated Sets the disabled background image with an Actor.
253    * @param[in] image The Actor to use.
254    */
255   void SetDisabledBackgroundImage( Actor image );
256
257   /**
258    * @Gets url of a image visual, used by GetProperty but for deprecated Properties
259    * @param[in] index Visual index of url required
260    * @return filename for the corresponding visual
261    */
262   std::string GetUrlForImageVisual( Property::Index index );
263
264
265   /**
266    * @copydoc Dali::Toolkit::Button::GetButtonImage
267    */
268   Actor GetButtonImage() const;
269
270   /**
271    * @copydoc Dali::Toolkit::Button::GetSelectedImage
272    */
273   Actor GetSelectedImage() const;
274
275 public:
276
277   /**
278    * Button's state
279    */
280   enum State
281   {
282     UNSELECTED_STATE,              ///< The button is unselected.
283     SELECTED_STATE,                ///< The button is selected.
284     DISABLED_UNSELECTED_STATE,     ///< The button is disabled and unselected.
285     DISABLED_SELECTED_STATE,       ///< The button is disabled and selected.
286     STATE_COUNT,                   ///< Number of States
287   };
288
289   /**
290    * Enum to distinguish the different style-able components of the button
291    */
292   enum Visuals
293   {
294     UNSELECTED_FOREGROUND = 0,
295     SELECTED_FOREGROUND,
296     DISABLED_SELECTED_FOREGROUND,
297     DISABLED_UNSELECTED_FOREGROUND,
298     UNSELECTED_BACKGROUND,
299     SELECTED_BACKGROUND,
300     DISABLED_UNSELECTED_BACKGROUND,
301     DISABLED_SELECTED_BACKGROUND,
302     VISUALS_COUNT
303   };
304
305   /**
306    * Enum to list types of visual a state can have.
307    */
308   enum VisualState
309   {
310     BACKGROUND = 0,
311     FOREGROUND,
312     VISUAL_STATE_COUNT
313   };
314
315 protected:
316
317   /**
318    * Button press state which is not the same as the actual button's state.
319    * A button can be DEPRESSED but the until released the button state may have not changed,
320    * For example DEPRESSING a toggle button that is already in the SELECTED state will not change the button state untill released.
321    */
322   enum PressState
323   {
324     DEPRESSED,                           ///< The button is up.
325     UNPRESSED,                           ///< The button is down.
326     TOGGLE_DEPRESSED,                    ///< The button has been pressed down and will stay depressed when released.
327   };
328
329   /**
330    * Construct a new Button.
331    */
332   Button();
333
334   /**
335    * A reference counted object may only be deleted by calling Unreference()
336    */
337   virtual ~Button();
338   /**
339    * @return A reference to the label actor.
340    */
341   Actor& GetLabelActor();
342
343   /**
344    * @return A reference to the unselected button image.
345    */
346   Actor GetUnselectedImage();
347
348   /**
349    * @return A reference to the selected image.
350    */
351   Actor GetSelectedImage();
352
353 private:
354
355   /**
356    * Perform the click action to click the button.
357    * @param[in] attributes The attributes to perfrom this action.
358    * @return true if this control can perform action.
359    */
360   bool DoClickAction( const Property::Map& attributes );
361
362   /**
363    * This method is called when the label is set.
364    * @param[in] noPadding Used to bypass padding if the label is to be treated generically.
365    */
366   virtual void OnLabelSet( bool noPadding ) {}
367
368   /**
369    * This method is called when the unselected button image is set
370    */
371   virtual void OnUnselectedImageSet() {}
372
373   /**
374    * This method is called when the selected image is set
375    */
376   virtual void OnSelectedImageSet() {}
377
378   /**
379    * This method is called when the background image is set
380    */
381   virtual void OnBackgroundImageSet() {}
382
383   /**
384    * This method is called when the selected background image is set
385    */
386   virtual void OnSelectedBackgroundImageSet() {}
387
388   /**
389    * This method is called when the disabled button image is set
390    */
391   virtual void OnDisabledImageSet() {}
392
393   /**
394    * This method is called when the disabled selected image is set
395    */
396   virtual void OnDisabledSelectedImageSet() {}
397
398   /**
399    * This method is called when the disabled background image is set
400    */
401   virtual void OnDisabledBackgroundImageSet() {}
402
403   /**
404    * This method is called the button is down.
405    * Could be reimplemented in subclasses to provide specific behaviour.
406    */
407   virtual void OnButtonDown();
408
409   /**
410    * This method is called when the button is up.
411    * Could be reimplemented in subclasses to provide specific behaviour.
412    */
413   virtual void OnButtonUp();
414
415   /**
416    * This method is called when touch leaves the boundary of the button or several touch points are received.
417    * Could be reimplemented in subclasses to provide specific behaviour.
418    */
419   virtual void OnTouchPointLeave();
420
421   /**
422    * This method is called when the touch is interrupted.
423    * Could be reimplemented in subclasses to provide specific behaviour.
424    */
425   virtual void OnTouchPointInterrupted();
426
427   /**
428    * This method is called when the \e selected property is changed.
429    */
430   virtual void OnStateChange( State newState ){}
431
432   /**
433    * This method is called when the \e disabled property is changed.
434    */
435   virtual void OnDisabled() {}
436
437   /**
438    * This method is called when the button is pressed.
439    */
440   virtual void OnPressed() {}
441
442   /**
443    * This method is called when the button is released.
444    */
445   virtual void OnReleased() {}
446
447 public:
448
449   /**
450    * @copydoc Dali::Toolkit::PushButton::PressedSignal()
451    */
452   Toolkit::Button::ButtonSignalType& PressedSignal();
453
454   /**
455    * @copydoc Dali::Toolkit::PushButton::ReleasedSignal()
456    */
457   Toolkit::Button::ButtonSignalType& ReleasedSignal();
458
459   /**
460    * @copydoc Dali::Toolkit::Button::ClickedSignal()
461    */
462   Toolkit::Button::ButtonSignalType& ClickedSignal();
463
464   /**
465    * @copydoc Dali::Toolkit::Button::StateChangedSignal()
466    */
467   Toolkit::Button::ButtonSignalType& StateChangedSignal();
468
469   /**
470    * Connects a callback function with the object's signals.
471    * @param[in] object The object providing the signal.
472    * @param[in] tracker Used to disconnect the signal.
473    * @param[in] signalName The signal to connect to.
474    * @param[in] functor A newly allocated FunctorDelegate.
475    * @return True if the signal was connected.
476    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
477    */
478   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
479
480   // Properties
481
482   /**
483    * Called when a property of an object of this type is set.
484    * @param[in] object The object whose property is set.
485    * @param[in] index The property index.
486    * @param[in] value The new property value.
487    */
488   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
489
490   /**
491    * Called to retrieve a property of an object of this type.
492    * @param[in] object The object whose property is to be retrieved.
493    * @param[in] index The property index.
494    * @return The current value of the property.
495    */
496   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
497
498 protected: // From Control
499
500   /**
501    * @copydoc Toolkit::Control::OnInitialize()
502    * @note If overridden by deriving button classes, then an up-call to Button::OnInitialize MUST be made at the start.
503    */
504   virtual void OnInitialize();
505
506   /**
507    * @copydoc Toolkit::Control::OnAccessibilityActivated()
508    */
509   virtual bool OnAccessibilityActivated();
510
511   /**
512    * @copydoc Toolkit::Control::OnKeyboardEnter()
513    */
514   virtual bool OnKeyboardEnter();
515
516   /**
517    * @copydoc Toolkit::Control::OnStageDisconnection()
518    * @note If overridden by deriving button classes, then an up-call to Button::OnStageDisconnection MUST be made at the end.
519    */
520   virtual void OnStageDisconnection();
521
522   /**
523    * @copydoc Toolkit::Control::OnStageConnnection()
524    */
525   virtual void OnStageConnection( int depth );
526
527   /**
528    * @copydoc Toolkit::Control::GetNaturalSize
529    */
530   virtual Vector3 GetNaturalSize();
531
532   /**
533    * @copydoc Toolkit::Control::OnSetResizePolicy
534    */
535   virtual void OnSetResizePolicy( ResizePolicy::Type policy, Dimension::Type dimension );
536
537   /**
538    * @copydoc Toolkit::Control::OnRelayout
539    */
540   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
541
542 private:
543
544   /**
545    * @brief Handler for touch data
546    * @param[in]  actor  The touched actor.
547    * @param[in]  touch  The touch info.
548    * @return true, if consumed, false otherwise.
549    */
550   bool OnTouch( Actor actor, const TouchData& touch );
551
552   /**
553    * Handler for tap events.
554    * We do not actually do anything when we receive a tap as the button handles tap event through
555    * the touch event system itself as it requires more than just tap handling (e.g. leave events).
556    * This stops any of our parents receiving a tap gesture when it occurs within our area.
557    * @param[in]  actor  The tapped actor.
558    * @param[in]  tap    The tap gesture.
559    */
560   void OnTap(Actor actor, const TapGesture& tap);
561
562   /**
563    * Sets up the autorepeating timer.
564    * @param[in] delay The delay time in seconds.
565    */
566   void SetUpTimer( float delay );
567
568   /**
569    * Button has been pressed
570    */
571   void Pressed();
572
573   /**
574    * Slot called when Dali::Timer::SignalTick signal. Resets the autorepeating timer.
575    */
576   bool AutoRepeatingSlot();
577
578   /**
579    *  Check the requested state is an allowed transition.
580    *  Some states can not be transitioned to from certain states.
581    *  @param[in] requestedState check if can transition to this state
582    *  @return bool true if state change valid
583    */
584   bool ValidateState( State requestedState );
585
586   /**
587    * Perform the given function on the visuals in the given state. Can be used to add and remove visuals.
588    * @param[in] functionPtr pointer to the function to perform an action on a visual
589    * @param[in] state Visuals in this state will be the target
590    */
591   void PerformFunctionOnVisualsInState( void(Button::*functionPtr)( Property::Index visualIndex), State state  );
592
593   /**
594    * Transition the visual in or out using the set animation
595    * @param[in] state State to transition in or out
596    */
597   void SetVisualsForTransition( State state );
598
599   /**
600    * Changes the button state when an action occurs on it
601    * @param[in] requestedState the state to change to
602    */
603   void ChangeState( State requestedState );
604
605   /**
606    * @brief Get unselected button color
607    * @return color as vector4
608    */
609   const Vector4 GetUnselectedColor() const;
610
611   /**
612    * @brief Get selected button color
613    * @return color as vector4
614    */
615   const Vector4 GetSelectedColor() const;
616
617   /**
618    * Sets the color of button in selected or unselected state, if image also supplied this color will be appplied to it.
619    * If no visual exists, it is created.
620    * @param[in]  color The color to use.
621    * @param[in]  visualIndex The Visual to apply the color
622    */
623   void SetColor( const Vector4& color, Property::Index visualIndex );
624
625   /**
626    * This method is called when the button is released.
627    */
628   void Released();
629
630 protected:
631
632   /**
633    * Set Text Label Padding
634    * @param[in] padding BEGIN END BOTTOM TOP
635    */
636   void SetLabelPadding( const Padding& padding );
637
638   /**
639    * Get Text Label padding
640    * @return Padding
641    */
642   Padding GetLabelPadding();
643
644   /**
645    * Set Foreground/icon Padding
646    * @param[in] padding BEGIN END BOTTOM TOP
647    */
648   void SetForegroundPadding( const Padding& padding);
649
650   /**
651    * Get Foreground padding
652    * @ return Padding
653    */
654   Padding GetForegroundPadding();
655
656   /**
657    * @brief Get the pressed state of the button
658    * @return ButtonPressedState the state the button is in
659    */
660   PressState GetPressedState();
661
662   /**
663    * @brief Get the state of the button
664    * @return PaintState the state the button is in
665    */
666   State GetButtonState();
667
668   /**
669    * @brief Setup the button components for example foregrounds and background
670    * @param[in] index the index of the visual to set
671    * @param[in] value the value to set on the component
672    * @param[in] visualDepth the depth of the visual if overlapping another
673    */
674   void CreateVisualsForComponent( Property::Index index ,const Property::Value& value, const float visualDepth );
675
676   /**
677    * Returns the animation to be used for transition, creating the animation if needed.
678    * @return The initialised transition animation.
679    */
680   Dali::Animation GetTransitionAnimation();
681
682   /**
683    * @brief Set distance between label and foreground/icon, if both present
684    * @param[in] length length of strut
685    */
686   void SetLabelStrutLength( unsigned int length );
687
688   /**
689    * @brief Set the position of the label relative to foreground/icon, if both present
690    * @param[in] labelAlignment given alignment setting
691    */
692   void SetLabelAlignment( Align labelAlignment);
693
694   /**
695    * @brief Get set distance between label and foreground/icon visual
696    * @return length of strut
697    */
698   float GetLabelStrutLength();
699
700   /**
701    * @brief Get set alignment of label in relation to foreground/icon
702    * @return Set alignment value
703    */
704   Align GetLabelAlignment();
705
706   /**
707    * Prepares the actor to be transitioned in.
708    * @param[in]  actor  The actor that will be transitioned in.
709    */
710   virtual void PrepareForTransitionIn( Actor actor ) {}
711
712   /**
713    * Prepares the actor to be transitioned in.
714    * @param[in]  actor  The actor that will be transitioned out.
715    */
716   virtual void PrepareForTransitionOut( Actor actor ) {}
717
718   /**
719    * Transitions the actor in, allowing derived classes to configure
720    * the GetTransitionAnimation() animation ready.
721    * Button is in charge of calling Dali::Animation::Play and so derived classes
722    * only need to add the animation.
723    */
724   virtual void OnTransitionIn( Actor actor );
725
726   /**
727    * Transitions the actor out, allowing derived classes to configure
728    * the GetTransitionAnimation() animation ready.
729    * Button is in charge of calling Dali::Animation::Play and so derived classes
730    * only need to add the animation.
731    */
732   virtual void OnTransitionOut( Actor actor ) {}
733
734   /**
735    * Removes the visual from the button (un-staged)
736    * If the derived button does not want the visual removed then use this virtual function to
737    * define the required behaviour.
738    * Can decide to only remove specified visuals via index
739    */
740   virtual void OnButtonVisualRemoval( Property::Index visualIndex );
741
742
743 private:
744
745   /**
746    * Starts the transition animation.
747    * Button::TransitionFinished is called when the animation finishes.
748    */
749   void StartTransitionAnimation();
750
751   /**
752    * This method stops and clears animations
753    */
754   void ClearTransitionAnimation();
755
756   /**
757    * Called when the transition animation finishes.
758    */
759   void TransitionAnimationFinished( Dali::Animation& source );
760
761   /**
762    * Transition button visual using an animation before removal from Stage
763    */
764   void TransitionButtonVisualOut( Property::Index visualIndex );
765
766   /**
767    * Transition button visual using an animation before adding to Stage
768    */
769   void TransitionButtonVisualIn( Property::Index visualIndex );
770
771   /**
772    * Removes the visual from the button and prepares it to be transitioned out
773    * @param[in] visualIndex the visual to remove
774    */
775   void RemoveVisual( Property::Index visualIndex );
776
777   /**
778    * Adds the required visual to the button.
779    * @param[in] visualIndex The Property index of the visual required
780    */
781   void SelectRequiredVisual( Property::Index visualIndex );
782
783   // Undefined
784   Button( const Button& );
785
786   // Undefined
787   Button& operator = ( const Button& );
788
789 private:
790
791   // Signals
792   Toolkit::Button::ButtonSignalType mPressedSignal;           ///< Signal emitted when the button is pressed.
793   Toolkit::Button::ButtonSignalType mReleasedSignal;          ///< Signal emitted when the button is released.
794   Toolkit::Button::ButtonSignalType mClickedSignal;           ///< Signal emitted when the button is clicked.
795   Toolkit::Button::ButtonSignalType mStateChangedSignal;      ///< Signal emitted when the button's state is changed.
796
797   Timer            mAutoRepeatingTimer;
798
799   Actor            mLabel;                      ///< Stores the button text label.
800   Padding          mLabelPadding;               ///< The padding around the label (if present).
801   Padding          mForegroundPadding;          ///< The padding around the foreground/icon visual (if present).
802
803   unsigned int     mForeGroundToLabelStrutLength; ///< Distance between foreground/icon and label.
804   Align            mTextLabelAlignment;           ///< Position of text label in relation to foreground/icon when both are present.
805
806   Animation        mTransitionAnimation;        ///< Used in the state transitions.
807
808   TapGestureDetector mTapDetector;
809
810   Vector4          mUnselectedColor;
811   Vector4          mSelectedColor;
812
813   bool             mAutoRepeating;              ///< Stores the autorepeating property.
814   bool             mTogglableButton;            ///< Stores the togglable property as a flag.
815   float            mInitialAutoRepeatingDelay;  ///< Stores the initial autorepeating delay in seconds.
816   float            mNextAutoRepeatingDelay;     ///< Stores the next autorepeating delay in seconds.
817
818   float            mAnimationTime;
819
820   PressState       mButtonPressedState;         ///< In relation to the button being pressed/released
821   State            mButtonState;
822   State            mPreviousButtonState;        ///< During a transition between two states, this stores the previous state so Visuals can be removed.
823
824   // Actions
825   bool             mClickActionPerforming;      ///< Used to manage signal emissions during action
826 };
827
828 } // namespace Internal
829
830 // Helpers for public-api forwarding methods
831
832 inline Toolkit::Internal::Button& GetImplementation( Toolkit::Button& button )
833 {
834   DALI_ASSERT_ALWAYS( button );
835
836   Dali::RefObject& handle = button.GetImplementation();
837
838   return static_cast<Toolkit::Internal::Button&>( handle );
839 }
840
841 inline const Toolkit::Internal::Button& GetImplementation( const Toolkit::Button& button )
842 {
843   DALI_ASSERT_ALWAYS( button );
844
845   const Dali::RefObject& handle = button.GetImplementation();
846
847   return static_cast<const Toolkit::Internal::Button&>( handle );
848 }
849
850 } // namespace Toolkit
851
852 } // namespace Dali
853
854 #endif // DALI_TOOLKIT_INTERNAL_BUTTON_H