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>
23 #include <dali/public-api/common/stage.h>
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>
46 * @brief A control which renders a short text string.
48 class TextLabel : public Control, public Text::ControlInterface, public Text::ScrollerInterface
53 * @copydoc Dali::Toollkit::TextLabel::New()
55 static Toolkit::TextLabel New();
60 * @brief Called when a property of an object of this type is set.
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.
66 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
69 * @brief Called to retrieve a property of an object of this type.
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.
75 static Property::Value GetProperty( BaseObject* object, Property::Index index );
77 private: // From Control
80 * @copydoc Control::OnInitialize()
82 virtual void OnInitialize() override ;
85 * @copydoc Control::OnStyleChange()
87 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change ) override ;
90 * @copydoc Control::OnRelayout()
92 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container ) override ;
95 * @copydoc Control::GetNaturalSize()
97 virtual Vector3 GetNaturalSize() override ;
100 * @copydoc Control::GetHeightForWidth()
102 virtual float GetHeightForWidth( float width ) override ;
105 * @copydoc Control::OnPropertySet()
107 virtual void OnPropertySet( Property::Index index, Property::Value propertyValue ) override ;
109 // From ControlInterface
112 * @copydoc Text::ControlInterface::RequestTextRelayout()
114 virtual void RequestTextRelayout() override ;
116 private: // from TextScroller
119 * @copydoc Text::ScrollerInterface::ScrollingFinished()
121 virtual void ScrollingFinished();
123 private: // Implementation
126 * Construct a new TextLabel.
131 * A reference counted object may only be deleted by calling Unreference()
133 virtual ~TextLabel();
137 // Undefined copy constructor and assignment operators
138 TextLabel(const TextLabel&);
139 TextLabel& operator=(const TextLabel& rhs);
142 * @brief Set up Autoscrolling
144 void SetUpAutoScrolling();
148 Text::ControllerPtr mController;
149 Text::TextScrollerPtr mTextScroller;
151 Toolkit::Visual::Base mVisual;
153 int mRenderingBackend;
154 bool mTextUpdateNeeded:1;
157 } // namespace Internal
159 // Helpers for public-api forwarding methods
161 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
163 DALI_ASSERT_ALWAYS(textLabel);
165 Dali::RefObject& handle = textLabel.GetImplementation();
167 return static_cast<Toolkit::Internal::TextLabel&>(handle);
170 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
172 DALI_ASSERT_ALWAYS(textLabel);
174 const Dali::RefObject& handle = textLabel.GetImplementation();
176 return static_cast<const Toolkit::Internal::TextLabel&>(handle);
179 } // namespace Toolkit
183 #endif // DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H