5 * Copyright (c) 2016 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/events/tap-gesture-detector.h>
25 #include <dali/public-api/object/ref-object.h>
26 #include <dali-toolkit/public-api/controls/control.h>
28 class ContactCardLayoutInfo;
31 * @brief Creates and sets up animations for a contact card
33 * Each contact card has two states, folded and unfolded.
34 * In this context, "unfolded" means when all the details, including the name, address and image are shown.
35 * In this scenario, the control takes up most of the screen.
37 * When the contact card is "folded", this means when only brief information is shown to the user, i.e. the image and name.
38 * In this scenario, the control is small and there should be several of these contact cards visible on the screen.
40 * The contact card creates several controls that it requires to appropriately display itself in both of these states.
42 class ContactCard : public Dali::RefObject
49 * This will create all the controls and add them to the stage so should only be called after the init-signal from the Application has been received.
51 * @param[in] contactCardLayoutInfo Reference to the common data used by all contact cards.
52 * @param[in] contactName The name of the contact to display.
53 * @param[in] contactAddress The address of the contact to display.
54 * @param[in] imagePath The path to the image to display.
55 * @param[in] position The unique folded position of this particular contact-card.
57 ContactCard( const ContactCardLayoutInfo& contactCardLayoutInfo, const std::string& contactName, const std::string& contactAddress, const std::string& imagePath, const Dali::Vector2& position );
62 * @brief Private Destructor. Will only be deleted when ref-count goes to 0.
64 * Unparent the created contact card (i.e. remove from stage).
69 * @brief Called when this contact card is tapped.
70 * @param[in] actor The tapped actor.
71 * @param[in] gesture The tap gesture.
73 void OnTap( Dali::Actor actor, const Dali::TapGesture& gesture );
76 * @brief Called when the animation finishes.
77 * @param[in] animation The animation which has just finished.
79 void OnAnimationFinished( Dali::Animation& animation );
81 Dali::TapGestureDetector mTapDetector; ///< Used for tap detection.
82 Dali::Toolkit::Control mContactCard; ///< Used for the background and to clip the contents.
83 Dali::Toolkit::Control mHeader; ///< Header shown when unfolded.
84 Dali::Toolkit::Control mClippedImage; ///< The image representing the contact (whose clipping can be animated).
85 Dali::Toolkit::Control mNameText; ///< The text shown when folded.
86 Dali::Toolkit::Control mDetailText; ///< The text shown when unfolded.
88 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.
90 const ContactCardLayoutInfo& mContactCardLayoutInfo; ///< Reference to the common data used by all contact cards.
91 const Dali::Vector2 foldedPosition; ///< The unique position of this card when it is folded.
92 Dali::Property::Index mClippedImagePropertyIndex; ///< Index used to animate the clipping of mClippedImage.
93 bool mFolded; ///< Whether the contact card is folded or not.
96 #endif // CONTACT_CARD_H