Merge "propagate unhandled key( DALI_KEY_SEARCH )" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / rendering / view-model.h
1 #ifndef DALI_TOOLKIT_TEXT_VIEW_MODEL_H
2 #define DALI_TOOLKIT_TEXT_VIEW_MODEL_H
3
4 /*
5  * Copyright (c) 2017 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/common/dali-vector.h>
23
24 // INTERNAL INCLUDES
25 #include <dali-toolkit/public-api/text/text-enumerations.h>
26 #include <dali-toolkit/internal/text/text-model-interface.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Text
35 {
36
37 /**
38  * @brief Responsible of creating and store temporary modifications of the text model.
39  * i.e. The elide of text.
40  */
41 class ViewModel : public ModelInterface
42 {
43 public:
44   /**
45    * @brief Constructor.
46    *
47    * Keeps the pointer to the text's model. It initializes all the members of the class to their defaults.
48    *
49    * @param[in] model Pointer to the text's model interface.
50    */
51   ViewModel( const ModelInterface* const model );
52
53   /**
54    * @brief Virtual destructor.
55    *
56    * It's a default destructor.
57    */
58   virtual ~ViewModel();
59
60   /**
61    * @copydoc ModelInterface::GetControlSize()
62    */
63   virtual const Size& GetControlSize() const;
64
65   /**
66    * @copydoc ModelInterface::GetLayoutSize()
67    */
68   virtual const Size& GetLayoutSize() const;
69
70   /**
71    * @copydoc ModelInterface::GetScrollPosition()
72    */
73   virtual const Vector2& GetScrollPosition() const;
74
75   /**
76    * @copydoc ModelInterface::GetHorizontalAlignment()
77    */
78   virtual Text::HorizontalAlignment::Type GetHorizontalAlignment() const;
79
80   /**
81    * @copydoc ModelInterface::GetVerticalAlignment()
82    */
83   virtual Text::VerticalAlignment::Type GetVerticalAlignment() const;
84
85   /**
86    * @copydoc ModelInterface::IsTextElideEnabled()
87    */
88   virtual bool IsTextElideEnabled() const;
89
90   /**
91    * @copydoc ModelInterface::GetNumberOfLines()
92    */
93   virtual Length GetNumberOfLines() const;
94
95   /**
96    * @copydoc ModelInterface::GetLines()
97    */
98   virtual const LineRun* const GetLines() const;
99
100   /**
101    * @copydoc ModelInterface::GetNumberOfScripts()
102    */
103   virtual Length GetNumberOfScripts() const;
104
105   /**
106    * @copydoc ModelInterface::GetScriptRuns()
107    */
108   virtual const ScriptRun* const GetScriptRuns() const;
109
110   /**
111    * @copydoc ModelInterface::GetNumberOfGlyphs()
112    */
113   virtual Length GetNumberOfGlyphs() const;
114
115   /**
116    * @copydoc ModelInterface::GetGlyphs()
117    */
118   virtual const GlyphInfo* const GetGlyphs() const;
119
120   /**
121    * @copydoc ModelInterface::GetLayout()
122    */
123   virtual const Vector2* const GetLayout() const;
124
125   /**
126    * @copydoc ModelInterface::GetColors()
127    */
128   virtual const Vector4* const GetColors() const;
129
130   /**
131    * @copydoc ModelInterface::GetColorIndices()
132    */
133   virtual const ColorIndex* const GetColorIndices() const;
134
135   /**
136    * @copydoc ModelInterface::GetDefaultColor()
137    */
138   virtual const Vector4& GetDefaultColor() const;
139
140   /**
141    * @copydoc ModelInterface::GetShadowOffset()
142    */
143   virtual const Vector2& GetShadowOffset() const;
144
145   /**
146    * @copydoc ModelInterface::GetShadowColor()
147    */
148   virtual const Vector4& GetShadowColor() const;
149
150   /**
151    * @copydoc ModelInterface::GetShadowBlurRadius()
152    */
153   virtual const float& GetShadowBlurRadius() const;
154
155   /**
156    * @copydoc ModelInterface::GetUnderlineColor()
157    */
158   virtual const Vector4& GetUnderlineColor() const;
159
160   /**
161    * @copydoc ModelInterface::IsUnderlineEnabled()
162    */
163   virtual bool IsUnderlineEnabled() const;
164
165   /**
166    * @copydoc ModelInterface::GetUnderlineHeight()
167    */
168   virtual float GetUnderlineHeight() const;
169
170   /**
171    * @copydoc ModelInterface::GetNumberOfUnderlineRuns()
172    */
173   virtual Length GetNumberOfUnderlineRuns() const;
174
175   /**
176    * @copydoc ModelInterface::GetUnderlineRuns()
177    */
178   virtual void GetUnderlineRuns( GlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns ) const;
179
180   /**
181    * @copydoc ModelInterface::GetOutlineColor()
182    */
183   virtual const Vector4& GetOutlineColor() const;
184
185   /**
186    * @copydoc ModelInterface::GetOutlineWidth()
187    */
188   virtual float GetOutlineWidth() const;
189
190  /**
191    * @brief Does the text elide.
192    *
193    * It stores a copy of the visible glyphs and removes as many glyphs as needed
194    * from the last visible line to add the ellipsis glyph.
195    *
196    * It stores as well a copy of the positions for each visible glyph.
197    */
198   void ElideGlyphs();
199
200 private:
201   const ModelInterface* const mModel;            ///< Pointer to the text's model.
202   Vector<GlyphInfo>           mElidedGlyphs;     ///< Stores the glyphs of the elided text.
203   Vector<Vector2>             mElidedLayout;     ///< Stores the positions of each glyph of the elided text.
204   bool                        mIsTextElided : 1; ///< Whether the text has been elided.
205 };
206
207 } // namespace Text
208
209 } // namespace Toolkit
210
211 } // namespace Dali
212
213 #endif // DALI_TOOLKIT_TEXT_VIEW_MODEL_H