1 #ifndef DALI_DEMO_TABLEVIEW_H
2 #define DALI_DEMO_TABLEVIEW_H
5 * Copyright (c) 2021 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
39 * @param application A reference to the application class
41 DaliTableView(Dali::Application& application);
46 ~DaliTableView() = default;
50 * Adds an Example to our demo showcase
52 * @param[in] example The Example description.
54 * @note Should be called before the Application MainLoop is started.
56 void AddExample(Example example);
59 * Sorts the example list alphabetically by Title if parameter is true.
61 * @param[in] sortAlphabetically If true, example list is sorted alphabetically.
63 * @note Should be called before the Application MainLoop is started.
64 * @note By default the examples are NOT sorted alphabetically by Title.
66 void SortAlphabetically(bool sortAlphabetically);
68 private: // Application callbacks & implementation
69 static constexpr unsigned int FOCUS_ANIMATION_ACTOR_NUMBER = 2; ///< The number of elements used to form the custom focus effect
72 * Initialize application.
74 * @param[in] app Application instance
76 void Initialize(Dali::Application& app);
79 * Populates the contents (ScrollView) with all the
80 * Examples that have been Added using the AddExample(...)
86 * Creates a tile for the main menu.
88 * @param[in] name The unique name for this Tile
89 * @param[in] title The text caption that appears on the Tile
90 * @param[in] parentSize Tile's parent size.
91 * @param[in] position The tiles relative position within a page
93 * @return The Actor for the created tile.
95 Dali::Actor CreateTile(const std::string& name, const std::string& title, const Dali::Vector3& sizeMultiplier, Dali::Vector2& position);
100 * Signal emitted when any tile has been pressed
102 * @param[in] actor The Actor representing this tile.
103 * @param[in] event The Touch information.
105 * @return Consume flag
107 bool OnTilePressed(Dali::Actor actor, const Dali::TouchEvent& event);
110 * Called by OnTilePressed & Accessibility to do the appropriate action.
112 * @param[in] actor The Actor representing this tile.
113 * @param[in] state The Touch state
115 * @return Consume flag
117 bool DoTilePress(Dali::Actor actor, Dali::PointState::Type state);
120 * Signal emitted when any tile has been hovered
122 * @param[in] actor The Actor representing this tile.
123 * @param[in] event The HoverEvent
125 * @return Consume flag
127 bool OnTileHovered(Dali::Actor actor, const Dali::HoverEvent& event);
130 * Signal emitted when the pressed animation has completed.
132 * @param[in] source The animation source.
134 void OnPressedAnimationFinished(Dali::Animation& source);
137 * Signal emitted when scrolling has started.
139 * @param[in] position The current position of the scroll contents.
141 void OnScrollStart(const Dali::Vector2& position);
144 * Signal emitted when scrolling has completed.
146 * @param[in] position The current position of the scroll contents.
148 void OnScrollComplete(const Dali::Vector2& position);
151 * Signal emitted when any Sensitive Actor has been touched
152 * (other than those touches consumed by OnTilePressed)
154 * @param[in] actor The Actor touched.
155 * @param[in] event The Touch information.
157 * @return Consume flag
159 bool OnScrollTouched(Dali::Actor actor, const Dali::TouchEvent& event);
162 * Setup the effect on the scroll view
164 void ApplyScrollViewEffect();
167 * Apply the cube effect to all the page actors
169 void ApplyCubeEffectToPages();
174 void OnKeyEvent(const Dali::KeyEvent& event);
177 * @brief Creates and sets up the custom effect used for the keyboard (and mouse) focus.
179 void CreateFocusEffect();
182 * Callback when the keyboard focus is going to be changed.
184 * @param[in] current The current focused actor
185 * @param[in] proposed The actor proposed by the keyboard focus manager to move the focus to
186 * @param[in] direction The direction to move the focus
187 * @return The actor to move the keyboard focus to.
189 Dali::Actor OnKeyboardPreFocusChange(Dali::Actor current, Dali::Actor proposed, Dali::Toolkit::Control::KeyboardFocus::Direction direction);
192 * Callback when the keyboard focused actor is activated.
194 * @param[in] activatedActor The activated actor
196 void OnFocusedActorActivated(Dali::Actor activatedActor);
199 * Callback when the keyboard focus indicator is enabled.
201 * @param[in] actor The keyboard focus indicator.
203 void OnFocusIndicatorEnabled(Dali::Actor actor);
206 * Callback when the keyboard focus indicator is disabled.
208 * @param[in] actor The keyboard focus indicator.
210 void OnFocusIndicatorDisabled(Dali::Actor actor);
213 * Called when the logo is tapped
215 * @param[in] actor The tapped actor
216 * @param[in] tap The tap information.
218 void OnLogoTapped(Dali::Actor actor, const Dali::TapGesture& tap);
221 Dali::Application& mApplication; ///< Application instance.
222 Dali::Actor mRootActor; ///< All content (excluding background is anchored to this Actor)
223 Dali::Animation mPressedAnimation; ///< Button press scaling animation.
224 Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples)
225 Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view
226 Dali::Actor mPressedActor; ///< The currently pressed actor.
227 Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo
228 Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information
229 BubbleAnimator mBubbleAnimator; ///< Provides bubble animations.
232 * This struct encapsulates all data relevant to each of the elements used within the custom keyboard focus effect.
236 Dali::Toolkit::ImageView actor; ///< The parent keyboard focus highlight actor
237 Dali::Animation animation; ///< The animation for the parent keyboard focus highlight actor
239 FocusEffect mFocusEffect[FOCUS_ANIMATION_ACTOR_NUMBER]; ///< The elements used to create the custom focus effect
241 std::vector<Dali::Actor> mPages; ///< List of pages.
242 ExampleList mExampleList; ///< List of examples.
244 float mPageWidth; ///< The width of a page within the scroll-view, used to calculate the domain
245 int mTotalPages; ///< Total pages within scrollview.
247 bool mScrolling : 1; ///< Flag indicating whether view is currently being scrolled
248 bool mSortAlphabetically : 1; ///< Sort examples alphabetically.
251 #endif // DALI_DEMO_TABLEVIEW_H