Commit 5d4268339e5a560c040f3609595dd7b6e35392ea

Authored by Kingsley Stephens
1 parent 20b3a7a6

Change Dali Demo to use CubeEffect

Change-Id: I79a3527d729ab9b4edd84884682531a643ba5cb8
demo/dali-table-view.cpp
@@ -53,11 +53,10 @@ const int MAX_PAGES = 256; ///< Maximum pag @@ -53,11 +53,10 @@ const int MAX_PAGES = 256; ///< Maximum pag
53 const int EXAMPLES_PER_ROW = 3; 53 const int EXAMPLES_PER_ROW = 3;
54 const int ROWS_PER_PAGE = 3; 54 const int ROWS_PER_PAGE = 3;
55 const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE; 55 const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE;
56 -const float TOP_ROW_HEIGHT = 35.0f;  
57 -const float BOTTOM_ROW_HEIGHT = 35.0f;  
58 const int BOTTOM_PADDING_HEIGHT = 40; 56 const int BOTTOM_PADDING_HEIGHT = 40;
59 -const int LOGO_BOTTOM_PADDING_HEIGHT = 30;  
60 -const Vector3 TABLE_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< TableView's relative size to the entire stage. 57 +const int LOGO_MARGIN = 50;
  58 +const Vector3 SCROLLVIEW_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< ScrollView's relative size to its parent
  59 +const Vector3 TABLE_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< TableView's relative size to the entire stage. The Y value will be calculated.
61 const float STENCIL_RELATIVE_SIZE = 1.0f; 60 const float STENCIL_RELATIVE_SIZE = 1.0f;
62 61
63 const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects 62 const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects
@@ -73,10 +72,18 @@ const float SCALE_SPEED_SIN = 0.1f; @@ -73,10 +72,18 @@ const float SCALE_SPEED_SIN = 0.1f;
73 72
74 const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs 73 const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs
75 74
76 -const float BACKGROUND_Z = -1000.0f;  
77 -const float BACKGROUND_SIZE_SCALE = 2.0f; 75 +const float BACKGROUND_Z = -1.0f;
  76 +const float BACKGROUND_SIZE_SCALE = 1.0f;
78 const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f ); 77 const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f );
79 78
  79 +const float BUBBLE_MIN_Z = -1.0;
  80 +const float BUBBLE_MAX_Z = 0.0f;
  81 +
  82 +// 3D Effect constants
  83 +const Vector2 ANGLE_SWING_3DEFFECT( Math::PI_2 * 0.75, Math::PI_2 * 0.75f ); ///< Angle Swing in radians
  84 +const Vector2 POSITION_SWING_3DEFFECT( 0.55f, 0.4f ); ///< Position Swing relative to stage size.
  85 +const Vector3 ANCHOR_3DEFFECT_STYLE0( -105.0f, 30.0f, -240.0f ); ///< Rotation Anchor position for 3D Effect (Style 0)
  86 +const Vector3 ANCHOR_3DEFFECT_STYLE1( 65.0f, -70.0f, -500.0f ); ///< Rotation Anchor position for 3D Effect (Style 1)
80 87
81 const std::string DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNeue"); 88 const std::string DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNeue");
82 const std::string DEFAULT_TEXT_STYLE_FONT_STYLE("Regular"); 89 const std::string DEFAULT_TEXT_STYLE_FONT_STYLE("Regular");
@@ -90,6 +97,12 @@ const Dali::PointSize TABLE_TEXT_STYLE_POINT_SIZE( 8.0f ); @@ -90,6 +97,12 @@ const Dali::PointSize TABLE_TEXT_STYLE_POINT_SIZE( 8.0f );
90 const Dali::TextStyle::Weight TABLE_TEXT_STYLE_WEIGHT(Dali::TextStyle::LIGHT); 97 const Dali::TextStyle::Weight TABLE_TEXT_STYLE_WEIGHT(Dali::TextStyle::LIGHT);
91 const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f); 98 const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
92 99
  100 +Vector3 ScalePointSize(const Vector3& vec)
  101 +{
  102 + return Vector3( DemoHelper::ScalePointSize( vec.x ), DemoHelper::ScalePointSize( vec.y ), DemoHelper::ScalePointSize( vec.z ) );
  103 +}
  104 +
  105 +#define DP(x) DemoHelper::ScalePointSize(x)
