/*
- * 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.
#include <vector>
#include <dali/public-api/adaptor-framework/application.h>
#include <dali/public-api/adaptor-framework/key.h>
-#include <dali/public-api/common/stage.h>
#include <dali/public-api/events/key-event.h>
+#include <dali-toolkit/devel-api/focus-manager/keyinput-focus-manager.h>
// 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 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
* 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.
* 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.
{
*/
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 )
{
- 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 );
}
}
*/
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();
+ }
}
}
}