-void DaliTableView::SetupBackground( Actor bubbleContainer )
-{
- // Add bubbles to the bubbleContainer.
- // Note: The bubbleContainer is parented externally to this function.
- AddBackgroundActors( bubbleContainer, NUM_BACKGROUND_IMAGES );
-}
-
-void DaliTableView::InitialiseBackgroundActors( Actor actor )
-{
- // Delete current animations
- mBackgroundAnimations.clear();
-
- // Create new animations
- const Vector3 size = actor.GetTargetSize();
-
- for( unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i )
- {
- Actor child = actor.GetChildAt( i );
-
- // Calculate a random position
- Vector3 childPos( Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.85f * BACKGROUND_SPREAD_SCALE ),
- Random::Range( -size.y, size.y ),
- Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) );
-
- child.SetProperty( Actor::Property::POSITION, childPos );
-
- // Define bubble horizontal parallax and vertical wrapping
- Constraint animConstraint = Constraint::New < Vector3 > ( child, Actor::Property::POSITION, AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ) ) );
- animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) );
- animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) );
- animConstraint.AddSource( Dali::LocalSource( Dali::Actor::Property::SIZE ) );
- animConstraint.SetRemoveAction( Constraint::Discard );
- animConstraint.Apply();
-
- // Kickoff animation
- Animation animation = Animation::New( Random::Range( 30.0f, 160.0f ) );
- animation.AnimateBy( Property( child, Actor::Property::POSITION ), Vector3( 0.0f, -2000.0f, 0.0f ), AlphaFunction::LINEAR );
- animation.SetLooping( true );
- animation.Play();
- mBackgroundAnimations.push_back( animation );
- }
-}
-
-void DaliTableView::AddBackgroundActors( Actor layer, int count )
-{
- for( int i = 0; i < count; ++i )
- {
- float randSize = Random::Range( 10.0f, 400.0f );
- int shapeType = static_cast<int>( Random::Range( 0.0f, NUMBER_OF_SHAPE_IMAGES - 1 ) + 0.5f );
-
- ImageView dfActor = ImageView::New();
- dfActor.SetProperty( Actor::Property::SIZE, Vector2( randSize, randSize ) );
- dfActor.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER );
-
- // Set the Image URL and the custom shader at the same time
- Dali::Property::Map effect = Toolkit::CreateDistanceFieldEffect();
- Property::Map imageMap;
- imageMap.Add( ImageVisual::Property::URL, SHAPE_IMAGE_TABLE[ shapeType ] );
- imageMap.Add( Toolkit::Visual::Property::SHADER, effect );
- dfActor.SetProperty( Toolkit::ImageView::Property::IMAGE, imageMap );
-
- dfActor.SetStyleName( BUBBLE_COLOR_STYLE_NAME[ i%NUMBER_OF_BUBBLE_COLORS ] );
-
- layer.Add( dfActor );
- }
-
- // Positioning will occur when the layer is relaid out
- layer.OnRelayoutSignal().Connect( this, &DaliTableView::InitialiseBackgroundActors );
-}
-
-bool DaliTableView::PauseBackgroundAnimation()
-{
- PauseAnimation();
-
- return false;
-}
-
-void DaliTableView::PauseAnimation()
-{
- if( mBackgroundAnimsPlaying )
- {
- for( AnimationListIter animIter = mBackgroundAnimations.begin(); animIter != mBackgroundAnimations.end(); ++animIter )
- {
- Animation anim = *animIter;
-
- anim.Stop();
- }
-
- mBackgroundAnimsPlaying = false;
- }
-}
-
-void DaliTableView::PlayAnimation()
-{
- if ( !mBackgroundAnimsPlaying )
- {
- for( AnimationListIter animIter = mBackgroundAnimations.begin(); animIter != mBackgroundAnimations.end(); ++animIter )
- {
- Animation anim = *animIter;
-
- anim.Play();
- }
-
- mBackgroundAnimsPlaying = true;
- }
-
- mAnimationTimer.SetInterval( BACKGROUND_ANIMATION_DURATION );
-}
-
-Dali::Actor DaliTableView::OnKeyboardPreFocusChange( Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction )