1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_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/table-view/table-view.h>
24 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h>
28 #include <dali/public-api/actors/image-actor.h>
29 #include <dali/public-api/actors/layer.h>
43 enum PopupCustomisations
54 class TextSelectionPopup : public Control
69 struct ButtonRequirement
80 ButtonRequirement( Buttons buttonId,
81 std::size_t buttonPriority,
82 const std::string& buttonName,
83 const std::string& buttonCaption,
84 Dali::Image& buttonIcon,
87 priority( buttonPriority ),
89 caption( buttonCaption ),
91 enabled( buttonEnabled )
102 struct ButtonPriorityCompare
104 bool operator()( const ButtonRequirement& lhs, const ButtonRequirement& rhs ) const {
105 return lhs.priority < rhs.priority;
110 * @copydoc Dali::Toollkit::TextSelectionPopup::New()
112 static Toolkit::TextSelectionPopup New();
117 * @brief Called when a property of an object of this type is set.
118 * @param[in] object The object whose property is set.
119 * @param[in] index The property index.
120 * @param[in] value The new property value.
122 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
125 * @brief Called to retrieve a property of an object of this type.
127 * @param[in] object The object whose property is to be retrieved.
128 * @param[in] index The property index.
129 * @return The current value of the property.
131 static Property::Value GetProperty( BaseObject* object, Property::Index index );
133 private: // From Control
136 * @copydoc Control::OnInitialize()
138 virtual void OnInitialize();
140 private: // Implementation
143 * @brief Method to set the dimension or dimension constraint on certain aspects of the Popup.
145 * @param[in] settingToCustomise The setting for the PopupCustomisations enum that can be customised
146 * @param[in] dimension The size to customise with
148 void SetDimensionToCustomise( const PopupCustomisations& settingToCustomise, const Size& dimension );
151 * @brief Method to get the dimension or dimension constraint on certain aspects of the Popup that was previously customised
153 * @param[in] setting The setting from the PopupCustomisations enum
155 Size GetDimensionToCustomise( const PopupCustomisations& setting );
158 * @brief Sets the image for the given button of the Popup.
160 * @param[in] button The button the image should be used for from the Buttons Enum.
161 * @param[in] image The image to use.
163 void SetButtonImage( Buttons button, Dali::Image image );
166 * @brief Retrieves the image of the given button used by the popup
168 * @param[in] button The button to get the image from
169 * @return The image used for that button.
171 Dali::Image GetButtonImage( Buttons button );
173 void CreateOrderedListOfPopupOptions();
175 void AddOption( const std::string& name, const std::string& caption, const Image iconImage, bool showDivider, bool showIcons, bool showCaption );
177 std::size_t GetNumberOfEnabledOptions();
179 void AddPopupOptionsToToolbar( bool showIcons, bool showCaptions );
184 * Construct a new TextField.
186 TextSelectionPopup();
189 * A reference counted object may only be deleted by calling Unreference()
191 virtual ~TextSelectionPopup();
195 // Undefined copy constructor and assignment operators
196 TextSelectionPopup(const TextSelectionPopup&);
197 TextSelectionPopup& operator=(const TextSelectionPopup& rhs);
202 Dali::Toolkit::TextSelectionToolbar mToolbar;
204 Dali::Toolkit::TableView mTableOfButtons; // Actor which holds all the buttons, sensitivity can be set on buttons via this actor
206 // Images to be used by the Popup buttons
208 Image mCopyIconImage;
209 Image mPasteIconImage;
210 Image mClipboardIconImage;
211 Image mSelectIconImage;
212 Image mSelectAllIconImage;
214 Size mMaxSize; // Maximum size of the Popup
215 Size mMinSize; // Minimum size of the Popup
217 Size mOptionMaxSize; // Maximum size of an Option button
218 Size mOptionMinSize; // Minimum size of an Option button
219 Size mOptionDividerSize; // Size of divider line
221 std::vector<ButtonRequirement> mOrderListOfButtons; // List of buttons in the order to be displayed and a flag to indicate if needed.
223 Vector4 mLineColor; // Color of the line around the text input popup
224 Vector4 mIconColor; // Color of the popup icon.
225 Vector4 mIconPressedColor; // Color of the popup icon when pressed.
227 // Priority of Options/Buttons in the Cut and Paste pop-up, higher priority buttons are displayed first, left to right.
228 std::size_t mSelectOptionPriority; // Position of Select Button
229 std::size_t mSelectAllOptionPriority; // Position of Select All button
230 std::size_t mCutOptionPriority; // Position of Cut button
231 std::size_t mCopyOptionPriority; // Position of Copy button
232 std::size_t mPasteOptionPriority; // Position of Paste button
233 std::size_t mClipboardOptionPriority; // Position of Clipboard button
235 bool mShowIcons; // Flag to show icons
236 bool mShowCaptions; // Flag to show text captions
240 } // namespace Internal
242 // Helpers for public-api forwarding methods
244 inline Toolkit::Internal::TextSelectionPopup& GetImpl( Toolkit::TextSelectionPopup& textSelectionPopup )
246 DALI_ASSERT_ALWAYS( textSelectionPopup );
248 Dali::RefObject& handle = textSelectionPopup.GetImplementation();
250 return static_cast<Toolkit::Internal::TextSelectionPopup&>(handle);
253 inline const Toolkit::Internal::TextSelectionPopup& GetImpl( const Toolkit::TextSelectionPopup& textSelectionPopup )
255 DALI_ASSERT_ALWAYS( textSelectionPopup );
257 const Dali::RefObject& handle = textSelectionPopup.GetImplementation();
259 return static_cast<const Toolkit::Internal::TextSelectionPopup&>(handle);
262 } // namespace Toolkit
266 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_POPUP_H__