93 106
94 TextStyle GetTableTextStyle() 107 TextStyle GetTableTextStyle()
95 { 108 {
@@ -249,7 +262,7 @@ void DaliTableView::Initialize( Application&amp; application ) @@ -249,7 +262,7 @@ void DaliTableView::Initialize( Application&amp; application )
249 { 262 {
250 Stage::GetCurrent().KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent ); 263 Stage::GetCurrent().KeyEventSignal().Connect( this, &DaliTableView::OnKeyEvent );
251 264
252 - Vector2 stageSize = Stage::GetCurrent().GetSize(); 265 + const Vector2 stageSize = Stage::GetCurrent().GetSize();
253 266
254 // Background 267 // Background
255 mBackground = CreateBackground( mBackgroundImagePath ); 268 mBackground = CreateBackground( mBackgroundImagePath );
@@ -261,7 +274,6 @@ void DaliTableView::Initialize( Application&amp; application ) @@ -261,7 +274,6 @@ void DaliTableView::Initialize( Application&amp; application )
261 mRootActor = TableView::New( 4, 1 ); 274 mRootActor = TableView::New( 4, 1 );
262 mRootActor.SetAnchorPoint( AnchorPoint::CENTER ); 275 mRootActor.SetAnchorPoint( AnchorPoint::CENTER );
263 mRootActor.SetParentOrigin( ParentOrigin::CENTER ); 276 mRootActor.SetParentOrigin( ParentOrigin::CENTER );
264 - mRootActor.SetFixedHeight( 3, BOTTOM_PADDING_HEIGHT );  
265 Stage::GetCurrent().Add( mRootActor ); 277 Stage::GetCurrent().Add( mRootActor );
266 278
267 // Toolbar at top 279 // Toolbar at top
@@ -273,11 +285,17 @@ void DaliTableView::Initialize( Application&amp; application ) @@ -273,11 +285,17 @@ void DaliTableView::Initialize( Application&amp; application )
273 DemoHelper::GetDefaultTextStyle()); 285 DemoHelper::GetDefaultTextStyle());
274 286
275 mRootActor.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) ); 287 mRootActor.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) );
276 - mRootActor.SetFixedHeight( 0, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight ); 288 + const float toolbarHeight = DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight;
  289 + mRootActor.SetFixedHeight( 0, toolbarHeight );
277 290
278 // Add logo 291 // Add logo
279 mLogo = CreateLogo( LOGO_PATH ); 292 mLogo = CreateLogo( LOGO_PATH );
280 - mRootActor.SetFixedHeight( 1, mLogo.GetImage().GetHeight() + LOGO_BOTTOM_PADDING_HEIGHT ); 293 + const float logoHeight = mLogo.GetImage().GetHeight() + DP(LOGO_MARGIN);
  294 + mRootActor.SetFixedHeight( 1, logoHeight );
  295 +
  296 + mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, ( stageSize.height - toolbarHeight - logoHeight - DP( BOTTOM_PADDING_HEIGHT ) ) / stageSize.height, TABLE_RELATIVE_SIZE.z );
  297 +
  298 + mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height );
281 299
282 Alignment alignment = Alignment::New(); 300 Alignment alignment = Alignment::New();
283 alignment.Add(mLogo); 301 alignment.Add(mLogo);
@@ -288,7 +306,8 @@ void DaliTableView::Initialize( Application&amp; application ) @@ -288,7 +306,8 @@ void DaliTableView::Initialize( Application&amp; application )
288 306
289 mScrollView.SetAnchorPoint( AnchorPoint::CENTER ); 307 mScrollView.SetAnchorPoint( AnchorPoint::CENTER );
290 mScrollView.SetParentOrigin( ParentOrigin::CENTER ); 308 mScrollView.SetParentOrigin( ParentOrigin::CENTER );
291 - mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ), Dali::RelativeToConstraint( TABLE_RELATIVE_SIZE ) ) ); 309 + mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ),
  310 + Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) );
