Fix compile errors on MS-Windows.
[platform/core/uifw/dali-demo.git] / examples / contact-cards / contact-card.h
1 #ifndef CONTACT_CARD_H
2 #define CONTACT_CARD_H
3
4 /*
5  * Copyright (c) 2018 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 // EXTERNAL INCLUDES
22 #include <string>
23 #include <dali/public-api/actors/actor.h>
24 #include <dali/public-api/animation/animation.h>
25 #include <dali/public-api/events/tap-gesture-detector.h>
26 #include <dali/public-api/object/ref-object.h>
27 #include <dali-toolkit/public-api/controls/control.h>
28
29 struct ContactCardLayoutInfo;
30
31 /**
32  * @brief Creates and sets up animations for a contact card
33  *
34  * Each contact card has two states, folded and unfolded.
35  * In this context, "unfolded" means when all the details, including the name, address and image are shown.
36  * In this scenario, the control takes up most of the screen.
37  *
38  * When the contact card is "folded", this means when only brief information is shown to the user, i.e. the image and name.
39  * In this scenario, the control is small and there should be several of these contact cards visible on the screen.
40  *
41  * The contact card creates several controls that it requires to appropriately display itself in both of these states.
42  */
43 class ContactCard : public Dali::RefObject
44 {
45 public:
46
47   /**
48    * @brief Constructor.
49    *
50    * 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    *
52    * @param[in]  contactCardLayoutInfo  Reference to the common data used by all contact cards.
53    * @param[in]  contactName            The name of the contact to display.
54    * @param[in]  contactAddress         The address of the contact to display.
55    * @param[in]  imagePath              The path to the image to display.
56    * @param[in]  position               The unique folded position of this particular contact-card.
57    */
58   ContactCard( const ContactCardLayoutInfo& contactCardLayoutInfo, const std::string& contactName, const std::string& contactAddress, const std::string& imagePath, const Dali::Vector2& position );
59
60 private:
61
62   /**
63    * @brief Private Destructor. Will only be deleted when ref-count goes to 0.
64    *
65    * Unparent the created contact card (i.e. remove from stage).
66    */
67   ~ContactCard();
68
69   /**
70    * @brief Called when this contact card is tapped.
71    * @param[in]  actor    The tapped actor.
72    * @param[in]  gesture  The tap gesture.
73    */
74   void OnTap( Dali::Actor actor, const Dali::TapGesture& gesture );
75
76   /**
77    * @brief Animates the fold/unfold animation as required.
78    */
79   void Animate();
80
81   /**
82    * @brief Called when the animation finishes.
83    * @param[in]  animation  The animation which has just finished.
84    */
85   void OnAnimationFinished( Dali::Animation& animation );
86
87   /**
88    * @brief Called when any key event is received
89    *
90    * Will use this to fold a contact card if it is unfolded.
91    * @param[in]  event  The key event information
92    */
93   void OnKeyEvent( const Dali::KeyEvent& event );
94
95   Dali::TapGestureDetector mTapDetector; ///< Used for tap detection.
96   Dali::Toolkit::Control mContactCard; ///< Used for the background and to clip the contents.
97   Dali::Toolkit::Control mHeader; ///< Header shown when unfolded.
98   Dali::Toolkit::Control mClippedImage; ///< The image representing the contact (whose clipping can be animated).
99   Dali::Toolkit::Control mMaskedImage; ///< The image with a mask (better quality around the edges than the clipped image when folded).
100   Dali::Toolkit::Control mNameText; ///< The text shown when folded.
101   Dali::Toolkit::Control mDetailText; ///< The text shown when unfolded.
102
103   Dali::Animation mAnimation; ///< The fold/unfold animation.
104
105   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.
106
107   const ContactCardLayoutInfo& mContactCardLayoutInfo; ///< Reference to the common data used by all contact cards.
108   const Dali::Vector2 foldedPosition; ///< The unique position of this card when it is folded.
109   Dali::Property::Index mClippedImagePropertyIndex; ///< Index used to animate the clipping of mClippedImage.
110   bool mFolded; ///< Whether the contact card is folded or not.
111 };
112
113 #endif // CONTACT_CARD_H