1 #ifndef DALI_DEMO_TABLEVIEW_H
2 #define DALI_DEMO_TABLEVIEW_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali-toolkit/dali-toolkit.h>
23 #include <dali-toolkit/devel-api/controls/popup/popup.h>
24 #include <dali/dali.h>
27 #include "bubble-animator.h"
33 class DaliTableView : public Dali::ConnectionTracker
40 * @param application A reference to the application class
42 DaliTableView(Dali::Application& application);
47 ~DaliTableView() = default;
51 * Adds an Example to our demo showcase
53 * @param[in] example The Example description.
55 * @note Should be called before the Application MainLoop is started.
57 void AddExample(Example example);
60 * Sorts the example list alphabetically by Title if parameter is true.
62 * @param[in] sortAlphabetically If true, example list is sorted alphabetically.
64 * @note Should be called before the Application MainLoop is started.
65 * @note By default the examples are NOT sorted alphabetically by Title.
67 void SortAlphabetically(bool sortAlphabetically);
69 private: // Application callbacks & implementation
70 static constexpr unsigned int FOCUS_ANIMATION_ACTOR_NUMBER = 2; ///< The number of elements used to form the custom focus effect
73 * Initialize application.
75 * @param[in] app Application instance
77 void Initialize(Dali::Application& app);
80 * Populates the contents (ScrollView) with all the
81 * Examples that have been Added using the AddExample(...)
87 * Creates a tile for the main menu.
89 * @param[in] name The unique name for this Tile
90 * @param[in] title The text caption that appears on the Tile
91 * @param[in] parentSize Tile's parent size.
92 * @param[in] position The tiles relative position within a page
94 * @return The Actor for the created tile.
96 Dali::Actor CreateTile(const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, Dali::Vector2& position);
101 * Signal emitted when any tile has been pressed
103 * @param[in] actor The Actor representing this tile.
104 * @param[in] event The Touch information.
106 * @return Consume flag
108 bool OnTilePressed(Dali::Actor actor, const Dali::TouchEvent& event);
111 * Called by OnTilePressed & Accessibility to do the appropriate action.
113 * @param[in] actor The Actor representing this tile.
114 * @param[in] state The Touch state
116 * @return Consume flag
118 bool DoTilePress(Dali::Actor actor, Dali::PointState::Type state);
121 * Signal emitted when any tile has been hovered
123 * @param[in] actor The Actor representing this tile.
124 * @param[in] event The HoverEvent
126 * @return Consume flag
128 bool OnTileHovered(Dali::Actor actor, const Dali::HoverEvent& event);
131 * Signal emitted when the pressed animation has completed.
133 * @param[in] source The animation source.
135 void OnPressedAnimationFinished(Dali::Animation& source);
138 * Signal emitted when scrolling has started.
140 * @param[in] position The current position of the scroll contents.
142 void OnScrollStart(const Dali::Vector2& position);
145 * Signal emitted when scrolling has completed.
147 * @param[in] position The current position of the scroll contents.
149 void OnScrollComplete(const Dali::Vector2& position);
152 * Signal emitted when any Sensitive Actor has been touched
153 * (other than those touches consumed by OnTilePressed)
155 * @param[in] actor The Actor touched.
156 * @param[in] event The Touch information.
158 * @return Consume flag
160 bool OnScrollTouched(Dali::Actor actor, const Dali::TouchEvent& event);
163 * Setup the effect on the scroll view
165 void ApplyScrollViewEffect();
168 * Apply the cube effect to all the page actors
170 void ApplyCubeEffectToPages();
175 void OnKeyEvent(const Dali::KeyEvent& event);
178 * @brief Creates and sets up the custom effect used for the keyboard (and mouse) focus.
180 void CreateFocusEffect();
183 * Callback when the keyboard focus is going to be changed.
185 * @param[in] current The current focused actor
186 * @param[in] proposed The actor proposed by the keyboard focus manager to move the focus to
187 * @param[in] direction The direction to move the focus
188 * @return The actor to move the keyboard focus to.
190 Dali::Actor OnKeyboardPreFocusChange(Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction);
193 * Callback when the keyboard focused actor is activated.
195 * @param[in] activatedActor The activated actor
197 void OnFocusedActorActivated(Dali::Actor activatedActor);
200 * Callback when the keyboard focus indicator is enabled.
202 * @param[in] actor The keyboard focus indicator.
204 void OnFocusIndicatorEnabled(Dali::Actor actor);
207 * Callback when the keyboard focus indicator is disabled.
209 * @param[in] actor The keyboard focus indicator.
211 void OnFocusIndicatorDisabled(Dali::Actor actor);
214 * Called when the logo is tapped
216 * @param[in] actor The tapped actor
217 * @param[in] tap The tap information.
219 void OnLogoTapped(Dali::Actor actor, const Dali::TapGesture& tap);
222 Dali::Application& mApplication; ///< Application instance.
223 Dali::Actor mRootActor; ///< All content (excluding background is anchored to this Actor)
224 Dali::Animation mPressedAnimation; ///< Button press scaling animation.
225 Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples)
226 Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view
227 Dali::Actor mPressedActor; ///< The currently pressed actor.
228 Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo
229 Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information
230 BubbleAnimator mBubbleAnimator; ///< Provides bubble animations.
233 * This struct encapsulates all data relevant to each of the elements used within the custom keyboard focus effect.
237 Dali::Toolkit::ImageView actor; ///< The parent keyboard focus highlight actor
238 Dali::Animation animation; ///< The animation for the parent keyboard focus highlight actor
240 FocusEffect mFocusEffect[FOCUS_ANIMATION_ACTOR_NUMBER]; ///< The elements used to create the custom focus effect
242 std::vector<Dali::Actor> mPages; ///< List of pages.
243 ExampleList mExampleList; ///< List of examples.
245 float mPageWidth; ///< The width of a page within the scroll-view, used to calculate the domain
246 int mTotalPages; ///< Total pages within scrollview.
248 bool mScrolling : 1; ///< Flag indicating whether view is currently being scrolled
249 bool mSortAlphabetically : 1; ///< Sort examples alphabetically.
252 #endif // DALI_DEMO_TABLEVIEW_H