Changes following Allow background property to be set as a URL string
[platform/core/uifw/dali-demo.git] / examples / buttons / buttons-example.cpp
index 14d532c..eddb106 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -157,7 +157,7 @@ class ButtonsController: public ConnectionTracker
 
     // Radio 1
     {
-      Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_1 ) );
+      Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_1 );
       image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
 
       mRadioButtonImage1 = Dali::Toolkit::RadioButton::New( "1" );
@@ -174,7 +174,7 @@ class ButtonsController: public ConnectionTracker
     {
       radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING;
 
-      Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_2 ) );
+      Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_2 );
       image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
 
       mRadioButtonImage2 = Dali::Toolkit::RadioButton::New( "2" );
@@ -190,7 +190,7 @@ class ButtonsController: public ConnectionTracker
     {
       radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING;
 
-      Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_3 ) );
+      Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_3 );
       image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
 
       mRadioButtonImage3 = Dali::Toolkit::RadioButton::New( "3" );
@@ -213,11 +213,7 @@ class ButtonsController: public ConnectionTracker
     radioGroup2Background.AddChild( mUpdateButton, Toolkit::TableView::CellPosition( 1, 0 ) );
 
     // ImageView to display selected image
-    mBigImage1 = ResourceImage::New( BIG_IMAGE_1 );
-    mBigImage2 = ResourceImage::New( BIG_IMAGE_2 );
-    mBigImage3 = ResourceImage::New( BIG_IMAGE_3 );
-
-    mImage = Toolkit::ImageView::New( mBigImage1 );
+    mImage = Toolkit::ImageView::New( BIG_IMAGE_1 );
     mImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
     mImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
     radioGroup2Background.AddChild( mImage, Toolkit::TableView::CellPosition( 0, 1, 2, 1 ) );
@@ -257,7 +253,7 @@ class ButtonsController: public ConnectionTracker
     textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
     textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
 
-    Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( ENABLED_IMAGE ) );
+    Toolkit::ImageView image = Toolkit::ImageView::New( ENABLED_IMAGE );
     image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) );
     image.SetPadding( Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) );
     tableView.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) );
@@ -310,6 +306,7 @@ class ButtonsController: public ConnectionTracker
       mCheckboxButton1.SetName( "checkbox1" );
       mCheckboxButton1.SetLabelText( "CheckBox1 is unselected" );
       mCheckboxButton1.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected );
+      mCheckboxButton1.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 
       checkBoxBackground.Add( mCheckboxButton1 );
     }
@@ -320,6 +317,7 @@ class ButtonsController: public ConnectionTracker
       mCheckboxButton2.SetLabelText( "CheckBox2 is selected" );
       mCheckboxButton2.SetSelected( true );
       mCheckboxButton2.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected );
+      mCheckboxButton2.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 
       checkBoxBackground.Add( mCheckboxButton2 );
     }
@@ -329,6 +327,7 @@ class ButtonsController: public ConnectionTracker
       mCheckboxButton3.SetName( "checkbox3" );
       mCheckboxButton3.SetLabelText( "CheckBox3 is unselected" );
       mCheckboxButton3.StateChangedSignal().Connect( this, &ButtonsController::OnCheckBoxesSelected );
+      mCheckboxButton3.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
 
       checkBoxBackground.Add( mCheckboxButton3 );
     }
@@ -425,15 +424,15 @@ class ButtonsController: public ConnectionTracker
   {
     if( mRadioButtonImage1.IsSelected() )
     {
-      mImage.SetImage( mBigImage1 );
+      mImage.SetImage( BIG_IMAGE_1 );
     }
     else if( mRadioButtonImage2.IsSelected() )
     {
-      mImage.SetImage( mBigImage2 );
+      mImage.SetImage( BIG_IMAGE_2 );
     }
     else if( mRadioButtonImage3.IsSelected() )
     {
-      mImage.SetImage( mBigImage3 );
+      mImage.SetImage( BIG_IMAGE_3 );
     }
     return true;
   }
@@ -498,11 +497,7 @@ private:
   Toolkit::CheckBoxButton mCheckboxButton3;
 
   Animation      mAnimation;
-  float          mLastPoint;
 
-  Image mBigImage1;
-  Image mBigImage2;
-  Image mBigImage3;
   Toolkit::ImageView mImage;
 };