1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__
5 * Copyright (c) 2015 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-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/public-api/controls/text-controls/text-label.h>
24 #include <dali-toolkit/internal/text/text-controller.h>
25 #include <dali-toolkit/internal/text/text-scroller-interface.h>
26 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
27 #include <dali-toolkit/internal/text/text-scroller.h>
39 * @brief A control which renders a short text string.
41 class TextLabel : public Control, public Text::ControlInterface, public Text::ScrollerInterface
46 * @copydoc Dali::Toollkit::TextLabel::New()
48 static Toolkit::TextLabel New();
53 * @brief Called when a property of an object of this type is set.
55 * @param[in] object The object whose property is set.
56 * @param[in] index The property index.
57 * @param[in] value The new property value.
59 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
62 * @brief Called to retrieve a property of an object of this type.
64 * @param[in] object The object whose property is to be retrieved.
65 * @param[in] index The property index.
66 * @return The current value of the property.
68 static Property::Value GetProperty( BaseObject* object, Property::Index index );
70 private: // From Control
73 * @copydoc Control::OnInitialize()
75 virtual void OnInitialize();
78 * @copydoc Control::OnStyleChange()
80 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
83 * @copydoc Control::OnRelayout()
85 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
88 * @copydoc Control::GetNaturalSize()
90 virtual Vector3 GetNaturalSize();
93 * @copydoc Control::GetHeightForWidth()
95 virtual float GetHeightForWidth( float width );
98 * @copydoc Text::ControlInterface::AddDecoration()
100 virtual void AddDecoration( Actor& actor, bool needsClipping );
103 * @copydoc Control::OnStageConnection()
105 virtual void OnStageConnection( int depth );
108 * @copydoc Text::ControlInterface::RequestTextRelayout()
110 virtual void RequestTextRelayout();
113 * @copydoc Text::ControlInterface::TextChanged()
115 virtual void TextChanged();
118 * @copydoc Text::ControlInterface::MaxLengthReached()
120 virtual void MaxLengthReached();
122 private: // from TextScroller
125 * @copydoc Text::ScrollerInterface::ScrollingFinished()
127 virtual void ScrollingFinished();
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);
147 // Connection needed to re-render text, when a Text Label returns to the stage
148 void OnStageConnect( Dali::Actor actor );
151 * @brief Render view, create and attach actor(s) to this Text Label
156 * @brief Set up Autoscrolling
158 void SetUpAutoScrolling();
162 Text::ControllerPtr mController;
163 Text::RendererPtr mRenderer;
164 Text::TextScrollerPtr mTextScroller;
165 Actor mRenderableActor;
166 int mRenderingBackend;
167 bool mHasBeenStaged:1;
170 } // namespace Internal
172 // Helpers for public-api forwarding methods
174 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
176 DALI_ASSERT_ALWAYS(textLabel);
178 Dali::RefObject& handle = textLabel.GetImplementation();
180 return static_cast<Toolkit::Internal::TextLabel&>(handle);
183 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
185 DALI_ASSERT_ALWAYS(textLabel);
187 const Dali::RefObject& handle = textLabel.GetImplementation();
189 return static_cast<const Toolkit::Internal::TextLabel&>(handle);
192 } // namespace Toolkit
196 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H__