46e633b66a73dce60f5373c82d133f4a18b4bfac
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-controls / text-selection-toolbar-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H
2 #define DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
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/table-view/table-view.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-toolbar.h>
26
27 // EXTERNAL INCLUDES
28 #include <dali/public-api/actors/layer.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38
39 class TextSelectionToolbar : public Control
40 {
41 public:
42
43   /**
44    * @copydoc Dali::Toollkit::TextSelectionToolbar::New()
45    */
46   static Toolkit::TextSelectionToolbar New();
47
48   // Properties
49
50   /**
51    * @brief Called when a property of an object of this type is set.
52    * @param[in] object The object whose property is set.
53    * @param[in] index The property index.
54    * @param[in] value The new property value.
55    */
56   static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
57
58   /**
59    * @brief Called to retrieve a property of an object of this type.
60    *
61    * @param[in] object The object whose property is to be retrieved.
62    * @param[in] index The property index.
63    * @return The current value of the property.
64    */
65   static Property::Value GetProperty( BaseObject* object, Property::Index index );
66
67   /**
68    *  @copydoc Toolkit::TextSelectionToolbar::AddOption()
69    */
70   void AddOption( Actor& option );
71
72   /**
73    *  @copydoc Toolkit::TextSelectionToolbar::AddDivider()
74    */
75   void AddDivider( Actor& divider );
76
77   /**
78    * @copydoc Toolkit::TextSelectionToolbar::ResizeDividers()
79    */
80   void ResizeDividers( Size& size );
81
82   /**
83    * @copydoc Toolkit::TextSelectionToolbar::RaiseAbove()
84    */
85   void RaiseAbove( Layer target );
86
87 private: // From Control
88
89   /**
90    * @copydoc Control::OnInitialize()
91    */
92   virtual void OnInitialize();
93
94   /**
95   * @copydoc Control::OnRelayout()
96   */
97   virtual void OnRelayout( const Vector2& size, RelayoutContainer& container );
98
99   /**
100    * @copydoc Control::OnStageConnection()
101    */
102   virtual void OnStageConnection( int depth );
103
104   /**
105    * @brief Set max size of Popup
106    * @param[in] maxSize Size (Vector2)
107    */
108   void SetPopupMaxSize( const Size& maxSize );
109
110   /**
111    * @brief Get Max size of Popup
112    * @return Vector2 the max size of the Popup
113    */
114   const Dali::Vector2& GetPopupMaxSize() const;
115
116 private: // Implementation
117
118   /**
119    * @copydoc Toolkit::TextSelectionToolbar::ConfigureScrollview()
120    */
121   void ConfigureScrollview( const Property::Map& properties );
122
123   /**
124    * @brief Set up scrollview to scroll Toolbar horizontally
125    */
126   void SetUpScrollView();
127
128   /**
129    * @brief Set up the parts that make the Toolbar
130    */
131   void SetUp();
132
133   /**
134    * Toolbar has started to scroll
135    * @param[in] position current scroll view position
136    */
137   void OnScrollStarted( const Vector2& position );
138
139   /**
140    * Toolbar has stopped scrolling
141    * @param[in] position current scroll view position
142    */
143   void OnScrollCompleted( const Vector2& position );
144
145   /**
146    * Construct a new TextField.
147    */
148   TextSelectionToolbar();
149
150   /**
151    * A reference counted object may only be deleted by calling Unreference()
152    */
153   virtual ~TextSelectionToolbar();
154
155 private:
156
157   // Undefined copy constructor and assignment operators
158   TextSelectionToolbar(const TextSelectionToolbar&);
159   TextSelectionToolbar& operator=(const TextSelectionToolbar& rhs);
160
161 private: // Data
162
163   Layer mToolbarLayer;                                ///< The layer used to house the toolbar.
164   Toolkit::TableView mTableOfButtons;                 ///< Actor which holds all the buttons, sensitivity can be set on buttons via this actor
165   Toolkit::ScrollView mScrollView;                    ///< Provides scrolling of Toolbar when content does not fit.
166   RulerPtr mRulerX;                                   ///< Ruler to clamp horizontal scrolling. Updates on Relayout
167   Size mMaxSize;                                      ///< Max size of the Toolbar
168   unsigned int mIndexInTable;                         ///< Index in table to add option
169   Dali::Vector< unsigned int > mDividerIndexes;       ///< Vector of indexes in the Toolbar that contain dividers.
170
171 };
172
173 } // namespace Internal
174
175 // Helpers for public-api forwarding methods
176
177 inline Toolkit::Internal::TextSelectionToolbar& GetImpl( Toolkit::TextSelectionToolbar& textSelectionToolbar )
178 {
179   DALI_ASSERT_ALWAYS( textSelectionToolbar );
180
181   Dali::RefObject& handle = textSelectionToolbar.GetImplementation();
182
183   return static_cast<Toolkit::Internal::TextSelectionToolbar&>(handle);
184 }
185
186 inline const Toolkit::Internal::TextSelectionToolbar& GetImpl( const Toolkit::TextSelectionToolbar& textSelectionToolbar )
187 {
188   DALI_ASSERT_ALWAYS( textSelectionToolbar );
189
190   const Dali::RefObject& handle = textSelectionToolbar.GetImplementation();
191
192   return static_cast<const Toolkit::Internal::TextSelectionToolbar&>(handle);
193 }
194
195 } // namespace Toolkit
196
197 } // namespace Dali
198
199 #endif // DALI_TOOLKIT_INTERNAL_TEXT_SELECTION_TOOLBAR_H