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