License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / text-input / text-input-popup-new-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_POPUP_NEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_POPUP_NEW_H__
3
4 /*
5  * Copyright (c) 2014 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/dali.h>
23
24 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
25 #include <dali-toolkit/public-api/controls/buttons/button.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 /**
37  * @brief Class to create and Popup bar made up of buttons.
38  * It provides signals when a button is pressed.
39  * The Popup must be positioned by it's owner.
40  * The future plan is to reuse the Toolkit Popup control to house the buttons.
41  */
42
43 class TextInputPopupNew : public ConnectionTracker
44 {
45
46 public:
47
48   enum State
49   {
50     StateHidden,
51     StateHiding,
52     StateShowing,
53     StateShown
54   };
55
56   // Signal names
57   static const char* const SIGNAL_PRESSED;
58   static const char* const SIGNAL_HIDE_FINISHED;
59   static const char* const SIGNAL_SHOW_FINISHED;
60
61   // Popup Button Pressed
62   typedef SignalV2< bool( Toolkit::Button ) > PopUpPressedSignal;
63
64   // Popup Hide Finished
65   typedef SignalV2< void( TextInputPopupNew& ) > PopUpHideFinishedSignal;
66
67   // Popup Show Finished
68   typedef SignalV2< void( TextInputPopupNew& ) > PopUpShowFinishedSignal;
69
70   /**
71    * Signal emitted when the button is touched.
72    */
73   PopUpPressedSignal& PressedSignal() { return mPressedSignal; }
74
75   /**
76    * Signal emitted when popup is completely hidden
77    * @note Only occurs after a Show() call with animation enabled.
78    */
79   PopUpHideFinishedSignal& HideFinishedSignal() {return mHideFinishedSignal;}
80
81   /**
82    * Signal emitted when popup is completely shown
83    * @note Only occurs after a Hide() call with animation enabled.
84    */
85   PopUpShowFinishedSignal& ShowFinishedSignal() {return mShowFinishedSignal;}
86
87 public:
88
89   /**
90    * Default constructor
91    * Creates an empty popup base actor (no content i.e. invisible)
92    */
93   TextInputPopupNew(){};
94
95   /**
96    * Destructor
97    */
98   ~TextInputPopupNew(){};
99
100   /**
101    * @return The root actor of for this popup is returned.
102    */
103   Actor Self() { return mRootActor; };
104
105   /**
106    * Clears popup options (popup no longer exists)
107    */
108   void Clear(){};
109
110   /**
111    * Create the label
112    * @param[in] styledCaption The text to be displayed
113    * @return the newly created label
114    */
115   Toolkit::TextView CreateLabel( const MarkupProcessor::StyledTextArray& styledCaption ){return Toolkit::TextView();};
116
117   /**
118    * Create the label
119    * @param[in] iconImage the image to be used
120    * @return the newly created Image actor to be used as the icon
121    */
122   ImageActor CreateIcon( Image iconImage ) {return ImageActor();};
123
124   /**
125    * Creates and sets up the popup background
126    */
127   void CreatePopUpBackground(){};
128
129   /**
130    * Create divider if multiple options
131    */
132   void CreateDivider(){};
133
134   /**
135    * Create a background to be used when button pressed
136    * @param[in] requiredSize size Image actor should be
137    * @param[in] finalFlag flag to be set if option is the final one.
138    * @return Returns an Image Actor to be used a pressed background
139    */
140   ImageActor CreatePressedBackground( const Vector3 requiredSize, const bool finalFlag ){ return ImageActor(); };
141
142   /**
143    * Adds a popup option button.
144    * @note Creates popup frame if not already created.
145    * @param[in] name The unique name for this option.
146    * @param[in] caption The caption (label) for this option
147    * @param[in] iconImage Image to displayed with text.
148    * @param[in] finalOption Flag to indicate that this is the final option.
149    * (set to true on the last option you add)
150    */
151   void AddButton(const std::string& name, const std::string& caption, const Image iconImage, bool finalOption ){};
152
153   /**
154    * Hides the popup
155    * @param[in] animate (optional) whether to animate popup to hide state over time (i.e. tween).
156    */
157   void Hide(bool animate = true){};
158
159   /**
160    * Shows the popup
161    * @param[in] animate (optional) whether to animate popup to show state over time (i.e. tween).
162    * @param[in] target Actor to parent popup.
163    */
164   void Show( Actor target, bool animate = true ){};
165
166   /**
167    * @brief Get the calculated size of the PopUp
168    * This can not be set directly as is calculated depending on the content added.
169    *
170    * @return Vector3 size of PopUp.
171    */
172   Vector3 GetSize() const { return Vector3::ZERO;};
173
174   /**
175    * Returns the current state of the popup.
176    * @return The state of the popup see enum State
177    */
178   State GetState(void) const{ return StateHidden;};
179
180   /**
181    * Get the root actor which the buttons are added to.
182    * @return the root actor
183    */
184   Actor GetRootActor() const { return Actor(); };
185
186   /**
187    * @brief Creates the PopUp with the required buttons for the provided states.
188    * @param[in] isAllTextSelectedAlready Is all the text already selected
189    * @param[in] isTextEmpty Contains some text
190    * @param[in] hasClipboardGotContent  Something to paste from clipboard
191    * @param[in] isSubsetOfTextAlreadySelected  Some but not all text is selected
192    */
193   void CreateCutCopyPastePopUp( bool isAllTextSelectedAlready, bool isTextEmpty, bool hasClipboardGotContent, bool isSubsetOfTextAlreadySelected ){};
194
195   /**
196    * @brief Applies constraint to keep Popup in view within the desired area.
197    * @param[in] bounding box in which the PopUp must remain.
198    *
199    */
200   void ApplyConfinementConstraint( Vector4 boundingBox ){};
201
202 private:
203
204   /**
205    * @brief Adds popup to the given parent
206    * @paran[in] parent target to add Popup to
207    */
208   void AddToParent( Actor parent ){};
209
210   /**
211    * Removes popup from Parent.
212    */
213   void RemoveFromStage(){};
214
215   /**
216    * Called when a button is pressed in the popup
217    * @param[in] button The button pressed.
218    */
219   bool OnButtonPressed( Toolkit::Button button ){return false;};
220
221   /**
222    * Invoked upon popup Hide animation completing.
223    * @note Only called for animating hide, not called for instantaneous (animate = false)
224    * @param[in] source The animation which completed.
225    */
226   void OnHideFinished(Animation& source){};
227
228   /**
229    * Invoked upon popup Show animation completing.
230    * @note Only called for animating show, not called for instantaneous (animate = false)
231    * @param[in] source The animation which completed.
232    */
233   void OnShowFinished(Animation& source);
234
235 private:
236
237   /**
238    * @brief Copy Constructor
239    * @param[in] popup
240    * Undefined/Hidden.
241    */
242   TextInputPopupNew(const TextInputPopupNew& popup );
243
244   /**
245    * @Assignment Constructor
246    * @param[in] rhs
247    * Undefined/Hidden.
248    */
249   TextInputPopupNew& operator=(const TextInputPopupNew& rhs);
250
251 private:
252
253   State mState;                                       // Popup State.
254   Actor mRootActor;                                   // The actor which all popup content is added to (i.e. panel and buttons)
255   Vector3 mPopupSize;                                 // Size of the PopUp determined by it's content and max/min size constraints.
256   ImageActor mBackground;                             // The background popup panel
257   ImageActor mTail;                                   // The tail for the popup
258   Vector3 mContentSize;                               // Size of Content (i.e. Buttons)
259   ActorContainer mButtonContainer;                    // List of buttons added to popup.
260   ActorContainer mDividerContainer;                   // List of dividers added to popup.
261   Animation mAnimation;                               // Popup Hide/Show animation.
262
263   PopUpPressedSignal mPressedSignal;                     // Signal emitted when a button within the popup is pressed.
264   PopUpHideFinishedSignal mHideFinishedSignal;           // Signal emitted when popup is completely hidden
265   PopUpShowFinishedSignal mShowFinishedSignal;           // Signal emitted when popup is completely shown
266
267 };
268
269 } // namespace Internal
270
271 } // namespace Toolkit
272
273 } // namespace Dali
274
275 #endif // __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_POPUP_NEW_H__