1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_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/scrollable/scroll-view/scroll-view.h>
24 #include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
25 #include <dali-toolkit/public-api/controls/table-view/table-view.h>
26 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h>
29 #include <dali/public-api/actors/layer.h>
40 class TextSelectionToolbar : public Control
45 * @copydoc Dali::Toollkit::TextSelectionToolbar::New()
47 static Toolkit::TextSelectionToolbar New();
52 * @brief Called when a property of an object of this type is set.
53 * @param[in] object The object whose property is set.
54 * @param[in] index The property index.
55 * @param[in] value The new property value.
57 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
60 * @brief Called to retrieve a property of an object of this type.
62 * @param[in] object The object whose property is to be retrieved.
63 * @param[in] index The property index.
64 * @return The current value of the property.
66 static Property::Value GetProperty( BaseObject* object, Property::Index index );
69 * @copydoc Toolkit::TextSelectionToolbar::AddOption()
71 void AddOption( Actor& option );
74 * @copydoc Toolkit::TextSelectionToolbar::AddDivider()
76 void AddDivider( Actor& divider );
79 * @copydoc Toolkit::TextSelectionToolbar::ResizeDividers()
81 void ResizeDividers( Size& size );
84 * @copydoc Toolkit::TextSelectionToolbar::RaiseAbove()
86 void RaiseAbove( Layer target );
89 * Sets the scroll bar padding.
91 * @param[in] padding The padding value.
93 void SetScrollBarPadding( const Vector2& padding );
96 * @return The padding value.
98 const Vector2& GetScrollBarPadding() const;
101 * @copydoc Toolkit::TextSelectionToolbar::ScrollTo()
103 void ScrollTo( const Vector2& position );
105 private: // From Control
108 * @copydoc Control::OnInitialize()
110 virtual void OnInitialize();
113 * @copydoc Control::OnRelayout()
115 virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
118 * @brief Set max size of Popup
119 * @param[in] maxSize Size (Vector2)
121 void SetPopupMaxSize( const Size& maxSize );
124 * @brief Get Max size of Popup
125 * @return Vector2 the max size of the Popup
127 const Dali::Vector2& GetPopupMaxSize() const;
129 private: // Implementation
132 * @copydoc Toolkit::TextSelectionToolbar::ConfigureScrollview()
134 void ConfigureScrollview( const Property::Map& properties );
137 * @brief Set up scrollview to scroll Toolbar horizontally
139 void SetUpScrollView();
142 * @brief Set up the parts that make the Toolbar
147 * @brief Enable or disable the scroll-bar
149 * @param[in] enable True if the scroll-bar is required
151 void SetUpScrollBar( bool enable );
154 * Toolbar has started to scroll
155 * @param[in] position current scroll view position
157 void OnScrollStarted( const Vector2& position );
160 * Toolbar has stopped scrolling
161 * @param[in] position current scroll view position
163 void OnScrollCompleted( const Vector2& position );
166 * Construct a new TextField.
168 TextSelectionToolbar();
171 * A reference counted object may only be deleted by calling Unreference()
173 virtual ~TextSelectionToolbar();
177 // Undefined copy constructor and assignment operators
178 TextSelectionToolbar(const TextSelectionToolbar&);
179 TextSelectionToolbar& operator=(const TextSelectionToolbar& rhs);
183 Layer mToolbarLayer; ///< The layer used to house the toolbar.
184 Toolkit::TableView mTableOfButtons; ///< Actor which holds all the buttons, sensitivity can be set on buttons via this actor
185 Toolkit::ScrollView mScrollView; ///< Provides scrolling of Toolbar when content does not fit.
186 Toolkit::ScrollBar mScrollBar; ///< An horizontal scroll bar for the text's popup options.
187 RulerPtr mRulerX; ///< Ruler to clamp horizontal scrolling. Updates on Relayout
188 Size mMaxSize; ///< Max size of the Toolbar
189 Vector2 mScrollBarPadding; ///< The padding used to position the scroll indicator.
190 unsigned int mIndexInTable; ///< Index in table to add option
191 Dali::Vector< unsigned int > mDividerIndexes; ///< Vector of indexes in the Toolbar that contain dividers.
192 bool mFirstScrollEnd; ///< Used for RTL mirroring. Avoids the overshoot to be shown the first time the popup is shown.
195 } // namespace Internal
197 // Helpers for public-api forwarding methods
199 inline Toolkit::Internal::TextSelectionToolbar& GetImpl( Toolkit::TextSelectionToolbar& textSelectionToolbar )
201 DALI_ASSERT_ALWAYS( textSelectionToolbar );
203 Dali::RefObject& handle = textSelectionToolbar.GetImplementation();
205 return static_cast<Toolkit::Internal::TextSelectionToolbar&>(handle);
208 inline const Toolkit::Internal::TextSelectionToolbar& GetImpl( const Toolkit::TextSelectionToolbar& textSelectionToolbar )
210 DALI_ASSERT_ALWAYS( textSelectionToolbar );
212 const Dali::RefObject& handle = textSelectionToolbar.GetImplementation();
214 return static_cast<const Toolkit::Internal::TextSelectionToolbar&>(handle);
217 } // namespace Toolkit
221 #endif // DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H