292 mScrollView.SetAxisAutoLock( true ); 311 mScrollView.SetAxisAutoLock( true );
293 mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); 312 mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete );
294 mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); 313 mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart );
@@ -297,37 +316,22 @@ void DaliTableView::Initialize( Application&amp; application ) @@ -297,37 +316,22 @@ void DaliTableView::Initialize( Application&amp; application )
297 mScrollViewLayer = Layer::New(); 316 mScrollViewLayer = Layer::New();
298 mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER ); 317 mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER );
299 mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER ); 318 mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER );
300 - mScrollViewLayer.SetSize( stageSize ); 319 + mScrollViewLayer.SetDrawMode( DrawMode::OVERLAY );
  320 +
  321 + // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show
  322 + SetupBackground( mScrollView, mScrollViewLayer, stageSize );
  323 +
301 mScrollViewLayer.Add( mScrollView ); 324 mScrollViewLayer.Add( mScrollView );
302 mRootActor.AddChild( mScrollViewLayer, TableView::CellPosition( 2, 0 ) ); 325 mRootActor.AddChild( mScrollViewLayer, TableView::CellPosition( 2, 0 ) );
303 326
304 - // Setup the scenegraph  
305 - // 1) Add scroll view effect and setup constraints on pages 327 + // Add scroll view effect and setup constraints on pages
306 ApplyScrollViewEffect(); 328 ApplyScrollViewEffect();
307 329
308 - // 2) Add pages and tiles 330 + // Add pages and tiles
309 Populate(); 331 Populate();
310 332
311 - // 3) Populate scrollview with background so constraints on background layers can work with scrollview  
312 - SetupBackground( mScrollView, stageSize );  
313 -  
314 - // 4) Remove constraints for inner cube effect  
315 - for( TableViewListIter pageIter = mTableViewList.begin(); pageIter != mTableViewList.end(); ++pageIter )  
316 - {  
317 - TableView page = *pageIter;  
318 -  
319 - unsigned int numChildren = page.GetChildCount();  
320 - Actor pageActor = page;  
321 - for( unsigned int i=0; i<numChildren; ++i)  
322 - {  
323 - // Remove old effect's manual constraints.  
324 - Actor child = pageActor.GetChildAt(i);  
325 - if( child )  
326 - {  
327 - child.RemoveConstraints();  
328 - }  
329 - }  
330 - } 333 + // Remove constraints for inner cube effect
  334 + ApplyCubeEffectToActors();
331 335
332 // Set initial orientation 336 // Set initial orientation
333 unsigned int degrees = application.GetOrientation().GetDegrees(); 337 unsigned int degrees = application.GetOrientation().GetDegrees();
@@ -354,12 +358,29 @@ void DaliTableView::Initialize( Application&amp; application ) @@ -354,12 +358,29 @@ void DaliTableView::Initialize( Application&amp; application )
354 KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated ); 358 KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
355 } 359 }
356 360
  361 +void DaliTableView::ApplyCubeEffectToActors()
  362 +{
  363 + for( ActorIter pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter )
  364 + {
  365 + Actor page = *pageIter;
  366 +
  367 + unsigned int numChildren = page.GetChildCount();
  368 + Actor pageActor = page;
  369 + for( unsigned int i=0; i<numChildren; ++i)
  370 + {
  371 + // Remove old effect's manual constraints.
  372 + Actor child = pageActor.GetChildAt(i);
  373 + if( child )
  374 + {
  375 + ApplyCubeEffectToActor( child );
  376 + }
  377 + }
  378 + }
  379 +}
