X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fscroll-view%2Fscroll-overshoot-indicator-impl.cpp;h=8652ac4f47a6dca4885c00f4d9dc0ea66f35364b;hp=b02d3fc344d449b72cad060a93354244c6e191e7;hb=a8d60282f49c906206c1ffb2f2425800b914d109;hpb=10d2080e1d25b75347daa2f8c2dcee494fbcb175 diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp index b02d3fc..8652ac4 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ #include // EXTERNAL INCLUDES -#include +#include // INTERNAL INCLUDES #include @@ -30,13 +30,13 @@ using namespace Dali; namespace { -const Vector2 OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE( 720.0f, 42.0f ); + const float OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD = 180.0f; // local helper function to resize the height of the bounce actor -float GetBounceActorHeight( float width ) +float GetBounceActorHeight( float width, float defaultHeight ) { - return (width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD) ? OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height : OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height * 0.5f; + return (width > OVERSHOOT_BOUNCE_ACTOR_RESIZE_THRESHOLD) ? defaultHeight : defaultHeight * 0.5f; } const float MAX_OVERSHOOT_NOTIFY_AMOUNT = 0.99f; // maximum amount to set notification for increased overshoot, beyond this we just wait for it to reduce again @@ -115,18 +115,6 @@ void ScrollOvershootIndicator::SetOvershootEffectColor( const Vector4& color ) } } -void ScrollOvershootIndicator::ClearOvershoot() -{ - if(mEffectX) - { - mEffectX->SetOvershoot(0.0f); - } - if(mEffectY) - { - mEffectY->SetOvershoot(0.0f); - } -} - ScrollOvershootEffect::ScrollOvershootEffect( bool vertical ) : mVertical(vertical) { @@ -144,13 +132,13 @@ ScrollOvershootEffectRipple::ScrollOvershootEffectRipple( bool vertical, Scrolla mOvershootProperty(Property::INVALID_INDEX), mEffectOvershootProperty(Property::INVALID_INDEX), mOvershoot(0.0f), + mOvershootSize( scrollable.GetOvershootSize() ), mAnimationStateFlags(0) { mOvershootOverlay = CreateBouncingEffectActor(mEffectOvershootProperty); mOvershootOverlay.SetColor(mAttachedScrollView.GetOvershootEffectColor()); mOvershootOverlay.SetParentOrigin(ParentOrigin::TOP_LEFT); mOvershootOverlay.SetAnchorPoint(AnchorPoint::TOP_LEFT); - mOvershootOverlay.SetDrawMode(DrawMode::OVERLAY); mOvershootOverlay.SetVisible(false); } @@ -158,10 +146,11 @@ ScrollOvershootEffectRipple::ScrollOvershootEffectRipple( bool vertical, Scrolla void ScrollOvershootEffectRipple::Apply() { Actor self = mAttachedScrollView.Self(); - mOvershootProperty = self.GetPropertyIndex(IsVertical() ? Toolkit::ScrollView::SCROLL_OVERSHOOT_Y_PROPERTY_NAME : Toolkit::ScrollView::SCROLL_OVERSHOOT_X_PROPERTY_NAME); + mOvershootProperty = IsVertical() ? Toolkit::ScrollView::Property::OVERSHOOT_Y : Toolkit::ScrollView::Property::OVERSHOOT_X; // make sure height is set, since we only create a constraint for image width - mOvershootOverlay.SetSize(OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.width, OVERSHOOT_BOUNCE_ACTOR_DEFAULT_SIZE.height); + mOvershootSize = mAttachedScrollView.GetOvershootSize(); + mOvershootOverlay.SetSize( mOvershootSize ); mAttachedScrollView.AddOverlay(mOvershootOverlay); @@ -257,13 +246,13 @@ void ScrollOvershootEffectRipple::UpdateVisibility( bool visible ) const Vector3 parentSize = self.GetCurrentSize(); if(IsVertical()) { - mOvershootOverlay.SetOrientation(Quaternion(0.0f, Vector3::ZAXIS)); - mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth); + mOvershootOverlay.SetOrientation( Quaternion( Radian( 0.0f ), Vector3::ZAXIS ) ); + mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width, mOvershootSize.height), size.depth); } else { - mOvershootOverlay.SetOrientation(Quaternion(1.5f * Math::PI, Vector3::ZAXIS)); - mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height), size.depth); + mOvershootOverlay.SetOrientation( Quaternion( Radian( 1.5f * Math::PI ), Vector3::ZAXIS ) ); + mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height, mOvershootSize.height), size.depth); relativeOffset = Vector3(0.0f, 1.0f, 0.0f); } mOvershootOverlay.SetPosition(relativeOffset * parentSize); @@ -276,14 +265,14 @@ void ScrollOvershootEffectRipple::UpdateVisibility( bool visible ) const Vector3 parentSize = self.GetCurrentSize(); if(IsVertical()) { - mOvershootOverlay.SetOrientation(Quaternion(Math::PI, Vector3::ZAXIS)); - mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width), size.depth); + mOvershootOverlay.SetOrientation( Quaternion( Radian( Math::PI ), Vector3::ZAXIS ) ); + mOvershootOverlay.SetSize(parentSize.width, GetBounceActorHeight(parentSize.width, mOvershootSize.height), size.depth); relativeOffset = Vector3(1.0f, 1.0f, 0.0f); } else { - mOvershootOverlay.SetOrientation(Quaternion(0.5f * Math::PI, Vector3::ZAXIS)); - mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height), size.depth); + mOvershootOverlay.SetOrientation( Quaternion( Radian( 0.5f * Math::PI ), Vector3::ZAXIS ) ); + mOvershootOverlay.SetSize(parentSize.height, GetBounceActorHeight(parentSize.height, mOvershootSize.height), size.depth); relativeOffset = Vector3(1.0f, 0.0f, 0.0f); } mOvershootOverlay.SetPosition(relativeOffset * parentSize); @@ -294,7 +283,7 @@ void ScrollOvershootEffectRipple::UpdateVisibility( bool visible ) void ScrollOvershootEffectRipple::OnOvershootNotification(PropertyNotification& source) { Actor self = mAttachedScrollView.Self(); - mOvershoot = self.GetProperty(mOvershootProperty); + mOvershoot = DevelHandle::GetCurrentProperty< float >( self, mOvershootProperty ); SetOvershoot(mOvershoot, false); UpdatePropertyNotifications(); }