Text - First Page Renderer 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-typesetter.h>
24 #include <dali-toolkit/internal/text/text-controller.h>
25
26 namespace Dali
27 {
28
29 namespace Toolkit
30 {
31
32 namespace Internal
33 {
34
35 class TextVisual;
36 typedef IntrusivePtr< TextVisual > TextVisualPtr;
37
38 /**
39  * The visual which renders text
40  *
41  * The following properties are optional:
42  *
43  * | %Property Name      | Type    |
44  * |---------------------|---------|
45  * | renderingBackend    | INTEGER |
46  * | text                | STRING  |
47  * | fontFamily          | STRING  |
48  * | fontStyle           | STRING  |
49  * | pointSize           | FLOAT   |
50  * | multiLine           | BOOLEAN |
51  * | horizontalAlignment | STRING  |
52  * | verticalAlignment   | STRING  |
53  * | textColor           | VECTOR4 |
54  * | enableMarkup        | BOOLEAN |
55  * | enableAutoScroll    | BOOLEAN |
56  * | autoScrollSpeed     | INTEGER |
57  * | autoScrollLoopCount | INTEGER |
58  * | autoScrollGap       | INTEGER |
59  * | lineSpacing         | FLOAT   |
60  * | underline           | STRING  |
61  * | shadow              | STRING  |
62  * | outline             | STRING  |
63  * | batchingEnabled     | BOOLEAN |
64  *
65  */
66 class TextVisual : public Visual::Base
67 {
68 public:
69
70   /**
71    * @brief Create a new text visual.
72    *
73    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
74    * @return A smart-pointer to the newly allocated visual.
75    */
76   static TextVisualPtr New( VisualFactoryCache& factoryCache );
77
78 public: // from Visual::Base
79
80   /**
81    * @copydoc Visual::Base::GetHeightForWidth()
82    */
83   virtual float GetHeightForWidth( float width ) const;
84
85   /**
86    * @copydoc Visual::Base::GetNaturalSize()
87    */
88   virtual void GetNaturalSize( Vector2& naturalSize );
89
90   /**
91    * @copydoc Visual::Base::CreatePropertyMap()
92    */
93   virtual void DoCreatePropertyMap( Property::Map& map ) const;
94
95 protected:
96
97   /**
98    * @brief Constructor.
99    *
100    * @param[in] factoryCache The VisualFactoryCache object
101    */
102   TextVisual( VisualFactoryCache& factoryCache );
103
104   /**
105    * @brief A reference counted object may only be deleted by calling Unreference().
106    */
107   virtual ~TextVisual();
108
109   // from Visual::Base
110
111   /**
112    * @copydoc Visual::Base::DoSetProperties()
113    */
114   virtual void DoSetProperties( 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   /**
137    * @copydoc Visual::Base::OnSetTransform
138    */
139   virtual void OnSetTransform();
140
141 private:
142
143   /**
144    * @brief Creates the text's renderer.
145    */
146   void CreateRenderer();
147
148   /**
149    * @brief Destroys the text's renderer.
150    */
151   void DestroyRenderer();
152
153 private:
154   Text::ControllerPtr mController; ///< The text's controller.
155   Text::TypesetterPtr mTypesetter; ///< The text's typesetter.
156   WeakHandle<Actor>   mControl;    ///< The control where the renderer is added.
157 };
158
159 } // namespace Internal
160
161 } // namespace Toolkit
162
163 } // namespace Dali
164
165 #endif /* DALI_TOOLKIT_INTERNAL_TEXT_VISUAL_H */