357 void DaliTableView::Populate() 380 void DaliTableView::Populate()
358 { 381 {
359 const Vector2 stageSize = Stage::GetCurrent().GetSize(); 382 const Vector2 stageSize = Stage::GetCurrent().GetSize();
360 383
361 - const Size demoTileSize( 0.25f * stageSize.width, 0.25f * stageSize.height );  
362 -  
363 mTotalPages = ( mExampleList.size() + EXAMPLES_PER_PAGE - 1 ) / EXAMPLES_PER_PAGE; 384 mTotalPages = ( mExampleList.size() + EXAMPLES_PER_PAGE - 1 ) / EXAMPLES_PER_PAGE;
364 385
365 // Populate ScrollView. 386 // Populate ScrollView.
@@ -372,41 +393,32 @@ void DaliTableView::Populate() @@ -372,41 +393,32 @@ void DaliTableView::Populate()
372 393
373 unsigned int exampleCount = 0; 394 unsigned int exampleCount = 0;
374 ExampleListConstIter iter = mExampleList.begin(); 395 ExampleListConstIter iter = mExampleList.begin();
  396 +
375 for( int t = 0; t < mTotalPages; t++ ) 397 for( int t = 0; t < mTotalPages; t++ )
376 { 398 {
377 // Create Table. (contains up to 9 Examples) 399 // Create Table. (contains up to 9 Examples)
378 - TableView tableView = TableView::New( 4, 3 ); 400 + Actor page = Actor::New();
  401 +
379 // Add tableView to container. 402 // Add tableView to container.
380 - mScrollView.Add( tableView );  
381 - ApplyEffectToPage( tableView, TABLE_RELATIVE_SIZE );  
382 -  
383 - tableView.SetAnchorPoint( AnchorPoint::CENTER );  
384 - tableView.SetParentOrigin( ParentOrigin::CENTER );  
385 - // 2 pixels of padding  
386 - tableView.SetCellPadding( Size( 2.0f, 2.0f ) );  
387 -  
388 - Constraint constraint = Constraint::New<Vector3>( Actor::SCALE,  
389 - LocalSource( Actor::SIZE ),  
390 - ParentSource( Actor::SIZE ),  
391 - ScaleToFitConstraint() );  
392 - tableView.ApplyConstraint(constraint);  
393 -  
394 - // Apply visibility constraint to table view  
395 - Constraint visibleConstraint = Constraint::New< bool >( Actor::VISIBLE,  
396 - LocalSource( Actor::POSITION ),  
397 - ParentSource( Actor::SIZE ),  
398 - TableViewVisibilityConstraint() );  
399 - visibleConstraint.SetRemoveAction( Constraint::Discard );  
400 - tableView.ApplyConstraint( visibleConstraint ); 403 + mScrollView.Add( page );
  404 +
  405 + page.SetAnchorPoint( AnchorPoint::CENTER );
  406 + page.SetParentOrigin( ParentOrigin::CENTER );
  407 + page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
401 408
402 // add cells to table 409 // add cells to table
403 - for( int y = 0; y < ROWS_PER_PAGE; y++ ) 410 + const float margin = 4.0f;
  411 +
  412 + // Calculate the number of images going across (columns) within a page, according to the screen resolution and dpi.
  413 + const Size tileSize((stageSize.x * mButtonsPageRelativeSize.x / EXAMPLES_PER_ROW) - margin, (stageSize.y * mButtonsPageRelativeSize.y / ROWS_PER_PAGE) - margin );
  414 +
  415 + for(int row = 0; row < ROWS_PER_PAGE; row++)
404 { 416 {
405 - for( int x = 0; x < EXAMPLES_PER_ROW; x++ ) 417 + for(int column = 0; column < EXAMPLES_PER_ROW; column++)
406 { 418 {
407 const Example& example = ( *iter ); 419 const Example& example = ( *iter );
408 420
409 - Actor tile = CreateTile( example.name, example.title, demoTileSize, true ); 421 + Actor tile = CreateTile( example.name, example.title, tileSize, true );
410 FocusManager focusManager = FocusManager::Get(); 422 FocusManager focusManager = FocusManager::Get();
411 focusManager.SetFocusOrder( tile, ++exampleCount ); 423 focusManager.SetFocusOrder( tile, ++exampleCount );
412 focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_LABEL, 424 focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_LABEL,
@@ -415,7 +427,13 @@ void DaliTableView::Populate() @@ -415,7 +427,13 @@ void DaliTableView::Populate()
415 focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_HINT, 427 focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_HINT,
416 "You can run this example" ); 428 "You can run this example" );
417 429
418 - tableView.AddChild( tile, TableView::CellPosition( y, x ) ); 430 + Vector3 position( margin * 0.5f + (tileSize.x + margin) * column - stageSize.width * mButtonsPageRelativeSize.x * 0.5f,
  431 + margin * 0.5f + (tileSize.y + margin) * row - stageSize.height * mButtonsPageRelativeSize.y * 0.5f,
  432 + 0.0f);
  433 + tile.SetPosition( position + Vector3( tileSize.x, tileSize.y, 0.0f ) * 0.5f );
  434 + tile.SetSize( tileSize );
  435 + page.Add( tile );
  436 +
419 iter++; 437 iter++;
420 438
421 if( iter == mExampleList.end() ) 439 if( iter == mExampleList.end() )
@@ -423,31 +441,18 @@ void DaliTableView::Populate() @@ -423,31 +441,18 @@ void DaliTableView::Populate()
423 break; 441 break;
424 } 442 }
425 } 443 }
  444 +
426 if( iter == mExampleList.end() ) 445 if( iter == mExampleList.end() )
427 { 446 {
428 break; 447 break;
429 } 448 }
430 } 449 }
431 450
432 - // last row is thin.  
433 - tableView.SetFixedHeight( 3, BOTTOM_ROW_HEIGHT );  
434 -  
435 - std::stringstream out;  
436 - out << ( t + 1 ) << " of " << mTotalPages;  
437 - Actor pageNumberText = CreateTile( "", out.str(), Size( 0.8f * stageSize.width, BOTTOM_ROW_HEIGHT ), false );  
438 -  
439 - pageNumberText.ApplyConstraint( Constraint::New< Vector3 >( Actor::POSITION, Source( tableView, Actor::WORLD_POSITION),  
440 - TranslateLocalConstraint( Vector3( 0.0f, stageSize.y * 0.4f, 0.0f ) ) ) );  
441 - pageNumberText.ApplyConstraint( Constraint::New< Quaternion >( Actor::ROTATION, Source( tableView, Actor::WORLD_ROTATION ), EqualToConstraint() ) );  
442 - pageNumberText.ApplyConstraint( Constraint::New< Vector4 >( Actor::COLOR, Source( tableView, Actor::COLOR ), EqualToConstraint() ) );  
443 -  
444 - //Stage::GetCurrent().Add( pageNumberText );  
445 -  
446 // Set tableview position 451 // Set tableview position
447 - Vector3 tableViewPos( stageSize.x * TABLE_RELATIVE_SIZE.x * t, 0.0f, 0.0f );  
448 - tableView.SetPosition( tableViewPos ); 452 + Vector3 pagePos( stageSize.x * mButtonsPageRelativeSize.x * t, 0.0f, 0.0f );
  453 + page.SetPosition( pagePos );
