2 * Copyright (c) 2021 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>
31 const float DEFAULT_VERTICAL_SCROLL_DURATION(0.15f); ///< Duration to complete scroll animation
37 TextVerticalScrollerPtr TextVerticalScroller::New()
39 TextVerticalScrollerPtr textScroller(new TextVerticalScroller());
43 TextVerticalScroller::TextVerticalScroller()
44 : mDuration(DEFAULT_VERTICAL_SCROLL_DURATION),
49 TextVerticalScroller::~TextVerticalScroller()
53 void TextVerticalScroller::CheckStartAnimation(Actor& sourceActor, float x, float y, float scrollAmount)
55 if(Equals(scrollAmount, 0.0f, Math::MACHINE_EPSILON_1))
57 // scroll animation isn't required, set position only
58 if(mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING)
60 mScrollAnimation.Clear();
62 sourceActor.SetProperty(Actor::Property::POSITION, Vector2(x, y));
65 float toY = y + scrollAmount;
66 // Either actor or scroll area is changed, so restart animation
69 mScrollAnimation.Clear();
73 // Create animation at first
74 mScrollAnimation = Animation::New(mDuration);
76 mScrollingActor = sourceActor;
79 // Set animation attribute
80 sourceActor.SetProperty(Actor::Property::POSITION, Vector2(x, y));
81 mScrollAnimation.AnimateTo(Property(sourceActor, Actor::Property::POSITION_Y), mScrollTo, AlphaFunction::EASE_OUT_SINE);
82 mScrollAnimation.Play();
85 void TextVerticalScroller::SetDuration(float duration)
92 } // namespace Toolkit