fix incorrect calculaion of natural size in text
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-vertical-scroller.h
1 #ifndef DALI_TOOLKIT_TEXT_VERTICAL_SCROLLER_H
2 #define DALI_TOOLKIT_TEXT_VERTICAL_SCROLLER_H
3
4 /*
5  * Copyright (c) 2021 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/animation/animation.h>
24
25 // INTERNAL INCLUDES
26
27 namespace Dali
28 {
29 namespace Toolkit
30 {
31 namespace Text
32 {
33 class TextVerticalScroller;
34
35 typedef IntrusivePtr<TextVerticalScroller> TextVerticalScrollerPtr;
36
37 /**
38  * @brief A helper class for scrolling text vertically
39  */
40 class TextVerticalScroller : public RefObject, public ConnectionTracker
41 {
42 public:
43   /**
44    * @brief Text Scrolling helper, used to automatically scroll text, StartScroll should be called when scrolling is needed.
45    *
46    */
47   static TextVerticalScrollerPtr New();
48
49   /**
50    * @brief variables required to set up scrolling animation
51    * @param[in] sourceActor actor to be animated
52    * @param[in] x The new x position
53    * @param[in] y The new y position
54    * @param[in] scrollAmount The distance to destination y position for actor to be animated
55    */
56   void CheckStartAnimation(Actor& sourceActor, float x, float y, float scrollAmount);
57
58   /**
59    * @brief Set duration the text should scroll
60    * @param[in] duration The duration in seconds
61    */
62   void SetDuration(float duration);
63
64 private: // Implementation
65   /**
66    * Constructor
67    */
68   TextVerticalScroller();
69
70   /**
71    * @brief Virtual Destructor.
72    */
73   virtual ~TextVerticalScroller();
74
75 private:
76   Animation mScrollAnimation; // Animation used to update the actor's position
77   Actor     mScrollingActor;  // The actor being animated
78   float     mDuration;        // The duration of text scrolling
79   float     mScrollTo;        // The destination y position
80 };                            // TextVerticalScroller class
81
82 } // namespace Text
83
84 } // namespace Toolkit
85
86 } // namespace Dali
87
88 #endif // DALI_TOOLKIT_TEXT_VERTICAL_SCROLLER_H