X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fcontact-cards%2Fcontact-cards-example.cpp;h=e856900dc3a7ebe9cf6a8f8bc0cbd7d20055d61c;hb=1b19fd140ff139b5854a1a62447faf31b175d8f6;hp=d9c4d579e2af1e5d77f36178b8ae3c51b0ecbfec;hpb=0646a5db2ded58d48c6cf3d2ca8ba60fc84d4821;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/contact-cards/contact-cards-example.cpp b/examples/contact-cards/contact-cards-example.cpp index d9c4d57..e856900 100644 --- a/examples/contact-cards/contact-cards-example.cpp +++ b/examples/contact-cards/contact-cards-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,22 +16,23 @@ */ // EXTERNAL INCLUDES -#include +#include #include #include -#include #include +#include // INTERNAL INCLUDES #include "contact-card-layouter.h" #include "contact-data.h" using namespace Dali; +using namespace Dali::Toolkit; namespace { -const Vector4 STAGE_COLOR( 211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f ); ///< The color of the stage -const char * const THEME_PATH( DEMO_STYLE_DIR "contact-cards-example-theme.json" ); ///< The theme used for this example +const Vector4 WINDOW_COLOR(211.0f / 255.0f, 211.0f / 255.0f, 211.0f / 255.0f, 1.0f); ///< The color of the window +const char* const THEME_PATH(DEMO_STYLE_DIR "contact-cards-example-theme.json"); ///< The theme used for this example } // unnamed namespace /** @@ -41,7 +42,7 @@ const char * const THEME_PATH( DEMO_STYLE_DIR "contact-cards-example-theme.json" * Additionally, this also shows how to morph between two different geometries. * * ContactCardLayouter: This class is used to lay out the different contact cards on the screen. - * This takes stage size into account but does not support relayouting. + * This takes window size into account but does not support relayouting. * ContactCard: This class represents each contact card on the screen. * Two animations are set up in this class which animate several properties with multiple start and stop times. * An overview of the two animations can be found in contact-card.cpp. @@ -51,42 +52,39 @@ const char * const THEME_PATH( DEMO_STYLE_DIR "contact-cards-example-theme.json" * This clipping comes in the form of a Circle or Quad. * The Vertex shader mixes in the Circle and Quad geometry depending on the value of a uniform float. * Animating this float between CIRCLE_GEOMETRY and QUAD_GEOMETRY is what enables the morphing between the two geometries. + * MaskedImage: This namespace provides a helper function which creates an ImageView with a mask that matches the Circle geometry provided by ClippedImage. + * Using a mask yields much better quality than when using an image with a circle geometry, so this is ONLY used when the contact card is folded. */ class ContactCardController : public ConnectionTracker // Inherit from ConnectionTracker so that our signals can be automatically disconnected upon our destruction. { public: - /** * @brief Constructor. * @param[in] application A reference to the Application class. */ - ContactCardController( Application& application ) - : mApplication( application ) + ContactCardController(Application& application) + : mApplication(application) { // Connect to the Application's Init signal - mApplication.InitSignal().Connect( this, &ContactCardController::Create ); + mApplication.InitSignal().Connect(this, &ContactCardController::Create); } private: - /** * @brief Called to initialise the application content * @param[in] application A reference to the Application class. */ - void Create( Application& application ) + void Create(Application& application) { - // Hide the indicator bar - application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); - - // Set the stage background color and connect to the stage's key signal to allow Back and Escape to exit. - Stage stage = Stage::GetCurrent(); - stage.SetBackgroundColor( STAGE_COLOR ); - stage.KeyEventSignal().Connect( this, &ContactCardController::OnKeyEvent ); + // Set the window background color and connect to the window's key signal to allow Back and Escape to exit. + Window window = application.GetWindow(); + window.SetBackgroundColor(WINDOW_COLOR); + window.KeyEventSignal().Connect(this, &ContactCardController::OnKeyEvent); // Add all the contacts to the layouter - for( size_t i = 0; i < ContactData::TABLE_SIZE; ++i ) + for(size_t i = 0; i < ContactData::TABLE_SIZE; ++i) { - mContactCardLayouter.AddContact( ContactData::TABLE[ i ].name, ContactData::TABLE[ i ].address, ContactData::TABLE[ i ].imagePath ); + mContactCardLayouter.AddContact(window, ContactData::TABLE[i].name, ContactData::TABLE[i].address, ContactData::TABLE[i].imagePath); } } @@ -96,25 +94,29 @@ private: * Will use this to quit the application if Back or the Escape key is received * @param[in] event The key event information */ - void OnKeyEvent( const KeyEvent& event ) + void OnKeyEvent(const KeyEvent& event) { - if( event.state == KeyEvent::Down ) + if(event.GetState() == KeyEvent::DOWN) { - if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + KeyInputFocusManager keyInputFocusManager = KeyInputFocusManager::Get(); + if(!keyInputFocusManager.GetCurrentFocusControl()) // Don't quit if a control has focus { - mApplication.Quit(); + if(IsKey(event, Dali::DALI_KEY_ESCAPE) || IsKey(event, Dali::DALI_KEY_BACK)) + { + mApplication.Quit(); + } } } } - Application& mApplication; ///< Reference to the application class. + Application& mApplication; ///< Reference to the application class. ContactCardLayouter mContactCardLayouter; ///< The contact card layouter. }; -int DALI_EXPORT_API main( int argc, char **argv ) +int DALI_EXPORT_API main(int argc, char** argv) { - Application application = Application::New( &argc, &argv, THEME_PATH ); - ContactCardController contactCardController( application ); + Application application = Application::New(&argc, &argv, THEME_PATH); + ContactCardController contactCardController(application); application.MainLoop(); return 0; }