1 #ifndef DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H
2 #define DALI_TOOLKIT_TEXT_MODEL_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/math/vector2.h>
25 #include <dali-toolkit/devel-api/text/text-enumerations-devel.h>
26 #include <dali-toolkit/internal/text/bounded-paragraph-run.h>
27 #include <dali-toolkit/internal/text/line-run.h>
28 #include <dali-toolkit/internal/text/script-run.h>
29 #include <dali-toolkit/internal/text/strikethrough-glyph-run.h>
30 #include <dali-toolkit/internal/text/text-definitions.h>
31 #include <dali-toolkit/internal/text/underlined-glyph-run.h>
32 #include <dali-toolkit/public-api/text/text-enumerations.h>
41 * @brief Interface class used to retrieve the text's model from the text-controller.
47 * @brief Virtual destructor.
49 virtual ~ModelInterface()
54 * @brief Retrives the control's size.
56 * @return The control's size.
58 virtual const Size& GetControlSize() const = 0;
61 * @brief Retrives the layout's size.
63 * @return The layout's size.
65 virtual const Size& GetLayoutSize() const = 0;
68 * @brief Retrieves the text's scroll position.
70 * @return The scroll position.
72 virtual const Vector2& GetScrollPosition() const = 0;
75 * @brief Retrieves the text's horizontal alignment.
77 * @return The horizontal alignment.
79 virtual HorizontalAlignment::Type GetHorizontalAlignment() const = 0;
82 * @brief Retrieves the text's vertical alignment.
84 * @return The vertical alignment.
86 virtual VerticalAlignment::Type GetVerticalAlignment() const = 0;
89 * @brief Retrieves the text's vertical line alignment.
91 * @return The vertical line alignment.
93 virtual DevelText::VerticalLineAlignment::Type GetVerticalLineAlignment() const = 0;
96 * @brief Retrieves ellipsis position for text.
98 * @return The ellipsis position.
100 virtual DevelText::EllipsisPosition::Type GetEllipsisPosition() const = 0;
103 * @brief Whether the text elide property is enabled.
105 * @return @e true if the text elide property is enabled, @e false otherwise.
107 virtual bool IsTextElideEnabled() const = 0;
110 * @brief Retrieves the number of laid-out lines.
112 * @return The number of laid-out lines.
114 virtual Length GetNumberOfLines() const = 0;
117 * @brief Retrieves the laid-out lines.
119 * @return A pointer to the vector with the laid-out lines.
121 virtual const LineRun* const GetLines() const = 0;
124 * @brief Retrieves the number of script runs.
126 * @return The number of script runs.
128 virtual Length GetNumberOfScripts() const = 0;
131 * @brief Retrieves the script runs.
133 * @return A pointer to the vector with the runs of characters with the same script..
135 virtual const ScriptRun* const GetScriptRuns() const = 0;
138 * @brief Retrieves the number of laid-out glyphs.
140 * @return The number of laid-out glyphs.
142 virtual Length GetNumberOfGlyphs() const = 0;
145 * @brief Retrieves the start index of laid-out glyphs.
147 * @return The start index of laid-out glyphs.
149 virtual GlyphIndex GetStartIndexOfElidedGlyphs() const = 0;
152 * @brief Retrieves the end index of laid-out glyphs.
154 * @return The end index of laid-out glyphs.
156 virtual GlyphIndex GetEndIndexOfElidedGlyphs() const = 0;
159 * @brief Retrieves the first middle index of elided glyphs, index before ellipsis of middle.
161 * @return The first middle index of elided glyphs, index before ellipsis of middle.
163 virtual GlyphIndex GetFirstMiddleIndexOfElidedGlyphs() const = 0;
166 * @brief Retrieves the second middle index of elided glyphs, index of ellipsis of middle.
168 * @return The second middle index of elided glyphs, index of ellipsis of middle.
170 virtual GlyphIndex GetSecondMiddleIndexOfElidedGlyphs() const = 0;
173 * @brief Retrieves the laid-out glyphs.
175 * @return A pointer to the vector with the laid-out glyphs.
177 virtual const GlyphInfo* const GetGlyphs() const = 0;
180 * @brief Retrieves the text layout.
182 * @return A pointer to the vector with the positions for each glyph.
184 virtual const Vector2* const GetLayout() const = 0;
187 * @brief Retrieves the vector of colors.
189 * @return Pointer to the vector of colors.
191 virtual const Vector4* const GetColors() const = 0;
194 * @brief Retrieves the vector of indices to the vector of colors.
196 * @return Pointer to a vector which stores for each glyph the index to the vector of colors.
198 virtual const ColorIndex* const GetColorIndices() const = 0;
201 * @brief Retrieves the vector of background colors.
203 * @return Pointer to the vector of background colors.
205 virtual const Vector4* const GetBackgroundColors() const = 0;
208 * @brief Retrieves the vector of indices to the vector of background colors.
210 * @return Pointer to a vector which stores for each glyph the index to the vector of background colors.
212 virtual const ColorIndex* const GetBackgroundColorIndices() const = 0;
215 * @brief checks if there is background colors set using markup.
217 * @return boolean if there is background colors set using markup .
219 virtual bool const IsMarkupBackgroundColorSet() const = 0;
222 * @brief Retrieves the text's default color.
224 * @return The default color.
226 virtual const Vector4& GetDefaultColor() const = 0;
229 * @brief Retrieves the shadow offset, 0 indicates no shadow.
231 * @return The shadow offset.
233 virtual const Vector2& GetShadowOffset() const = 0;
236 * @brief Retrieves the shadow color.
238 * @return The shadow color.
240 virtual const Vector4& GetShadowColor() const = 0;
243 * @brief Retrieve the shadow blur radius.
245 * @return The shadow blur radius.
247 virtual const float& GetShadowBlurRadius() const = 0;
250 * @brief Retrieves the underline color.
252 * @return The underline color.
254 virtual const Vector4& GetUnderlineColor() const = 0;
257 * @brief Returns whether underline is enabled or not.
259 * @return The underline state.
261 virtual bool IsUnderlineEnabled() const = 0;
264 * @brief Retrieves the underline height override
266 * @return Returns the override height for an underline, 0 indicates that adaptor will determine the height
268 virtual float GetUnderlineHeight() const = 0;
271 * @brief Retrieves the underline type override.
273 * @return Returns the override type for an underline.
275 virtual Text::Underline::Type GetUnderlineType() const = 0;
278 * @brief Retrieves the dashed underline width override
280 * @return Returns the override width for the dashed underline.
282 virtual float GetDashedUnderlineWidth() const = 0;
285 * @brief Retrieves the dashed underline gap override
287 * @return Returns the override gap for the dashed underline.
289 virtual float GetDashedUnderlineGap() const = 0;
292 * @brief Retrieves the number of underline runs.
294 * @return The number of underline runs.
296 virtual Length GetNumberOfUnderlineRuns() const = 0;
299 * @brief Retrieves the underline runs.
301 * @param[out] underlineRuns Pointer to a buffer where the underline runs are copied.
302 * @param[in] index Index of the first underline run to be copied.
303 * @param[in] numberOfRuns Number of underline runs to be copied.
305 virtual void GetUnderlineRuns(UnderlinedGlyphRun* underlineRuns, UnderlineRunIndex index, Length numberOfRuns) const = 0;
308 * @brief Retrieve the outline color.
310 * @return The outline color.
312 virtual const Vector4& GetOutlineColor() const = 0;
315 * @brief Retrieves the width of an outline
317 * @return The width of the outline.
319 virtual uint16_t GetOutlineWidth() const = 0;
322 * @brief Retrieves the background color.
324 * @return The background color.
326 virtual const Vector4& GetBackgroundColor() const = 0;
329 * @brief Returns whether background is enabled or not.
331 * @return The background state.
333 virtual bool IsBackgroundEnabled() const = 0;
336 * @brief Returns whether markup-processor is enabled or not.
338 * @return The markup-processor state.
340 virtual bool IsMarkupProcessorEnabled() const = 0;
343 * @brief Returns the hyphens glyph info.
345 * @return hyphens glyph info.
347 virtual const GlyphInfo* GetHyphens() const = 0;
350 * @brief Returns the indices of the hyphen in the text.
352 * @return the hyphen indices.
354 virtual const Length* GetHyphenIndices() const = 0;
357 * @brief Returns number of hyphens to add in text.
359 * @return number of hyphens.
361 virtual Length GetHyphensCount() const = 0;
364 * @brief Retrieves the strikethrough color.
366 * @return The strikethrough color.
368 virtual const Vector4& GetStrikethroughColor() const = 0;
371 * @brief Returns whether strikethrough is enabled or not.
373 * @return The strikethrough state.
375 virtual bool IsStrikethroughEnabled() const = 0;
378 * @brief Retrieves the strikethrough height override
380 * @return Returns the override height for a strikethrough, 0 indicates that adaptor will determine the height
382 virtual float GetStrikethroughHeight() const = 0;
385 * @brief Retrieves the number of strikethrough runs.
387 * @return The number of strikethrough runs.
389 virtual Length GetNumberOfStrikethroughRuns() const = 0;
392 * @brief Retrieves the number of bounded paragraph runs.
394 * @return The number of bounded paragraph runs.
396 virtual Length GetNumberOfBoundedParagraphRuns() const = 0;
399 * @brief Retrieves the reference for bounded paragraph runs.
401 * @return The reference for bounded paragraph runs.
403 virtual const Vector<BoundedParagraphRun>& GetBoundedParagraphRuns() const = 0;
406 * @brief Retrieves the strikethrough runs.
408 * @param[out] strikethroughRuns Pointer to a buffer where the strikethrough runs are copied.
409 * @param[in] index Index of the first strikethrough run to be copied.
410 * @param[in] numberOfRuns Number of strikethrough runs to be copied.
412 virtual void GetStrikethroughRuns(StrikethroughGlyphRun* strikethroughRuns, StrikethroughRunIndex index, Length numberOfRuns) const = 0;
415 * @brief Retrieves the character spacing.
417 * @note A positive value will make the characters far apart (expanded) and a negative value will bring them closer (condensed).
419 * @return The character spacing.
421 virtual const float GetCharacterSpacing() const = 0;
424 * @brief Retrieves the text buffer.
426 * @return The text buffer.
428 virtual const Character* GetTextBuffer() const = 0;
431 * @brief Retrieves the Glyphs to Characters Array.
433 * @return The GlyphsToCharacters.
435 virtual const Vector<CharacterIndex>& GetGlyphsToCharacters() const = 0;
440 } // namespace Toolkit
444 #endif // DALI_TOOLKIT_TEXT_MODEL_INTERFACE_H