1 #ifndef DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H
2 #define DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H
5 * Copyright (c) 2022 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/dali-vector.h>
25 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
26 #include <dali-toolkit/internal/text/text-definitions.h>
27 #include <dali-toolkit/public-api/text/text-enumerations.h>
39 struct StrikethroughGlyphRun;
42 * @brief Abstract interface to provide the information necessary to display text.
45 * - The font & glyph IDs needed to get bitmaps etc. from TextAbstraction
46 * - The visual position of each glyph within the layout
47 * - A window into the text layout e.g. which page of a document to view
58 * @brief Virtual destructor
60 virtual ~ViewInterface();
63 * @brief Retrieves the target size of the UI control.
65 * @return The control's size.
67 virtual const Vector2& GetControlSize() const = 0;
70 * @brief Retrieves the text's layout size.
72 * @return The text's size. Note that this may be larger than the control size,
73 * in the case where text is scrolling/clipped.
75 virtual const Vector2& GetLayoutSize() const = 0;
78 * Retrieves the number of glyphs.
80 * @return The number of glyphs.
82 virtual Length GetNumberOfGlyphs() const = 0;
85 * @brief Retrieves glyphs and positions in the given buffers.
87 * @note The size of the @p glyphs and @p glyphPositions buffers need to be big enough to copy the @p numberOfGlyphs glyphs and positions.
88 * @note The returned number of glyphs may be less than @p numberOfGlyphs if a line has ellipsis.
90 * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
91 * @param[out] glyphPositions Pointer to a buffer where the glyph's positions are copied.
92 * @param[out] minLineOffset The minimum line offset.
93 * @param[in] glyphIndex Index to the first glyph.
94 * @param[in] numberOfGlyphs Number of glyphs to be copied.
96 * @return The number of glyphs.
98 virtual Length GetGlyphs(GlyphInfo* glyphs,
99 Vector2* glyphPositions,
100 float& minLineOffset,
101 GlyphIndex glyphIndex,
102 Length numberOfGlyphs) const = 0;
105 * @brief Retrieves the vector of colors.
107 * @return Pointer to the vector of colors.
109 virtual const Vector4* const GetColors() const = 0;
112 * @brief Retrieves the vector of indices to the vector of colors.
114 * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
116 virtual const ColorIndex* const GetColorIndices() const = 0;
119 * @brief Retrieves the vector of background colors.
121 * @return Pointer to the vector of background colors.
123 virtual const Vector4* const GetBackgroundColors() const = 0;
126 * @brief Retrieves the vector of indices to the vector of background colors.
128 * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
130 virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
133 * @brief checks if there is background colors set using markup.
135 * @return boolean if there is background colors set using markup .
137 virtual bool const IsMarkupBackgroundColorSet() const = 0;
140 * @brief Retrieves the text color
142 * @return The text color
144 virtual const Vector4& GetTextColor() const = 0;
147 * @brief Retrieves the shadow offset, 0 indicates no shadow.
149 * @return The shadow offset.
151 virtual const Vector2& GetShadowOffset() const = 0;
154 * @brief Retrieves the shadow color.
156 * @return The shadow color.
158 virtual const Vector4& GetShadowColor() const = 0;
161 * @brief Retrieves the underline color.
163 * @return The underline color.
165 virtual const Vector4& GetUnderlineColor() const = 0;
168 * @brief Returns whether underline is enabled or not.
170 * @return The underline state.
172 virtual bool IsUnderlineEnabled() const = 0;
175 * @brief Returns the hyphens glyph info.
177 * @return hyphens glyph info.
179 virtual const GlyphInfo* GetHyphens() const = 0;
182 * @brief Returns the indices of the hyphen in the text.
184 * @return the hyphen indices.
186 virtual const Length* GetHyphenIndices() const = 0;
189 * @brief Returns number of hyphens to add in text.
191 * @return number of hyphens.
193 virtual Length GetHyphensCount() const = 0;
195 * @brief Retrieves the underline height override
197 * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
199 virtual float GetUnderlineHeight() const = 0;
202 * @brief Retrieves the underline type override
204 * @return Returns the override type for an underline.
206 virtual Text::Underline::Type GetUnderlineType() const = 0;
209 * @brief Retrieves the dashed underline width override.
211 * @return Returns the override width for the dashed underline.
213 virtual float GetDashedUnderlineWidth() const = 0;
216 * @brief Retrieves the dashed underline gap override.
218 * @return Returns the override gap for the dashed underline.
220 virtual float GetDashedUnderlineGap() const = 0;
223 * @brief Retrieves the number of underline runs.
225 * @return The number of underline runs.
227 virtual Length GetNumberOfUnderlineRuns() const = 0;
230 * @brief Retrieves the underline runs.
232 * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
233 * @param[in] index Index of the first underline run to be copied.
234 * @param[in] numberOfRuns Number of underline runs to be copied.
236 virtual void GetUnderlineRuns(GlyphRun* underlineRuns,
237 UnderlineRunIndex index,
238 Length numberOfRuns) const = 0;
241 * @brief Retrieve the outline color.
243 * @return The outline color.
245 virtual const Vector4& GetOutlineColor() const = 0;
248 * @brief Retrieves the width of an outline
250 * @return The width of the outline.
252 virtual uint16_t GetOutlineWidth() const = 0;
255 * @brief Retrieves ellipsis position for text.
257 * @return The ellipsis position.
259 virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
262 * @brief Whether the text elide property is enabled.
264 * @return @e true if the text elide property is enabled, @e false otherwise.
266 virtual bool IsTextElideEnabled() const = 0;
269 * @brief Retrieves the start index of laid-out glyphs.
271 * @return The start index of laid-out glyphs.
273 virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
276 * @brief Retrieves the end index of laid-out glyphs.
278 * @return The end index of laid-out glyphs.
280 virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
283 * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
285 * @return The first middle index of elided glyphs, index before ellipsis of middle.
287 virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
290 * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
292 * @return The second middle index of elided glyphs, index of ellipsis of middle.
294 virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
297 * @brief Retrieves the strikethrough color.
299 * @return The strikethrough color.
301 virtual const Vector4& GetStrikethroughColor() const = 0;
304 * @brief Returns whether strikethrough is enabled or not.
306 * @return The strikethrough state.
308 virtual bool IsStrikethroughEnabled() const = 0;
311 * @brief Retrieves the strikethrough height override
313 * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
315 virtual float GetStrikethroughHeight() const = 0;
318 * @brief Retrieves the number of strikethrough runs.
320 * @return The number of strikethrough runs.
322 virtual Length GetNumberOfStrikethroughRuns() const = 0;
325 * @brief Retrieves the strikethrough runs.
327 * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
328 * @param[in] index Index of the first strikethrough run to be copied.
329 * @param[in] numberOfRuns Number of strikethrough runs to be copied.
331 virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
332 StrikethroughRunIndex index,
333 Length numberOfRuns) const = 0;
336 * @brief The spaces between characters in Pixels.
338 * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
340 * @return characterSpacing.
342 virtual const float GetCharacterSpacing() const = 0;
345 * @brief The text buffer.
347 * @return The text buffer.
349 virtual const Character* GetTextBuffer() const = 0;
352 * @brief The text Glyph to Characters Array.
354 * @return GetGlyphsToCharacters.
356 virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
361 } // namespace Toolkit
365 #endif // DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H