Revert "Revert "Renamed KeyEvent enum values to comply with coding standards.""
[platform/core/uifw/dali-demo.git] / examples / buttons / buttons-example.cpp
1 /*
2  * Copyright (c) 2020 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 #include "shared/view.h"
19 #include <dali/dali.h>
20 #include <dali-toolkit/dali-toolkit.h>
21 #include <dali-toolkit/devel-api/controls/table-view/table-view.h>
22
23 using namespace Dali;
24
25 // Define this so that it is interchangeable
26 // "DP" stands for Device independent Pixels
27 #define DP(x) x
28
29
30 namespace
31 {
32
33 const char* const BACKGROUND_IMAGE = DEMO_IMAGE_DIR "background-gradient.jpg";
34 const char* const TOOLBAR_IMAGE = DEMO_IMAGE_DIR "top-bar.png";
35
36 const char* const TOOLBAR_TITLE = "Buttons";
37
38 const char* const SMALL_IMAGE_1 = DEMO_IMAGE_DIR "gallery-small-14.jpg";
39 const char* const BIG_IMAGE_1   = DEMO_IMAGE_DIR "gallery-large-4.jpg";
40
41 const char* const SMALL_IMAGE_2 = DEMO_IMAGE_DIR "gallery-small-20.jpg";
42 const char* const BIG_IMAGE_2   = DEMO_IMAGE_DIR "gallery-large-11.jpg";
43
44 const char* const SMALL_IMAGE_3 = DEMO_IMAGE_DIR "gallery-small-25.jpg";
45 const char* const BIG_IMAGE_3   = DEMO_IMAGE_DIR "gallery-large-13.jpg";
46
47 const char* const ENABLED_IMAGE = DEMO_IMAGE_DIR "item-select-check.png";
48
49 const Vector4 BACKGROUND_COLOUR( 1.0f, 1.0f, 1.0f, 0.15f );
50
51 // Layout sizes
52 const int RADIO_LABEL_THUMBNAIL_SIZE = 60;
53 const int RADIO_LABEL_THUMBNAIL_SIZE_SMALL = 40;
54 const int RADIO_IMAGE_SPACING = 8;
55 const int BUTTON_HEIGHT = 48;
56
57 const int MARGIN_SIZE = 10;
58 const int TOP_MARGIN = 85;
59 const int GROUP2_HEIGHT = 238;
60 const int GROUP1_HEIGHT = 120;
61 const int GROUP3_HEIGHT = 190;
62 const int GROUP4_HEIGHT = BUTTON_HEIGHT + MARGIN_SIZE * 2;
63
64 }  // namespace
65
66 /** This example shows how to create and use different buttons.
67  *
68  * 1. First group of radio buttons with image actor labels selects an image to load
69  * 2. A push button loads the selected thumbnail image into the larger image pane
70  * 3. Second group of radio buttons with a table view label containing a text view and image view, and a normal text view.
71  *    Selecting one of these will enable/disable the image loading push button
72  * 4. A group of check boxes
73  */
74 class ButtonsController: public ConnectionTracker
75 {
76  public:
77
78   ButtonsController( Application& application )
79     : mApplication( application )
80   {
81     // Connect to the Application's Init signal
82     mApplication.InitSignal().Connect( this, &ButtonsController::Create );
83   }
84
85   ~ButtonsController()
86   {
87     // Nothing to do here
88   }
89
90   void Create( Application& application )
91   {
92     // The Init signal is received once (only) during the Application lifetime
93
94     // Respond to key events
95     application.GetWindow().KeyEventSignal().Connect(this, &ButtonsController::OnKeyEvent);
96
97     // Creates a default view with a default tool bar.
98     // The view is added to the window.
99     mContentLayer = DemoHelper::CreateView( application,
100                                             mView,
101                                             mToolBar,
102                                             BACKGROUND_IMAGE,
103                                             TOOLBAR_IMAGE,
104                                             TOOLBAR_TITLE );
105
106     Toolkit::TableView contentTable = Toolkit::TableView::New( 4, 1 );
107     contentTable.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
108     contentTable.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
109     contentTable.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
110     contentTable.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
111     contentTable.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE * 0.5f ) );
112
113     for( unsigned int i = 0; i < contentTable.GetRows(); ++i )
114     {
115       contentTable.SetFitHeight( i );
116     }
117
118     contentTable.SetProperty( Actor::Property::POSITION, Vector2( 0.0f, TOP_MARGIN ));
119
120     mContentLayer.Add( contentTable );
121
122     // Image selector radio group
123     Toolkit::TableView radioGroup2Background = Toolkit::TableView::New( 2, 2 );
124     radioGroup2Background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
125     radioGroup2Background.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
126     radioGroup2Background.SetBackgroundColor( BACKGROUND_COLOUR );
127     radioGroup2Background.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE ) );
128     radioGroup2Background.SetFitHeight( 0 );
129     radioGroup2Background.SetFitHeight( 1 );
130     radioGroup2Background.SetFitWidth( 0 );
131
132     contentTable.Add( radioGroup2Background );
133
134     Toolkit::TableView radioButtonsGroup2 = Toolkit::TableView::New( 3, 1 );
135     radioButtonsGroup2.SetCellPadding( Size( 0.0f, MARGIN_SIZE * 0.5f ) );
136     radioButtonsGroup2.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
137     for( unsigned int i = 0; i < radioButtonsGroup2.GetRows(); ++i )
138     {
139       radioButtonsGroup2.SetFitHeight( i );
140     }
141     radioButtonsGroup2.SetFitWidth( 0 );
142
143     radioGroup2Background.AddChild( radioButtonsGroup2, Toolkit::TableView::CellPosition( 0, 0 ) );
144
145     // TableView to lay out 3x Radio buttons on the left, and 3x Image thumbnails on the right.
146     Toolkit::TableView imageSelectTableView = Toolkit::TableView::New( 3, 2 );
147     imageSelectTableView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
148     imageSelectTableView.SetFitHeight( 0 );
149     imageSelectTableView.SetFitHeight( 1 );
150     imageSelectTableView.SetFitHeight( 2 );
151     imageSelectTableView.SetFitWidth( 0 );
152     imageSelectTableView.SetFitWidth( 1 );
153     imageSelectTableView.SetCellPadding( Vector2( 6.0f, 0.0f ) );
154
155     radioButtonsGroup2.Add( imageSelectTableView );
156
157     int radioY = 0;
158
159     // Radio 1
160     {
161       Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_1 );
162       image.SetProperty( Actor::Property::SIZE, Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) );
163
164       mRadioButtonImage1 = Dali::Toolkit::RadioButton::New( "1" );
165       mRadioButtonImage1.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
166       mRadioButtonImage1.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
167       mRadioButtonImage1.SetProperty( Actor::Property::POSITION, Vector2( 0, DP(radioY) ));
168       mRadioButtonImage1.SetProperty( Toolkit::Button::Property::SELECTED, true );
169
170       imageSelectTableView.AddChild( mRadioButtonImage1, Toolkit::TableView::CellPosition( 0, 0 ) );
171       imageSelectTableView.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
172     }
173
174     // Radio 2
175     {
176       radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING;
177
178       Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_2 );
179       image.SetProperty( Actor::Property::SIZE, Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) );
180
181       mRadioButtonImage2 = Dali::Toolkit::RadioButton::New( "2" );
182       mRadioButtonImage2.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
183       mRadioButtonImage2.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
184       mRadioButtonImage2.SetProperty( Actor::Property::POSITION, Vector2( 0, DP(radioY) ));
185
186       imageSelectTableView.AddChild( mRadioButtonImage2, Toolkit::TableView::CellPosition( 1, 0 ) );
187       imageSelectTableView.AddChild( image, Toolkit::TableView::CellPosition( 1, 1 ) );
188     }
189
190     // Radio 3
191     {
192       radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING;
193
194       Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_3 );
195       image.SetProperty( Actor::Property::SIZE, Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) );
196
197       mRadioButtonImage3 = Dali::Toolkit::RadioButton::New( "3" );
198       mRadioButtonImage3.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
199       mRadioButtonImage3.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
200       mRadioButtonImage3.SetProperty( Actor::Property::POSITION, Vector2( 0, DP(radioY) ));
201
202       imageSelectTableView.AddChild( mRadioButtonImage3, Toolkit::TableView::CellPosition( 2, 0 ) );
203       imageSelectTableView.AddChild( image, Toolkit::TableView::CellPosition( 2, 1 ) );
204     }
205
206     // Create select button
207     mUpdateButton = Toolkit::PushButton::New();
208     mUpdateButton.SetProperty( Toolkit::Button::Property::LABEL, "Select" );
209     mUpdateButton.SetProperty( Dali::Actor::Property::NAME, "selectButton" );
210     mUpdateButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
211
212     mUpdateButton.ClickedSignal().Connect( this, &ButtonsController::OnButtonClicked );
213
214     radioGroup2Background.AddChild( mUpdateButton, Toolkit::TableView::CellPosition( 1, 0 ) );
215
216     // ImageView to display selected image
217     mImage = Toolkit::ImageView::New( BIG_IMAGE_1 );
218     mImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
219     mImage.SetProperty( Actor::Property::SIZE_SCALE_POLICY, SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
220     radioGroup2Background.AddChild( mImage, Toolkit::TableView::CellPosition( 0, 1, 2, 1 ) );
221
222     // The enable/disable radio group
223     Toolkit::TableView radioGroup1Background = Toolkit::TableView::New( 1, 1 );
224     radioGroup1Background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
225     radioGroup1Background.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
226     radioGroup1Background.SetBackgroundColor( BACKGROUND_COLOUR );
227     radioGroup1Background.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE ) );
228     radioGroup1Background.SetFitHeight( 0 );
229
230     contentTable.Add( radioGroup1Background );
231
232     // Radio group
233     Toolkit::TableView radioButtonsGroup1 = Toolkit::TableView::New( 2, 1 );
234     radioButtonsGroup1.SetCellPadding( Size( 0.0f, MARGIN_SIZE * 0.5f ) );
235     radioButtonsGroup1.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
236     for( unsigned int i = 0; i < radioButtonsGroup1.GetRows(); ++i )
237     {
238       radioButtonsGroup1.SetFitHeight( i );
239     }
240     radioButtonsGroup1.SetFitWidth( 0 );
241
242     radioGroup1Background.Add( radioButtonsGroup1 );
243
244     // TableView to lay out 2x Radio buttons on the left, and 1x Tick image on the right.
245     Toolkit::TableView tableView = Toolkit::TableView::New( 2, 2 );
246     tableView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
247     tableView.SetFitHeight( 0 );
248     tableView.SetFitHeight( 1 );
249     tableView.SetFitWidth( 0 );
250     tableView.SetFitWidth( 1 );
251
252     Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( "Select enabled" );
253     textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::WIDTH );
254     textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
255     textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
256
257     Toolkit::ImageView image = Toolkit::ImageView::New( ENABLED_IMAGE );
258     image.SetProperty( Actor::Property::SIZE, Vector2( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ) );
259     image.SetProperty( Actor::Property::PADDING, Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) );
260     tableView.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
261
262     radioButtonsGroup1.Add( tableView );
263
264     // First radio button
265     {
266       Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( "Select enabled" );
267       radioButton.SetProperty( Dali::Actor::Property::NAME, "radioSelectEnable" );
268       radioButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
269       radioButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
270       radioButton.SetProperty( Actor::Property::POSITION, Vector2( 0, 0 ));
271       radioButton.SetProperty( Toolkit::Button::Property::SELECTED, true );
272
273       radioButton.StateChangedSignal().Connect( this, &ButtonsController::EnableSelectButton );
274
275       tableView.AddChild( radioButton, Toolkit::TableView::CellPosition( 0, 0 ) );
276     }
277
278     // Second radio button
279     {
280       Toolkit::RadioButton radioButton = Dali::Toolkit::RadioButton::New( "Select disabled" );
281       radioButton.SetProperty( Dali::Actor::Property::NAME, "radioSelectDisable" );
282       radioButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT );
283       radioButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT );
284       radioButton.SetProperty( Actor::Property::POSITION, Vector2( 0, DP(50) ));
285
286       radioButton.StateChangedSignal().Connect( this, &ButtonsController::EnableSelectButton );
287
288       tableView.AddChild( radioButton, Toolkit::TableView::CellPosition( 1, 0 ) );
289     }
290
291     // CheckBoxes
292     Toolkit::TableView checkBoxBackground = Toolkit::TableView::New( 3, 1 );
293     checkBoxBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
294     checkBoxBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
295     checkBoxBackground.SetBackgroundColor( BACKGROUND_COLOUR );
296     checkBoxBackground.SetCellPadding( Size( MARGIN_SIZE / 2.0f, MARGIN_SIZE / 2.0f ) );
297
298     for( unsigned int i = 0; i < checkBoxBackground.GetRows(); ++i )
299     {
300       checkBoxBackground.SetFitHeight( i );
301     }
302
303     contentTable.Add( checkBoxBackground );
304
305     {
306       mCheckboxButton1 = Toolkit::CheckBoxButton::New();
307       mCheckboxButton1.SetProperty( Dali::Actor::Property::NAME, "checkbox1" );
308       mCheckboxButton1.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox1 is unselected" );
309       mCheckboxButton1.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected );
310       mCheckboxButton1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
311
312       checkBoxBackground.Add( mCheckboxButton1 );
313     }
314
315     {
316       mCheckboxButton2 = Toolkit::CheckBoxButton::New();
317       mCheckboxButton2.SetProperty( Dali::Actor::Property::NAME, "checkbox2" );
318       mCheckboxButton2.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox2 is selected" );
319       mCheckboxButton2.SetProperty( Toolkit::Button::Property::SELECTED, true );
320       mCheckboxButton2.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected );
321       mCheckboxButton2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
322
323       checkBoxBackground.Add( mCheckboxButton2 );
324     }
325
326     {
327       mCheckboxButton3 = Toolkit::CheckBoxButton::New();
328       mCheckboxButton3.SetProperty( Dali::Actor::Property::NAME, "checkbox3" );
329       mCheckboxButton3.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox3 is unselected" );
330       mCheckboxButton3.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected );
331       mCheckboxButton3.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
332
333       checkBoxBackground.Add( mCheckboxButton3 );
334     }
335
336     // Create togglabe button
337     Toolkit::TableView toggleBackground = Toolkit::TableView::New( 3, 1 );
338     toggleBackground.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
339     toggleBackground.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
340     toggleBackground.SetBackgroundColor( BACKGROUND_COLOUR );
341     toggleBackground.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE ) );
342
343     for( unsigned int i = 0; i < toggleBackground.GetRows(); ++i )
344     {
345       toggleBackground.SetFitHeight( i );
346     }
347
348     contentTable.Add( toggleBackground );
349
350     mToggleButton = Toolkit::PushButton::New();
351     mToggleButton.SetProperty( Toolkit::Button::Property::TOGGLABLE, true );
352     mToggleButton.SetProperty( Toolkit::Button::Property::LABEL, "Unselected" );
353     mToggleButton.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
354     mToggleButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::HEIGHT );
355     mToggleButton.StateChangedSignal().Connect( this, &ButtonsController::OnButtonSelected );
356
357     toggleBackground.Add( mToggleButton );
358   }
359
360   void OnKeyEvent( const KeyEvent& event )
361   {
362     if( event.GetState() == KeyEvent::DOWN )
363     {
364       if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) )
365       {
366         // Exit application when click back or escape.
367         mApplication.Quit();
368       }
369     }
370   }
371
372   bool OnButtonSelected( Toolkit::Button button )
373   {
374     Toolkit::PushButton pushButton = Toolkit::PushButton::DownCast( button );
375     if( pushButton )
376     {
377       bool isSelected = button.GetProperty( Toolkit::Button::Property::SELECTED ).Get<bool>();
378       if( isSelected )
379       {
380         pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Selected" );
381       }
382       else
383       {
384         pushButton.SetProperty( Toolkit::Button::Property::LABEL, "Unselected" );
385       }
386     }
387
388     return true;
389   }
390
391   bool EnableSelectButton( Toolkit::Button button )
392   {
393     bool isSelected = button.GetProperty( Toolkit::Button::Property::SELECTED ).Get<bool>();
394     if( !isSelected )
395     {
396       return true;
397     }
398
399     if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "radioSelectEnable" )
400     {
401       mUpdateButton.SetProperty( Toolkit::Button::Property::DISABLED, false );
402
403       mRadioButtonImage1.SetProperty( Toolkit::Button::Property::DISABLED, false );
404       mRadioButtonImage2.SetProperty( Toolkit::Button::Property::DISABLED, false );
405       mRadioButtonImage3.SetProperty( Toolkit::Button::Property::DISABLED, false );
406
407       mCheckboxButton1.SetProperty( Toolkit::Button::Property::DISABLED, false );
408       mCheckboxButton2.SetProperty( Toolkit::Button::Property::DISABLED, false );
409       mCheckboxButton3.SetProperty( Toolkit::Button::Property::DISABLED, false );
410
411       mToggleButton.SetProperty( Toolkit::Button::Property::DISABLED, false );
412     }
413     else if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "radioSelectDisable" )
414     {
415       mUpdateButton.SetProperty( Toolkit::Button::Property::DISABLED, true );
416
417       mRadioButtonImage1.SetProperty( Toolkit::Button::Property::DISABLED, true );
418       mRadioButtonImage2.SetProperty( Toolkit::Button::Property::DISABLED, true );
419       mRadioButtonImage3.SetProperty( Toolkit::Button::Property::DISABLED, true );
420
421       mCheckboxButton1.SetProperty( Toolkit::Button::Property::DISABLED, true );
422       mCheckboxButton2.SetProperty( Toolkit::Button::Property::DISABLED, true );
423       mCheckboxButton3.SetProperty( Toolkit::Button::Property::DISABLED, true );
424
425       mToggleButton.SetProperty( Toolkit::Button::Property::DISABLED, true );
426     }
427
428     return true;
429   }
430
431   bool OnButtonClicked(Toolkit::Button button)
432   {
433     if( mRadioButtonImage1.GetProperty( Toolkit::Button::Property::SELECTED ).Get<bool>() )
434     {
435       mImage.SetImage( BIG_IMAGE_1 );
436     }
437     else if( mRadioButtonImage2.GetProperty( Toolkit::Button::Property::SELECTED ).Get<bool>() )
438     {
439       mImage.SetImage( BIG_IMAGE_2 );
440     }
441     else if( mRadioButtonImage3.GetProperty( Toolkit::Button::Property::SELECTED ).Get<bool>() )
442     {
443       mImage.SetImage( BIG_IMAGE_3 );
444     }
445     return true;
446   }
447
448   bool OnCheckBoxesSelected( Toolkit::Button button )
449   {
450     bool isSelected = button.GetProperty( Toolkit::Button::Property::SELECTED ).Get<bool>();
451     if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "checkbox1" )
452     {
453       if( isSelected )
454       {
455         button.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox1 is selected");
456       }
457       else
458       {
459         button.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox1 is unselected");
460       }
461     }
462
463     if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "checkbox2" )
464     {
465       if( isSelected )
466       {
467         button.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox2 is selected");
468       }
469       else
470       {
471         button.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox2 is unselected");
472       }
473     }
474
475     if( button.GetProperty< std::string >( Dali::Actor::Property::NAME ) == "checkbox3" )
476     {
477       if( isSelected )
478       {
479         button.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox3 is selected");
480       }
481       else
482       {
483         button.SetProperty( Toolkit::Button::Property::LABEL, "CheckBox3 is unselected");
484       }
485     }
486
487     return true;
488   }
489
490 private:
491
492   Application&      mApplication;
493   Toolkit::Control  mView;                              ///< The View instance.
494   Toolkit::ToolBar  mToolBar;                           ///< The View's Toolbar.
495   Layer             mContentLayer;                      ///< Content layer
496
497   Toolkit::RadioButton mRadioButtonImage1;
498   Toolkit::RadioButton mRadioButtonImage2;
499   Toolkit::RadioButton mRadioButtonImage3;
500
501   Toolkit::PushButton mUpdateButton;
502   Toolkit::PushButton mToggleButton;
503
504   Toolkit::CheckBoxButton mCheckboxButton1;
505   Toolkit::CheckBoxButton mCheckboxButton2;
506   Toolkit::CheckBoxButton mCheckboxButton3;
507
508   Animation      mAnimation;
509
510   Toolkit::ImageView mImage;
511 };
512
513 int DALI_EXPORT_API main( int argc, char **argv )
514 {
515   Application application = Application::New( &argc, &argv, DEMO_THEME_PATH );
516   ButtonsController test( application );
517   application.MainLoop();
518   return 0;
519 }