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/internal/text/underlined-glyph-run.h>
28 #include <dali-toolkit/public-api/text/text-enumerations.h>
40 struct StrikethroughGlyphRun;
43 * @brief Abstract interface to provide the information necessary to display text.
46 * - The font & glyph IDs needed to get bitmaps etc. from TextAbstraction
47 * - The visual position of each glyph within the layout
48 * - A window into the text layout e.g. which page of a document to view
59 * @brief Virtual destructor
61 virtual ~ViewInterface();
64 * @brief Retrieves the target size of the UI control.
66 * @return The control's size.
68 virtual const Vector2& GetControlSize() const = 0;
71 * @brief Retrieves the text's layout size.
73 * @return The text's size. Note that this may be larger than the control size,
74 * in the case where text is scrolling/clipped.
76 virtual const Vector2& GetLayoutSize() const = 0;
79 * Retrieves the number of glyphs.
81 * @return The number of glyphs.
83 virtual Length GetNumberOfGlyphs() const = 0;
86 * @brief Retrieves glyphs and positions in the given buffers.
88 * @note The size of the @p glyphs and @p glyphPositions buffers need to be big enough to copy the @p numberOfGlyphs glyphs and positions.
89 * @note The returned number of glyphs may be less than @p numberOfGlyphs if a line has ellipsis.
91 * @param[out] glyphs Pointer to a buffer where the glyphs are copied.
92 * @param[out] glyphPositions Pointer to a buffer where the glyph's positions are copied.
93 * @param[out] minLineOffset The minimum line offset.
94 * @param[in] glyphIndex Index to the first glyph.
95 * @param[in] numberOfGlyphs Number of glyphs to be copied.
97 * @return The number of glyphs.
99 virtual Length GetGlyphs(GlyphInfo* glyphs,
100 Vector2* glyphPositions,
101 float& minLineOffset,
102 GlyphIndex glyphIndex,
103 Length numberOfGlyphs) const = 0;
106 * @brief Retrieves the vector of colors.
108 * @return Pointer to the vector of colors.
110 virtual const Vector4* const GetColors() const = 0;
113 * @brief Retrieves the vector of indices to the vector of colors.
115 * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
117 virtual const ColorIndex* const GetColorIndices() const = 0;
120 * @brief Retrieves the vector of background colors.
122 * @return Pointer to the vector of background colors.
124 virtual const Vector4* const GetBackgroundColors() const = 0;
127 * @brief Retrieves the vector of indices to the vector of background colors.
129 * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
131 virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
134 * @brief checks if there is background colors set using markup.
136 * @return boolean if there is background colors set using markup .
138 virtual bool const IsMarkupBackgroundColorSet() const = 0;
141 * @brief Retrieves the text color
143 * @return The text color
145 virtual const Vector4& GetTextColor() const = 0;
148 * @brief Retrieves the shadow offset, 0 indicates no shadow.
150 * @return The shadow offset.
152 virtual const Vector2& GetShadowOffset() const = 0;
155 * @brief Retrieves the shadow color.
157 * @return The shadow color.
159 virtual const Vector4& GetShadowColor() const = 0;
162 * @brief Retrieves the underline color.
164 * @return The underline color.
166 virtual const Vector4& GetUnderlineColor() const = 0;
169 * @brief Returns whether underline is enabled or not.
171 * @return The underline state.
173 virtual bool IsUnderlineEnabled() const = 0;
176 * @brief Returns the hyphens glyph info.
178 * @return hyphens glyph info.
180 virtual const GlyphInfo* GetHyphens() const = 0;
183 * @brief Returns the indices of the hyphen in the text.
185 * @return the hyphen indices.
187 virtual const Length* GetHyphenIndices() const = 0;
190 * @brief Returns number of hyphens to add in text.
192 * @return number of hyphens.
194 virtual Length GetHyphensCount() const = 0;
196 * @brief Retrieves the underline height override
198 * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
200 virtual float GetUnderlineHeight() const = 0;
203 * @brief Retrieves the underline type override
205 * @return Returns the override type for an underline.
207 virtual Text::Underline::Type GetUnderlineType() const = 0;
210 * @brief Retrieves the dashed underline width override.
212 * @return Returns the override width for the dashed underline.
214 virtual float GetDashedUnderlineWidth() const = 0;
217 * @brief Retrieves the dashed underline gap override.
219 * @return Returns the override gap for the dashed underline.
221 virtual float GetDashedUnderlineGap() const = 0;
224 * @brief Retrieves the number of underline runs.
226 * @return The number of underline runs.
228 virtual Length GetNumberOfUnderlineRuns() const = 0;
231 * @brief Retrieves the underline runs.
233 * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
234 * @param[in] index Index of the first underline run to be copied.
235 * @param[in] numberOfRuns Number of underline runs to be copied.
237 virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns,
238 UnderlineRunIndex index,
239 Length numberOfRuns) const = 0;
242 * @brief Retrieve the outline color.
244 * @return The outline color.
246 virtual const Vector4& GetOutlineColor() const = 0;
249 * @brief Retrieves the width of an outline
251 * @return The width of the outline.
253 virtual uint16_t GetOutlineWidth() const = 0;
256 * @brief Retrieves ellipsis position for text.
258 * @return The ellipsis position.
260 virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
263 * @brief Whether the text elide property is enabled.
265 * @return @e true if the text elide property is enabled, @e false otherwise.
267 virtual bool IsTextElideEnabled() const = 0;
270 * @brief Retrieves the start index of laid-out glyphs.
272 * @return The start index of laid-out glyphs.
274 virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
277 * @brief Retrieves the end index of laid-out glyphs.
279 * @return The end index of laid-out glyphs.
281 virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
284 * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
286 * @return The first middle index of elided glyphs, index before ellipsis of middle.
288 virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
291 * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
293 * @return The second middle index of elided glyphs, index of ellipsis of middle.
295 virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
298 * @brief Retrieves the strikethrough color.
300 * @return The strikethrough color.
302 virtual const Vector4& GetStrikethroughColor() const = 0;
305 * @brief Returns whether strikethrough is enabled or not.
307 * @return The strikethrough state.
309 virtual bool IsStrikethroughEnabled() const = 0;
312 * @brief Retrieves the strikethrough height override
314 * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
316 virtual float GetStrikethroughHeight() const = 0;
319 * @brief Retrieves the number of strikethrough runs.
321 * @return The number of strikethrough runs.
323 virtual Length GetNumberOfStrikethroughRuns() const = 0;
326 * @brief Retrieves the strikethrough runs.
328 * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
329 * @param[in] index Index of the first strikethrough run to be copied.
330 * @param[in] numberOfRuns Number of strikethrough runs to be copied.
332 virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns,
333 StrikethroughRunIndex index,
334 Length numberOfRuns) const = 0;
337 * @brief The spaces between characters in Pixels.
339 * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
341 * @return characterSpacing.
343 virtual const float GetCharacterSpacing() const = 0;
346 * @brief The text buffer.
348 * @return The text buffer.
350 virtual const Character* GetTextBuffer() const = 0;
353 * @brief The text Glyph to Characters Array.
355 * @return GetGlyphsToCharacters.
357 virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
362 } // namespace Toolkit
366 #endif // DALI_TOOLKIT_TEXT_VIEW_INTERFACE_H