TextVisual implementation.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / text / text-visual.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_VISUAL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_VISUAL_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 // INTERNAL INCLUDES
22 #include <dali-toolkit/internal/visuals/visual-base-impl.h>
23 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
24 #include <dali-toolkit/internal/text/text-controller.h>
25 #include <dali-toolkit/internal/text/text-scroller.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 class TextVisual;
37 typedef IntrusivePtr< TextVisual > TextVisualPtr;
38
39 /**
40  * The visual which renders text
41  *
42  * The following properties are optional:
43  *
44  * | %Property Name      | Type    |
45  * |---------------------|---------|
46  * | renderingBackend    | INTEGER |
47  * | text                | STRING  |
48  * | fontFamily          | STRING  |
49  * | fontStyle           | STRING  |
50  * | pointSize           | FLOAT   |
51  * | multiLine           | BOOLEAN |
52  * | horizontalAlignment | STRING  |
53  * | verticalAlignment   | STRING  |
54  * | textColor           | VECTOR4 |
55  * | enableMarkup        | BOOLEAN |
56  * | enableAutoScroll    | BOOLEAN |
57  * | autoScrollSpeed     | INTEGER |
58  * | autoScrollLoopCount | INTEGER |
59  * | autoScrollGap       | INTEGER |
60  * | lineSpacing         | FLOAT   |
61  * | underline           | STRING  |
62  * | shadow              | STRING  |
63  * | outline             | STRING  |
64  * | batchingEnabled     | BOOLEAN |
65  *
66  */
67 class TextVisual : public Visual::Base
68 {
69 public:
70
71   /**
72    * @brief Constructor.
73    *
74    * @param[in] factoryCache The VisualFactoryCache object
75    */
76   TextVisual( VisualFactoryCache& factoryCache );
77
78   /**
79    * @brief A reference counted object may only be deleted by calling Unreference().
80    */
81   ~TextVisual();
82
83   /**
84    *
85    */
86   void SetTextControlInterface( Text::ControlInterface* controlInterface );
87
88 public: // from Visual::Base
89
90   /**
91    * @copydoc Visual::Base::GetHeightForWidth()
92    */
93   float GetHeightForWidth( float width ) const;
94
95   /**
96    * @copydoc Visual::Base::GetNaturalSize()
97    */
98   virtual void SetSize( const Vector2& size );
99
100   /**
101    * @copydoc Visual::Base::GetNaturalSize()
102    */
103   virtual void GetNaturalSize( Vector2& naturalSize ) const;
104
105   /**
106    * @copydoc Visual::Base::CreatePropertyMap()
107    */
108   virtual void DoCreatePropertyMap( Property::Map& map ) const;
109
110 protected: // from Visual::Base
111   /**
112    * @copydoc Visual::Base::DoInitialize()
113    */
114   virtual void DoInitialize( Actor& actor, const Property::Map& propertyMap );
115
116   /**
117    * @copydoc Visual::Base::DoSetOnStage()
118    */
119   virtual void DoSetOnStage( Actor& actor );
120
121   /**
122    * @copydoc Visual::Base::DoSetOffStage()
123    */
124   virtual void DoSetOffStage( Actor& actor );
125
126   /**
127    *@copydoc Visual::Base::DoSetProperty
128    */
129   virtual void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
130
131   /**
132    * @copydoc Visual::Base::DoGetProperty
133    */
134   virtual Dali::Property::Value DoGetProperty( Dali::Property::Index index );
135
136 private:
137
138   /**
139    * @brief Render view, create and attach actor(s) to this TextView.
140    * @todo In a next patch a new text render back-end won't add extra actors.
141    */
142   void RenderText();
143
144   /**
145    * @brief Stops the text auto scroll.
146    */
147   void StopTextAutoScrolling();
148
149   /**
150    * @brief Set up Autoscrolling.
151    */
152   void SetUpAutoScrolling();
153
154 private:
155   Text::ControllerPtr          mController;               ///< The text's controller.
156   Actor                        mSelf;
157
158   Text::RendererPtr            mRenderer;
159   Text::TextScrollerPtr        mTextScroller;
160   Actor                        mRenderableActor;
161
162   int mRenderingBackend;
163   bool mHasBeenStaged           : 1;
164 };
165
166 } // namespace Internal
167
168 } // namespace Toolkit
169
170 } // namespace Dali
171
172 #endif /* DALI_TOOLKIT_INTERNAL_TEXT_VISUAL_H */