Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-demo.git] / examples / dissolve-effect / dissolve-effect-example.cpp
index 2f0a4eb..3bd1dc7 100644 (file)
@@ -71,6 +71,25 @@ const int VIEWINGTIME = 2000; // 2 seconds
 const float TRANSITION_DURATION = 2.5f; //2.5 second
 
 const float INITIAL_DEPTH = -10.0f;
+
+/**
+ * @brief Load an image, scaled-down to no more than the stage dimensions.
+ *
+ * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at
+ * load time to cover the entire stage with pixels with no borders,
+ * and filter mode ImageAttributes::BoxThenLinear to sample the image with
+ * maximum quality.
+ */
+ResourceImage LoadStageFillingImage( const char * const imagePath )
+{
+  Size stageSize = Stage::GetCurrent().GetSize();
+  ImageAttributes attributes;
+  attributes.SetSize( stageSize.x, stageSize.y );
+  attributes.SetFilterMode( ImageAttributes::BoxThenLinear );
+  attributes.SetScalingMode( ImageAttributes::ScaleToFill );
+  return ResourceImage::New( imagePath, attributes );
+}
+
 } // namespace
 
 class DissolveEffectApp : public ConnectionTracker
@@ -138,7 +157,6 @@ private:
   Toolkit::View                   mView;
   Toolkit::ToolBar                mToolBar;
   Layer                           mContent;
-  Toolkit::TextView               mTitleActor;
   Actor                           mParent;
 
   ImageActor                      mCurrentImage;
@@ -201,10 +219,7 @@ void DissolveEffectApp::OnInit( Application& application )
   mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
 
   // Add title to the tool bar.
-  mTitleActor = Toolkit::TextView::New();
-  mTitleActor.SetText( APPLICATION_TITLE_HIGHP );
-  mTitleActor.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle());
-  mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
+  // TODO
 
   // Add an slide-show button on the right of the title
   mIconPlay = ResourceImage::New( PLAY_ICON );
@@ -232,10 +247,10 @@ void DissolveEffectApp::OnInit( Application& application )
   mParent.SetPositionInheritanceMode( USE_PARENT_POSITION );
   mContent.Add( mParent );
 
-  mSizeConstraint= Constraint::New<Vector3>( Actor::SCALE, LocalSource( Actor::SIZE ), ParentSource( Actor::SIZE ), ScaleToFitKeepAspectRatioConstraint() );
+  mSizeConstraint= Constraint::New<Vector3>( Actor::Property::SCALE, LocalSource( Actor::Property::SIZE ), ParentSource( Actor::Property::SIZE ), ScaleToFitKeepAspectRatioConstraint() );
 
   // show the first image
-  mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) );
+  mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) );
   mCurrentImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
   mCurrentImage.ApplyConstraint( mSizeConstraint );
   mParent.Add( mCurrentImage );
@@ -263,7 +278,7 @@ void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture )
       mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES;
     }
 
-    Image image = ResourceImage::New( IMAGES[ mIndex ] );
+    Image image = LoadStageFillingImage( IMAGES[ mIndex ] );
     mNextImage = ImageActor::New( image );
     mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
     mNextImage.ApplyConstraint( mSizeConstraint );
@@ -320,15 +335,12 @@ bool DissolveEffectApp::OnEffectButtonClicked( Toolkit::Button button )
   mCurrentImageEffect = Toolkit::DissolveEffect::New(mUseHighPrecision);
   if(mUseHighPrecision)
   {
-    mTitleActor.SetText( APPLICATION_TITLE_HIGHP );
     mEffectChangeButton.SetBackgroundImage(mIconHighP);
   }
   else
   {
-    mTitleActor.SetText( APPLICATION_TITLE_MEDIUMP );
     mEffectChangeButton.SetBackgroundImage(mIconMediumP);
   }
-  mTitleActor.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle());
 
   return true;
 }
@@ -375,7 +387,7 @@ bool DissolveEffectApp::OnTimerTick()
   if(mSlideshow)
   {
     mIndex = (mIndex + 1)%NUM_IMAGES;
-    Image image = ResourceImage::New( IMAGES[ mIndex ] );
+    Image image = LoadStageFillingImage( IMAGES[ mIndex ] );
     mNextImage = ImageActor::New( image );
     mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION);
     mNextImage.ApplyConstraint( mSizeConstraint );
@@ -410,7 +422,7 @@ bool DissolveEffectApp::OnTimerTick()
   return false;   //return false to stop the timer
 }
 
-// Entry point for Linux & SLP applications
+// Entry point for Linux & Tizen applications
 int main( int argc, char **argv )
 {
   Application application = Application::New( &argc, &argv );