Follow the include-order coding conventions
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / buttons / button-impl.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include "button-impl.h"
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/events/touch-event.h>
23 #include <dali/public-api/object/type-registry.h>
24 #include <dali/public-api/actors/image-actor.h>
25 #include <dali/public-api/scripting/scripting.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 const Property::Index Button::PROPERTY_DISABLED                     = Internal::Button::BUTTON_PROPERTY_START_INDEX;
37 const Property::Index Button::PROPERTY_AUTO_REPEATING               = Internal::Button::BUTTON_PROPERTY_START_INDEX + 1;
38 const Property::Index Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY = Internal::Button::BUTTON_PROPERTY_START_INDEX + 2;
39 const Property::Index Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY    = Internal::Button::BUTTON_PROPERTY_START_INDEX + 3;
40 const Property::Index Button::PROPERTY_TOGGLABLE                    = Internal::Button::BUTTON_PROPERTY_START_INDEX + 4;
41 const Property::Index Button::PROPERTY_SELECTED                     = Internal::Button::BUTTON_PROPERTY_START_INDEX + 5;
42 const Property::Index Button::PROPERTY_NORMAL_STATE_ACTOR           = Internal::Button::BUTTON_PROPERTY_START_INDEX + 6;
43 const Property::Index Button::PROPERTY_SELECTED_STATE_ACTOR         = Internal::Button::BUTTON_PROPERTY_START_INDEX + 7;
44 const Property::Index Button::PROPERTY_DISABLED_STATE_ACTOR         = Internal::Button::BUTTON_PROPERTY_START_INDEX + 8;
45 const Property::Index Button::PROPERTY_LABEL_ACTOR                  = Internal::Button::BUTTON_PROPERTY_START_INDEX + 9;
46
47 namespace Internal
48 {
49
50 namespace
51 {
52
53 const unsigned int INITIAL_AUTOREPEATING_DELAY( 0.15f );
54 const unsigned int NEXT_AUTOREPEATING_DELAY( 0.05f );
55
56 // Signals
57
58 const char* const SIGNAL_PRESSED =       "pressed";
59 const char* const SIGNAL_RELEASED =      "released";
60 const char* const SIGNAL_CLICKED =       "clicked";
61 const char* const SIGNAL_STATE_CHANGED = "state-changed";
62
63 // Actions
64
65 const char* const ACTION_BUTTON_CLICK =  "button-click";
66
67 BaseHandle Create()
68 {
69   // empty handle as we cannot create button (but type registered for clicked signal)
70   return BaseHandle();
71 }
72
73 TypeRegistration typeRegistration( typeid( Toolkit::Button ), typeid( Toolkit::Control ), Create );
74
75 SignalConnectorType signalConnector1( typeRegistration, SIGNAL_PRESSED , &Button::DoConnectSignal );
76 SignalConnectorType signalConnector2( typeRegistration, SIGNAL_RELEASED, &Button::DoConnectSignal );
77 SignalConnectorType signalConnector3( typeRegistration, SIGNAL_CLICKED, &Button::DoConnectSignal );
78 SignalConnectorType signalConnector4( typeRegistration, SIGNAL_STATE_CHANGED, &Button::DoConnectSignal );
79
80 TypeAction action1( typeRegistration, ACTION_BUTTON_CLICK, &Button::DoAction );
81
82 PropertyRegistration property1( typeRegistration, "disabled",                     Toolkit::Button::PROPERTY_DISABLED,                     Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
83 PropertyRegistration property2( typeRegistration, "auto-repeating",               Toolkit::Button::PROPERTY_AUTO_REPEATING,               Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
84 PropertyRegistration property3( typeRegistration, "initial-auto-repeating-delay", Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY, Property::FLOAT,   &Button::SetProperty, &Button::GetProperty );
85 PropertyRegistration property4( typeRegistration, "next-auto-repeating-delay",    Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY,    Property::FLOAT,   &Button::SetProperty, &Button::GetProperty );
86 PropertyRegistration property5( typeRegistration, "togglable",                    Toolkit::Button::PROPERTY_TOGGLABLE,                    Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
87 PropertyRegistration property6( typeRegistration, "selected",                     Toolkit::Button::PROPERTY_SELECTED,                     Property::BOOLEAN, &Button::SetProperty, &Button::GetProperty );
88 PropertyRegistration property7( typeRegistration, "normal-state-actor",           Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR,           Property::MAP,     &Button::SetProperty, &Button::GetProperty );
89 PropertyRegistration property8( typeRegistration, "selected-state-actor",         Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR,         Property::MAP,     &Button::SetProperty, &Button::GetProperty );
90 PropertyRegistration property9( typeRegistration, "disabled-state-actor",         Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR,         Property::MAP,     &Button::SetProperty, &Button::GetProperty );
91 PropertyRegistration property10( typeRegistration, "label-actor",                 Toolkit::Button::PROPERTY_LABEL_ACTOR,                  Property::MAP,     &Button::SetProperty, &Button::GetProperty );
92
93 } // unnamed namespace
94
95 Button::Button()
96 : Control( ControlBehaviour( REQUIRES_TOUCH_EVENTS | REQUIRES_STYLE_CHANGE_SIGNALS ) ),
97   mTogglableButton( false ),
98   mSelected( false ),
99   mPainter( NULL ),
100   mAutoRepeatingTimer(),
101   mDisabled( false ),
102   mAutoRepeating( false ),
103 //  mTogglableButton( false ),
104 //  mSelected( false ),
105   mInitialAutoRepeatingDelay( INITIAL_AUTOREPEATING_DELAY ),
106   mNextAutoRepeatingDelay( NEXT_AUTOREPEATING_DELAY ),
107   mClickActionPerforming( false ),
108   mState( ButtonUp )
109 {
110 }
111
112 Button::~Button()
113 {
114   if( mAutoRepeatingTimer )
115   {
116     mAutoRepeatingTimer.Reset();
117   }
118 }
119
120 void Button::SetDisabled( bool disabled )
121 {
122   mDisabled = disabled;
123
124   // Notifies the painter.
125   Toolkit::Button handle( GetOwner() );
126   if( mPainter )
127   {
128     mPainter->SetDisabled( handle, mDisabled );
129   }
130 }
131
132 bool Button::IsDisabled() const
133 {
134   return mDisabled;
135 }
136
137 void Button::SetAutoRepeating( bool autoRepeating )
138 {
139   mAutoRepeating = autoRepeating;
140
141   // An autorepeating button can't be a togglable button.
142   if( autoRepeating )
143   {
144     mTogglableButton = false;
145     if( mSelected )
146     {
147       // Emit a signal is not wanted, only change the appearance.
148       Toolkit::Button handle( GetOwner() );
149       mPainter->Selected( handle );
150       mSelected = false;
151     }
152   }
153
154   // Notifies the painter.
155   mPainter->SetAutoRepeating( mAutoRepeating );
156 }
157
158 bool Button::IsAutoRepeating() const
159 {
160   return mAutoRepeating;
161 }
162
163 void Button::SetInitialAutoRepeatingDelay( float initialAutoRepeatingDelay )
164 {
165   DALI_ASSERT_ALWAYS( initialAutoRepeatingDelay > 0.f );
166   mInitialAutoRepeatingDelay = initialAutoRepeatingDelay;
167 }
168
169 float Button::GetInitialAutoRepeatingDelay() const
170 {
171   return mInitialAutoRepeatingDelay;
172 }
173
174 void Button::SetNextAutoRepeatingDelay( float nextAutoRepeatingDelay )
175 {
176   DALI_ASSERT_ALWAYS( nextAutoRepeatingDelay > 0.f );
177   mNextAutoRepeatingDelay = nextAutoRepeatingDelay;
178 }
179
180 float Button::GetNextAutoRepeatingDelay() const
181 {
182   return mNextAutoRepeatingDelay;
183 }
184
185 void Button::SetTogglableButton( bool togglable )
186 {
187   mTogglableButton = togglable;
188
189   // A togglable button can't be an autorepeating button.
190   if( togglable )
191   {
192     mAutoRepeating = false;
193
194     // Notifies the painter.
195     mPainter->SetAutoRepeating( mAutoRepeating );
196   }
197 }
198
199 bool Button::IsTogglableButton() const
200 {
201   return mTogglableButton;
202 }
203
204 void Button::SetSelected( bool selected )
205 {
206   if( !mDisabled && mTogglableButton && ( selected != mSelected ) )
207   {
208     mSelected = selected;
209
210     Toolkit::Button handle( GetOwner() );
211
212     // Notifies the painter the button has been selected.
213     mPainter->Selected( handle );
214
215     // Emit signal.
216     mStateChangedSignal.Emit( handle );
217   }
218 }
219
220 bool Button::IsSelected() const
221 {
222   return mTogglableButton && mSelected;
223 }
224
225 void Button::SetAnimationTime( float animationTime )
226 {
227   OnAnimationTimeSet( animationTime );
228 }
229
230 float Button::GetAnimationTime() const
231 {
232   return OnAnimationTimeRequested();
233 }
234
235 void Button::SetLabel( const std::string& label )
236 {
237   Toolkit::TextView textView = Toolkit::TextView::New( label );
238   textView.SetWidthExceedPolicy( Toolkit::TextView::ShrinkToFit ); // Make sure our text always fits inside the button
239   SetLabel( textView );
240
241   RelayoutRequest();
242 }
243
244 void Button::SetLabel( Actor label )
245 {
246   Toolkit::Button handle( GetOwner() );
247
248   mPainter->SetLabel( handle, label );
249 }
250
251 Actor Button::GetLabel() const
252 {
253   return mLabel;
254 }
255
256 Actor& Button::GetLabel()
257 {
258   return mLabel;
259 }
260
261 void Button::SetButtonImage( Image image )
262 {
263   SetButtonImage( ImageActor::New( image ) );
264 }
265
266 void Button::SetButtonImage( Actor image )
267 {
268   Toolkit::Button handle( GetOwner() );
269   mPainter->SetButtonImage( handle, image );
270 }
271
272 Actor Button::GetButtonImage() const
273 {
274   return mButtonImage;
275 }
276
277 Actor& Button::GetButtonImage()
278 {
279   return mButtonImage;
280 }
281
282 void Button::SetSelectedImage( Image image )
283 {
284   SetSelectedImage( ImageActor::New( image ) );
285 }
286
287 void Button::SetSelectedImage( Actor image )
288 {
289   Toolkit::Button handle( GetOwner() );
290   mPainter->SetSelectedImage( handle, image );
291 }
292
293 Actor Button::GetSelectedImage() const
294 {
295   return mSelectedImage;
296 }
297
298 Actor& Button::GetSelectedImage()
299 {
300   return mSelectedImage;
301 }
302
303 void Button::SetBackgroundImage( Image image )
304 {
305   SetBackgroundImage( ImageActor::New( image ) );
306 }
307
308 void Button::SetBackgroundImage( Actor image )
309 {
310   Toolkit::Button handle( GetOwner() );
311   mPainter->SetBackgroundImage( handle, image );
312 }
313
314 Actor Button::GetBackgroundImage() const
315 {
316   return mBackgroundImage;
317 }
318
319 Actor& Button::GetBackgroundImage()
320 {
321   return mBackgroundImage;
322 }
323
324 void Button::SetDisabledImage( Image image )
325 {
326   SetDisabledImage( ImageActor::New( image ) );
327 }
328
329 void Button::SetDisabledImage( Actor image )
330 {
331   Toolkit::Button handle( GetOwner() );
332   mPainter->SetDisabledImage( handle, image );
333 }
334
335 Actor Button::GetDisabledImage() const
336 {
337   return mDisabledImage;
338 }
339
340 Actor& Button::GetDisabledImage()
341 {
342   return mDisabledImage;
343 }
344
345 void Button::SetDisabledSelectedImage( Image image )
346 {
347   SetDisabledSelectedImage( ImageActor::New( image ) );
348 }
349
350 void Button::SetDisabledSelectedImage( Actor image )
351 {
352   Toolkit::Button handle( GetOwner() );
353   mPainter->SetDisabledSelectedImage( handle, image );
354 }
355
356 Actor Button::GetDisabledSelectedImage() const
357 {
358   return mDisabledSelectedImage;
359 }
360
361 Actor& Button::GetDisabledSelectedImage()
362 {
363   return mDisabledSelectedImage;
364 }
365
366 void Button::SetDisabledBackgroundImage( Image image )
367 {
368   SetDisabledBackgroundImage( ImageActor::New( image ) );
369 }
370
371 void Button::SetDisabledBackgroundImage( Actor image )
372 {
373   Toolkit::Button handle( GetOwner() );
374   mPainter->SetDisabledBackgroundImage( handle, image );
375 }
376
377 Actor Button::GetDisabledBackgroundImage() const
378 {
379   return mDisabledBackgroundImage;
380 }
381
382 Actor& Button::GetDisabledBackgroundImage()
383 {
384   return mDisabledBackgroundImage;
385 }
386
387 Actor& Button::GetFadeOutButtonImage()
388 {
389   return mFadeOutButtonImage;
390 }
391
392 Actor& Button::GetFadeOutSelectedImage()
393 {
394   return mFadeOutSelectedImage;
395 }
396
397 Actor& Button::GetFadeOutBackgroundImage()
398 {
399   return mFadeOutBackgroundImage;
400 }
401
402 bool Button::DoAction( BaseObject* object, const std::string& actionName, const PropertyValueContainer& attributes )
403 {
404   bool ret = false;
405
406   Dali::BaseHandle handle( object );
407
408   Toolkit::Button button = Toolkit::Button::DownCast( handle );
409
410   DALI_ASSERT_ALWAYS( button );
411
412   if( 0 == strcmp( actionName.c_str(), ACTION_BUTTON_CLICK ) )
413   {
414     GetImplementation( button ).DoClickAction( attributes );
415     ret = true;
416   }
417
418   return ret;
419 }
420
421 void Button::DoClickAction( const PropertyValueContainer& attributes )
422 {
423   // Prevents the button signals from doing a recursive loop by sending an action
424   // and re-emitting the signals.
425   if( !mClickActionPerforming )
426   {
427     mClickActionPerforming = true;
428     OnButtonDown();
429     mState = ButtonDown;
430     OnButtonUp();
431     mClickActionPerforming = false;
432   }
433 }
434
435 void Button::OnAnimationTimeSet( float animationTime )
436 {
437   mPainter->SetAnimationTime( animationTime );
438 }
439
440 float Button::OnAnimationTimeRequested() const
441 {
442   return mPainter->GetAnimationTime();
443 }
444
445 void Button::OnButtonStageDisconnection()
446 {
447   if( ButtonDown == mState )
448   {
449     if( !mTogglableButton )
450     {
451       Toolkit::Button handle( GetOwner() );
452
453       // Notifies the painter the button has been released.
454       mPainter->Released( handle );
455
456       if( mAutoRepeating )
457       {
458         mAutoRepeatingTimer.Reset();
459       }
460     }
461   }
462 }
463
464 void Button::OnButtonDown()
465 {
466   if( !mTogglableButton )
467   {
468     Toolkit::Button handle( GetOwner() );
469
470     // Notifies the painter the button has been pressed.
471     mPainter->Pressed( handle );
472
473     if( mAutoRepeating )
474     {
475       SetUpTimer( mInitialAutoRepeatingDelay );
476     }
477
478     //Emit signal.
479     mPressedSignal.Emit( handle );
480   }
481 }
482
483 void Button::OnButtonUp()
484 {
485   if( ButtonDown == mState )
486   {
487     if( mTogglableButton )
488     {
489       SetSelected( !mSelected );
490     }
491     else
492     {
493       Toolkit::Button handle( GetOwner() );
494
495       // Notifies the painter the button has been clicked.
496       mPainter->Released( handle );
497       mPainter->Clicked( handle );
498
499       if( mAutoRepeating )
500       {
501         mAutoRepeatingTimer.Reset();
502       }
503
504       //Emit signal.
505       mReleasedSignal.Emit( handle );
506       mClickedSignal.Emit( handle );
507     }
508   }
509 }
510
511 void Button::OnTouchPointLeave()
512 {
513   if( ButtonDown == mState )
514   {
515     if( !mTogglableButton )
516     {
517       Toolkit::Button handle( GetOwner() );
518
519       // Notifies the painter the button has been released.
520       mPainter->Released( handle );
521
522       if( mAutoRepeating )
523       {
524         mAutoRepeatingTimer.Reset();
525       }
526
527       //Emit signal.
528       mReleasedSignal.Emit( handle );
529     }
530   }
531 }
532
533 void Button::OnTouchPointInterrupted()
534 {
535   OnTouchPointLeave();
536 }
537
538 Toolkit::Button::ButtonSignalType& Button::PressedSignal()
539 {
540   return mPressedSignal;
541 }
542
543 Toolkit::Button::ButtonSignalType& Button::ReleasedSignal()
544 {
545   return mReleasedSignal;
546 }
547
548 Toolkit::Button::ButtonSignalType& Button::ClickedSignal()
549 {
550   return mClickedSignal;
551 }
552
553 Toolkit::Button::ButtonSignalType& Button::StateChangedSignal()
554 {
555   return mStateChangedSignal;
556 }
557
558 bool Button::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
559 {
560   Dali::BaseHandle handle( object );
561
562   bool connected( true );
563   Toolkit::Button button = Toolkit::Button::DownCast( handle );
564
565   if( 0 == strcmp( signalName.c_str(), SIGNAL_PRESSED ) )
566   {
567     button.PressedSignal().Connect( tracker, functor );
568   }
569   else if( 0 == strcmp( signalName.c_str(), SIGNAL_RELEASED ) )
570   {
571     button.ReleasedSignal().Connect( tracker, functor );
572   }
573   else if( 0 == strcmp( signalName.c_str(), SIGNAL_CLICKED ) )
574   {
575     button.ClickedSignal().Connect( tracker, functor );
576   }
577   else if( 0 == strcmp( signalName.c_str(), SIGNAL_STATE_CHANGED ) )
578   {
579     button.StateChangedSignal().Connect( tracker, functor );
580   }
581   else
582   {
583     // signalName does not match any signal
584     connected = false;
585   }
586
587   return connected;
588 }
589
590 bool Button::OnTouchEvent(const TouchEvent& event)
591 {
592   // Only events are processed when the button is not disabled and the touch event has only
593   // one touch point.
594   if( ( !mDisabled ) && ( 1 == event.GetPointCount() ) )
595   {
596     switch( event.GetPoint(0).state )
597     {
598       case TouchPoint::Down:
599       {
600         OnButtonDown(); // Notification for derived classes.
601
602         // Sets the button state to ButtonDown.
603         mState = ButtonDown;
604         break;
605       }
606       case TouchPoint::Up:
607       {
608         OnButtonUp(); // Notification for derived classes.
609
610         // Sets the button state to ButtonUp.
611         mState = ButtonUp;
612         break;
613       }
614       case TouchPoint::Interrupted:
615       {
616         OnTouchPointInterrupted(); // Notification for derived classes.
617
618         // Sets the button state to the default (ButtonUp).
619         mState = ButtonUp;
620         break;
621       }
622       case TouchPoint::Leave:
623       {
624         OnTouchPointLeave(); // Notification for derived classes.
625
626         // Sets the button state to the default (ButtonUp).
627         mState = ButtonUp;
628         break;
629       }
630       case TouchPoint::Motion:
631       case TouchPoint::Stationary: // FALLTHROUGH
632       {
633         // Nothing to do
634         break;
635       }
636       default:
637       {
638         DALI_ASSERT_ALWAYS( !"Point status unhandled." );
639         break;
640       }
641     }
642   }
643   else if( 1 < event.GetPointCount() )
644   {
645     OnTouchPointLeave(); // Notification for derived classes.
646
647     // Sets the button state to the default (ButtonUp).
648     mState = ButtonUp;
649   }
650
651   return false;
652 }
653
654 void Button::OnInitialize()
655 {
656   // Initialize the painter and notifies subclasses.
657   Toolkit::Button handle( GetOwner() );
658   if( mPainter )
659   {
660     mPainter->Initialize( handle );
661   }
662
663   Actor self = Self();
664
665   mTapDetector = TapGestureDetector::New();
666   mTapDetector.Attach( self );
667   mTapDetector.DetectedSignal().Connect(this, &Button::OnTap);
668
669   OnButtonInitialize();
670
671   self.SetKeyboardFocusable( true );
672 }
673
674 void Button::OnActivated()
675 {
676   // When the button is activated, it performs the click action
677   PropertyValueContainer attributes;
678   DoClickAction( attributes );
679 }
680
681 void Button::OnControlSizeSet(const Vector3& targetSize)
682 {
683   Toolkit::Button handle( GetOwner() );
684   if( mPainter )
685   {
686     mPainter->SetSize( handle, targetSize );
687   }
688 }
689
690 void Button::OnTap(Actor actor, const TapGesture& tap)
691 {
692   // Do nothing.
693 }
694
695 void Button::SetUpTimer( float delay )
696 {
697   mAutoRepeatingTimer = Dali::Timer::New( static_cast<unsigned int>( 1000.f * delay ) );
698   mAutoRepeatingTimer.TickSignal().Connect( this, &Button::AutoRepeatingSlot );
699   mAutoRepeatingTimer.Start();
700 }
701
702 bool Button::AutoRepeatingSlot()
703 {
704   bool consumed = false;
705   if( !mDisabled )
706   {
707     // Restart the autorepeat timer.
708     SetUpTimer( mNextAutoRepeatingDelay );
709
710     Toolkit::Button handle( GetOwner() );
711
712     // Notifies the painter the button has been pressed.
713     mPainter->Pressed( handle );
714
715     //Emit signal.
716     consumed = mReleasedSignal.Emit( handle );
717     consumed |= mClickedSignal.Emit( handle );
718     consumed |= mPressedSignal.Emit( handle );
719  }
720
721   return consumed;
722 }
723
724 void Button::OnControlStageDisconnection()
725 {
726   OnButtonStageDisconnection(); // Notification for derived classes.
727   mState = ButtonUp;
728 }
729
730 void Button::SetPainter(ButtonPainterPtr painter)
731 {
732   mPainter = painter;
733 }
734
735 Button::ButtonState Button::GetState()
736 {
737   return mState;
738 }
739
740 void Button::SetProperty( BaseObject* object, Property::Index index, const Property::Value& value )
741 {
742   Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
743
744   if ( button )
745   {
746     switch ( index )
747     {
748       case Toolkit::Button::PROPERTY_DISABLED:
749       {
750         GetImplementation( button ).SetDisabled( value.Get<bool>() );
751         break;
752       }
753
754       case Toolkit::Button::PROPERTY_AUTO_REPEATING:
755       {
756         GetImplementation( button ).SetAutoRepeating( value.Get< bool >() );
757         break;
758       }
759
760       case Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY:
761       {
762         GetImplementation( button ).SetInitialAutoRepeatingDelay( value.Get< float >() );
763         break;
764       }
765
766       case Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY:
767       {
768         GetImplementation( button ).SetNextAutoRepeatingDelay( value.Get< float >() );
769         break;
770       }
771
772       case Toolkit::Button::PROPERTY_TOGGLABLE:
773       {
774         GetImplementation( button ).SetTogglableButton( value.Get< bool >() );
775         break;
776       }
777
778       case Toolkit::Button::PROPERTY_SELECTED:
779       {
780         GetImplementation( button ).SetSelected( value.Get< bool >() );
781         break;
782       }
783
784       case Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR:
785       {
786         GetImplementation( button ).SetButtonImage( Scripting::NewActor( value.Get< Property::Map >() ) );
787         break;
788       }
789
790       case Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR:
791       {
792         GetImplementation( button ).SetSelectedImage( Scripting::NewActor( value.Get< Property::Map >() ) );
793         break;
794       }
795
796       case Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR:
797       {
798         GetImplementation( button ).SetDisabledImage( Scripting::NewActor( value.Get< Property::Map >() ) );
799         break;
800       }
801
802       case Toolkit::Button::PROPERTY_LABEL_ACTOR:
803       {
804         GetImplementation( button ).SetLabel( Scripting::NewActor( value.Get< Property::Map >() ) );
805         break;
806       }
807     }
808   }
809 }
810
811 Property::Value Button::GetProperty( BaseObject* object, Property::Index propertyIndex )
812 {
813   Property::Value value;
814
815   Toolkit::Button button = Toolkit::Button::DownCast( Dali::BaseHandle( object ) );
816
817   if ( button )
818   {
819     switch ( propertyIndex )
820     {
821       case Toolkit::Button::PROPERTY_DISABLED:
822       {
823         value = GetImplementation( button ).mDisabled;
824         break;
825       }
826
827       case Toolkit::Button::PROPERTY_AUTO_REPEATING:
828       {
829         value = GetImplementation( button ).mAutoRepeating;
830         break;
831       }
832
833       case Toolkit::Button::PROPERTY_INITIAL_AUTO_REPEATING_DELAY:
834       {
835         value = GetImplementation( button ).mInitialAutoRepeatingDelay;
836         break;
837       }
838
839       case Toolkit::Button::PROPERTY_NEXT_AUTO_REPEATING_DELAY:
840       {
841         value = GetImplementation( button ).mNextAutoRepeatingDelay;
842         break;
843       }
844
845       case Toolkit::Button::PROPERTY_TOGGLABLE:
846       {
847         value = GetImplementation( button ).mTogglableButton;
848         break;
849       }
850
851       case Toolkit::Button::PROPERTY_SELECTED:
852       {
853         value = GetImplementation( button ).mSelected;
854         break;
855       }
856
857       case Toolkit::Button::PROPERTY_NORMAL_STATE_ACTOR:
858       {
859         Property::Map map;
860         Scripting::CreatePropertyMap( GetImplementation( button ).mButtonImage, map );
861         value = map;
862         break;
863       }
864
865       case Toolkit::Button::PROPERTY_SELECTED_STATE_ACTOR:
866       {
867         Property::Map map;
868         Scripting::CreatePropertyMap( GetImplementation( button ).mSelectedImage, map );
869         value = map;
870         break;
871       }
872
873       case Toolkit::Button::PROPERTY_DISABLED_STATE_ACTOR:
874       {
875         Property::Map map;
876         Scripting::CreatePropertyMap( GetImplementation( button ).mDisabledImage, map );
877         value = map;
878         break;
879       }
880
881       case Toolkit::Button::PROPERTY_LABEL_ACTOR:
882       {
883         Property::Map map;
884         Scripting::CreatePropertyMap( GetImplementation( button ).mLabel, map );
885         value = map;
886         break;
887       }
888     }
889   }
890
891   return value;
892 }
893
894 } // namespace Internal
895
896 } // namespace Toolkit
897
898 } // namespace Dali