Merge "Remove batching." into devel/master
[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  *
64  */
65 class TextVisual : public Visual::Base
66 {
67 public:
68
69   /**
70    * @brief Create a new text visual.
71    *
72    * @param[in] factoryCache A pointer pointing to the VisualFactoryCache object
73    * @param[in] properties A Property::Map containing settings for this visual
74    * @return A smart-pointer to the newly allocated visual.
75    */
76   static TextVisualPtr New( VisualFactoryCache& factoryCache, const Property::Map& properties );
77
78   /**
79    * @brief Converts all strings keys in property map to index keys.  Property Map can then be merged correctly.
80    * @param[in,out] propertyMap containing string keys or a mix of strings and indexes. Will be changed to index keys.
81    */
82   static void ConvertStringKeysToIndexKeys( Property::Map& propertyMap );
83
84 public: // from Visual::Base
85
86   /**
87    * @copydoc Visual::Base::GetHeightForWidth()
88    */
89   virtual float GetHeightForWidth( float width );
90
91   /**
92    * @copydoc Visual::Base::GetNaturalSize()
93    */
94   virtual void GetNaturalSize( Vector2& naturalSize );
95
96   /**
97    * @copydoc Visual::Base::CreatePropertyMap()
98    */
99   virtual void DoCreatePropertyMap( Property::Map& map ) const;
100
101 protected:
102
103   /**
104    * @brief Constructor.
105    *
106    * @param[in] factoryCache The VisualFactoryCache object
107    */
108   TextVisual( VisualFactoryCache& factoryCache );
109
110   /**
111    * @brief A reference counted object may only be deleted by calling Unreference().
112    */
113   virtual ~TextVisual();
114
115   // from Visual::Base
116
117   /**
118    * @copydoc Visual::Base::DoSetProperties()
119    */
120   virtual void DoSetProperties( const Property::Map& propertyMap );
121
122   /**
123    * @copydoc Visual::Base::DoSetOnStage()
124    */
125   virtual void DoSetOnStage( Actor& actor );
126
127   /**
128    * @copydoc Visual::Base::DoSetOffStage()
129    */
130   virtual void DoSetOffStage( Actor& actor );
131
132   /**
133    * @copydoc Visual::Base::OnSetTransform
134    */
135   virtual void OnSetTransform();
136
137 private:
138   /**
139    * @brief Set the individual property to the given value.
140    *
141    * @param[in] index The index key used to reference this value within the initial property map.
142    *
143    * @param[in] propertyValue The value to set.
144    */
145   void DoSetProperty( Dali::Property::Index index, const Dali::Property::Value& propertyValue );
146
147   /**
148    * @brief Updates the text's renderer.
149    * @param[in] initializeRendererAndTexture Set flag to true to initialize textures and add renderer to control.
150    */
151   void UpdateRenderer( bool initializeRendererAndTexture );
152
153   /**
154    * @brief Removes the texture set from the renderer.
155    */
156   void RemoveTextureSet();
157
158 private:
159   Text::ControllerPtr mController; ///< The text's controller.
160   Text::TypesetterPtr mTypesetter; ///< The text's typesetter.
161   WeakHandle<Actor>   mControl;    ///< The control where the renderer is added.
162 };
163
164 } // namespace Internal
165
166 } // namespace Toolkit
167
168 } // namespace Dali
169
170 #endif /* DALI_TOOLKIT_INTERNAL_TEXT_VISUAL_H */