449 454
450 - mTableViewList.push_back( tableView ); 455 + mPages.push_back( page );
451 456
452 if( iter == mExampleList.end() ) 457 if( iter == mExampleList.end() )
453 { 458 {
@@ -457,9 +462,9 @@ void DaliTableView::Populate() @@ -457,9 +462,9 @@ void DaliTableView::Populate()
457 } 462 }
458 463
459 // Update Ruler info. 464 // Update Ruler info.
460 - mScrollRulerX = new FixedRuler( stageSize.width * TABLE_RELATIVE_SIZE.x ); 465 + mScrollRulerX = new FixedRuler( stageSize.width * mButtonsPageRelativeSize.x );
461 mScrollRulerY = new DefaultRuler(); 466 mScrollRulerY = new DefaultRuler();
462 - mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * TABLE_RELATIVE_SIZE.x, true ) ); 467 + mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * mButtonsPageRelativeSize.x, true ) );
463 mScrollRulerY->Disable(); 468 mScrollRulerY->Disable();
464 mScrollView.SetRulerX( mScrollRulerX ); 469 mScrollView.SetRulerX( mScrollRulerX );
465 mScrollView.SetRulerY( mScrollRulerY ); 470 mScrollView.SetRulerY( mScrollRulerY );
@@ -500,9 +505,6 @@ Actor DaliTableView::CreateTile( const std::string&amp; name, const std::string&amp; tit @@ -500,9 +505,6 @@ Actor DaliTableView::CreateTile( const std::string&amp; name, const std::string&amp; tit
500 tile.SetAnchorPoint( AnchorPoint::CENTER ); 505 tile.SetAnchorPoint( AnchorPoint::CENTER );
501 tile.SetParentOrigin( ParentOrigin::CENTER ); 506 tile.SetParentOrigin( ParentOrigin::CENTER );
502 507
503 - // make the tile 100% of parent  
504 - tile.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );  
505 -  
506 Actor content = Actor::New(); 508 Actor content = Actor::New();
507 content.SetAnchorPoint( AnchorPoint::CENTER ); 509 content.SetAnchorPoint( AnchorPoint::CENTER );
508 content.SetParentOrigin( ParentOrigin::CENTER ); 510 content.SetParentOrigin( ParentOrigin::CENTER );
@@ -673,8 +675,9 @@ void DaliTableView::OnScrollComplete( const Dali::Vector3&amp; position ) @@ -673,8 +675,9 @@ void DaliTableView::OnScrollComplete( const Dali::Vector3&amp; position )
673 675
674 // move focus to 1st item of new page 676 // move focus to 1st item of new page
675 FocusManager focusManager = FocusManager::Get(); 677 FocusManager focusManager = FocusManager::Get();
676 - focusManager.SetCurrentFocusActor(mTableViewList[mScrollView.GetCurrentPage()].GetChildAt(TableView::CellPosition(1, 0)) ); 678 + focusManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) );
677 679
  680 + ApplyCubeEffectToActors();
