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-toolkit/devel-api/text/text-enumerations-devel.h>
23 #include <dali-toolkit/internal/text/text-definitions.h>
24 #include <dali-toolkit/public-api/text/text-enumerations.h>
36 struct StrikethroughGlyphRun;
39 * @brief Abstract interface to provide the information necessary to display text.
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
55 * @brief Virtual destructor
57 virtual ~ViewInterface();
60 * @brief Retrieves the target size of the UI control.
62 * @return The control's size.
64 virtual const Vector2& GetControlSize() const = 0;
67 * @brief Retrieves the text's layout size.
69 * @return The text's size. Note that this may be larger than the control size,
70 * in the case where text is scrolling/clipped.
72 virtual const Vector2& GetLayoutSize() const = 0;
75 * Retrieves the number of glyphs.
77 * @return The number of glyphs.
79 virtual Length GetNumberOfGlyphs() const = 0;
82 * @brief Retrieves glyphs and positions in the given buffers.
84 * @note The size of the @p glyphs and @p glyphPositions buffers need to be big enough to copy the @p numberOfGlyphs glyphs and positions.
85 * @note The returned number of glyphs may be less than @p numberOfGlyphs if a line has ellipsis.
87 * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
88 * @param[out] glyphPositions Pointer to a buffer where the glyph's positions are copied.
89 * @param[out] minLineOffset The minimum line offset.
90 * @param[in] glyphIndex Index to the first glyph.
91 * @param[in] numberOfGlyphs Number of glyphs to be copied.
93 * @return The number of glyphs.
95 virtual Length GetGlyphs(GlyphInfo* glyphs,
96 Vector2* glyphPositions,
98 GlyphIndex glyphIndex,
99 Length numberOfGlyphs) const = 0;
102 * @brief Retrieves the vector of colors.
104 * @return Pointer to the vector of colors.
106 virtual const Vector4* const GetColors() const = 0;
109 * @brief Retrieves the vector of indices to the vector of colors.
111 * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
113 virtual const ColorIndex* const GetColorIndices() const = 0;
116 * @brief Retrieves the vector of background colors.
118 * @return Pointer to the vector of background colors.
120 virtual const Vector4* const GetBackgroundColors() const = 0;
123 * @brief Retrieves the vector of indices to the vector of background colors.
125 * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
127 virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
130 * @brief checks if there is background colors set using markup.
132 * @return boolean if there is background colors set using markup .
134 virtual bool const IsMarkupBackgroundColorSet() const = 0;
137 * @brief Retrieves the text color
139 * @return The text color
141 virtual const Vector4& GetTextColor() const = 0;
144 * @brief Retrieves the shadow offset, 0 indicates no shadow.
146 * @return The shadow offset.
148 virtual const Vector2& GetShadowOffset() const = 0;
151 * @brief Retrieves the shadow color.
153 * @return The shadow color.
155 virtual const Vector4& GetShadowColor() const = 0;
158 * @brief Retrieves the underline color.
160 * @return The underline color.
162 virtual const Vector4& GetUnderlineColor() const = 0;
165 * @brief Returns whether underline is enabled or not.
167 * @return The underline state.
169 virtual bool IsUnderlineEnabled() const = 0;
172 * @brief Returns the hyphens glyph info.
174 * @return hyphens glyph info.
176 virtual const GlyphInfo* GetHyphens() const = 0;
179 * @brief Returns the indices of the hyphen in the text.
181 * @return the hyphen indices.
183 virtual const Length* GetHyphenIndices() const = 0;
186 * @brief Returns number of hyphens to add in text.
188 * @return number of hyphens.
190 virtual Length GetHyphensCount() const = 0;
192 * @brief Retrieves the underline height override
194 * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
196 virtual float GetUnderlineHeight() const = 0;
199 * @brief Retrieves the underline type override
201 * @return Returns the override type for an underline.
203 virtual Text::Underline::Type GetUnderlineType() const = 0;
206 * @brief Retrieves the dashed underline width override.
208 * @return Returns the override width for the dashed underline.
210 virtual float GetDashedUnderlineWidth() const = 0;
213 * @brief Retrieves the dashed underline gap override.
215 * @return Returns the override gap for the dashed underline.
217 virtual float GetDashedUnderlineGap() const = 0;
220 * @brief Retrieves the number of underline runs.
222 * @return The number of underline runs.
224 virtual Length GetNumberOfUnderlineRuns() const = 0;
227 * @brief Retrieves the underline runs.
229 * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
230 * @param[in] index Index of the first underline run to be copied.
231 * @param[in] numberOfRuns Number of underline runs to be copied.
233 virtual void GetUnderlineRuns(GlyphRun* underlineRuns,
234 UnderlineRunIndex index,
235 Length numberOfRuns) const = 0;
238 * @brief Retrieve the outline color.
240 * @return The outline color.
242 virtual const Vector4& GetOutlineColor() const = 0;
245 * @brief Retrieves the width of an outline
247 * @return The width of the outline.
249 virtual uint16_t GetOutlineWidth() const = 0;
252 * @brief Retrieves ellipsis position for text.
254 * @return The ellipsis position.
256 virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
259 * @brief Whether the text elide property is enabled.
261 * @return @e true if the text elide property is enabled, @e false otherwise.
263 virtual bool IsTextElideEnabled() const = 0;
266 * @brief Retrieves the start index of laid-out glyphs.
268 * @return The start index of laid-out glyphs.
270 virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
273 * @brief Retrieves the end index of laid-out glyphs.
275 * @return The end index of laid-out glyphs.
277 virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
280 * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
282 * @return The first middle index of elided glyphs, index before ellipsis of middle.
284 virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
287 * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
289 * @return The second middle index of elided glyphs, index of ellipsis of middle.
291 virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
294 * @brief Retrieves the strikethrough color.
296 * @return The strikethrough color.
298 virtual const Vector4& GetStrikethroughColor() const = 0;
301 * @brief Returns whether strikethrough is enabled or not.
303 * @return The strikethrough state.
305 virtual bool IsStrikethroughEnabled() const = 0;
308 * @brief Retrieves the strikethrough height override
310 * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
312 virtual float GetStrikethroughHeight() const = 0;
315 * @brief Retrieves the number of strikethrough runs.
317 * @return The number of strikethrough runs.
319 virtual Length GetNumberOfStrikethroughRuns() const = 0;
322 * @brief Retrieves the strikethrough runs.
324 * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
325 * @param[in] index Index of the first strikethrough run to be copied.
326 * @param[in] numberOfRuns Number of strikethrough runs to be copied.
328 virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
329 StrikethroughRunIndex index,
330 Length numberOfRuns) const = 0;
335 } // namespace Toolkit
339 #endif // DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H