[3.0] Remove bubble-effect from dali demo main screen
[platform/core/uifw/dali-demo.git] / demo / dali-table-view.h
1 #ifndef DALI_DEMO_H
2 #define DALI_DEMO_H
3
4 /*
5  * Copyright (c) 2016 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 #include <dali/dali.h>
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/controls/popup/popup.h>
24
25 class Example;
26
27 typedef std::vector<Example> ExampleList;
28 typedef ExampleList::iterator ExampleListIter;
29 typedef ExampleList::const_iterator ExampleListConstIter;
30
31 typedef std::vector<Dali::Animation> AnimationList;
32 typedef AnimationList::iterator AnimationListIter;
33 typedef AnimationList::const_iterator AnimationListConstIter;
34
35
36 /**
37  * Example information
38  *
39  * Represents a single Example.
40  */
41 struct Example
42 {
43   // Constructors
44
45   /**
46    * @param[in] name unique name of example
47    * @param[in] title The caption for the example to appear on a tile button.
48    */
49   Example(std::string name, std::string title)
50   : name(name),
51     title(title)
52   {
53   }
54
55   Example()
56   {
57   }
58
59   // Data
60
61   std::string name;                       ///< unique name of example
62   std::string title;                      ///< title (caption) of example to appear on tile button.
63 };
64
65
66
67 /**
68  * Dali-Demo instance
69  */
70 class DaliTableView : public Dali::ConnectionTracker
71 {
72 public:
73
74   DaliTableView(Dali::Application& application);
75   ~DaliTableView();
76
77 public:
78
79   /**
80    * Adds an Example to our demo showcase
81    *
82    * @param[in] example The Example description.
83    *
84    * @note Should be called before the Application MainLoop is started.
85    */
86   void AddExample(Example example);
87
88   /**
89    * Sorts the example list alphabetically by Title if parameter is true.
90    *
91    * @param[in] sortAlphabetically If true, example list is sorted alphabetically.
92    *
93    * @note Should be called before the Application MainLoop is started.
94    * @note By default the examples are NOT sorted alphabetically by Title.
95    */
96   void SortAlphabetically( bool sortAlphabetically );
97
98 private: // Application callbacks & implementation
99
100   /**
101    * Initialize application.
102    *
103    * @param[in] app Application instance
104    */
105   void Initialize( Dali::Application& app );
106
107   /**
108    * Populates the contents (ScrollView) with all the
109    * Examples that have been Added using the AddExample(...)
110    * call
111    */
112   void Populate();
113
114   /**
115    * Rotate callback from the device.
116    *
117    * @param[in] orientation that device notified.
118    */
119   void OrientationChanged( Dali::Orientation orientation );
120
121   /**
122    * Rotates RootActor orientation to that specified.
123    *
124    * @param[in] degrees The requested angle.
125    */
126   void Rotate( unsigned int degrees );
127
128   /**
129    * Creates a tile for the main menu and toolbar.
130    *
131    * @param[in] name The unique name for this Tile
132    * @param[in] title The text caption that appears on the Tile
133    * @param[in] parentSize Tile's parent size.
134    * @param[in] color The color (including alpha) of the tiles contents.
135    *
136    * @return The Actor for the created tile.
137    */
138   Dali::Actor CreateTile( const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, const Dali::Vector4& color );
139
140   // Signal handlers
141
142   /**
143    * Signal emitted when any tile has been pressed
144    *
145    * @param[in] actor The Actor representing this tile.
146    * @param[in] event The Touch information.
147    *
148    * @return Consume flag
149    */
150   bool OnTilePressed( Dali::Actor actor, const Dali::TouchData& event );
151
152   /**
153    * Called by OnTilePressed & Accessibility to do the appropriate action.
154    *
155    * @param[in] actor The Actor representing this tile.
156    * @param[in] state The Touch state
157    *
158    * @return Consume flag
159    */
160   bool DoTilePress( Dali::Actor actor, Dali::PointState::Type state );
161
162   /**
163    * Signal emitted when any tile has been hovered
164    *
165    * @param[in] actor The Actor representing this tile.
166    * @param[in] event The HoverEvent
167    *
168    * @return Consume flag
169    */
170   bool OnTileHovered( Dali::Actor actor, const Dali::HoverEvent& event );
171
172   /**
173    * Signal emitted when the pressed animation has completed.
174    *
175    * @param[in] source The animation source.
176    */
177   void OnPressedAnimationFinished(Dali::Animation& source);
178
179   /**
180    * Signal emitted when the button has been clicked
181    *
182    * @param[in] button The Button that is clicked.
183    *
184    * @return Consume flag
185    */
186   bool OnButtonClicked( Dali::Toolkit::Button& button );
187
188   /**
189    * Signal emitted when scrolling has started.
190    *
191    * @param[in] position The current position of the scroll contents.
192    */
193   void OnScrollStart(const Dali::Vector2& position);
194
195   /**
196    * Signal emitted when scrolling has completed.
197    *
198    * @param[in] position The current position of the scroll contents.
199    */
200   void OnScrollComplete(const Dali::Vector2& position);
201
202   /**
203    * Signal emitted when any Sensitive Actor has been touched
204    * (other than those touches consumed by OnTilePressed)
205    *
206    * @param[in] actor The Actor touched.
207    * @param[in] event The Touch information.
208    *
209    * @return Consume flag
210    */
211   bool OnScrollTouched( Dali::Actor actor, const Dali::TouchData& event );
212
213   /**
214    * Setup the effect on the scroll view
215    */
216   void ApplyScrollViewEffect();
217
218   /**
219    * Apply the cube effect to all the page actors
220    */
221   void ApplyCubeEffectToPages();
222
223   /**
224    * Setup the inner cube effect
225    */
226   void SetupInnerPageCubeEffect();
227
228   /**
229    * Apply a shader effect to a table tile
230    */
231   void ApplyEffectToTile(Dali::Actor tile);
232
233   /**
234    * Apply effect to the content of a tile
235    */
236   void ApplyEffectToTileContent(Dali::Actor tileContent);
237
238   /**
239    * Key event handler
240    */
241   void OnKeyEvent( const Dali::KeyEvent& event );
242
243   /**
244    * Creates the logo.
245    *
246    * @param[in] imagePath The path to the image file to load
247    *
248    * @return The created image actor
249    */
250   Dali::Toolkit::ImageView CreateLogo( std::string imagePath );
251
252   /**
253    * Callback when the keyboard focus is going to be changed.
254    *
255    * @param[in] current The current focused actor
256    * @param[in] proposed The actor proposed by the keyboard focus manager to move the focus to
257    * @param[in] direction The direction to move the focus
258    * @return The actor to move the keyboard focus to.
259    */
260   Dali::Actor OnKeyboardPreFocusChange( Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction );
261
262   /**
263    * Callback when the keyboard focused actor is activated.
264    *
265    * @param[in] activatedActor The activated actor
266    */
267   void OnFocusedActorActivated( Dali::Actor activatedActor );
268
269   /**
270    * Called when the logo is tapped
271    *
272    * @param[in]  actor  The tapped actor
273    * @param[in]  tap    The tap information.
274    */
275   void OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap );
276
277   /**
278    * Hides the popup
279    */
280   void HideVersionPopup();
281
282  /*
283   * @brief Callback called when the buttons page actor is relaid out
284   *
285   * @param[in] actor The page actor
286   */
287  void OnButtonsPageRelayout( const Dali::Actor& actor );
288
289 private:
290
291   Dali::Application&              mApplication;              ///< Application instance.
292   Dali::Layer                     mBackgroundLayer;          ///< Background resides on a separate layer.
293   Dali::Toolkit::TableView        mRootActor;                ///< All content (excluding background is anchored to this Actor)
294   Dali::Animation                 mRotateAnimation;          ///< Animation to rotate and resize mRootActor.
295   Dali::Animation                 mPressedAnimation;         ///< Button press scaling animation.
296   Dali::Layer                     mScrollViewLayer;          ///< ScrollView resides on a separate layer.
297   Dali::Toolkit::ScrollView       mScrollView;               ///< ScrollView container (for all Examples)
298   Dali::Toolkit::ScrollViewEffect mScrollViewEffect;         ///< Effect to be applied to the scroll view
299   Dali::Toolkit::RulerPtr         mScrollRulerX;             ///< ScrollView X (horizontal) ruler
300   Dali::Toolkit::RulerPtr         mScrollRulerY;             ///< ScrollView Y (vertical) ruler
301   Dali::Actor                     mPressedActor;             ///< The currently pressed actor.
302   Dali::TapGestureDetector        mLogoTapDetector;          ///< To detect taps on the logo
303   Dali::Toolkit::Popup            mVersionPopup;             ///< Displays DALi library version information
304
305   std::vector< Dali::Actor >      mPages;                    ///< List of pages.
306   ExampleList                     mExampleList;              ///< List of examples.
307
308   int                             mTotalPages;               ///< Total pages within scrollview.
309
310   bool                            mScrolling:1;              ///< Flag indicating whether view is currently being scrolled
311   bool                            mSortAlphabetically:1;     ///< Sort examples alphabetically.
312
313 };
314
315 #endif // DALI_DEMO_H