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.
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/adaptor-framework/window.h>
25 #include <dali/public-api/animation/animation.h>
26 #include <dali/public-api/events/tap-gesture-detector.h>
27 #include <dali/public-api/object/ref-object.h>
28 #include <dali-toolkit/public-api/controls/control.h>
30 struct ContactCardLayoutInfo;
33 * @brief Creates and sets up animations for a contact card
35 * Each contact card has two states, folded and unfolded.
36 * In this context, "unfolded" means when all the details, including the name, address and image are shown.
37 * In this scenario, the control takes up most of the screen.
39 * When the contact card is "folded", this means when only brief information is shown to the user, i.e. the image and name.
40 * In this scenario, the control is small and there should be several of these contact cards visible on the screen.
42 * The contact card creates several controls that it requires to appropriately display itself in both of these states.
44 class ContactCard : public Dali::RefObject
51 * This will create all the controls and add them to the window so should only be called after the init-signal from the Application has been received.
53 * @param[in] window The window to add the contact card to.
54 * @param[in] contactCardLayoutInfo Reference to the common data used by all contact cards.
55 * @param[in] contactName The name of the contact to display.
56 * @param[in] contactAddress The address of the contact to display.
57 * @param[in] imagePath The path to the image to display.
58 * @param[in] position The unique folded position of this particular contact-card.
60 ContactCard( Dali::Window window, const ContactCardLayoutInfo& contactCardLayoutInfo, const std::string& contactName, const std::string& contactAddress, const std::string& imagePath, const Dali::Vector2& position );
65 * @brief Private Destructor. Will only be deleted when ref-count goes to 0.
67 * Unparent the created contact card (i.e. remove from window).
72 * @brief Called when this contact card is tapped.
73 * @param[in] actor The tapped actor.
74 * @param[in] gesture The tap gesture.
76 void OnTap( Dali::Actor actor, const Dali::TapGesture& gesture );
79 * @brief Animates the fold/unfold animation as required.
84 * @brief Called when the animation finishes.
85 * @param[in] animation The animation which has just finished.
87 void OnAnimationFinished( Dali::Animation& animation );
90 * @brief Called when any key event is received
92 * Will use this to fold a contact card if it is unfolded.
93 * @param[in] event The key event information
95 void OnKeyEvent( const Dali::KeyEvent& event );
97 Dali::TapGestureDetector mTapDetector; ///< Used for tap detection.
98 Dali::Toolkit::Control mContactCard; ///< Used for the background and to clip the contents.
99 Dali::Toolkit::Control mHeader; ///< Header shown when unfolded.
100 Dali::Toolkit::Control mClippedImage; ///< The image representing the contact (whose clipping can be animated).
101 Dali::Toolkit::Control mMaskedImage; ///< The image with a mask (better quality around the edges than the clipped image when folded).
102 Dali::Toolkit::Control mNameText; ///< The text shown when folded.
103 Dali::Toolkit::Control mDetailText; ///< The text shown when unfolded.
105 Dali::Animation mAnimation; ///< The fold/unfold animation.
107 Dali::SlotDelegate< ContactCard > mSlotDelegate; ///< Used to automatically disconnect our member functions from signals that this class connects to upon destruction. Can be used instead of inheriting from ConnectionTracker.
109 const ContactCardLayoutInfo& mContactCardLayoutInfo; ///< Reference to the common data used by all contact cards.
110 const Dali::Vector2 foldedPosition; ///< The unique position of this card when it is folded.
111 Dali::Property::Index mClippedImagePropertyIndex; ///< Index used to animate the clipping of mClippedImage.
112 bool mFolded; ///< Whether the contact card is folded or not.
115 #endif // CONTACT_CARD_H