Commit 082ae2a3af2972df3db5c46e617d3814fc516b8e
1 parent
303b7296
Added another cube effect to scrollview example
Change-Id: I02c2df1a9bb89cb26b813539fd1def5d10c582f8 Signed-off-by: David Steele <david.steele@partner.samsung.com>
Showing
1 changed file
with
44 additions
and
1 deletions
examples/scroll-view/scroll-view-example.cpp
| @@ -42,6 +42,7 @@ const Vector3 ICON_SIZE(100.0f, 100.0f, 0.0f); | @@ -42,6 +42,7 @@ const Vector3 ICON_SIZE(100.0f, 100.0f, 0.0f); | ||
| 42 | const char* EFFECT_MODE_NAME[] = { | 42 | const char* EFFECT_MODE_NAME[] = { |
| 43 | "OuterCube", | 43 | "OuterCube", |
| 44 | "Depth", | 44 | "Depth", |
| 45 | + "Cube", | ||
| 45 | "InnerCube", | 46 | "InnerCube", |
| 46 | "Carousel", | 47 | "Carousel", |
| 47 | "Spiral", | 48 | "Spiral", |
| @@ -134,6 +135,13 @@ const Vector2 OFFSET_EXTENT_DEPTH_EFFECT(1.0f, 1.0f); ///< | @@ -134,6 +135,13 @@ const Vector2 OFFSET_EXTENT_DEPTH_EFFECT(1.0f, 1.0f); ///< | ||
| 134 | const float POSITION_SCALE_DEPTH_EFFECT(1.5f); ///< Position scaling. | 135 | const float POSITION_SCALE_DEPTH_EFFECT(1.5f); ///< Position scaling. |
| 135 | const float SCALE_EXTENT_DEPTH_EFFECT(0.5f); ///< Maximum scale factor when Actors scrolled one page away (50% size) | 136 | const float SCALE_EXTENT_DEPTH_EFFECT(0.5f); ///< Maximum scale factor when Actors scrolled one page away (50% size) |
| 136 | 137 | ||
| 138 | +// 3D Effect constants | ||
| 139 | +const Vector2 ANGLE_SWING_3DEFFECT(Math::PI_2 * 0.75, Math::PI_2 * 0.75f); ///< Angle Swing in radians | ||
| 140 | +const Vector2 POSITION_SWING_3DEFFECT(0.25f, 0.25f); ///< Position Swing relative to stage size. | ||
| 141 | +const Vector3 ANCHOR_3DEFFECT_STYLE0(-105.0f, 30.0f, -240.0f); ///< Rotation Anchor position for 3D Effect (Style 0) | ||
| 142 | +const Vector3 ANCHOR_3DEFFECT_STYLE1(65.0f, -70.0f, -300.0f); ///< Rotation Anchor position for 3D Effect (Style 1) | ||
| 143 | + | ||
| 144 | + | ||
| 137 | const unsigned int IMAGE_THUMBNAIL_WIDTH = 256; ///< Width of Thumbnail Image in texels | 145 | const unsigned int IMAGE_THUMBNAIL_WIDTH = 256; ///< Width of Thumbnail Image in texels |
| 138 | const unsigned int IMAGE_THUMBNAIL_HEIGHT = 256; ///< Height of Thumbnail Image in texels | 146 | const unsigned int IMAGE_THUMBNAIL_HEIGHT = 256; ///< Height of Thumbnail Image in texels |
| 139 | 147 | ||
| @@ -159,7 +167,7 @@ public: | @@ -159,7 +167,7 @@ public: | ||
| 159 | : mApplication( application ), | 167 | : mApplication( application ), |
| 160 | mView(), | 168 | mView(), |
| 161 | mScrolling(false), | 169 | mScrolling(false), |
| 162 | - mEffectMode(CarouselEffect) | 170 | + mEffectMode(CubeEffect) |
| 163 | { | 171 | { |
| 164 | // Connect to the Application's Init and orientation changed signal | 172 | // Connect to the Application's Init and orientation changed signal |
| 165 | mApplication.InitSignal().Connect(this, &ExampleController::OnInit); | 173 | mApplication.InitSignal().Connect(this, &ExampleController::OnInit); |
| @@ -192,6 +200,7 @@ public: | @@ -192,6 +200,7 @@ public: | ||
| 192 | 200 | ||
| 193 | mEffectIcon[ OuterCubeEffect ] = Image::New( EFFECT_OUTER_CUBE_IMAGE ); | 201 | mEffectIcon[ OuterCubeEffect ] = Image::New( EFFECT_OUTER_CUBE_IMAGE ); |
| 194 | mEffectIcon[ DepthEffect ] = Image::New( EFFECT_DEPTH_IMAGE ); | 202 | mEffectIcon[ DepthEffect ] = Image::New( EFFECT_DEPTH_IMAGE ); |
| 203 | + mEffectIcon[ CubeEffect ] = Image::New( EFFECT_INNER_CUBE_IMAGE ); | ||
| 195 | mEffectIcon[ InnerCubeEffect ] = Image::New( EFFECT_INNER_CUBE_IMAGE ); | 204 | mEffectIcon[ InnerCubeEffect ] = Image::New( EFFECT_INNER_CUBE_IMAGE ); |
| 196 | mEffectIcon[ CarouselEffect ] = Image::New( EFFECT_CAROUSEL_IMAGE ); | 205 | mEffectIcon[ CarouselEffect ] = Image::New( EFFECT_CAROUSEL_IMAGE ); |
| 197 | mEffectIcon[ SpiralEffect ] = Image::New( EFFECT_SPIRAL_IMAGE ); | 206 | mEffectIcon[ SpiralEffect ] = Image::New( EFFECT_SPIRAL_IMAGE ); |
| @@ -356,6 +365,16 @@ private: | @@ -356,6 +365,16 @@ private: | ||
| 356 | mScrollView.RemoveConstraintsFromChildren(); | 365 | mScrollView.RemoveConstraintsFromChildren(); |
| 357 | break; | 366 | break; |
| 358 | } | 367 | } |
| 368 | + case CubeEffect: | ||
| 369 | + { | ||
| 370 | + mScrollViewEffect = ScrollViewCubeEffect::New(); | ||
| 371 | + mScrollView.SetScrollSnapDuration(EFFECT_SNAP_DURATION); | ||
| 372 | + mScrollView.SetScrollFlickDuration(EFFECT_FLICK_DURATION); | ||
| 373 | + mScrollView.SetScrollSnapAlphaFunction(AlphaFunctions::EaseOutBack); | ||
| 374 | + mScrollView.SetScrollFlickAlphaFunction(AlphaFunctions::EaseOutBack); | ||
| 375 | + mScrollView.RemoveConstraintsFromChildren(); | ||
| 376 | + break; | ||
| 377 | + } | ||
| 359 | 378 | ||
| 360 | case InnerCubeEffect: | 379 | case InnerCubeEffect: |
| 361 | { | 380 | { |
| @@ -526,6 +545,10 @@ private: | @@ -526,6 +545,10 @@ private: | ||
| 526 | { | 545 | { |
| 527 | ApplyDepthEffectToActor( child ); | 546 | ApplyDepthEffectToActor( child ); |
| 528 | } | 547 | } |
| 548 | + else if(mEffectMode == CubeEffect ) | ||
| 549 | + { | ||
| 550 | + ApplyCubeEffectToActor( child ); | ||
| 551 | + } | ||
| 529 | } | 552 | } |
| 530 | 553 | ||
| 531 | /** | 554 | /** |
| @@ -543,6 +566,25 @@ private: | @@ -543,6 +566,25 @@ private: | ||
| 543 | SCALE_EXTENT_DEPTH_EFFECT ); | 566 | SCALE_EXTENT_DEPTH_EFFECT ); |
| 544 | } | 567 | } |
| 545 | 568 | ||
| 569 | + void ApplyCubeEffectToActor( Actor child ) | ||
| 570 | + { | ||
| 571 | + Vector3 anchor; | ||
| 572 | + if(rand()&1) | ||
| 573 | + { | ||
| 574 | + anchor = ANCHOR_3DEFFECT_STYLE0; | ||
| 575 | + } | ||
| 576 | + else | ||
| 577 | + { | ||
| 578 | + anchor = ANCHOR_3DEFFECT_STYLE1; | ||
| 579 | + } | ||
| 580 | + | ||
| 581 | + ScrollViewCubeEffect cubeEffect = ScrollViewCubeEffect::DownCast(mScrollViewEffect); | ||
| 582 | + cubeEffect.ApplyToActor( child, | ||
| 583 | + anchor, | ||
| 584 | + ANGLE_SWING_3DEFFECT, | ||
| 585 | + POSITION_SWING_3DEFFECT * Vector2(Stage::GetCurrent().GetSize())); | ||
| 586 | + } | ||
| 587 | + | ||
| 546 | /** | 588 | /** |
| 547 | * Creates an Image (Helper) | 589 | * Creates an Image (Helper) |
| 548 | * | 590 | * |
| @@ -672,6 +714,7 @@ private: | @@ -672,6 +714,7 @@ private: | ||
| 672 | { | 714 | { |
| 673 | OuterCubeEffect, ///< Outer Cube Effect | 715 | OuterCubeEffect, ///< Outer Cube Effect |
| 674 | DepthEffect, ///< Depth Effect | 716 | DepthEffect, ///< Depth Effect |
| 717 | + CubeEffect, ///< Cube effect | ||
| 675 | InnerCubeEffect, ///< Page Cube Effect | 718 | InnerCubeEffect, ///< Page Cube Effect |
| 676 | CarouselEffect, ///< Page Carousel Effect | 719 | CarouselEffect, ///< Page Carousel Effect |
| 677 | SpiralEffect, ///< Page Spiral Effect | 720 | SpiralEffect, ///< Page Spiral Effect |