TextController refactor.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-view-interface.h
1 #ifndef __DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H__
2 #define __DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H__
3
4 /*
5  * Copyright (c) 2015 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/text/text-definitions.h>
23
24 namespace Dali
25 {
26
27 struct Vector2;
28 struct Vector4;
29
30 namespace Toolkit
31 {
32
33 namespace Text
34 {
35
36 struct GlyphRun;
37
38 /**
39  * @brief Abstract interface to provide the information necessary to display text.
40  *
41  * This includes:
42  * - The font & glyph IDs needed to get bitmaps etc. from TextAbstraction
43  * - The visual position of each glyph within the layout
44  * - A window into the text layout e.g. which page of a document to view
45  */
46 class ViewInterface
47 {
48 public:
49
50   /**
51    * @brief Constructor.
52    */
53   ViewInterface();
54
55   /**
56    * @brief Virtual destructor
57    */
58   virtual ~ViewInterface();
59
60   /**
61    * @brief Retrieves the target size of the UI control.
62    *
63    * @return The control's size.
64    */
65   virtual const Vector2& GetControlSize() const = 0;
66
67   /**
68    * @brief Retrieves the text's layout size.
69    *
70    * @return The text's size. Note that this may be larger than the control size,
71    * in the case where text is scrolling/clipped.
72    */
73   virtual const Vector2& GetLayoutSize() const = 0;
74
75   /**
76    * Retrieves the number of glyphs.
77    *
78    * @return The number of glyphs.
79    */
80   virtual Length GetNumberOfGlyphs() const = 0;
81
82   /**
83    * @brief Retrieves glyphs and positions in the given buffers.
84    *
85    * @note The size of the @p glyphs and @p glyphPositions buffers need to be big enough to copy the @p numberOfGlyphs glyphs and positions.
86    * @note The returned number of glyphs may be less than @p numberOfGlyphs if a line has ellipsis.
87    *
88    * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
89    * @param[out] glyphPositions Pointer to a buffer where the glyph's positions are copied.
90    * @param[in] glyphIndex Index to the first glyph.
91    * @param[in] numberOfGlyphs Number of glyphs to be copied.
92    *
93    * @return The number of glyphs.
94    */
95   virtual Length GetGlyphs( GlyphInfo* glyphs,
96                             Vector2* glyphPositions,
97                             GlyphIndex glyphIndex,
98                             Length numberOfGlyphs ) const = 0;
99
100   /**
101    * @brief Retrieves the vector of colors.
102    *
103    * @return Pointer to the vector of colors.
104    */
105   virtual const Vector4* const GetColors() const = 0;
106
107   /**
108    * @brief Retrieves the vector of indices to the vector of colors.
109    *
110    * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
111    */
112   virtual const ColorIndex* const GetColorIndices() const = 0;
113
114   /**
115    * @brief Retrieves the text color
116    *
117    * @return The text color
118    */
119   virtual const Vector4& GetTextColor() const = 0;
120
121   /**
122    * @brief Retrieves the shadow offset, 0 indicates no shadow.
123    *
124    * @return The shadow offset.
125    */
126   virtual const Vector2& GetShadowOffset() const = 0;
127
128   /**
129    * @brief Retrieves the shadow color.
130    *
131    * @return The shadow color.
132    */
133   virtual const Vector4& GetShadowColor() const = 0;
134
135   /**
136    * @brief Retrieves the underline color.
137    *
138    * @return The underline color.
139    */
140   virtual const Vector4& GetUnderlineColor() const = 0;
141
142   /**
143    * @brief Returns whether underline is enabled or not.
144    *
145    * @return The underline state.
146    */
147   virtual bool IsUnderlineEnabled() const = 0;
148
149   /**
150    * @brief Retrieves the underline height override
151    *
152    * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
153    */
154   virtual float GetUnderlineHeight() const = 0;
155
156   /**
157    * @brief Retrieves the number of underline runs.
158    *
159    * @return The number of underline runs.
160    */
161   virtual Length GetNumberOfUnderlineRuns() const = 0;
162
163   /**
164    * @brief Retrieves the underline runs.
165    *
166    * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
167    * @param[in] index Index of the first underline run to be copied.
168    * @param[in] numberOfRuns Number of underline runs to be copied.
169    */
170   virtual void GetUnderlineRuns( GlyphRun* underlineRuns,
171                                  UnderlineRunIndex index,
172                                  Length numberOfRuns ) const = 0;
173 };
174
175 } // namespace Text
176
177 } // namespace Toolkit
178
179 } // namespace Dali
180
181 #endif // __DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H__