// CLASS HEADER
#include "dali-table-view.h"
-#include "examples/shared/view.h"
// EXTERNAL INCLUDES
#include <algorithm>
#include <sstream>
-#include<unistd.h>
+#include <unistd.h>
+#include <dali/devel-api/images/distance-field.h>
+#include <dali-toolkit/devel-api/shader-effects/alpha-discard-effect.h>
+#include <dali-toolkit/devel-api/shader-effects/distance-field-effect.h>
+
+// INTERNAL INCLUDES
+#include "shared/view.h"
using namespace Dali;
using namespace Dali::Toolkit;
const int EXAMPLES_PER_ROW = 3;
const int ROWS_PER_PAGE = 3;
const int EXAMPLES_PER_PAGE = EXAMPLES_PER_ROW * ROWS_PER_PAGE;
-const float LOGO_MARGIN_RATIO = 0.5f / 0.9f;
+const float LOGO_MARGIN_RATIO = 0.1f / 0.3f;
const float BOTTOM_PADDING_RATIO = 0.4f / 0.9f;
const Vector3 SCROLLVIEW_RELATIVE_SIZE(0.9f, 1.0f, 0.8f ); ///< ScrollView's relative size to its parent
-const Vector3 TABLE_RELATIVE_SIZE(0.9f, 0.9f, 0.8f ); ///< TableView's relative size to the entire stage. The Y value means sum of the logo and table relative heights.
+const Vector3 TABLE_RELATIVE_SIZE(0.95f, 0.9f, 0.8f ); ///< TableView's relative size to the entire stage. The Y value means sum of the logo and table relative heights.
const float STENCIL_RELATIVE_SIZE = 1.0f;
const float EFFECT_SNAP_DURATION = 0.66f; ///< Scroll Snap Duration for Effects
const float EFFECT_FLICK_DURATION = 0.5f; ///< Scroll Flick Duration for Effects
const Vector3 ANGLE_CUBE_PAGE_ROTATE(Math::PI * 0.5f, Math::PI * 0.5f, 0.0f);
-const int NUM_BACKGROUND_IMAGES = 20;
+
+
+const int NUM_BACKGROUND_IMAGES = 18;
const float BACKGROUND_SWIPE_SCALE = 0.025f;
const float BACKGROUND_SPREAD_SCALE = 1.5f;
const float SCALE_MOD = 1000.0f * Math::PI * 2.0f;
const unsigned int BACKGROUND_ANIMATION_DURATION = 15000; // 15 secs
const float BACKGROUND_Z = -1.0f;
-const float BACKGROUND_SIZE_SCALE = 1.0f;
const Vector4 BACKGROUND_COLOR( 1.0f, 1.0f, 1.0f, 1.0f );
const float BUBBLE_MIN_Z = -1.0;
const float BUBBLE_MAX_Z = 0.0f;
-// 3D Effect constants
-const Vector2 ANGLE_SWING_3DEFFECT( Math::PI_2 * 0.75, Math::PI_2 * 0.75f ); ///< Angle Swing in radians
-const Vector2 POSITION_SWING_3DEFFECT( 0.55f, 0.4f ); ///< Position Swing relative to stage size.
-const Vector3 ANCHOR_3DEFFECT_STYLE0( -105.0f, 30.0f, -240.0f ); ///< Rotation Anchor position for 3D Effect (Style 0)
-const Vector3 ANCHOR_3DEFFECT_STYLE1( 65.0f, -70.0f, -500.0f ); ///< Rotation Anchor position for 3D Effect (Style 1)
-
-//const std::string DEFAULT_TEXT_STYLE_FONT_FAMILY("HelveticaNeue");
-//const std::string DEFAULT_TEXT_STYLE_FONT_STYLE("Regular");
-//const Dali::Vector4 DEFAULT_TEXT_STYLE_COLOR(0.7f, 0.7f, 0.7f, 1.0f);
-
-//const std::string TABLE_TEXT_STYLE_FONT_FAMILY("HelveticaNeue");
-//const std::string TABLE_TEXT_STYLE_FONT_STYLE("Regular");
-//const Dali::PointSize TABLE_TEXT_STYLE_POINT_SIZE( 8.0f );
-//const Dali::TextStyle::Weight TABLE_TEXT_STYLE_WEIGHT(Dali::TextStyle::LIGHT);
-//const Dali::Vector4 TABLE_TEXT_STYLE_COLOR(0.0f, 0.0f, 0.0f, 1.0f);
-
-Vector3 ScalePointSize(const Vector3& vec)
-{
- return Vector3( DemoHelper::ScalePointSize( vec.x ), DemoHelper::ScalePointSize( vec.y ), DemoHelper::ScalePointSize( vec.z ) );
-}
-
-#define DP(x) DemoHelper::ScalePointSize(x)
-
/**
* Creates the background image
*/
ImageActor CreateBackground( std::string imagePath )
{
- Image image = Image::New( imagePath );
+ Image image = ResourceImage::New( imagePath );
ImageActor background = ImageActor::New( image );
-
+ background.SetName( "BACKGROUND" );
background.SetAnchorPoint( AnchorPoint::CENTER );
background.SetParentOrigin( ParentOrigin::CENTER );
background.SetZ( -1.0f );
+ background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
return background;
}
const float IMAGE_BORDER_BOTTOM = IMAGE_BORDER_LEFT;
/**
- * TableViewVisibilityConstraint
+ * Constraint to return a position for a bubble based on the scroll value and vertical wrapping
*/
-struct TableViewVisibilityConstraint
-{
- bool operator()( const bool& current,
- const PropertyInput& pagePositionProperty,
- const PropertyInput& pageSizeProperty )
- {
- // Only the tableview in the current page should be visible.
- const Vector3& pagePosition = pagePositionProperty.GetVector3();
- const Vector3& pageSize = pageSizeProperty.GetVector3();
- return fabsf( pagePosition.x ) < pageSize.x;
- }
-};
-
-/**
- * Constraint to wrap an actor in y that is moving vertically
- */
-Vector3 ShapeMovementConstraint( const Vector3& current,
- const PropertyInput& shapeSizeProperty,
- const PropertyInput& parentSizeProperty )
-{
- const Vector3& shapeSize = shapeSizeProperty.GetVector3();
- const Vector3& parentSize = parentSizeProperty.GetVector3();
-
- Vector3 pos( current );
- if( pos.y + shapeSize.y * 0.5f < -parentSize.y * 0.5f )
- {
- pos.y += parentSize.y + shapeSize.y;
- }
-
- return pos;
-}
-
-/**
- * Constraint to return a position for the background based on the scroll value
- */
-struct AnimScrollConstraint
+struct AnimateBubbleConstraint
{
public:
-
- AnimScrollConstraint( const Vector3& initialPos, float scale )
- : mInitialPos( initialPos ),
+ AnimateBubbleConstraint( const Vector3& initialPos, float scale )
+ : mInitialX( initialPos.x ),
mScale( scale )
{
-
- }
-
- Vector3 operator()( const Vector3& current, const PropertyInput& scrollProperty )
- {
- float scrollPos = scrollProperty.GetVector3().x;
-
- return mInitialPos + Vector3( -scrollPos * mScale, 0.0f, 0.0f );
}
-private:
- Vector3 mInitialPos;
- float mScale;
-};
-
-/**
- * Constraint to return a tracked world position added to the constant local position
- */
-struct TranslateLocalConstraint
-{
-public:
-
- TranslateLocalConstraint( const Vector3& localPos )
- : mLocalPos( localPos )
+ void operator()( Vector3& position, const PropertyInputContainer& inputs )
{
- }
+ const Vector3& parentSize = inputs[1]->GetVector3();
+ const Vector3& childSize = inputs[2]->GetVector3();
- Vector3 operator()( const Vector3& current, const PropertyInput& pagePosProperty )
- {
- Vector3 worldPos = pagePosProperty.GetVector3();
+ // Wrap bubbles verically.
+ if( position.y + childSize.y * 0.5f < -parentSize.y * 0.5f )
+ {
+ position.y = parentSize.y * 0.5f + childSize.y * 0.5f;
+ }
- return ( worldPos + mLocalPos );
+ // Bubbles X position moves parallax to horizontal
+ // panning by a scale factor unique to each bubble.
+ position.x = mInitialX + ( inputs[0]->GetVector2().x * mScale );
}
private:
- Vector3 mLocalPos;
+ float mInitialX;
+ float mScale;
+ float mShapeSize;
};
-
bool CompareByTitle( const Example& lhs, const Example& rhs )
{
return lhs.title < rhs.title;
} // namespace
DaliTableView::DaliTableView( Application& application )
- : mApplication( application ),
- mScrolling( false ),
- mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ),
- mSortAlphabetically( false ),
- mBackgroundAnimsPlaying( false )
+: mApplication( application ),
+ mBackgroundLayer(),
+ mRootActor(),
+ mRotateAnimation(),
+ mBackground(),
+ mPressedAnimation(),
+ mScrollViewLayer(),
+ mScrollView(),
+ mScrollViewEffect(),
+ mScrollRulerX(),
+ mScrollRulerY(),
+ mButtons(),
+ mPressedActor(),
+ mAnimationTimer(),
+ mLogoTapDetector(),
+ mVersionPopup(),
+ mButtonsPageRelativeSize(),
+ mPages(),
+ mTableViewImages(),
+ mBackgroundActors(),
+ mBackgroundAnimations(),
+ mExampleList(),
+ mExampleMap(),
+ mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ),
+ mTotalPages(),
+ mScrolling( false ),
+ mSortAlphabetically( false ),
+ mBackgroundAnimsPlaying( false ),
+ mVersionPopupShown( false )
{
application.InitSignal().Connect( this, &DaliTableView::Initialize );
}
const Vector2 stageSize = Stage::GetCurrent().GetSize();
- TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
- fontClient.SetDpi( 96, 96 );
-
// Background
- mBackground = CreateBackground( mBackgroundImagePath );
- // set same size as parent actor
- mBackground.SetSize( stageSize );
- Stage::GetCurrent().Add( mBackground );
+ Actor background = CreateBackground( mBackgroundImagePath );
+ Stage::GetCurrent().Add( background );
// Render entire content as overlays, as is all on same 2D plane.
mRootActor = TableView::New( 4, 1 );
mRootActor.SetAnchorPoint( AnchorPoint::CENTER );
mRootActor.SetParentOrigin( ParentOrigin::CENTER );
+ mRootActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
Stage::GetCurrent().Add( mRootActor );
// Toolbar at top
DemoHelper::DEFAULT_VIEW_STYLE);
mRootActor.AddChild( toolBarLayer, TableView::CellPosition( 0, 0 ) );
- const float toolbarHeight = DemoHelper::DEFAULT_VIEW_STYLE.mToolBarHeight;
- mRootActor.SetFixedHeight( 0, toolbarHeight );
+ mRootActor.SetFitHeight( 0 );
// Add logo
- mLogo = CreateLogo( LOGO_PATH );
+ Dali::ImageActor logo = CreateLogo( LOGO_PATH );
+ logo.SetName( "LOGO_IMAGE" );
+ logo.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
const float paddingHeight = ( ( 1.f-TABLE_RELATIVE_SIZE.y ) * stageSize.y );
const float logoMargin = paddingHeight * LOGO_MARGIN_RATIO;
- const float logoHeight = mLogo.GetImage().GetHeight() + logoMargin;
- mRootActor.SetFixedHeight( 1, logoHeight );
+
+ // Show version in a popup when log is tapped
+ mLogoTapDetector = TapGestureDetector::New();
+ mLogoTapDetector.Attach( logo );
+ mLogoTapDetector.DetectedSignal().Connect( this, &DaliTableView::OnLogoTapped );
const float bottomMargin = paddingHeight * BOTTOM_PADDING_RATIO;
- mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, 1.f - ( toolbarHeight + logoHeight + bottomMargin) / stageSize.height, TABLE_RELATIVE_SIZE.z );
- mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height );
Alignment alignment = Alignment::New();
- alignment.Add(mLogo);
+ alignment.SetName( "LOGO_ALIGNMENT" );
+ alignment.Add( logo );
+ alignment.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
+ alignment.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
+ Actor alignmentActor = alignment;
+ alignmentActor.SetPadding( Padding( 0.0f, 0.0f, logoMargin, logoMargin ));
mRootActor.AddChild( alignment, TableView::CellPosition( 1, 0 ) );
+ mRootActor.SetFitHeight( 1 );
// scrollview occupying the majority of the screen
mScrollView = ScrollView::New();
mScrollView.SetAnchorPoint( AnchorPoint::CENTER );
mScrollView.SetParentOrigin( ParentOrigin::CENTER );
- mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::SIZE, Dali::ParentSource( Dali::Actor::SIZE ),
- Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) );
+ mScrollView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ const float buttonsPageMargin = ( 1.0f - TABLE_RELATIVE_SIZE.x ) * 0.5f * stageSize.width;
+ mScrollView.SetPadding( Padding( buttonsPageMargin, buttonsPageMargin, 0.0f, 0.0f ) );
+
mScrollView.SetAxisAutoLock( true );
mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete );
mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart );
mScrollViewLayer.SetAnchorPoint( AnchorPoint::CENTER );
mScrollViewLayer.SetParentOrigin( ParentOrigin::CENTER );
mScrollViewLayer.SetDrawMode( DrawMode::OVERLAY );
+ mScrollViewLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
+ // Create solid background colour.
+ ImageActor backgroundColourActor = Dali::Toolkit::CreateSolidColorActor( BACKGROUND_COLOR );
+ backgroundColourActor.SetAnchorPoint( AnchorPoint::CENTER );
+ backgroundColourActor.SetParentOrigin( ParentOrigin::CENTER );
+ backgroundColourActor.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ backgroundColourActor.SetSizeModeFactor( Vector3( 1.0f, 1.5f, 1.0f ) );
+ backgroundColourActor.SetZ( BACKGROUND_Z );
+ mScrollViewLayer.Add( backgroundColourActor );
// Populate background and bubbles - needs to be scrollViewLayer so scroll ends show
- SetupBackground( mScrollView, mScrollViewLayer, stageSize );
+ Actor bubbleContainer = Actor::New();
+ bubbleContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ bubbleContainer.SetAnchorPoint( AnchorPoint::CENTER );
+ bubbleContainer.SetParentOrigin( ParentOrigin::CENTER );
+ mScrollViewLayer.Add( bubbleContainer );
+
+ SetupBackground( bubbleContainer );
+
+ Alignment buttonsAlignment = Alignment::New();
+ buttonsAlignment.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ buttonsAlignment.Add( mScrollViewLayer );
mScrollViewLayer.Add( mScrollView );
- mRootActor.AddChild( mScrollViewLayer, TableView::CellPosition( 2, 0 ) );
+
+ mRootActor.AddChild( buttonsAlignment, TableView::CellPosition( 2, 0 ) );
+
+ mRootActor.SetFixedHeight( 3, bottomMargin );
// Add scroll view effect and setup constraints on pages
ApplyScrollViewEffect();
Populate();
// Remove constraints for inner cube effect
- ApplyCubeEffectToActors();
-
- // Set initial orientation
- unsigned int degrees = application.GetOrientation().GetDegrees();
- Rotate( degrees );
+ ApplyCubeEffectToPages();
Dali::Window winHandle = application.GetWindow();
winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT );
winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE );
winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE );
+ // Set initial orientation
Dali::Orientation orientation = winHandle.GetOrientation();
+
+ unsigned int degrees = winHandle.GetOrientation().GetDegrees();
+ Rotate( degrees );
+
orientation.ChangedSignal().Connect( this, &DaliTableView::OrientationChanged );
winHandle.ShowIndicator( Dali::Window::INVISIBLE );
- //
+ // Background animation
mAnimationTimer = Timer::New( BACKGROUND_ANIMATION_DURATION );
mAnimationTimer.TickSignal().Connect( this, &DaliTableView::PauseBackgroundAnimation );
mAnimationTimer.Start();
KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
}
-void DaliTableView::ApplyCubeEffectToActors()
+void DaliTableView::ApplyCubeEffectToPages()
{
- for( ActorIter pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter )
+ ScrollViewPagePathEffect effect = ScrollViewPagePathEffect::DownCast( mScrollViewEffect );
+ unsigned int pageCount(0);
+ for( std::vector< Actor >::iterator pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter )
{
Actor page = *pageIter;
-
- unsigned int numChildren = page.GetChildCount();
- Actor pageActor = page;
- for( unsigned int i=0; i<numChildren; ++i)
- {
- // Remove old effect's manual constraints.
- Actor child = pageActor.GetChildAt(i);
- if( child )
- {
- ApplyCubeEffectToActor( child );
- }
- }
+ effect.ApplyToPage( page, pageCount++ );
}
}
+
+void DaliTableView::OnButtonsPageRelayout( const Dali::Actor& actor )
+{
+
+}
+
void DaliTableView::Populate()
{
const Vector2 stageSize = Stage::GetCurrent().GetSize();
for( int t = 0; t < mTotalPages; t++ )
{
// Create Table. (contains up to 9 Examples)
- Actor page = Actor::New();
-
- // Add tableView to container.
- mScrollView.Add( page );
-
+ TableView page = TableView::New( 3, 3 );
page.SetAnchorPoint( AnchorPoint::CENTER );
page.SetParentOrigin( ParentOrigin::CENTER );
- page.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
-
- // add cells to table
- const float margin = 4.0f;
+ page.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ mScrollView.Add( page );
// Calculate the number of images going across (columns) within a page, according to the screen resolution and dpi.
- const Size tileSize((stageSize.x * mButtonsPageRelativeSize.x / EXAMPLES_PER_ROW) - margin, (stageSize.y * mButtonsPageRelativeSize.y / ROWS_PER_PAGE) - margin );
+ const float margin = 2.0f;
+ const float tileParentMultiplier = 1.0f / EXAMPLES_PER_ROW;
for(int row = 0; row < ROWS_PER_PAGE; row++)
{
{
const Example& example = ( *iter );
- Actor tile = CreateTile( example.name, example.title, tileSize, true );
+ Actor tile = CreateTile( example.name, example.title, Vector3( tileParentMultiplier, tileParentMultiplier, 1.0f ), true );
FocusManager focusManager = FocusManager::Get();
focusManager.SetFocusOrder( tile, ++exampleCount );
focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_LABEL,
focusManager.SetAccessibilityAttribute( tile, Dali::Toolkit::FocusManager::ACCESSIBILITY_HINT,
"You can run this example" );
- Vector3 position( margin * 0.5f + (tileSize.x + margin) * column - stageSize.width * mButtonsPageRelativeSize.x * 0.5f,
- margin * 0.5f + (tileSize.y + margin) * row - stageSize.height * mButtonsPageRelativeSize.y * 0.5f,
- 0.0f);
- tile.SetPosition( position + Vector3( tileSize.x, tileSize.y, 0.0f ) * 0.5f );
- tile.SetSize( tileSize );
- page.Add( tile );
+ tile.SetPadding( Padding( margin, margin, margin, margin ) );
+
+ page.AddChild( tile, TableView::CellPosition( row, column ) );
iter++;
}
// Set tableview position
- Vector3 pagePos( stageSize.x * mButtonsPageRelativeSize.x * t, 0.0f, 0.0f );
+ Vector3 pagePos( stageSize.width * TABLE_RELATIVE_SIZE.x * t, 0.0f, 0.0f );
page.SetPosition( pagePos );
mPages.push_back( page );
}
// Update Ruler info.
- mScrollRulerX = new FixedRuler( stageSize.width * mButtonsPageRelativeSize.x );
+ mScrollRulerX = new FixedRuler( stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f );
mScrollRulerY = new DefaultRuler();
- mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * mButtonsPageRelativeSize.x, true ) );
+ mScrollRulerX->SetDomain( RulerDomain( 0.0f, (mTotalPages+1) * stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f, true ) );
mScrollRulerY->Disable();
mScrollView.SetRulerX( mScrollRulerX );
mScrollView.SetRulerY( mScrollRulerY );
}
mRotateAnimation = Animation::New( ROTATE_ANIMATION_TIME );
- mRotateAnimation.RotateTo( mRootActor, Degree( 360 - degrees ), Vector3::ZAXIS, AlphaFunctions::EaseOut );
- mRotateAnimation.Resize( mRootActor, targetSize, AlphaFunctions::EaseOut );
+ mRotateAnimation.AnimateTo( Property( mRootActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( 360 - degrees ) ), Vector3::ZAXIS ), AlphaFunction::EASE_OUT );
+ mRotateAnimation.AnimateTo( Property( mRootActor, Actor::Property::SIZE ), targetSize, AlphaFunction::EASE_OUT );
mRotateAnimation.Play();
}
-Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Size& parentSize, bool addBackground )
+Actor DaliTableView::CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, bool addBackground )
{
- Actor tile = Actor::New();
- tile.SetName( name );
- tile.SetAnchorPoint( AnchorPoint::CENTER );
- tile.SetParentOrigin( ParentOrigin::CENTER );
-
Actor content = Actor::New();
+ content.SetName( name );
content.SetAnchorPoint( AnchorPoint::CENTER );
content.SetParentOrigin( ParentOrigin::CENTER );
- content.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
- tile.Add(content);
+ content.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
+ content.SetSizeModeFactor( sizeMultiplier );
// create background image
if( addBackground )
{
- Image bg = Image::New( TILE_BACKGROUND );
+ Image bg = ResourceImage::New( TILE_BACKGROUND );
ImageActor image = ImageActor::New( bg );
image.SetAnchorPoint( AnchorPoint::CENTER );
image.SetParentOrigin( ParentOrigin::CENTER );
// make the image 100% of tile
- image.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+ image.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
+
// move image back to get text appear in front
image.SetZ( -1 );
image.SetStyle( ImageActor::STYLE_NINE_PATCH );
image.SetNinePatchBorder( Vector4( IMAGE_BORDER_LEFT, IMAGE_BORDER_TOP, IMAGE_BORDER_RIGHT, IMAGE_BORDER_BOTTOM ) );
-
content.Add( image );
// Add stencil
ImageActor stencil = NewStencilImage();
- stencil.ApplyConstraint( Constraint::New<Vector3>( Actor::SIZE, ParentSource( Actor::SIZE ), EqualToConstraint() ) );
+ stencil.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
image.Add( stencil );
}
TextLabel label = TextLabel::New();
- label.SetParentOrigin( ParentOrigin::TOP_LEFT );
label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- label.SetProperty( TextLabel::PROPERTY_MULTI_LINE, true );
- label.SetProperty( TextLabel::PROPERTY_TEXT, title );
- label.SetColor( Color::BLACK );
+ label.SetProperty( Control::Property::STYLE_NAME, "launcherlabel" );
+ label.SetProperty( TextLabel::Property::MULTI_LINE, true );
+ label.SetProperty( TextLabel::Property::TEXT, title );
+ label.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
+ label.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" );
+ label.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT );
content.Add( label );
- // FIXME - This is a kludge because size negotiation is not finished
- label.SetSize( parentSize );
-
// Set the tile to be keyboard focusable
- tile.SetKeyboardFocusable(true);
+ content.SetKeyboardFocusable(true);
// connect to the touch events
- tile.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed );
- tile.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered );
+ content.TouchedSignal().Connect( this, &DaliTableView::OnTilePressed );
+ content.HoveredSignal().Connect( this, &DaliTableView::OnTileHovered );
- return tile;
+ return content;
}
ImageActor DaliTableView::NewStencilImage()
{
- Image alpha = Image::New( TILE_BACKGROUND_ALPHA );
+ Image alpha = ResourceImage::New( TILE_BACKGROUND_ALPHA );
ImageActor stencilActor = ImageActor::New( alpha );
stencilActor.SetStyle( ImageActor::STYLE_NINE_PATCH );
// scale the content actor within the Tile, as to not affect the placement within the Table.
Actor content = actor.GetChildAt(0);
- mPressedAnimation.ScaleTo( content, Vector3( 0.9f, 0.9f, 1.0f ), AlphaFunctions::EaseInOut, 0.0f,
- BUTTON_PRESS_ANIMATION_TIME * 0.5f );
- mPressedAnimation.ScaleTo( content, Vector3::ONE, AlphaFunctions::EaseInOut, BUTTON_PRESS_ANIMATION_TIME * 0.5f,
- BUTTON_PRESS_ANIMATION_TIME * 0.5f );
+ mPressedAnimation.AnimateTo( Property( content, Actor::Property::SCALE ), Vector3( 0.9f, 0.9f, 1.0f ), AlphaFunction::EASE_IN_OUT,
+ TimePeriod( 0.0f, BUTTON_PRESS_ANIMATION_TIME * 0.5f ) );
+ mPressedAnimation.AnimateTo( Property( content, Actor::Property::SCALE ), Vector3::ONE, AlphaFunction::EASE_IN_OUT,
+ TimePeriod( BUTTON_PRESS_ANIMATION_TIME * 0.5f, BUTTON_PRESS_ANIMATION_TIME * 0.5f ) );
mPressedAnimation.Play();
mPressedAnimation.FinishedSignal().Connect( this, &DaliTableView::OnPressedAnimationFinished );
}
}
}
-void DaliTableView::OnScrollStart( const Dali::Vector3& position )
+void DaliTableView::OnScrollStart( const Dali::Vector2& position )
{
mScrolling = true;
PlayAnimation();
}
-void DaliTableView::OnScrollComplete( const Dali::Vector3& position )
+void DaliTableView::OnScrollComplete( const Dali::Vector2& position )
{
mScrolling = false;
// move focus to 1st item of new page
FocusManager focusManager = FocusManager::Get();
focusManager.SetCurrentFocusActor(mPages[mScrollView.GetCurrentPage()].GetChildAt(0) );
-
- ApplyCubeEffectToActors();
}
bool DaliTableView::OnScrollTouched( Actor actor, const TouchEvent& event )
void DaliTableView::SetupInnerPageCubeEffect()
{
- mScrollViewEffect = ScrollViewCubeEffect::New();
- mScrollView.SetScrollSnapDuration( EFFECT_SNAP_DURATION );
- mScrollView.SetScrollFlickDuration( EFFECT_FLICK_DURATION );
- mScrollView.RemoveConstraintsFromChildren();
-}
+ const Vector2 stageSize = Stage::GetCurrent().GetSize();
-void DaliTableView::ApplyCubeEffectToActor( Actor actor )
-{
- actor.RemoveConstraints();
+ Dali::Path path = Dali::Path::New();
+ Dali::Property::Array points;
+ points.Resize(3);
+ points[0] = Vector3( stageSize.x*0.5, 0.0f, stageSize.x*0.5f);
+ points[1] = Vector3( 0.0f, 0.0f, 0.0f );
+ points[2] = Vector3( -stageSize.x*0.5f, 0.0f, stageSize.x*0.5f);
+ path.SetProperty( Path::Property::POINTS, points );
- ScrollViewCubeEffect cubeEffect = ScrollViewCubeEffect::DownCast(mScrollViewEffect);
- cubeEffect.ApplyToActor( actor,
- ScalePointSize( ( rand() & 1 ) ? ANCHOR_3DEFFECT_STYLE0 : ANCHOR_3DEFFECT_STYLE1 ),
- ANGLE_SWING_3DEFFECT,
- POSITION_SWING_3DEFFECT * Vector2(Stage::GetCurrent().GetSize()));
+ Dali::Property::Array controlPoints;
+ controlPoints.Resize(4);
+ controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, stageSize.x*0.3f );
+ controlPoints[1] = Vector3( stageSize.x*0.3f, 0.0f, 0.0f );
+ controlPoints[2] = Vector3(-stageSize.x*0.3f, 0.0f, 0.0f );
+ controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, stageSize.x*0.3f );
+ path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints );
+
+
+ mScrollViewEffect = ScrollViewPagePathEffect::New(path,
+ Vector3(-1.0f,0.0f,0.0f),
+ Toolkit::ScrollView::Property::SCROLL_FINAL_X,
+ Vector3(stageSize.x*TABLE_RELATIVE_SIZE.x,stageSize.y*TABLE_RELATIVE_SIZE.y,0.0f),mTotalPages);
}
void DaliTableView::OnKeyEvent( const KeyEvent& event )
{
if ( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) )
{
- mApplication.Quit();
+ if ( mVersionPopup && mVersionPopupShown )
+ {
+ HideVersionPopup();
+ }
+ else
+ {
+ mApplication.Quit();
+ }
}
}
}
-Actor CreateBackgroundActor( const Vector2& size )
-{
- Actor layer = Actor::New();
- layer.SetAnchorPoint( AnchorPoint::CENTER );
- layer.SetParentOrigin( ParentOrigin::CENTER );
- layer.SetSize( size );
- return layer;
-}
-
-void DaliTableView::SetupBackground( Actor bubbleLayer, Actor backgroundLayer, const Vector2& size )
+void DaliTableView::SetupBackground( Actor bubbleContainer )
{
- // Create distance field shape
- BitmapImage distanceField;
+ // Create distance field shape.
+ BufferImage distanceField;
Size imageSize( 512, 512 );
CreateShapeImage( CIRCLE, imageSize, distanceField );
- // Create layers
- Actor backgroundAnimLayer0 = CreateBackgroundActor( size );
- Actor backgroundAnimLayer1 = CreateBackgroundActor( size );
- Actor backgroundAnimLayer2 = CreateBackgroundActor( size );
+ // Add bubbles to the bubbleContainer.
+ // Note: The bubbleContainer is parented externally to this function.
+ AddBackgroundActors( bubbleContainer, NUM_BACKGROUND_IMAGES, distanceField );
+}
- // Add constraints
- Constraint animConstraint0 = Constraint::New < Vector3 > ( Actor::POSITION,
- Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
- AnimScrollConstraint( backgroundAnimLayer0.GetCurrentPosition(), 0.75f ) );
- backgroundAnimLayer0.ApplyConstraint( animConstraint0 );
+void DaliTableView::InitialiseBackgroundActors( Actor actor )
+{
+ // Delete current animations
+ mBackgroundAnimations.clear();
- Constraint animConstraint1 = Constraint::New < Vector3 > ( Actor::POSITION,
- Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
- AnimScrollConstraint( backgroundAnimLayer1.GetCurrentPosition(), 0.5f ) );
- backgroundAnimLayer1.ApplyConstraint( animConstraint1 );
+ // Create new animations
+ const Vector3 size = actor.GetTargetSize();
- Constraint animConstraint2 = Constraint::New < Vector3 > ( Actor::POSITION,
- Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ),
- AnimScrollConstraint( backgroundAnimLayer2.GetCurrentPosition(), 0.25f ) );
- backgroundAnimLayer2.ApplyConstraint( animConstraint2 );
+ for( unsigned int i = 0, childCount = actor.GetChildCount(); i < childCount; ++i )
+ {
+ Actor child = actor.GetChildAt( i );
- // Background
- ImageActor layer = Dali::Toolkit::CreateSolidColorActor( BACKGROUND_COLOR );
- layer.SetAnchorPoint( AnchorPoint::CENTER );
- layer.SetParentOrigin( ParentOrigin::CENTER );
- layer.SetSize( size * BACKGROUND_SIZE_SCALE );
- layer.SetZ( BACKGROUND_Z );
- layer.SetPositionInheritanceMode( DONT_INHERIT_POSITION );
- backgroundLayer.Add( layer );
+ // Calculate a random position
+ Vector3 childPos( Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ),
+ Random::Range( -size.y, size.y ),
+ Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) );
- // Parent the layers
- bubbleLayer.Add( backgroundAnimLayer0 );
- bubbleLayer.Add( backgroundAnimLayer1 );
- bubbleLayer.Add( backgroundAnimLayer2 );
+ child.SetPosition( childPos );
- // Add all the children
- AddBackgroundActors( backgroundAnimLayer0, NUM_BACKGROUND_IMAGES / 3, distanceField, size );
- AddBackgroundActors( backgroundAnimLayer1, NUM_BACKGROUND_IMAGES / 3, distanceField, size );
- AddBackgroundActors( backgroundAnimLayer2, NUM_BACKGROUND_IMAGES / 3, distanceField, size );
+ // 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.Apply();
+
+ // Kickoff animation
+ Animation animation = Animation::New( Random::Range( 40.0f, 80.0f ) );
+ animation.AnimateBy( Property( child, Actor::Property::POSITION ), Vector3( 0.0f, -1.0f, 0.0f ), AlphaFunction::LINEAR );
+ animation.SetLooping( true );
+ animation.Play();
+ mBackgroundAnimations.push_back( animation );
+ }
}
-void DaliTableView::AddBackgroundActors( Actor layer, int count, BitmapImage distanceField, const Dali::Vector2& size )
+void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage distanceField )
{
for( int i = 0; i < count; ++i )
{
float randSize = Random::Range( 10.0f, 400.0f );
float hue = Random::Range( 0.3f, 1.0f );
- Vector4 randColour( hue, hue*0.5, 0.0f, Random::Range( 0.3f, 0.6f ));
+ Vector4 randColour( hue, hue * 0.5, 0.0f, Random::Range( 0.3f, 0.6f ));
ImageActor dfActor = ImageActor::New( distanceField );
- mBackgroundActors.push_back( dfActor );
dfActor.SetSize( Vector2( randSize, randSize ) );
dfActor.SetParentOrigin( ParentOrigin::CENTER );
effect.SetOutlineParams( Vector2( 0.55f, 0.00f ) );
effect.SetSmoothingEdge( 0.5f );
layer.Add( dfActor );
-
- // Setup animation
- Vector3 actorPos(
- Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ),
- Random::Range( -size.y * 0.5f - randSize, size.y * 0.5f + randSize ),
- Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) );
- dfActor.SetPosition( actorPos );
-
- Constraint movementConstraint = Constraint::New < Vector3 > ( Actor::POSITION,
- LocalSource( Actor::SIZE ),
- ParentSource( Actor::SIZE ),
- ShapeMovementConstraint );
- dfActor.ApplyConstraint( movementConstraint );
-
- // Kickoff animation
- Animation animation = Animation::New( Random::Range( 40.0f, 200.0f ) );
- KeyFrames keyframes = KeyFrames::New();
- keyframes.Add( 0.0f, actorPos );
- Vector3 toPos( actorPos );
- toPos.y -= ( size.y + randSize );
- keyframes.Add( 1.0f, toPos );
- animation.AnimateBetween( Property( dfActor, Actor::POSITION ), keyframes );
- animation.SetLooping( true );
- animation.Play();
- mBackgroundAnimations.push_back( animation );
}
+
+ // Positioning will occur when the layer is relaid out
+ layer.OnRelayoutSignal().Connect( this, &DaliTableView::InitialiseBackgroundActors );
}
-void DaliTableView::CreateShapeImage( ShapeType shapeType, const Size& size, BitmapImage& distanceFieldOut )
+void DaliTableView::CreateShapeImage( ShapeType shapeType, const Size& size, BufferImage& distanceFieldOut )
{
// this bitmap will hold the alpha map for the distance field shader
- distanceFieldOut = BitmapImage::New( size.width, size.height, Pixel::A8 );
+ distanceFieldOut = BufferImage::New( size.width, size.height, Pixel::A8 );
// Generate bit pattern
std::vector< unsigned char > imageDataA8;
ImageActor DaliTableView::CreateLogo( std::string imagePath )
{
- Image image = Image::New( imagePath );
+ Image image = ResourceImage::New( imagePath );
ImageActor logo = ImageActor::New( image );
logo.SetAnchorPoint( AnchorPoint::CENTER );
- logo.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
+ logo.SetParentOrigin( ParentOrigin::CENTER );
return logo;
}
{
Animation anim = *animIter;
- anim.Pause();
+ anim.Stop();
}
mBackgroundAnimsPlaying = false;
return true;
}
+void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap )
+{
+ if ( !mVersionPopupShown )
+ {
+ if ( !mVersionPopup )
+ {
+ std::ostringstream stream;
+ stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")" << std::endl << std::endl;
+ stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")" << std::endl << std::endl;
+ stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")";
+
+ mVersionPopup = Dali::Toolkit::Popup::New();
+ mVersionPopup.SetParentOrigin( ParentOrigin::CENTER );
+ mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER );
+ mVersionPopup.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH );
+ mVersionPopup.SetSizeModeFactor( Vector3( 0.75f, 1.0f, 1.0f ) );
+ mVersionPopup.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
+ mVersionPopup.SetTitle( stream.str() );
+ mVersionPopup.HideTail();
+ mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup );
+ mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden );
+ }
+
+ mVersionPopup.Show();
+ mVersionPopupShown = true;
+ }
+}
+
+void DaliTableView::HideVersionPopup()
+{
+ if ( mVersionPopup )
+ {
+ mVersionPopup.Hide();
+ }
+}
+void DaliTableView::PopupHidden()
+{
+ if ( mVersionPopup )
+ {
+ mVersionPopupShown = false;
+ }
+}