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