cfb7e83526b4ce0de2b7d2e6c3dbd874ee24ea9b
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / text / text-controller-relayouter.h
1 #ifndef DALI_TOOLKIT_TEXT_CONTROLLER_RELAYOUTER_H
2 #define DALI_TOOLKIT_TEXT_CONTROLLER_RELAYOUTER_H
3
4 /*
5  * Copyright (c) 2020 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/actors/actor-enumerations.h>
23 #include <dali/public-api/math/vector2.h>
24 #include <dali/public-api/math/vector3.h>
25
26 // INTERNAL INCLUDES
27 #include <dali-toolkit/internal/text/text-controller.h>
28
29 namespace Dali
30 {
31
32 namespace Toolkit
33 {
34
35 namespace Text
36 {
37
38 /**
39  * Contains all the relayouting related methods for Text::Controller
40  */
41 struct Controller::Relayouter
42 {
43   /**
44    * @brief Called by the Controller to retrieve the natural size.
45    *
46    * @param[in] controller A reference to the controller class
47    * @return
48    */
49   static Vector3 GetNaturalSize(Controller& controller);
50
51   /**
52    * @brief Called by the Controller to check if the text fits.
53    *
54    * @param[in] controller A reference to the controller class
55    * @param[in] pointSize The point size
56    * @param[in] layoutSize The layout size
57    * @return
58    */
59   static bool CheckForTextFit(Controller& controller, float pointSize, const Size& layoutSize);
60
61   /**
62    * @brief Called by the Controller to get the height for a particular width.
63    *
64    * @param[in] controller A reference to the controller class
65    * @param[in] width The width we want the height for
66    * @return
67    */
68   static float GetHeightForWidth(Controller& controller, float width);
69
70   /**
71    * @brief Called by the Controller to do the relayout itself.
72    *
73    * @param[in] controller A reference to the controller class
74    * @param[in] size The size to set
75    * @param[in] layoutDirection The layout direction
76    * @return
77    */
78   static Controller::UpdateTextType Relayout(Controller& controller, const Size& size, Dali::LayoutDirection::Type layoutDirection);
79
80   /**
81    * @brief Called by the Controller to do certain operations when relayouting.
82    *
83    * @param[in] controller A reference to the controller class
84    * @param[in] size The size to set
85    * @param[in] operationsRequired The operations we need to do
86    * @param[in/out] layoutSize The Layout size which can be updated depending on the result of the performed operations
87    * @return
88    */
89   static bool DoRelayout(Controller& controller, const Size& size, OperationsMask operationsRequired, Size& layoutSize );
90
91   /**
92    * @brief Called by the Controller to calculate the veritcal offset give the control size.
93    *
94    * @param[in] controller A reference to the controller class
95    * @param[in] controlSize The control size
96    */
97   static void CalculateVerticalOffset(Controller& controller, const Size& controlSize);
98 };
99
100 } // namespace Text
101
102 } // namespace Toolkit
103
104 } // namespace Dali
105
106 #endif // DALI_TOOLKIT_TEXT_CONTROLLER_RELAYOUTER_H