Add 'ExclusiveArch: armv7l' limit build to arm architecture
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / text-input / text-input-popup-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_POPUP_H__
2 #define __DALI_TOOLKIT_INTERNAL_TEXT_INPUT_POPUP_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/dali.h>
22
23 #include <dali-toolkit/public-api/controls/text-view/text-view.h>
24
25 namespace Dali
26 {
27
28 namespace Toolkit
29 {
30
31 class Button;
32
33 namespace Internal
34 {
35
36 class TextInputPopup : public ConnectionTracker
37 {
38
39 public:
40
41   enum State
42   {
43     StateHidden,
44     StateHiding,
45     StateShowing,
46     StateShown
47   };
48
49   // Signal names
50   static const char* const SIGNAL_PRESSED;
51   static const char* const SIGNAL_HIDE_FINISHED;
52   static const char* const SIGNAL_SHOW_FINISHED;
53
54   // Popup Button Pressed
55   typedef SignalV2< bool( Toolkit::Button ) > PressedSignalV2;
56
57   // Popup Hide Finished
58   typedef SignalV2< void( TextInputPopup& ) > HideFinishedSignalV2;
59
60   // Popup Show Finished
61   typedef SignalV2< void( TextInputPopup& ) > ShowFinishedSignalV2;
62
63   /**
64    * Signal emitted when the button is touched.
65    */
66   PressedSignalV2& PressedSignal();
67
68   /**
69    * Signal emitted when popup is completely hidden
70    * @note Only occurs after a Show() call with animation enabled.
71    */
72   HideFinishedSignalV2& HideFinishedSignal();
73
74   /**
75    * Signal emitted when popup is completely shown
76    * @note Only occurs after a Hide() call with animation enabled.
77    */
78   ShowFinishedSignalV2& ShowFinishedSignal();
79
80 public:
81
82   /**
83    * Default constructor
84    * Creates an empty popup base actor (no content i.e. invisible)
85    */
86   TextInputPopup();
87
88   /**
89    * @return The root actor of for this popup is returned.
90    */
91   Actor Self();
92
93   /**
94    * Clears popup options (popup no longer exists)
95    */
96   void Clear();
97
98   /**
99    * Create the label
100    * @param[in] styledCaption The text to be displayed
101    * @return the newly created label
102    */
103   Toolkit::TextView CreateOptionText( const MarkupProcessor::StyledTextArray& styledCaption );
104
105   /**
106    * Create the label
107    * @param[in] iconImage the image to be used
108    * @return the newly created Image actor to be used as the icon
109    */
110   ImageActor CreateOptionIcon( Image iconImage );
111
112   /**
113    * Creates and sets up the popup background
114    */
115   void CreatePopUpBackground();
116
117   /**
118    * Create divider if multiple options
119    */
120   void CreateDivider();
121
122   /**
123    * Create a background to be used when button pressed
124    * @param[in] requiredSize size Image actor should be
125    * @param[in] finalFlag flag to be set if option is the final one.
126    * @return Returns an Image Actor to be used a pressed background
127    */
128   ImageActor CreatePressedBackground( const Vector3 requiredSize, const bool finalFlag );
129
130   /**
131    * Adds a popup option.
132    * @note Creates popup frame if not already created.
133    * @param[in] name The unique name for this option.
134    * @param[in] caption The caption (label) for this option
135    * @param[in] iconImage Image to displayed with text.
136    * @param[in] finalOption Flag to indicate that this is the final option.
137    * (set to true on the last option you add)
138    */
139   void AddOption(const std::string& name, const std::string& caption, const Image iconImage, bool finalOption);
140
141   /**
142    * Hides the popup
143    * @param[in] animate (optional) whether to animate popup to hide state over time (i.e. tween).
144    */
145   void Hide(bool animate = true);
146
147   /**
148    * Shows the popup
149    * @param[in] animate (optional) whether to animate popup to show state over time (i.e. tween).
150    */
151   void Show(bool animate = true);
152
153   /**
154    * Sets Alternative offset property.
155    * The alternative offset property is how much to move in the horizontal and vertical
156    * axes when the popup goes out of the screen on the left/right sides or top/bottom sides.
157    * @param[in] offset Vector holding the left/right offset (x) and top/bottom offset (y)
158    */
159   void SetAlternativeOffset(Vector2 offset);
160
161   /**
162    * Returns the current state of the popup.
163    * @return The state of the popup see enum State
164    */
165   State GetState(void) const;
166
167   /**
168    * Get the root actor which the buttons are added to.
169    * @return the root actor
170    */
171   Actor GetRootActor() const;
172
173 private:
174
175   /**
176    * Adds popup to the stage (ideally on a separate top-most layer and as an overlay)
177    */
178   void AddToStage();
179
180   /**
181    * Applies constraint to keep Popup in view within the desired area.
182    */
183   void ApplyConfinementConstraint();
184
185   /**
186    * Removes popup from the stage.
187    */
188   void RemoveFromStage();
189
190   /**
191    * Called when a button is pressed in the popup
192    * @param[in] button The button pressed.
193    */
194   bool OnButtonPressed( Toolkit::Button button );
195
196   /**
197    * Invoked upon popup Hide animation completing.
198    * @note Only called for animating hide, not called for instantaneous (animate = false)
199    * @param[in] source The animation which completed.
200    */
201   void OnHideFinished(Animation& source);
202
203   /**
204    * Invoked upon popup Show animation completing.
205    * @note Only called for animating show, not called for instantaneous (animate = false)
206    * @param[in] source The animation which completed.
207    */
208   void OnShowFinished(Animation& source);
209
210 private:
211
212   State mState;                                       ///< Popup State.
213   Actor mRootActor;                                   ///< The actor which all popup content is added to (i.e. panel and buttons)
214   Property::Index mAlternativeOffsetProperty;         ///< Property [Vector3] how much to offset the popup if it goes out of the screen
215   ImageActor mBackground;                             ///< The background popup panel
216   ImageActor mTail;                                   ///< The tail for the popup
217   Vector3 mContentSize;                               ///< Size of Content (i.e. Buttons)
218   ActorContainer mButtonContainer;                    ///< List of buttons added to popup.
219   ActorContainer mDividerContainer;                   ///< List of dividers added to popup.
220   Animation mAnimation;                               ///< Popup Hide/Show animation.
221
222   PressedSignalV2 mPressedSignal;              ///< Signal emitted when a button within the popup is pressed.
223   HideFinishedSignalV2 mHideFinishedSignal;    ///< Signal emitted when popup is completely hidden
224   ShowFinishedSignalV2 mShowFinishedSignal;    ///< Signal emitted when popup is completely shown
225
226 };
227
228 } // namespace Internal
229
230 } // namespace Toolkit
231
232 } // namespace Dali
233
234 #endif // __DALI_TOOLKIT_INTERNAL_ITEM_VIEW_H__