[dali_1.2.11] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-scroller.h
1 #ifndef __DALI_TOOLKIT_TEXT_SCROLLER_H__
2 #define __DALI_TOOLKIT_TEXT_SCROLLER_H__
3
4 /*
5  * Copyright (c) 2016 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/camera-actor.h>
23 #include <dali/public-api/animation/animation.h>
24 #include <dali/public-api/render-tasks/render-task.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/internal/text/text-definitions.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Text
36 {
37
38 class TextScroller;
39 class ScrollerInterface;
40 struct ScrollerData;
41
42 typedef IntrusivePtr<TextScroller> TextScrollerPtr;
43
44 /**
45  * @brief A helper class for scrolling text
46  */
47 class TextScroller : public RefObject, public ConnectionTracker
48 {
49 public:
50   /**
51    * @brief Text Scrolling helper, used to automatically scroll text, SetParameters should be called before scrolling is needed.
52    * CleanUp removes the Scrolling actors from stage whilst keeping the Scroller object alive and preserving Speed, Gap and Loop count.
53    *
54    * @param[in] scrollerInterface scroller interface
55    */
56   static TextScrollerPtr New( ScrollerInterface& scrollerInterface );
57
58   /**
59    * @brief Starts the text scrolling.
60    *
61    * @param[in] sourceActor source actor to be scrolled
62    * @param[in] data Parameters needed to set up the text scrolling.
63    *
64    */
65   void StartScrolling( Actor sourceActor,
66                        const ScrollerData& data );
67
68   /**
69    * @brief Stops the text scrolling.
70    */
71   void StopScrolling();
72
73   /**
74    * @brief Get the camera used to look at source, should be added to the parent of target actor.
75    * @return camera Actor
76    */
77   Actor GetSourceCamera() const;
78
79   /**
80    * @brief Get the resulting scrolling text actor, add to target actor which will show scrolling text
81    * @return mesh Actor
82    */
83   Actor GetScrollingText() const;
84
85 private: // Implementation
86
87   /**
88    * Constructor
89    */
90   TextScroller( ScrollerInterface& scrollerInterface );
91
92   /**
93    * Destructor
94    */
95   ~TextScroller();
96
97   // Undefined
98   TextScroller( const TextScroller& handle );
99
100   // Undefined
101   TextScroller& operator=( const TextScroller& handle );
102
103   /**
104    * @brief Callback for end of animation
105    * @param[in] animation Animation handle
106    */
107   void AutoScrollAnimationFinished( Dali::Animation& animation );
108
109   /**
110    * @brief When scrolling ended, the actors are cleaned up so no longer staged.
111    */
112   void CleanUp();
113
114 private:
115
116   RenderTask         mRenderTask;               // Renders full text to a FrameBuffer which is then scrolled.
117   CameraActor        mOffscreenCameraActor;     // Camera used by render task
118   Actor              mScrollingTextActor;       // Actor used to show scrolling text
119   ScrollerInterface& mScrollerInterface;        // Interface implemented by control that requires scrolling
120   Property::Index    mScrollDeltaIndex;         // Property used by shader to represent distance to scroll
121   Animation          mScrollAnimation;          // Animation used to update the mScrollDeltaIndex
122
123 }; // TextScroller class
124
125 } // namespace Text
126
127 } // namespace Toolkit
128
129 } // namespace Dali
130
131 #endif // __DALI_TOOLKIT_TEXT_SCROLLER_H__
132