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