Add api for get the internal media player handle of the VideoView
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-vertical-scroller.cpp
1 /*
2  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali-toolkit/internal/text/text-vertical-scroller.h>
20
21 // EXTERNAL INCLUDES
22
23 // INTERNAL INCLUDES
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 namespace
32 {
33
34 const float DEFAULT_VERTICAL_SCROLL_DURATION(0.15f);     ///< Duration to complete scroll animation
35
36 } // namespace
37
38 namespace Text
39 {
40
41 TextVerticalScrollerPtr TextVerticalScroller::New()
42 {
43   TextVerticalScrollerPtr textScroller( new TextVerticalScroller() );
44   return textScroller;
45 }
46
47 TextVerticalScroller::TextVerticalScroller()
48 : mDuration( DEFAULT_VERTICAL_SCROLL_DURATION ),
49   mScrollTo( 0.0f )
50 {
51 }
52
53 TextVerticalScroller::~TextVerticalScroller()
54 {
55 }
56
57 void TextVerticalScroller::CheckStartAnimation( Actor& sourceActor, float x, float y, float scrollAmount )
58 {
59   if ( Equals( scrollAmount, 0.0f, Math::MACHINE_EPSILON_1 ) )
60   {
61     // scroll animation isn't required, set position only
62     if( mScrollAnimation && mScrollAnimation.GetState() == Animation::PLAYING )
63     {
64       mScrollAnimation.Clear();
65     }
66     sourceActor.SetPosition( x, y );
67     return;
68   }
69   float toY = y + scrollAmount;
70   // Either actor or scroll area is changed, so restart animation
71   if( mScrollAnimation )
72   {
73     mScrollAnimation.Clear();
74   }
75   else
76   {
77     // Create animation at first
78     mScrollAnimation = Animation::New( mDuration );
79   }
80   mScrollingActor = sourceActor;
81   mScrollTo = toY;
82
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();
87 }
88
89 void TextVerticalScroller::SetDuration( float duration )
90 {
91   mDuration = duration;
92 }
93
94 } // namespace Text
95
96 } // namespace Toolkit
97
98 } // namespace Dali