1 #ifndef __DALI_TOOLKIT_TEXT_CONTROLLER_H__
2 #define __DALI_TOOLKIT_TEXT_CONTROLLER_H__
5 * Copyright (c) 2015 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/text/text-view.h>
25 #include <dali/public-api/common/intrusive-ptr.h>
26 #include <dali/public-api/math/vector3.h>
27 #include <dali/public-api/math/vector2.h>
28 #include <dali/public-api/object/ref-object.h>
43 typedef IntrusivePtr<Controller> ControllerPtr;
46 * @brief A Text Controller is used by UI Controls which display text.
48 * It manipulates the Logical & Visual text models on behalf of the UI Controls.
49 * It provides a view of the text that can be used by rendering back-ends.
51 class Controller : public RefObject
56 * @brief Text related operations to be done in the relayout process.
61 CONVERT_TO_UTF32 = 0x1,
64 GET_LINE_BREAKS = 0x8,
65 GET_WORD_BREAKS = 0x10,
67 GET_GLYPH_METRICS = 0x40,
72 ALL_OPERATIONS = 0xFFF
78 * @brief Create a new instance of a Controller.
80 * @return A pointer to a new Controller.
82 static ControllerPtr New();
85 * @brief Replaces any text previously set.
87 * @note This will be converted into UTF-32 when stored in the text model.
88 * @param[in] text A string of UTF-8 characters.
90 void SetText( const std::string& text );
93 * @brief Triggers a relayout which updates View (if necessary).
95 * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
96 * @param[in] size A the size of a bounding box to layout text within.
97 * @return True if the View was updated.
99 bool Relayout( const Vector2& size );
104 bool DoRelayout( const Vector2& size, OperationsMask operations );
107 * @copydoc Control::GetNaturalSize()
109 Vector3 GetNaturalSize();
112 * @copydoc Control::GetHeightForWidth()
114 float GetHeightForWidth( float width );
117 * @brief Return the layout engine.
119 * @return A reference to the layout engine.
121 LayoutEngine& GetLayoutEngine();
124 * @brief Return a view of the text.
126 * @return A reference to the view.
133 * @brief A reference counted object may only be deleted by calling Unreference().
135 virtual ~Controller();
140 * @brief Private constructor.
145 * @brief Populates the visual model.
147 void UpdateVisualModel();
150 Controller( const Controller& handle );
153 Controller& operator=( const Controller& handle );
163 } // namespace Toolkit
167 #endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__