678 } 681 }
679 682
680 bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event ) 683 bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event )
@@ -705,36 +708,21 @@ void DaliTableView::ApplyScrollViewEffect() @@ -705,36 +708,21 @@ void DaliTableView::ApplyScrollViewEffect()
705 708
706 void DaliTableView::SetupInnerPageCubeEffect() 709 void DaliTableView::SetupInnerPageCubeEffect()
707 { 710 {
708 - ScrollViewCustomEffect customEffect;  
709 - mScrollViewEffect = customEffect = ScrollViewCustomEffect::New(); 711 + mScrollViewEffect = ScrollViewCubeEffect::New();
710 mScrollView.SetScrollSnapDuration( EFFECT_SNAP_DURATION ); 712 mScrollView.SetScrollSnapDuration( EFFECT_SNAP_DURATION );
711 mScrollView.SetScrollFlickDuration( EFFECT_FLICK_DURATION ); 713 mScrollView.SetScrollFlickDuration( EFFECT_FLICK_DURATION );
712 mScrollView.RemoveConstraintsFromChildren(); 714 mScrollView.RemoveConstraintsFromChildren();
713 -  
714 - customEffect.SetPageSpacing( Vector2( 30.0f, 30.0f ) );  
715 - customEffect.SetAngledOriginPageRotation( ANGLE_CUBE_PAGE_ROTATE );  
716 - customEffect.SetSwingAngle( ANGLE_CUBE_PAGE_ROTATE.x, Vector3( 0, -1, 0 ) );  
717 - customEffect.SetOpacityThreshold( 0.5f ); // Make fade out on edges  
718 } 715 }
719 716
720 -void DaliTableView::ApplyEffectToPage( Actor page, const Vector3& tableRelativeSize ) 717 +void DaliTableView::ApplyCubeEffectToActor( Actor actor )
721 { 718 {
722 - page.RemoveConstraints(); 719 + actor.RemoveConstraints();
723 720
724 - Constraint constraint = Constraint::New<Vector3>( Actor::SCALE,  
725 - LocalSource( Actor::SIZE ),  
726 - ParentSource( Actor::SIZE ),  
727 - ScaleToFitConstraint() );  
728 - page.ApplyConstraint(constraint);  
729 -  
730 - ApplyCustomEffectToPage( page );  
731 -}  
732 -  
733 -void DaliTableView::ApplyCustomEffectToPage( Actor page )  
734 -{  
735 - ScrollViewCustomEffect customEffect = ScrollViewCustomEffect::DownCast( mScrollViewEffect );  
736 - Vector2 vStageSize( Stage::GetCurrent().GetSize() );  
737 - customEffect.ApplyToPage( page, Vector3( vStageSize.x, vStageSize.y, 1.0f ) ); 721 + ScrollViewCubeEffect cubeEffect = ScrollViewCubeEffect::DownCast(mScrollViewEffect);
  722 + cubeEffect.ApplyToActor( actor,
  723 + ScalePointSize( ( rand() & 1 ) ? ANCHOR_3DEFFECT_STYLE0 : ANCHOR_3DEFFECT_STYLE1 ),
  724 + ANGLE_SWING_3DEFFECT,
  725 + POSITION_SWING_3DEFFECT * Vector2(Stage::GetCurrent().GetSize()));
738 } 726 }
739 727
740 void DaliTableView::OnKeyEvent( const KeyEvent& event ) 728 void DaliTableView::OnKeyEvent( const KeyEvent& event )
@@ -757,7 +745,7 @@ Actor CreateBackgroundActor( const Vector2&amp; size ) @@ -757,7 +745,7 @@ Actor CreateBackgroundActor( const Vector2&amp; size )
757 return layer; 745 return layer;
758 } 746 }
759 747
760 -void DaliTableView::SetupBackground( Actor addToLayer, const Vector2& size ) 748 +void DaliTableView::SetupBackground( Actor bubbleLayer, Actor backgroundLayer, const Vector2& size )
761 { 749 {
762 // Create distance field shape 750 // Create distance field shape
763 BitmapImage distanceField; 751 BitmapImage distanceField;
@@ -792,13 +780,12 @@ void DaliTableView::SetupBackground( Actor addToLayer, const Vector2&amp; size ) @@ -792,13 +780,12 @@ void DaliTableView::SetupBackground( Actor addToLayer, const Vector2&amp; size )
792 layer.SetSize( size * BACKGROUND_SIZE_SCALE ); 780 layer.SetSize( size * BACKGROUND_SIZE_SCALE );
793 layer.SetZ( BACKGROUND_Z ); 781 layer.SetZ( BACKGROUND_Z );
794 layer.SetPositionInheritanceMode( DONT_INHERIT_POSITION ); 782 layer.SetPositionInheritanceMode( DONT_INHERIT_POSITION );
795 -  
796 - addToLayer.Add( layer ); 783 + backgroundLayer.Add( layer );
797 784
798 // Parent the layers 785 // Parent the layers
799 - addToLayer.Add( backgroundAnimLayer0 );  
800 - addToLayer.Add( backgroundAnimLayer1 );  
801 - addToLayer.Add( backgroundAnimLayer2 ); 786 + bubbleLayer.Add( backgroundAnimLayer0 );
  787 + bubbleLayer.Add( backgroundAnimLayer1 );
  788 + bubbleLayer.Add( backgroundAnimLayer2 );
802 789
803 // Add all the children 790 // Add all the children
804 AddBackgroundActors( backgroundAnimLayer0, NUM_BACKGROUND_IMAGES / 3, distanceField, size ); 791 AddBackgroundActors( backgroundAnimLayer0, NUM_BACKGROUND_IMAGES / 3, distanceField, size );
@@ -830,7 +817,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage dis @@ -830,7 +817,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage dis
830 Vector3 actorPos( 817 Vector3 actorPos(
831 Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), 818 Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ),
832 Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ), 819 Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ),
833 - Random::Range(-1.0f, 0.0f) ); 820 + Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) );
834 dfActor.SetPosition( actorPos ); 821 dfActor.SetPosition( actorPos );
835 822
836 Constraint movementConstraint = Constraint::New < Vector3 > ( Actor::POSITION, 823 Constraint movementConstraint = Constraint::New < Vector3 > ( Actor::POSITION,
@@ -974,7 +961,7 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali:: @@ -974,7 +961,7 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali::
974 if ( !current && !proposed ) 961 if ( !current && !proposed )
975 { 962 {
976 // Set the initial focus to the first tile in the current page should be focused. 963 // Set the initial focus to the first tile in the current page should be focused.
977 - nextFocusActor = mTableViewList[mScrollView.GetCurrentPage()].GetChildAt(TableView::CellPosition(0, 0)); 964 + nextFocusActor = mPages[mScrollView.GetCurrentPage()].GetChildAt(0);
978 } 965 }
979 else if( !proposed || (proposed && proposed == mScrollViewLayer) ) 966 else if( !proposed || (proposed && proposed == mScrollViewLayer) )
980 { 967 {
@@ -1014,12 +1001,12 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali:: @@ -1014,12 +1001,12 @@ Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali::
1014 int colPos = remainingExamples >= EXAMPLES_PER_PAGE ? EXAMPLES_PER_ROW - 1 : ( remainingExamples % EXAMPLES_PER_PAGE - rowPos * EXAMPLES_PER_ROW - 1 ); 1001 int colPos = remainingExamples >= EXAMPLES_PER_PAGE ? EXAMPLES_PER_ROW - 1 : ( remainingExamples % EXAMPLES_PER_PAGE - rowPos * EXAMPLES_PER_ROW - 1 );
1015 1002
1016 // Move the focus to the last tile in the new page. 1003 // Move the focus to the last tile in the new page.
1017 - nextFocusActor = mTableViewList[newPage].GetChildAt(TableView::CellPosition(rowPos, colPos)); 1004 + nextFocusActor = mPages[newPage].GetChildAt(colPos * EXAMPLES_PER_ROW + rowPos);
1018 } 1005 }
1019 else 1006 else
1020 { 1007 {
1021 // Move the focus to the first tile in the new page. 1008 // Move the focus to the first tile in the new page.
1022 - nextFocusActor = mTableViewList[newPage].GetChildAt(TableView::CellPosition(0, 0)); 1009 + nextFocusActor = mPages[newPage].GetChildAt(0);
1023 } 1010 }
1024 } 1011 }
1025 1012
demo/dali-table-view.h
@@ -243,19 +243,19 @@ private: // Application callbacks &amp; implementation @@ -243,19 +243,19 @@ private: // Application callbacks &amp; implementation
243 void ApplyScrollViewEffect(); 243 void ApplyScrollViewEffect();
244 244
245 /** 245 /**
246 - * Setup the inner cube effect 246 + * Apply the cube effect to all the page actors
247 */ 247 */
248 - void SetupInnerPageCubeEffect(); 248 + void ApplyCubeEffectToActors();
249 249
250 /** 250 /**
251 - * Apply the scroll view effect to a page 251 + * Setup the inner cube effect
252 */ 252 */
253 - void ApplyEffectToPage(Dali::Actor page, const Dali::Vector3& tableRelativeSize); 253 + void SetupInnerPageCubeEffect();
254 254
255 /** 255 /**
256 - * Apply a custom effect scroll view effect to a page 256 + * Apply the cube effect to an actor
257 */ 257 */
258 - void ApplyCustomEffectToPage(Dali::Actor page); 258 + void ApplyCubeEffectToActor( Dali::Actor actor );
259 259
260 /** 260 /**
261 * Apply a shader effect to a table tile 261 * Apply a shader effect to a table tile
@@ -275,9 +275,10 @@ private: // Application callbacks &amp; implementation @@ -275,9 +275,10 @@ private: // Application callbacks &amp; implementation
275 /** 275 /**
276 * Create a depth field background 276 * Create a depth field background
277 * 277 *
278 - * @param[in] addToLayer Add the graphics to this layer 278 + * @param[in] bubbleLayer Add the graphics to this layer
  279 + * @param[in] backgroundLayer Add the background to this layer
279 */ 280 */
280 - void SetupBackground( Dali::Actor addToLayer, const Dali::Vector2& size ); 281 + void SetupBackground( Dali::Actor bubbleLayer, Dali::Actor backgroundLayer, const Dali::Vector2& size );
281 282
282 /** 283 /**
283 * Create background actors for the given layer 284 * Create background actors for the given layer
@@ -378,7 +379,7 @@ private: @@ -378,7 +379,7 @@ private:
378 Dali::Toolkit::TableView mButtons; ///< Navigation buttons 379 Dali::Toolkit::TableView mButtons; ///< Navigation buttons
379 ExampleList mExampleList; ///< List of examples. 380 ExampleList mExampleList; ///< List of examples.
380 ExampleMap mExampleMap; ///< Map LUT for examples. 381 ExampleMap mExampleMap; ///< Map LUT for examples.
381 - TableViewList mTableViewList; ///< List of tableviews 382 + Dali::ActorContainer mPages; ///< List of pages.
382 Dali::Actor mPressedActor; ///< The currently pressed actor. 383 Dali::Actor mPressedActor; ///< The currently pressed actor.
383 int mTotalPages; ///< Total pages within scrollview. 384 int mTotalPages; ///< Total pages within scrollview.
384 std::string mBackgroundImagePath; ///< The path to the background image. 385 std::string mBackgroundImagePath; ///< The path to the background image.
@@ -390,6 +391,8 @@ private: @@ -390,6 +391,8 @@ private:
390 AnimationList mBackgroundAnimations;///< List of background bubble animations 391 AnimationList mBackgroundAnimations;///< List of background bubble animations
391 Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period 392 Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period
392 bool mBackgroundAnimsPlaying; ///< Are background animations playing 393 bool mBackgroundAnimsPlaying; ///< Are background animations playing
  394 +
  395 + Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size
393 }; 396 };
394 397
395 #endif // __DALI_DEMO_H__ 398 #endif // __DALI_DEMO_H__