Added some LayoutEngine skeleton code
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / public-api / text / text-controller.h
1 #ifndef __DALI_TOOLKIT_TEXT_CONTROLLER_H__
2 #define __DALI_TOOLKIT_TEXT_CONTROLLER_H__
3
4 /*
5  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/object/ref-object.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/text/text-view.h>
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Text
35 {
36
37 class Controller;
38 class LayoutEngine;
39
40 typedef IntrusivePtr<Controller> ControllerPtr;
41
42 /**
43  * @brief A Text Controller is used by UI Controls which display text.
44  *
45  * It manipulates the Logical & Visual text models on behalf of the UI Controls.
46  * It provides a view of the text that can be used by rendering back-ends.
47  */
48 class Controller : public RefObject
49 {
50 public:
51
52   /**
53    * @brief Create a new instance of a Controller.
54    *
55    * @return A pointer to a new Controller.
56    */
57   static ControllerPtr New();
58
59   /**
60    * @brief Replaces any text previously set.
61    *
62    * @note This will be converted into UTF-32 when stored in the text model.
63    * @param[in] text A string of UTF-8 characters.
64    */
65   void SetText( const std::string& text );
66
67   /**
68    * @brief Triggers a relayout which updates View (if necessary).
69    *
70    * @note UI Controls are expected to minimize calls to this method e.g. call once after size negotiation.
71    * @param[in] size A the size of a bounding box to layout text within.
72    * @return True if the View was updated.
73    */
74   bool Relayout( const Vector2& size );
75
76   /**
77    * @brief Return the layout engine.
78    *
79    * @return A reference to the layout engine.
80    */
81   LayoutEngine& GetLayoutEngine();
82
83   /**
84    * @brief Return a view of the text.
85    *
86    * @return A reference to the view.
87    */
88   View& GetView();
89
90 protected:
91
92   /**
93    * @brief A reference counted object may only be deleted by calling Unreference().
94    */
95   virtual ~Controller();
96
97 private:
98
99   /**
100    * @brief Private constructor.
101    */
102   Controller();
103
104   /**
105    * @brief Populates the visual model.
106    */
107   void UpdateVisualModel();
108
109   // Undefined
110   Controller( const Controller& handle );
111
112   // Undefined
113   Controller& operator=( const Controller& handle );
114
115 private:
116
117   struct Impl;
118   Impl* mImpl;
119 };
120 } // namespace Text
121
122 } // namespace Toolkit
123
124 } // namespace Dali
125
126 #endif // __DALI_TOOLKIT_TEXT_CONTROLLER_H__