Remove ResourceImage usage from demos
[platform/core/uifw/dali-demo.git] / examples / buttons / buttons-example.cpp
index 8f993fc..bd10f40 100644 (file)
@@ -108,7 +108,6 @@ class ButtonsController: public ConnectionTracker
     contentTable.SetAnchorPoint( AnchorPoint::TOP_LEFT );
     contentTable.SetParentOrigin( ParentOrigin::TOP_LEFT );
     contentTable.SetCellPadding( Size( MARGIN_SIZE, MARGIN_SIZE * 0.5f ) );
-//    contentTable.TouchedSignal().Connect( this, &ButtonsController::OnTouchEvent );
 
     for( unsigned int i = 0; i < contentTable.GetRows(); ++i )
     {
@@ -158,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" );
@@ -175,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" );
@@ -191,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" );
@@ -214,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 ) );
@@ -258,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 ) );
@@ -426,15 +421,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;
   }
@@ -480,35 +475,7 @@ class ButtonsController: public ConnectionTracker
     return true;
   }
 
-  bool OnTouchEvent( Actor actor, const TouchEvent& event )
-  {
-    if( 1u == event.GetPointCount() )
-    {
-      const TouchPoint::State state = event.GetPoint(0u).state;
-
-      // Clamp to integer values; this is to reduce flicking due to pixel misalignment
-      const float localPoint = static_cast<float>( static_cast<int>( event.GetPoint( 0 ).local.y ) );
-
-      if( TouchPoint::Down == state )
-      {
-        mLastPoint = localPoint;
-        mAnimation = Animation::New( 0.25f );
-      }
-      else if( TouchPoint::Motion == state )
-      {
-        if( mAnimation )
-        {
-          mAnimation.AnimateBy( Property(actor, Actor::Property::POSITION), Vector3( 0.f, localPoint - mLastPoint, 0.f ), AlphaFunction::LINEAR );
-          mAnimation.Play();
-          mLastPoint = localPoint;
-        }
-      }
-    }
-
-    return true;
-  }
-
- private:
+private:
 
   Application&      mApplication;
   Toolkit::Control  mView;                              ///< The View instance.
@@ -529,9 +496,6 @@ class ButtonsController: public ConnectionTracker
   Animation      mAnimation;
   float          mLastPoint;
 
-  Image mBigImage1;
-  Image mBigImage2;
-  Image mBigImage3;
   Toolkit::ImageView mImage;
 };