X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Ftilt%2Ftilt-example.cpp;h=2ac324e54f7543b83baddc66c8e61867a6521e4c;hb=cc86309efaef5f77c85ece1199f95e08534e4a32;hp=0adc72e3ab0aaeed34dd224b72fdbba6e19b8bd9;hpb=661bf429a56def085e118b5c7a48ae48ee41c86e;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/tilt/tilt-example.cpp b/examples/tilt/tilt-example.cpp index 0adc72e..2ac324e 100644 --- a/examples/tilt/tilt-example.cpp +++ b/examples/tilt/tilt-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2017 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. @@ -46,25 +46,28 @@ public: stage.SetBackgroundColor( Color::BLUE); mTextLabel = TextLabel::New( "Tilt Sensor Demo" ); - mTextLabel.SetParentOrigin( ParentOrigin::CENTER ); - mTextLabel.SetAnchorPoint( AnchorPoint::CENTER ); + mTextLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + mTextLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); mTextLabel.SetProperty( TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); mTextLabel.SetProperty( TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); mTextLabel.SetProperty( TextLabel::Property::TEXT_COLOR, Color::WHITE ); mTextLabel.SetProperty( TextLabel::Property::POINT_SIZE, 15.0f ); - mTextLabel.SetName( "tiltLabel" ); + mTextLabel.SetProperty( Dali::Actor::Property::NAME, "tiltLabel" ); stage.Add( mTextLabel ); // Respond to a click anywhere on the stage stage.GetRootLayer().TouchSignal().Connect( this, &TiltController::OnTouch ); CreateSensor(); + + // Connect signals to allow Back and Escape to exit. + stage.KeyEventSignal().Connect( this, &TiltController::OnKeyEvent ); } void CreateSensor() { mTiltSensor = TiltSensor::Get(); - if ( mTiltSensor.Enable() ) + if ( mTiltSensor.Start() ) { // Get notifications when the device is tilted mTiltSensor.TiltedSignal().Connect( this, &TiltController::OnTilted ); @@ -88,14 +91,27 @@ public: mTextLabel.RotateBy(pitchRot);; } + /** + * @brief OnKeyEvent signal handler. + * @param[in] event The key event information + */ + void OnKeyEvent( const KeyEvent& event ) + { + if( event.state == KeyEvent::Down ) + { + if ( IsKey( event, Dali::DALI_KEY_ESCAPE ) || IsKey( event, Dali::DALI_KEY_BACK ) ) + { + mApplication.Quit(); + } + } + } + private: Application& mApplication; TiltSensor mTiltSensor; TextLabel mTextLabel; }; -// Entry point for Linux & Tizen applications -// int DALI_EXPORT_API main( int argc, char **argv ) { Application application = Application::New( &argc, &argv );