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