1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H
2 #define DALI_TOOLKIT_INTERNAL_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/public-api/object/property-map.h>
25 #include <dali-toolkit/public-api/controls/control-impl.h>
26 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
27 #include <dali-toolkit/internal/text/text-control-interface.h>
28 #include <dali-toolkit/internal/text/text-controller.h>
29 #include <dali-toolkit/internal/text/text-scroller-interface.h>
30 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
31 #include <dali-toolkit/internal/text/text-scroller.h>
32 #include <dali-toolkit/internal/visuals/text/text-visual.h>
45 * @brief A control which renders a short text string.
47 class TextLabel : public Control, public Text::ControlInterface, public Text::ScrollerInterface
52 * @copydoc Dali::Toollkit::TextLabel::New()
54 static Toolkit::TextLabel New();
59 * @brief Called when a property of an object of this type is set.
61 * @param[in] object The object whose property is set.
62 * @param[in] index The property index.
63 * @param[in] value The new property value.
65 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
68 * @brief Called to retrieve a property of an object of this type.
70 * @param[in] object The object whose property is to be retrieved.
71 * @param[in] index The property index.
72 * @return The current value of the property.
74 static Property::Value GetProperty( BaseObject* object, Property::Index index );
76 private: // From Control
79 * @copydoc Control::OnInitialize()
81 virtual void OnInitialize() override ;
84 * @copydoc Control::OnStyleChange()
86 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) override ;
89 * @copydoc Control::OnRelayout()
91 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) override ;
94 * @copydoc Control::GetNaturalSize()
96 virtual Vector3 GetNaturalSize() override ;
99 * @copydoc Control::GetHeightForWidth()
101 virtual float GetHeightForWidth( float width ) override ;
104 * @copydoc Control::OnPropertySet()
106 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) override ;
108 // From ControlInterface
111 * @copydoc Text::ControlInterface::RequestTextRelayout()
113 virtual void RequestTextRelayout() override ;
115 private: // from TextScroller
118 * @copydoc Text::ScrollerInterface::ScrollingFinished()
120 virtual void ScrollingFinished();
123 * @brief Callbacks when the layout direction changes
124 * @param[in] actor The actor whose layoutDirection is changed.
125 * @param[in] type The layoutDirection.
127 void OnLayoutDirectionChanged( Dali::Actor actor, Dali::LayoutDirection::Type type );
129 private: // Implementation
132 * Construct a new TextLabel.
137 * A reference counted object may only be deleted by calling Unreference()
139 virtual ~TextLabel();
143 // Undefined copy constructor and assignment operators
144 TextLabel(const TextLabel&);
145 TextLabel& operator=(const TextLabel& rhs);
148 * @brief Set up Autoscrolling
150 void SetUpAutoScrolling();
154 Text::ControllerPtr mController;
155 Text::TextScrollerPtr mTextScroller;
157 Toolkit::Visual::Base mVisual;
159 int mRenderingBackend;
160 bool mTextUpdateNeeded:1;
163 } // namespace Internal
165 // Helpers for public-api forwarding methods
167 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
169 DALI_ASSERT_ALWAYS(textLabel);
171 Dali::RefObject& handle = textLabel.GetImplementation();
173 return static_cast<Toolkit::Internal::TextLabel&>(handle);
176 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
178 DALI_ASSERT_ALWAYS(textLabel);
180 const Dali::RefObject& handle = textLabel.GetImplementation();
182 return static_cast<const Toolkit::Internal::TextLabel&>(handle);
185 } // namespace Toolkit
189 #endif // DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H