2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali-toolkit/internal/text/text-vertical-scroller.h>
34 const float DEFAULT_VERTICAL_SCROLL_DURATION(0.15f); ///< Duration to complete scroll animation
41 TextVerticalScrollerPtr TextVerticalScroller::New()
43 TextVerticalScrollerPtr textScroller( new TextVerticalScroller() );
47 TextVerticalScroller::TextVerticalScroller()
48 : mDuration( DEFAULT_VERTICAL_SCROLL_DURATION ),
53 TextVerticalScroller::~TextVerticalScroller()
57 void TextVerticalScroller::CheckStartAnimation( Actor& sourceActor, float x, float y, float scrollAmount )
59 if ( Equals( scrollAmount, 0.0f, Math::MACHINE_EPSILON_1 ) )
61 // scroll animation isn't required, set position only
62 if( mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING )
64 mScrollAnimation.Clear();
66 sourceActor.SetPosition( x, y );
69 float toY = y + scrollAmount;
70 // Either actor or scroll area is changed, so restart animation
71 if( mScrollAnimation )
73 mScrollAnimation.Clear();
77 // Create animation at first
78 mScrollAnimation = Animation::New( mDuration );
80 mScrollingActor = sourceActor;
83 // Set animation attribute
84 sourceActor.SetPosition( x, y );
85 mScrollAnimation.AnimateTo( Property(sourceActor, Actor::Property::POSITION_Y), mScrollTo, AlphaFunction::EASE_OUT_SINE );
86 mScrollAnimation.Play();
89 void TextVerticalScroller::SetDuration( float duration )
96 } // namespace Toolkit