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-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-control-interface.h>
25 #include <dali-toolkit/internal/text/text-controller.h>
26 #include <dali-toolkit/internal/text/text-scroller-interface.h>
27 #include <dali-toolkit/internal/text/rendering/text-renderer.h>
28 #include <dali-toolkit/internal/text/text-scroller.h>
40 * @brief A control which renders a short text string.
42 class TextLabel : public Control, public Text::ControlInterface, public Text::ScrollerInterface
47 * @copydoc Dali::Toollkit::TextLabel::New()
49 static Toolkit::TextLabel New();
54 * @brief Called when a property of an object of this type is set.
56 * @param[in] object The object whose property is set.
57 * @param[in] index The property index.
58 * @param[in] value The new property value.
60 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
63 * @brief Called to retrieve a property of an object of this type.
65 * @param[in] object The object whose property is to be retrieved.
66 * @param[in] index The property index.
67 * @return The current value of the property.
69 static Property::Value GetProperty( BaseObject* object, Property::Index index );
71 private: // From Control
74 * @copydoc Control::OnInitialize()
76 virtual void OnInitialize();
79 * @copydoc Control::OnStyleChange()
81 virtual void OnStyleChange( Toolkit::StyleManager styleManager, StyleChange::Type change );
84 * @copydoc Control::OnRelayout()
86 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
89 * @copydoc Control::GetNaturalSize()
91 virtual Vector3 GetNaturalSize();
94 * @copydoc Control::GetHeightForWidth()
96 virtual float GetHeightForWidth( float width );
98 // From ControlInterface
101 * @copydoc Text::ControlInterface::RequestTextRelayout()
103 virtual void RequestTextRelayout();
105 private: // from TextScroller
108 * @copydoc Text::ScrollerInterface::ScrollingFinished()
110 virtual void ScrollingFinished();
112 private: // Implementation
115 * Construct a new TextLabel.
120 * A reference counted object may only be deleted by calling Unreference()
122 virtual ~TextLabel();
126 // Undefined copy constructor and assignment operators
127 TextLabel(const TextLabel&);
128 TextLabel& operator=(const TextLabel& rhs);
130 // Connection needed to re-render text, when a Text Label returns to the stage
131 void OnStageConnect( Dali::Actor actor );
134 * @brief Render view, create and attach actor(s) to this Text Label
139 * @brief Set up Autoscrolling
141 void SetUpAutoScrolling();
145 Text::ControllerPtr mController;
146 Text::RendererPtr mRenderer;
147 Text::TextScrollerPtr mTextScroller;
148 Actor mRenderableActor;
149 int mRenderingBackend;
150 bool mHasBeenStaged:1;
153 } // namespace Internal
155 // Helpers for public-api forwarding methods
157 inline Toolkit::Internal::TextLabel& GetImpl( Toolkit::TextLabel& textLabel )
159 DALI_ASSERT_ALWAYS(textLabel);
161 Dali::RefObject& handle = textLabel.GetImplementation();
163 return static_cast<Toolkit::Internal::TextLabel&>(handle);
166 inline const Toolkit::Internal::TextLabel& GetImpl( const Toolkit::TextLabel& textLabel )
168 DALI_ASSERT_ALWAYS(textLabel);
170 const Dali::RefObject& handle = textLabel.GetImplementation();
172 return static_cast<const Toolkit::Internal::TextLabel&>(handle);
175 } // namespace Toolkit
179 #endif // DALI_TOOLKIT_INTERNAL_TEXT_LABEL_H