Commit 01b5ab9d4d072bbebbfa38b68f5b7ec1a76888e3

Authored by Kimmo Hoikka
Committed by Gerrit Code Review
2 parents 4a9709b6 df76acd2

Merge "Changed Cube Transition example to use new CubeTransitionEffect." into devel/master

examples/cube-transition-effect/cube-transition-effect-example.cpp
@@ -167,9 +167,9 @@ private: @@ -167,9 +167,9 @@ private:
167 /** 167 /**
168 * Callback function of cube transition completed signal 168 * Callback function of cube transition completed signal
169 * @param[in] effect The cube effect used for the transition 169 * @param[in] effect The cube effect used for the transition
170 - * @param[in] imageActor The target imageActor of the completed transition 170 + * @param[in] image The target Image of the completed transition
171 */ 171 */
172 - void OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, ImageActor imageActor); 172 + void OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, Image image );
173 /** 173 /**
174 * Callback function of timer tick 174 * Callback function of timer tick
175 * The timer is used to count the image display duration in slideshow, 175 * The timer is used to count the image display duration in slideshow,
@@ -181,13 +181,12 @@ private: @@ -181,13 +181,12 @@ private:
181 Toolkit::Control mView; 181 Toolkit::Control mView;
182 Toolkit::ToolBar mToolBar; 182 Toolkit::ToolBar mToolBar;
183 Layer mContent; 183 Layer mContent;
184 - Toolkit::TextLabel mTitleActor;  
185 - Actor mParent; 184 + Toolkit::TextLabel mTitle;
186 185
187 Vector2 mViewSize; 186 Vector2 mViewSize;
188 187
189 - ImageActor mCurrentImage;  
190 - ImageActor mNextImage; 188 + ResourceImage mCurrentImage;
  189 + ResourceImage mNextImage;
191 unsigned int mIndex; 190 unsigned int mIndex;
192 bool mIsImageLoading; 191 bool mIsImageLoading;
193 192
@@ -238,8 +237,8 @@ void CubeTransitionApp::OnInit( Application& application ) @@ -238,8 +237,8 @@ void CubeTransitionApp::OnInit( Application& application )
238 mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); 237 mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
239 238
240 // Add title to the tool bar. 239 // Add title to the tool bar.
241 - mTitleActor = DemoHelper::CreateToolBarLabel( APPLICATION_TITLE_WAVE );  
242 - mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); 240 + mTitle = DemoHelper::CreateToolBarLabel( APPLICATION_TITLE_WAVE );
  241 + mToolBar.AddControl( mTitle, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
243 242
244 //Add an slideshow icon on the right of the title 243 //Add an slideshow icon on the right of the title
245 mSlideshowButton = Toolkit::PushButton::New(); 244 mSlideshowButton = Toolkit::PushButton::New();
@@ -251,53 +250,55 @@ void CubeTransitionApp::OnInit( Application& application ) @@ -251,53 +250,55 @@ void CubeTransitionApp::OnInit( Application& application )
251 // Set size to stage size to avoid seeing a black border on transition 250 // Set size to stage size to avoid seeing a black border on transition
252 mViewSize = Stage::GetCurrent().GetSize(); 251 mViewSize = Stage::GetCurrent().GetSize();
253 252
254 - mParent = Actor::New();  
255 - mParent.SetSize( mViewSize );  
256 - mParent.SetPositionInheritanceMode( USE_PARENT_POSITION );  
257 - mContent.Add( mParent );  
258 -  
259 - // use pan gesture to detect the cursor or finger movement  
260 - mPanGestureDetector = PanGestureDetector::New();  
261 - mPanGestureDetector.DetectedSignal().Connect( this, &CubeTransitionApp::OnPanGesture );  
262 - mPanGestureDetector.Attach( mParent ); 253 + // show the first image
  254 + mCurrentImage = LoadStageFillingImage( IMAGES[mIndex] );
263 255
264 //use small cubes 256 //use small cubes
265 - mCubeWaveEffect = Toolkit::CubeTransitionWaveEffect::New(NUM_ROWS_WAVE, NUM_COLUMNS_WAVE, mViewSize); 257 + mCubeWaveEffect = Toolkit::CubeTransitionWaveEffect::New( NUM_ROWS_WAVE, NUM_COLUMNS_WAVE );
266 mCubeWaveEffect.SetTransitionDuration( ANIMATION_DURATION_WAVE ); 258 mCubeWaveEffect.SetTransitionDuration( ANIMATION_DURATION_WAVE );
267 mCubeWaveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_WAVE ); 259 mCubeWaveEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_WAVE );
268 mCubeWaveEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted); 260 mCubeWaveEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
269 - mParent.Add(mCubeWaveEffect.GetRoot()); 261 +
  262 + mCubeWaveEffect.SetSize( mViewSize );
  263 + mCubeWaveEffect.SetPositionInheritanceMode( USE_PARENT_POSITION );
  264 + mCubeWaveEffect.SetCurrentImage( mCurrentImage );
  265 +
270 // use big cubes 266 // use big cubes
271 - mCubeCrossEffect = Toolkit::CubeTransitionCrossEffect::New(NUM_ROWS_CROSS, NUM_COLUMNS_CROSS, mViewSize);  
272 - mCubeCrossEffect.SetTransitionDuration( ANIMATION_DURATION_CROSS); 267 + mCubeCrossEffect = Toolkit::CubeTransitionCrossEffect::New(NUM_ROWS_CROSS, NUM_COLUMNS_CROSS );
  268 + mCubeCrossEffect.SetTransitionDuration( ANIMATION_DURATION_CROSS );
273 mCubeCrossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_CROSS ); 269 mCubeCrossEffect.SetCubeDisplacement( CUBE_DISPLACEMENT_CROSS );
274 mCubeCrossEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted); 270 mCubeCrossEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
275 - mParent.Add(mCubeCrossEffect.GetRoot());  
276 271
277 - mCubeFoldEffect = Toolkit::CubeTransitionFoldEffect::New(NUM_ROWS_FOLD, NUM_COLUMNS_FOLD, mViewSize);  
278 - mCubeFoldEffect.SetTransitionDuration( ANIMATION_DURATION_FOLD); 272 + mCubeCrossEffect.SetSize( mViewSize );
  273 + mCubeCrossEffect.SetPositionInheritanceMode( USE_PARENT_POSITION );
  274 + mCubeCrossEffect.SetCurrentImage( mCurrentImage );
  275 +
  276 + mCubeFoldEffect = Toolkit::CubeTransitionFoldEffect::New( NUM_ROWS_FOLD, NUM_COLUMNS_FOLD );
  277 + mCubeFoldEffect.SetTransitionDuration( ANIMATION_DURATION_FOLD );
279 mCubeFoldEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted); 278 mCubeFoldEffect.TransitionCompletedSignal().Connect(this, &CubeTransitionApp::OnTransitionCompleted);
280 - mParent.Add(mCubeFoldEffect.GetRoot()); 279 +
  280 + mCubeFoldEffect.SetSize( mViewSize );
  281 + mCubeFoldEffect.SetPositionInheritanceMode( USE_PARENT_POSITION );
  282 + mCubeFoldEffect.SetCurrentImage( mCurrentImage );
281 283
282 mViewTimer = Timer::New( VIEWINGTIME ); 284 mViewTimer = Timer::New( VIEWINGTIME );
283 mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick ); 285 mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick );
284 286
285 - // show the first image  
286 - mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) );  
287 - mCurrentImage.SetPositionInheritanceMode( USE_PARENT_POSITION );  
288 - mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );  
289 - mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );  
290 - mParent.Add( mCurrentImage );  
291 287
292 mCurrentEffect = mCubeWaveEffect; 288 mCurrentEffect = mCubeWaveEffect;
293 - mCurrentEffect.SetCurrentImage( mCurrentImage ); 289 + mContent.Add( mCurrentEffect );
  290 +
  291 + // use pan gesture to detect the cursor or finger movement
  292 + mPanGestureDetector = PanGestureDetector::New();
  293 + mPanGestureDetector.DetectedSignal().Connect( this, &CubeTransitionApp::OnPanGesture );
  294 + mPanGestureDetector.Attach( mContent );
294 } 295 }
295 296
296 // signal handler, called when the pan gesture is detected 297 // signal handler, called when the pan gesture is detected
297 void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture ) 298 void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture )
298 { 299 {
299 // does not response when the transition has not finished 300 // does not response when the transition has not finished
300 - if( mIsImageLoading || mCubeWaveEffect.IsTransiting() || mCubeCrossEffect.IsTransiting() || mCubeFoldEffect.IsTransiting() || mSlideshow ) 301 + if( mIsImageLoading || mCubeWaveEffect.IsTransitioning() || mCubeCrossEffect.IsTransitioning() || mCubeFoldEffect.IsTransitioning() || mSlideshow )
301 { 302 {
302 return; 303 return;
303 } 304 }
@@ -321,22 +322,17 @@ void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture ) @@ -321,22 +322,17 @@ void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture )
321 322
322 void CubeTransitionApp::GoToNextImage() 323 void CubeTransitionApp::GoToNextImage()
323 { 324 {
324 - ResourceImage image = LoadStageFillingImage( IMAGES[ mIndex ] );  
325 - mNextImage = ImageActor::New( image );  
326 -  
327 - mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION);  
328 - mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );  
329 - mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );  
330 - mCurrentEffect.SetTargetImage(mNextImage);  
331 - if( image.GetLoadingState() == ResourceLoadingSucceeded ) 325 + mNextImage = LoadStageFillingImage( IMAGES[ mIndex ] );
  326 + mCurrentEffect.SetTargetImage( mNextImage );
  327 + if( mNextImage.GetLoadingState() == ResourceLoadingSucceeded )
332 { 328 {
333 mIsImageLoading = false; 329 mIsImageLoading = false;
334 - OnImageLoaded( image ); 330 + OnImageLoaded( mNextImage );
335 } 331 }
336 else 332 else
337 { 333 {
338 mIsImageLoading = true; 334 mIsImageLoading = true;
339 - image.LoadingFinishedSignal().Connect( this, &CubeTransitionApp::OnImageLoaded ); 335 + mNextImage.LoadingFinishedSignal().Connect( this, &CubeTransitionApp::OnImageLoaded );
340 } 336 }
341 } 337 }
342 338
@@ -344,17 +340,16 @@ void CubeTransitionApp::OnImageLoaded(ResourceImage image) @@ -344,17 +340,16 @@ void CubeTransitionApp::OnImageLoaded(ResourceImage image)
344 { 340 {
345 mIsImageLoading = false; 341 mIsImageLoading = false;
346 mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement ); 342 mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement );
347 - mParent.Remove(mCurrentImage);  
348 - mParent.Add(mNextImage);  
349 mCurrentImage = mNextImage; 343 mCurrentImage = mNextImage;
350 } 344 }
351 345
352 bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button ) 346 bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button )
353 { 347 {
  348 + mContent.Remove( mCurrentEffect );
354 if(mCurrentEffect == mCubeWaveEffect) 349 if(mCurrentEffect == mCubeWaveEffect)
355 { 350 {
356 mCurrentEffect = mCubeCrossEffect; 351 mCurrentEffect = mCubeCrossEffect;
357 - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_CROSS) ); 352 + mTitle.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_CROSS) );
358 mEffectChangeButton.SetUnselectedImage( EFFECT_CROSS_IMAGE ); 353 mEffectChangeButton.SetUnselectedImage( EFFECT_CROSS_IMAGE );
359 mEffectChangeButton.SetSelectedImage( EFFECT_CROSS_IMAGE_SELECTED ); 354 mEffectChangeButton.SetSelectedImage( EFFECT_CROSS_IMAGE_SELECTED );
360 355
@@ -362,21 +357,22 @@ bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button ) @@ -362,21 +357,22 @@ bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button )
362 else if(mCurrentEffect == mCubeCrossEffect) 357 else if(mCurrentEffect == mCubeCrossEffect)
363 { 358 {
364 mCurrentEffect = mCubeFoldEffect; 359 mCurrentEffect = mCubeFoldEffect;
365 - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_FOLD) ); 360 + mTitle.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_FOLD) );
366 mEffectChangeButton.SetUnselectedImage( EFFECT_FOLD_IMAGE ); 361 mEffectChangeButton.SetUnselectedImage( EFFECT_FOLD_IMAGE );
367 mEffectChangeButton.SetSelectedImage( EFFECT_FOLD_IMAGE_SELECTED ); 362 mEffectChangeButton.SetSelectedImage( EFFECT_FOLD_IMAGE_SELECTED );
368 } 363 }
369 else 364 else
370 { 365 {
371 mCurrentEffect = mCubeWaveEffect; 366 mCurrentEffect = mCubeWaveEffect;
372 - mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_WAVE) ); 367 + mTitle.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_WAVE) );
373 mEffectChangeButton.SetUnselectedImage( EFFECT_WAVE_IMAGE ); 368 mEffectChangeButton.SetUnselectedImage( EFFECT_WAVE_IMAGE );
374 mEffectChangeButton.SetSelectedImage( EFFECT_WAVE_IMAGE_SELECTED ); 369 mEffectChangeButton.SetSelectedImage( EFFECT_WAVE_IMAGE_SELECTED );
375 } 370 }
  371 + mContent.Add( mCurrentEffect );
376 372
377 // Set the current image to cube transition effect 373 // Set the current image to cube transition effect
378 // only need to set at beginning or change from another effect 374 // only need to set at beginning or change from another effect
379 - mCurrentEffect.SetCurrentImage(mCurrentImage); 375 + mCurrentEffect.SetCurrentImage( mCurrentImage );
380 return true; 376 return true;
381 } 377 }
382 378
@@ -385,7 +381,7 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button ) @@ -385,7 +381,7 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button )
385 mSlideshow = !mSlideshow; 381 mSlideshow = !mSlideshow;
386 if( mSlideshow ) 382 if( mSlideshow )
387 { 383 {
388 - mPanGestureDetector.Detach( mParent ); 384 + mPanGestureDetector.Detach( mContent );
389 mSlideshowButton.SetUnselectedImage( SLIDE_SHOW_STOP_ICON ); 385 mSlideshowButton.SetUnselectedImage( SLIDE_SHOW_STOP_ICON );
390 mSlideshowButton.SetSelectedImage( SLIDE_SHOW_STOP_ICON_SELECTED ); 386 mSlideshowButton.SetSelectedImage( SLIDE_SHOW_STOP_ICON_SELECTED );
391 mPanPosition = Vector2( mViewSize.width, mViewSize.height*0.5f ); 387 mPanPosition = Vector2( mViewSize.width, mViewSize.height*0.5f );
@@ -394,7 +390,7 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button ) @@ -394,7 +390,7 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button )
394 } 390 }
395 else 391 else
396 { 392 {
397 - mPanGestureDetector.Attach( mParent ); 393 + mPanGestureDetector.Attach( mContent );
398 mSlideshowButton.SetUnselectedImage( SLIDE_SHOW_START_ICON ); 394 mSlideshowButton.SetUnselectedImage( SLIDE_SHOW_START_ICON );
399 mSlideshowButton.SetSelectedImage( SLIDE_SHOW_START_ICON_SELECTED ); 395 mSlideshowButton.SetSelectedImage( SLIDE_SHOW_START_ICON_SELECTED );
400 mViewTimer.Stop(); 396 mViewTimer.Stop();
@@ -402,7 +398,7 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button ) @@ -402,7 +398,7 @@ bool CubeTransitionApp::OnSildeshowButtonClicked( Toolkit::Button button )
402 return true; 398 return true;
403 } 399 }
404 400
405 -void CubeTransitionApp::OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, ImageActor imageActor) 401 +void CubeTransitionApp::OnTransitionCompleted(Toolkit::CubeTransitionEffect effect, Image image )
406 { 402 {
407 if( mSlideshow ) 403 if( mSlideshow )
408 { 404 {