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 = 18;
const float BACKGROUND_SWIPE_SCALE = 0.025f;
const float BACKGROUND_SPREAD_SCALE = 1.5f;
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)
-
-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
*/
Populate();
// Remove constraints for inner cube effect
- ApplyCubeEffectToActors();
+ ApplyCubeEffectToPages();
Dali::Window winHandle = application.GetWindow();
winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT );
KeyboardFocusManager::Get().FocusedActorActivatedSignal().Connect( this, &DaliTableView::OnFocusedActorActivated );
}
-void DaliTableView::ApplyCubeEffectToActors()
+void DaliTableView::ApplyCubeEffectToPages()
{
+ ScrollViewPagePathEffect effect = ScrollViewPagePathEffect::DownCast( mScrollViewEffect );
+ unsigned int pageCount(0);
for( std::vector< Actor >::iterator pageIter = mPages.begin(); pageIter != mPages.end(); ++pageIter )
{
Actor page = *pageIter;
-
- for( unsigned int i = 0, numChildren = page.GetChildCount(); i < numChildren; ++i)
- {
- // Remove old effect's manual constraints.
- Actor child = page.GetChildAt(i);
- if( child )
- {
- ApplyCubeEffectToActor( child );
- }
- }
+ effect.ApplyToPage( page, pageCount++ );
}
}
}
// Update Ruler info.
- mScrollRulerX = new FixedRuler( stageSize.width * TABLE_RELATIVE_SIZE.x );
+ mScrollRulerX = new FixedRuler( stageSize.width * TABLE_RELATIVE_SIZE.x * 0.5f );
mScrollRulerY = new DefaultRuler();
- mScrollRulerX->SetDomain( RulerDomain( 0.0f, mTotalPages * stageSize.width * TABLE_RELATIVE_SIZE.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 );
void DaliTableView::SetupInnerPageCubeEffect()
{
- mScrollViewEffect = ScrollViewCubeEffect::New();
- mScrollView.SetScrollSnapDuration( EFFECT_SNAP_DURATION );
- mScrollView.SetScrollFlickDuration( EFFECT_FLICK_DURATION );
- mScrollView.RemoveConstraintsFromChildren();
-}
-
-void DaliTableView::ApplyCubeEffectToActor( Actor actor )
-{
- actor.RemoveConstraints();
+ const Vector2 stageSize = Stage::GetCurrent().GetSize();
- 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::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 );
+
+ 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 )
const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
const char * const APPLICATION_TITLE( "Clusters" );
const char * const LAYOUT_NONE_IMAGE( DALI_IMAGE_DIR "icon-cluster-none.png" );
-const char * const LAYOUT_WOBBLE_IMAGE( DALI_IMAGE_DIR "icon-cluster-wobble.png" );
+const char * const LAYOUT_MOTION_BLUR_IMAGE( DALI_IMAGE_DIR "icon-cluster-wobble.png" );
const char * const LAYOUT_CAROUSEL_IMAGE( DALI_IMAGE_DIR "icon-cluster-carousel.png" );
const char * const LAYOUT_SPHERE_IMAGE( DALI_IMAGE_DIR "icon-cluster-sphere.png" );
const float CLUSTER_COLUMN_INDENT = 0.1f; ///< Left Indentation in screen coordinates.
const float CLUSTER_ROW_INDENT = 0.13f; ///< Top Indentation in screen coordinates.
-const Vector3 SHEAR_EFFECT_ANCHOR_POINT(0.5f, 1.0f, 0.5f); ///< Anchor Point used for the shear effect (extends outside of Cluster)
-const float SHEAR_EFFECT_MAX_OVERSHOOT = 30.0f; ///< Max Overshoot for shear effect (in degrees).
-
const float UI_MARGIN = 10.0f; ///< Screen Margin for placement of UI buttons
const float CAROUSEL_EFFECT_RADIUS = 500.0f; ///< In Carousel Effect mode: Radius of carousel (Z peak depth)
enum ExampleEffectType
{
NO_EFFECT,
- WOBBLE_EFFECT,
+ MOTION_BLUR_EFFECT,
CAROUSEL_EFFECT,
SPHERE_EFFECT,
TOTAL_EFFECTS
/**
* List of effect type names that appear on the Effect button.
*/
-const char* EXAMPLE_EFFECT_LABEL[] = { "NONE",
- "WOBBLE",
- "CAROUSEL",
- "SPHERE",
+const char* EXAMPLE_EFFECT_LABEL[] = { "None",
+ "Motion Blur",
+ "Carousel",
+ "Sphere",
};
/**
};
/**
- * ShearEffectConstraint
- *
- * Constrains ShearEffect's tilt to be a function of scrollview's
- * horizontal overshoot amount.
- */
-struct ShearEffectConstraint
-{
- /**
- * @param[in] stageSize The stage size (not subject to orientation)
- * @param[in] maxOvershoot Maximum amount overshoot can affect shear.
- * @param[in] componentMask Whether constraint should take the X shear
- * or the Y shear component.
- */
- ShearEffectConstraint(Vector2 stageSize, float maxOvershoot, Vector2 componentMask)
- : mStageSize(stageSize),
- mMaxOvershoot(maxOvershoot),
- mComponentMask(componentMask)
- {
- }
-
- /**
- * @param[in,out] current The current shear effect Angle.
- * @param[in] inputs Contains the overshoot property from ScrollView and the orientation of the view e.g. Portrait, Landscape.
- * @return angle to provide ShearShaderEffect
- */
- void operator()( float& current, const PropertyInputContainer& inputs )
- {
- float f = inputs[0]->GetVector3().x;
-
- float mag = fabsf(f);
- float halfWidth = mStageSize.x * 0.5f;
-
- // inverse exponential tail-off
- float overshoot = 1.0f - halfWidth / (halfWidth + mag);
- if (f > 0.0f)
- {
- overshoot = -overshoot;
- }
-
- // Channel this shear value into either the X or Y axis depending on
- // the component mask passed in.
- Vector3 axis;
- Radian angle;
- inputs[1]->GetQuaternion().ToAxisAngle( axis, angle );
- Vector2 direction( cosf(angle), sinf(angle) );
- float yield = direction.x * mComponentMask.x + direction.y * mComponentMask.y;
-
- current = overshoot * mMaxOvershoot * yield;
- }
-
- Vector2 mStageSize;
- float mMaxOvershoot;
- Vector2 mComponentMask;
-};
-
-/**
- * ShearEffectCenterConstraint
- *
- * Sets ShearEffect's center to be a function of the
- * screen orientation (portrait or landscape).
- */
-struct ShearEffectCenterConstraint
-{
- /**
- * @param[in] stageSize The stage size (not subject to orientation)
- * @param[in] center Shear Center position based on initial orientation.
- */
- ShearEffectCenterConstraint(Vector2 stageSize, Vector2 center)
- : mStageSize(stageSize),
- mCenter(center)
- {
- }
-
- /**
- * @param[in,out] current The current center
- * @param[in] inputs Contains the current view size
- * @return vector to provide ShearShaderEffect
- */
- void operator()( Vector2& current, const PropertyInputContainer& inputs )
- {
- float f = inputs[0]->GetVector3().width / mStageSize.width;
- current.x = f * mCenter.x;
- current.y = mCenter.y;
- }
-
- Vector2 mStageSize;
- Vector2 mCenter;
-};
-
-/**
* SphereEffectOffsetConstraint
*
* Sets SphereEffect's center to be a function of the
// Create a effect toggle button. (right of toolbar)
mLayoutButtonImages[ NO_EFFECT ] = ResourceImage::New( LAYOUT_NONE_IMAGE );
- mLayoutButtonImages[ WOBBLE_EFFECT ] = ResourceImage::New( LAYOUT_WOBBLE_IMAGE );
+ mLayoutButtonImages[ MOTION_BLUR_EFFECT ] = ResourceImage::New( LAYOUT_MOTION_BLUR_IMAGE );
mLayoutButtonImages[ CAROUSEL_EFFECT ] = ResourceImage::New( LAYOUT_CAROUSEL_IMAGE );
mLayoutButtonImages[ SPHERE_EFFECT ] = ResourceImage::New( LAYOUT_SPHERE_IMAGE );
mScrollView = ScrollView::New();
mScrollView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- // attach Wobble Effect to ScrollView
- mScrollViewEffect = ScrollViewWobbleEffect::New();
- mScrollView.ApplyEffect(mScrollViewEffect);
-
// anchor the scroll view from its center point to the middle of its parent
mScrollView.SetAnchorPoint(AnchorPoint::CENTER);
mScrollView.SetParentOrigin(ParentOrigin::CENTER);
AddCluster( MUSIC, ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle2) );
AddCluster( MAGAZINE, ClusterStyleStandard::New(ClusterStyleStandard::ClusterStyle3) );
- SetEffect(WOBBLE_EFFECT);
+ SetEffect(MOTION_BLUR_EFFECT);
}
/**
pageView.SetPosition(Vector3(stageSize.width * column, 0.0f, 0.0f));
pageView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- // Create cluster actors, add them to scroll view, and set the shear effect with the given center point.
+ // Create cluster actors and add them to scroll view
Vector3 clusterSize;
Cluster cluster = CreateClusterActor( clusterType, style, clusterSize );
cluster.SetParentOrigin(ParentOrigin::TOP_LEFT);
}
/**
+ * Sets motion blur effect to a cluster and all its children
+ *
+ * @param[in] actor Cluster control to which the effect will be applied
+ */
+ void SetMotionBlurEffect( Actor actor )
+ {
+ // only do something if the actor and effect are valid
+ if( actor )
+ {
+ // first remove from this actor
+ RenderableActor renderable = RenderableActor::DownCast( actor );
+ if( renderable )
+ {
+ MotionBlurEffect shaderEffect = MotionBlurEffect::New();
+ shaderEffect.SetSpeedScalingFactor(0.1f);
+
+ Dali::Property::Index uModelProperty = shaderEffect.GetPropertyIndex( "uModelLastFrame" );
+ Constraint constraint = Constraint::New<Matrix>( shaderEffect, uModelProperty, EqualToConstraint() );
+ constraint.AddSource( Source( actor , Actor::Property::WORLD_MATRIX ) );
+ constraint.Apply();
+ renderable.SetShaderEffect( shaderEffect );
+ }
+ // then all children recursively
+ const unsigned int count = actor.GetChildCount();
+ for( unsigned int index = 0; index < count; ++index )
+ {
+ Actor child( actor.GetChildAt( index ) );
+ SetMotionBlurEffect( child );
+ }
+ }
+ }
+
+ /**
* Resets ScrollView and Clusters settings
* to reflect the new ExampleEffectType
*
break;
}
- case WOBBLE_EFFECT:
+ case MOTION_BLUR_EFFECT:
{
for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i )
{
- Cluster cluster = i->mCluster;
- Vector3 position = i->mPosition;
- Vector3 size = i->mSize;
-
- ShearEffect shaderEffect = ShearEffect::New();
- Vector3 shearAnchor = SHEAR_EFFECT_ANCHOR_POINT;
-
- Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) );
- Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName());
- Constraint constraint = Constraint::New<Vector2>( shaderEffect, centerProperty, ShearEffectCenterConstraint(stageSize, shearCenter) );
- constraint.AddSource( Source(mView, Actor::Property::SIZE) );
-
- constraint.Apply();
-
- SetShaderEffectRecursively( cluster,shaderEffect );
-
- // Apply Constraint to Shader Effect
- Property::Index scrollOvershootProperty = /*targetGroup*/mScrollView.GetPropertyIndex(ScrollViewWobbleEffect::EFFECT_OVERSHOOT);
- Property::Index angleXAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleXAxisPropertyName());
- Property::Index angleYAxisProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetAngleYAxisPropertyName());
-
- constraint = Constraint::New<float>( shaderEffect, angleXAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) );
- constraint.AddSource( Source(mScrollView, scrollOvershootProperty) );
- constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) );
- constraint.Apply();
-
- constraint = Constraint::New<float>( shaderEffect, angleYAxisProperty, ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS ) );
- constraint.AddSource( Source(mScrollView, scrollOvershootProperty) );
- constraint.AddSource( Source(mView, Actor::Property::ORIENTATION) );
- constraint.Apply();
-
-
+ SetMotionBlurEffect( i->mCluster );
}
break;
}
Layer mContentLayer; ///< Content layer (scrolling cluster content)
ScrollView mScrollView; ///< The ScrollView container for all clusters
- ScrollViewWobbleEffect mScrollViewEffect; ///< ScrollView Wobble effect
Image mClusterBorderImage; ///< The border frame that appears on each image
std::vector<ClusterInfo> mClusterInfo; ///< Keeps track of each cluster's information.
const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-default.png" );
const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" );
const char * const APPLICATION_TITLE( "ScrollView" );
-const char * const EFFECT_DEPTH_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-depth.png" );
-const char * const EFFECT_INNER_CUBE_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-inner-cube.png" );
const char * const EFFECT_CAROUSEL_IMAGE( DALI_IMAGE_DIR "icon-scroll-view-carousel.png" );
const Vector3 ICON_SIZE(100.0f, 100.0f, 0.0f);
const char* EFFECT_MODE_NAME[] = {
- "Depth",
- "Cube",
"PageCarousel",
"PageCube",
"PageSpiral",
const int PAGE_ROWS = 1; ///< Number of Pages going down (rows)
const int IMAGE_ROWS = 5; ///< Number of Images going down (rows) with a Page
-// 3D Effect constants
-const Vector3 ANGLE_CUBE_PAGE_ROTATE(Math::PI * 0.2f, Math::PI * 0.2f, 0.0f); ///< Cube page rotates as if it has ten sides with the camera positioned inside
-const Vector2 ANGLE_CUSTOM_CUBE_SWING(-Math::PI * 0.45f, -Math::PI * 0.45f); ///< outer cube pages swing 90 degrees as they pan offscreen
-const Vector2 ANGLE_SPIRAL_SWING_IN(Math::PI * 0.45f, Math::PI * 0.45f);
-const Vector2 ANGLE_SPIRAL_SWING_OUT(Math::PI * 0.3f, Math::PI * 0.3f);
-
-// Depth Effect constants
-const Vector2 POSITION_EXTENT_DEPTH_EFFECT(0.5f, 2.5f); ///< Extent of X & Y position to alter function exponent.
-const Vector2 OFFSET_EXTENT_DEPTH_EFFECT(1.0f, 1.0f); ///< Function exponent offset constant.
-const float POSITION_SCALE_DEPTH_EFFECT(1.5f); ///< Position scaling.
-const float SCALE_EXTENT_DEPTH_EFFECT(0.5f); ///< Maximum scale factor when Actors scrolled one page away (50% size)
-
-// 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.25f, 0.25f); ///< 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, -300.0f); ///< Rotation Anchor position for 3D Effect (Style 1)
-
-
const unsigned int IMAGE_THUMBNAIL_WIDTH = 256; ///< Width of Thumbnail Image in texels
const unsigned int IMAGE_THUMBNAIL_HEIGHT = 256; ///< Height of Thumbnail Image in texels
: mApplication( application ),
mView(),
mScrolling(false),
- mEffectMode(CubeEffect)
+ mEffectMode(PageCarouselEffect)
{
// Connect to the Application's Init and orientation changed signal
mApplication.InitSignal().Connect(this, &ExampleController::OnInit);
TOOLBAR_IMAGE,
"" );
- mEffectIcon[ DepthEffect ] = ResourceImage::New( EFFECT_DEPTH_IMAGE );
- mEffectIcon[ CubeEffect ] = ResourceImage::New( EFFECT_INNER_CUBE_IMAGE );
mEffectIcon[ PageCarouselEffect ] = ResourceImage::New( EFFECT_CAROUSEL_IMAGE );
mEffectIcon[ PageCubeEffect ] = ResourceImage::New( EFFECT_CAROUSEL_IMAGE );
mEffectIcon[ PageSpiralEffect ] = ResourceImage::New( EFFECT_CAROUSEL_IMAGE );
{
Actor page = *pageIter;
ApplyEffectToPage( page, pageCount++ );
-
- unsigned int numChildren = (*pageIter).GetChildCount();
- for(unsigned int i=0; i<numChildren; ++i)
- {
- Actor image = (*pageIter).GetChildAt(i);
-
- // Remove old effect's manual constraints.
- image.RemoveConstraints();
-
- // Apply new effect's manual constraints.
- ApplyEffectToActor( image, page );
- }
}
}
rulerX->SetDomain(RulerDomain(0.0f, stageSize.x * PAGE_COLUMNS, !wrap));
rulerY->Disable();
- switch( mEffectMode )
+ Dali::Path path = Dali::Path::New();
+ Dali::Property::Array points;
+ points.Resize(3);
+ Dali::Property::Array controlPoints;
+ controlPoints.Resize(4);
+ Vector3 forward;
+ if( mEffectMode == PageCarouselEffect)
{
- case DepthEffect:
- {
- mScrollViewEffect = ScrollViewDepthEffect::New();
- mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION);
- mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION);
- mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT);
- mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT);
- mScrollView.RemoveConstraintsFromChildren();
- break;
- }
- case CubeEffect:
- {
- mScrollViewEffect = ScrollViewCubeEffect::New();
- mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION);
- mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION);
- mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT_BACK);
- mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT_BACK);
- mScrollView.RemoveConstraintsFromChildren();
- break;
- }
+ points[0] = Vector3( stageSize.x*0.75, 0.0f, -stageSize.x*0.75f);
+ points[1] = Vector3( 0.0f, 0.0f, 0.0f );
+ points[2] = Vector3( -stageSize.x*0.75f, 0.0f, -stageSize.x*0.75f);
+ path.SetProperty( Path::Property::POINTS, points );
- case PageCarouselEffect:
- case PageCubeEffect:
- case PageSpiralEffect:
- case PageWaveEffect:
- {
- Dali::Path path = Dali::Path::New();
- Dali::Property::Array points;
- points.Resize(3);
- Dali::Property::Array controlPoints;
- controlPoints.Resize(4);
- Vector3 forward;
- if( mEffectMode == PageCarouselEffect)
- {
-
- points[0] = Vector3( stageSize.x*0.75, 0.0f, -stageSize.x*0.75f);
- points[1] = Vector3( 0.0f, 0.0f, 0.0f );
- points[2] = Vector3( -stageSize.x*0.75f, 0.0f, -stageSize.x*0.75f);
- path.SetProperty( Path::Property::POINTS, points );
-
- controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
- controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
- controlPoints[2] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f );
- controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f );
- path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints );
-
- forward = Vector3::ZERO;
- }
- else if( mEffectMode == PageCubeEffect)
- {
- 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 );
-
- 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 );
-
- forward = Vector3(-1.0f,0.0f,0.0f);
- }
- else if( mEffectMode == PageSpiralEffect)
- {
- 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 );
-
- controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
- controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
- controlPoints[2] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f );
- controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f );
- path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints );
-
- forward = Vector3(-1.0f,0.0f,0.0f);
- }
- else if( mEffectMode == PageWaveEffect)
- {
- points[0] = Vector3( stageSize.x, 0.0f, -stageSize.x);
- points[1] = Vector3( 0.0f, 0.0f, 0.0f );
- points[2] = Vector3( -stageSize.x, 0.0f, -stageSize.x);
- path.SetProperty( Path::Property::POINTS, points );
-
- controlPoints[0] = Vector3( 0.0f, 0.0f, -stageSize.x );
- controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
- controlPoints[2] = Vector3( -stageSize.x*0.5f, 0.0f, 0.0f);
- controlPoints[3] = Vector3(0.0f, 0.0f,-stageSize.x );
- path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints );
-
- forward = Vector3(-1.0f,0.0f,0.0f);
- }
-
- mScrollViewEffect = ScrollViewPagePathEffect::New(path, forward,Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(stageSize.x,stageSize.y,0.0f),PAGE_COLUMNS);
- mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION);
- mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION);
- mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT);
- mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT);
- mScrollView.RemoveConstraintsFromChildren();
-
- rulerX = CreateRuler(snap ? stageSize.width * 0.5f : 0.0f);
- if( wrap )
- {
- rulerX->SetDomain(RulerDomain(0.0f, stageSize.x * 0.5f * PAGE_COLUMNS, !wrap));
- }
- else
- {
- rulerX->SetDomain(RulerDomain(0.0f, stageSize.x*0.5f* (PAGE_COLUMNS+1), !wrap));
- }
-
- break;
- }
+ controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
+ controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
+ controlPoints[2] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f );
+ controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f );
+ path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints );
- default:
- {
- break;
- }
+ forward = Vector3::ZERO;
+ }
+ else if( mEffectMode == PageCubeEffect)
+ {
+ 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 );
+
+ 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 );
+
+ forward = Vector3(-1.0f,0.0f,0.0f);
+ }
+ else if( mEffectMode == PageSpiralEffect)
+ {
+ 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 );
+
+ controlPoints[0] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
+ controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
+ controlPoints[2] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f );
+ controlPoints[3] = Vector3(-stageSize.x*0.5f, 0.0f, 0.0f );
+ path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints );
+
+ forward = Vector3(-1.0f,0.0f,0.0f);
+ }
+ else if( mEffectMode == PageWaveEffect)
+ {
+ points[0] = Vector3( stageSize.x, 0.0f, -stageSize.x);
+ points[1] = Vector3( 0.0f, 0.0f, 0.0f );
+ points[2] = Vector3( -stageSize.x, 0.0f, -stageSize.x);
+ path.SetProperty( Path::Property::POINTS, points );
+
+ controlPoints[0] = Vector3( 0.0f, 0.0f, -stageSize.x );
+ controlPoints[1] = Vector3( stageSize.x*0.5f, 0.0f, 0.0f );
+ controlPoints[2] = Vector3( -stageSize.x*0.5f, 0.0f, 0.0f);
+ controlPoints[3] = Vector3(0.0f, 0.0f,-stageSize.x );
+ path.SetProperty( Path::Property::CONTROL_POINTS, controlPoints );
+
+ forward = Vector3(-1.0f,0.0f,0.0f);
+ }
+
+ mScrollViewEffect = ScrollViewPagePathEffect::New(path, forward,Toolkit::ScrollView::Property::SCROLL_FINAL_X, Vector3(stageSize.x,stageSize.y,0.0f),PAGE_COLUMNS);
+ mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION);
+ mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION);
+ mScrollView.SetScrollSnapAlphaFunction(AlphaFunction::EASE_OUT);
+ mScrollView.SetScrollFlickAlphaFunction(AlphaFunction::EASE_OUT);
+ mScrollView.RemoveConstraintsFromChildren();
+
+ rulerX = CreateRuler(snap ? stageSize.width * 0.5f : 0.0f);
+ if( wrap )
+ {
+ rulerX->SetDomain(RulerDomain(0.0f, stageSize.x * 0.5f * PAGE_COLUMNS, !wrap));
+ }
+ else
+ {
+ rulerX->SetDomain(RulerDomain(0.0f, stageSize.x*0.5f* (PAGE_COLUMNS+1), !wrap));
}
unsigned int currentPage = mScrollView.GetCurrentPage();
page.RemoveConstraints();
page.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS );
- switch( mEffectMode )
- {
- case PageCarouselEffect:
- case PageCubeEffect:
- case PageSpiralEffect:
- case PageWaveEffect:
- {
- ScrollViewPagePathEffect effect = ScrollViewPagePathEffect::DownCast( mScrollViewEffect );
- effect.ApplyToPage( page, pageOrder );
- break;
- }
-
- default:
- {
- break;
- }
- }
+ ScrollViewPagePathEffect effect = ScrollViewPagePathEffect::DownCast( mScrollViewEffect );
+ effect.ApplyToPage( page, pageOrder );
}
/**
- * [Actor]
- * Applies effect to child which resides in page (which in turn resides in scrollview)
- *
- * @note Page is typically the Parent of child, although in
- * some scenarios Page is simply a container which has a child as
- * a descendent.
- *
- * @param[in] child The child actor to apply effect to
- * @param[in] page The page which this child is inside
- */
- void ApplyEffectToActor( Actor child, Actor page )
- {
- switch( mEffectMode )
- {
- case DepthEffect:
- {
- ApplyDepthEffectToActor( child );
- break;
- }
-
- case CubeEffect:
- {
- ApplyCubeEffectToActor( child );
- break;
- }
-
- default:
- {
- break;
- }
- }
- }
-
- /**
- * Applies depth effect to the child which resides in page (which in turn resides in scrollview)
- *
- * @param[in] child The child actor to apply depth effect to
- */
- void ApplyDepthEffectToActor( Actor child )
- {
- ScrollViewDepthEffect depthEffect = ScrollViewDepthEffect::DownCast(mScrollViewEffect);
- depthEffect.ApplyToActor( child,
- POSITION_EXTENT_DEPTH_EFFECT,
- OFFSET_EXTENT_DEPTH_EFFECT,
- POSITION_SCALE_DEPTH_EFFECT,
- SCALE_EXTENT_DEPTH_EFFECT );
- }
-
- void ApplyCubeEffectToActor( Actor child )
- {
- Vector3 anchor;
- if(rand()&1)
- {
- anchor = ANCHOR_3DEFFECT_STYLE0;
- }
- else
- {
- anchor = ANCHOR_3DEFFECT_STYLE1;
- }
-
- ScrollViewCubeEffect cubeEffect = ScrollViewCubeEffect::DownCast(mScrollViewEffect);
- cubeEffect.ApplyToActor( child,
- anchor,
- ANGLE_SWING_3DEFFECT,
- POSITION_SWING_3DEFFECT * Vector2(Stage::GetCurrent().GetSize()));
- }
-
- /**
* Creates an Image (Helper)
*
* @param[in] filename the path of the image.
*/
enum EffectMode
{
- DepthEffect, ///< Depth Effect
- CubeEffect, ///< Cube effect
PageCarouselEffect, ///< Page carousel effect
PageCubeEffect, ///< Page cube effect
PageSpiralEffect, ///< Page spiral effect