1 #ifndef __DALI_TOOLKIT_TEXT_LABEL_H__
2 #define __DALI_TOOLKIT_TEXT_LABEL_H__
5 * Copyright (c) 2017 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/public-api/controls/control.h>
30 namespace Internal DALI_INTERNAL
35 * @addtogroup dali_toolkit_controls_text_controls
40 * @brief A control which renders a short text string.
42 * Text labels are lightweight, non-editable and do not respond to user input.
44 * @section TextLabelProperties Properties
45 * |%Property enum |String name |Type |Writable|Animatable|
46 * |----------------------------------|---------------------|----------------|--------|----------|
47 * | Property::RENDERING_BACKEND | renderingBackend | INTEGER | O | X |
48 * | Property::TEXT | text | STRING | O | X |
49 * | Property::FONT_FAMILY | fontFamily | STRING | O | X |
50 * | Property::FONT_STYLE | fontStyle | STRING or MAP | O | X |
51 * | Property::POINT_SIZE | pointSize | FLOAT | O | X |
52 * | Property::MULTI_LINE | multiLine | BOOLEAN | O | X |
53 * | Property::HORIZONTAL_ALIGNMENT | horizontalAlignment | STRING | O | X |
54 * | Property::VERTICAL_ALIGNMENT | verticalAlignment | STRING | O | X |
55 * | Property::TEXT_COLOR | textColor | VECTOR4 | O | X |
56 * | Property::ENABLE_MARKUP | enableMarkup | BOOLEAN | O | X |
57 * | Property::ENABLE_AUTO_SCROLL | enableAutoScroll | BOOLEAN | O | X |
58 * | Property::AUTO_SCROLL_SPEED | autoScrollSpeed | INTEGER | O | X |
59 * | Property::AUTO_SCROLL_LOOP_COUNT | autoScrollLoopCount | INTEGER | O | X |
60 * | Property::AUTO_SCROLL_GAP | autoScrollGap | INTEGER | O | X |
61 * | Property::SHADOW | shadow | STRING or MAP | O | X |
62 * | Property::UNDERLINE | underline | STRING or MAP | O | X |
66 class DALI_IMPORT_API TextLabel : public Control
71 * @brief Enumeration for the start and end property ranges for this control.
76 PROPERTY_START_INDEX = Control::CONTROL_PROPERTY_END_INDEX + 1, ///< @SINCE_1_0.0
77 PROPERTY_END_INDEX = PROPERTY_START_INDEX + 1000, ///< Reserve property indices @SINCE_1_0.0
79 ANIMATABLE_PROPERTY_START_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX, ///< @SINCE_1_2.60
80 ANIMATABLE_PROPERTY_END_INDEX = ANIMATABLE_PROPERTY_REGISTRATION_START_INDEX + 1000 ///< Reserve animatable property indices @SINCE_1_2.60
84 * @brief Enumeration for the instance of properties belonging to the TextLabel class.
90 * @brief Enumeration for the instance of properties belonging to the TextLabel class.
95 ///////////////////////////////////////////////////////////////////////////////
96 // Event side (non-animatable) properties
97 ///////////////////////////////////////////////////////////////////////////////
100 * @DEPRECATED_1_2.53 No longer be supported and will be ignored.
101 * @brief The type of rendering e.g. bitmap-based.
102 * @details Name "renderingBackend", type Property::INT.
105 RENDERING_BACKEND = PROPERTY_START_INDEX,
108 * @brief The text to display in UTF-8 format.
109 * @details Name "text", type Property::STRING.
115 * @brief The requested font family to use.
116 * @details Name "fontFamily", type Property::STRING.
122 * @brief The requested font style to use.
123 * @details Name "fontStyle", type Property::STRING or Property::MAP.
129 * @brief The size of font in points.
130 * @details Name "pointSize", type Property::FLOAT.
131 * Conversion from Pixel size to Point size:
132 * Point size = Pixel size * 72 / DPI
138 * @brief The single-line or multi-line layout option.
139 * @details Name "multiLine", type Property::BOOLEAN.
141 * @note Default is false.
146 * @brief The line horizontal alignment.
147 * @details Name "horizontalAlignment", type Property::STRING or type HorizontalAlignment::Type (Property::INTEGER)
148 * Values "BEGIN", "CENTER", "END", default BEGIN.
149 * @note Return type is Property::STRING
152 HORIZONTAL_ALIGNMENT,
155 * @brief The line vertical alignment.
156 * @details Name "verticalAlignment", type Property::STRING or type VerticalAlignment::Type (Property::INTEGER).
157 * Values "TOP", "CENTER", "BOTTOM" @SINCE_1_0.0, default TOP.
158 * @note Return type is Property::STRING
164 * @DEPRECATED_1_2.60 Use the new enum value of TEXT_COLOR instead.
165 * @brief The color of the text.
166 * @details Name "unusedPropertyTextColor", type Property::VECTOR4.
169 UNUSED_PROPERTY_TEXT_COLOR,
172 * @DEPRECATED_1_1.37 Use SHADOW instead
173 * @brief The drop shadow offset 0 indicates no shadow.
174 * @details Name "shadowOffset", type Property::VECTOR2.
179 * @DEPRECATED_1_1.37 Use SHADOW instead
180 * @brief The color of a drop shadow.
181 * @details Name "shadowColor", type Property::VECTOR4
186 * @DEPRECATED_1_1.37 Use UNDERLINE instead
187 * @brief The underline enabled flag.
188 * @details Name "underlineEnabled", type Property::BOOLEAN.
193 * @DEPRECATED_1_1.37 Use UNDERLINE instead
194 * @brief The color of the underline.
195 * @details Name "underlineColor", type Property::VECTOR4.
200 * @DEPRECATED_1_1.37 Use UNDERLINE instead
201 * @brief Overrides the underline height from font metrics.
202 * @details Name "underlineHeight", type Property::FLOAT.
207 * @brief Whether the mark-up processing is enabled.
208 * @details Name "enableMarkup", type Property::BOOLEAN.
210 * @note Default is false.
215 * @brief Starts or stops auto scrolling.
216 * @details Name "enableAutoScroll", type Property::BOOLEAN.
218 * @note Default is false.
223 * @brief Sets the speed of scrolling in pixels per second.
224 * @details Name "autoScrollSpeed", type Property::INT.
226 * @note Default in style sheet.
231 * @brief Number of complete loops when scrolling enabled.
232 * @details Name "autoScrollLoopCount", type Property::INT.
234 * @note Default in style sheet.
236 AUTO_SCROLL_LOOP_COUNT,
239 * @brief Gap before scrolling wraps.
240 * @details Name "autoScrollGap", type Property::INT.
242 * @note Default in style sheet but can be overridden to prevent same text being shown at start and end.
243 * @note Displayed gap size is not guaranteed if the text length plus gap exceeds the maximum texture size (i.e. GL_MAX_TEXTURE_SIZE).
248 * @brief The default extra space between lines in points.
249 * @details Name "lineSpacing", type Property::FLOAT.
255 * @brief The default underline parameters.
256 * @details Name "underline", type Property::MAP.
262 * @brief The default shadow parameters.
263 * @details Name "shadow", type Property::MAP.
269 * @brief The default emboss parameters.
270 * @details Name "emboss", type Property::MAP.
276 * @brief The default outline parameters.
277 * @details Name "outline", type Property::MAP.
283 * @brief The size of font in pixels.
284 * @details Name "pixelSize", type Property::FLOAT.
285 * Conversion from Point size to Pixel size:
286 * Pixel size = Point size * DPI / 72
292 * @brief Whether we should show the ellipsis if required.
293 * @details Name "ellipsis", type Property::BOOLEAN.
299 * @brief The amount of time to delay the starting time of auto scrolling and further loops.
300 * @details Name "autoScrollLoopDelay", type Property::FLOAT.
303 AUTO_SCROLL_LOOP_DELAY,
306 * @brief The auto scrolling stop behaviour.
307 * @details Name "autoScrollStopMode", type AutoScrollStopMode::Type (Property::INTEGER) or Property::STRING.
309 * @note Default is AutoScrollStopMode::FINISH_LOOP.
310 * @see AutoScrollStopMode::Type
312 AUTO_SCROLL_STOP_MODE,
315 * @brief The line count of text.
316 * @details name "lineCount", type Property::INTEGER.
318 * @note This property is read-only.
323 * @brief Line wrap mode when text lines are greater than the layout width.
324 * @details Name "lineWrapMode", type Text::LineWrap::Mode (Text::Property::INTEGER) or Property::STRING.
326 * @note Default is Text::LineWrap::WORD.
327 * @note Return type is Text::LineWrap::Mode (Text::Property::INTEGER).
328 * @see Text::LineWrap
332 ///////////////////////////////////////////////////////////////////////////////
333 // Animatable Properties
334 ///////////////////////////////////////////////////////////////////////////////
337 * @brief The color of the text.
338 * @details Name "textColor", type Property::VECTOR4.
341 TEXT_COLOR = ANIMATABLE_PROPERTY_START_INDEX,
344 * @brief The red component of the text color.
345 * @details Name "textColorRed", type Property::FLOAT.
352 * @brief The green component of the text color.
353 * @details Name "textColorGreen", type Property::FLOAT.
360 * @brief The blue component of the text color.
361 * @details Name "textColorBlue", type Property::FLOAT.
368 * @brief The alpha component of the text color.
369 * @details Name "textColorAlpha", type Property::FLOAT.
378 * @brief The enumerations used for auto scroll stop mode.
380 * @see Property::AUTO_SCROLL_STOP_MODE.
382 struct AutoScrollStopMode
385 * @brief The enumerations used for auto scroll stop mode.
387 * @see Property::AUTO_SCROLL_STOP_MODE.
391 FINISH_LOOP = 0, ///< Stop animation after current loop finishes. @SINCE_1_2.60
392 IMMEDIATE ///< Stop animation immediately and reset position. @SINCE_1_2.60
397 * @brief Creates the TextLabel control.
400 * @return A handle to the TextLabel control
402 static TextLabel New();
405 * @brief Creates the TextLabel control.
408 * @param[in] text The text to display
409 * @return A handle to the TextLabel control
411 static TextLabel New( const std::string& text );
414 * @brief Creates an empty handle.
420 * @brief Copy constructor.
423 * @param[in] handle The handle to copy from
425 TextLabel( const TextLabel& handle );
428 * @brief Assignment operator.
431 * @param[in] handle The handle to copy from
432 * @return A reference to this
434 TextLabel& operator=( const TextLabel& handle );
439 * This is non-virtual since derived Handle types must not contain data or virtual methods.
445 * @brief Downcasts a handle to TextLabel.
447 * If the BaseHandle points is a TextLabel, the downcast returns a valid handle.
448 * If not, the returned handle is left empty.
451 * @param[in] handle Handle to an object
452 * @return Handle to a TextLabel or an empty handle
454 static TextLabel DownCast( BaseHandle handle );
456 public: // Not intended for application developers
460 * @brief Creates a handle using the Toolkit::Internal implementation.
463 * @param[in] implementation The Control implementation
465 DALI_INTERNAL TextLabel( Internal::TextLabel& implementation );
468 * @brief Allows the creation of this Control from an Internal::CustomActor pointer.
471 * @param[in] internal A pointer to the internal CustomActor
473 explicit DALI_INTERNAL TextLabel( Dali::Internal::CustomActor* internal );
480 } // namespace Toolkit
484 #endif // __DALI_TOOLKIT_TEXT_LABEL_H__