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 | 42 | const char* EFFECT_MODE_NAME[] = { |
| 43 | 43 | "OuterCube", |
| 44 | 44 | "Depth", |
| 45 | + "Cube", | |
| 45 | 46 | "InnerCube", |
| 46 | 47 | "Carousel", |
| 47 | 48 | "Spiral", |
| ... | ... | @@ -134,6 +135,13 @@ const Vector2 OFFSET_EXTENT_DEPTH_EFFECT(1.0f, 1.0f); ///< |
| 134 | 135 | const float POSITION_SCALE_DEPTH_EFFECT(1.5f); ///< Position scaling. |
| 135 | 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 | 145 | const unsigned int IMAGE_THUMBNAIL_WIDTH = 256; ///< Width of Thumbnail Image in texels |
| 138 | 146 | const unsigned int IMAGE_THUMBNAIL_HEIGHT = 256; ///< Height of Thumbnail Image in texels |
| 139 | 147 | |
| ... | ... | @@ -159,7 +167,7 @@ public: |
| 159 | 167 | : mApplication( application ), |
| 160 | 168 | mView(), |
| 161 | 169 | mScrolling(false), |
| 162 | - mEffectMode(CarouselEffect) | |
| 170 | + mEffectMode(CubeEffect) | |
| 163 | 171 | { |
| 164 | 172 | // Connect to the Application's Init and orientation changed signal |
| 165 | 173 | mApplication.InitSignal().Connect(this, &ExampleController::OnInit); |
| ... | ... | @@ -192,6 +200,7 @@ public: |
| 192 | 200 | |
| 193 | 201 | mEffectIcon[ OuterCubeEffect ] = Image::New( EFFECT_OUTER_CUBE_IMAGE ); |
| 194 | 202 | mEffectIcon[ DepthEffect ] = Image::New( EFFECT_DEPTH_IMAGE ); |
| 203 | + mEffectIcon[ CubeEffect ] = Image::New( EFFECT_INNER_CUBE_IMAGE ); | |
| 195 | 204 | mEffectIcon[ InnerCubeEffect ] = Image::New( EFFECT_INNER_CUBE_IMAGE ); |
| 196 | 205 | mEffectIcon[ CarouselEffect ] = Image::New( EFFECT_CAROUSEL_IMAGE ); |
| 197 | 206 | mEffectIcon[ SpiralEffect ] = Image::New( EFFECT_SPIRAL_IMAGE ); |
| ... | ... | @@ -356,6 +365,16 @@ private: |
| 356 | 365 | mScrollView.RemoveConstraintsFromChildren(); |
| 357 | 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 | 379 | case InnerCubeEffect: |
| 361 | 380 | { |
| ... | ... | @@ -526,6 +545,10 @@ private: |
| 526 | 545 | { |
| 527 | 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 | 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 | 589 | * Creates an Image (Helper) |
| 548 | 590 | * |
| ... | ... | @@ -672,6 +714,7 @@ private: |
| 672 | 714 | { |
| 673 | 715 | OuterCubeEffect, ///< Outer Cube Effect |
| 674 | 716 | DepthEffect, ///< Depth Effect |
| 717 | + CubeEffect, ///< Cube effect | |
| 675 | 718 | InnerCubeEffect, ///< Page Cube Effect |
| 676 | 719 | CarouselEffect, ///< Page Carousel Effect |
| 677 | 720 | SpiralEffect, ///< Page Spiral Effect | ... | ... |