[Tizen] code clean up : Relayout again for LTR / RTL order when layout direction is
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-label-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H
3
4 /*
5  * Copyright (c) 2017 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/object/property-map.h>
23 #include <dali/public-api/common/stage.h>
24
25 // INTERNAL INCLUDES
26 #include <dali-toolkit/public-api/controls/control-impl.h>
27 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
28 #include <dali-toolkit/internal/text/text-control-interface.h>
29 #include <dali-toolkit/internal/text/text-controller.h>
30 #include <dali-toolkit/internal/text/text-scroller-interface.h>
31 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
32 #include <dali-toolkit/internal/text/text-scroller.h>
33 #include <dali-toolkit/internal/visuals/text/text-visual.h>
34
35
36 namespace Dali
37 {
38
39 namespace Toolkit
40 {
41
42 namespace Internal
43 {
44
45 /**
46  * @brief A control which renders a short text string.
47  */
48 class TextLabel : public Control, public Text::ControlInterface, public Text::ScrollerInterface
49 {
50 public:
51
52   /**
53    * @copydoc Dali::Toollkit::TextLabel::New()
54    */
55   static Toolkit::TextLabel New();
56
57   // Properties
58
59   /**
60    * @brief Called when a property of an object of this type is set.
61    *
62    * @param[in] object The object whose property is set.
63    * @param[in] index The property index.
64    * @param[in] value The new property value.
65    */
66   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
67
68   /**
69    * @brief Called to retrieve a property of an object of this type.
70    *
71    * @param[in] object The object whose property is to be retrieved.
72    * @param[in] index The property index.
73    * @return The current value of the property.
74    */
75   static Property::Value GetProperty( BaseObject* object, Property::Index index );
76
77 private: // From Control
78
79   /**
80    * @copydoc Control::OnInitialize()
81    */
82   virtual void OnInitialize() override ;
83
84   /**
85    * @copydoc Control::OnStyleChange()
86    */
87   virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) override ;
88
89   /**
90    * @copydoc Control::OnRelayout()
91    */
92   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) override ;
93
94   /**
95    * @copydoc Control::GetNaturalSize()
96    */
97   virtual Vector3 GetNaturalSize() override ;
98
99   /**
100    * @copydoc Control::GetHeightForWidth()
101    */
102   virtual float GetHeightForWidth( float width ) override ;
103
104   /**
105    * @copydoc Control::OnPropertySet()
106    */
107   virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) override ;
108
109   // From ControlInterface
110
111   /**
112    * @copydoc Text::ControlInterface::RequestTextRelayout()
113    */
114   virtual void RequestTextRelayout() override ;
115
116 private: // from TextScroller
117
118   /**
119    * @copydoc Text::ScrollerInterface::ScrollingFinished()
120    */
121   virtual void ScrollingFinished();
122
123 private: // Implementation
124
125   /**
126    * Construct a new TextLabel.
127    */
128   TextLabel();
129
130   /**
131    * A reference counted object may only be deleted by calling Unreference()
132    */
133   virtual ~TextLabel();
134
135 private:
136
137   // Undefined copy constructor and assignment operators
138   TextLabel(const TextLabel&);
139   TextLabel& operator=(const TextLabel& rhs);
140
141   /**
142    * @brief Set up Autoscrolling
143    */
144   void SetUpAutoScrolling();
145
146 private: // Data
147
148   Text::ControllerPtr mController;
149   Text::TextScrollerPtr mTextScroller;
150
151   Toolkit::Visual::Base mVisual;
152
153   int mRenderingBackend;
154   bool mTextUpdateNeeded:1;
155 };
156
157 } // namespace Internal
158
159 // Helpers for public-api forwarding methods
160
161 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
162 {
163   DALI_ASSERT_ALWAYS(textLabel);
164
165   Dali::RefObject& handle = textLabel.GetImplementation();
166
167   return static_cast<Toolkit::Internal::TextLabel&>(handle);
168 }
169
170 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
171 {
172   DALI_ASSERT_ALWAYS(textLabel);
173
174   const Dali::RefObject& handle = textLabel.GetImplementation();
175
176   return static_cast<const Toolkit::Internal::TextLabel&>(handle);
177 }
178
179 } // namespace Toolkit
180
181 } // namespace Dali
182
183 #endif // DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H