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