X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fpre-render-callback%2Fpre-render-callback-example.cpp;h=57b3bdb6d12f9eeae4771fe59902d8e1f68d968e;hb=c70446e9b125ae8bb236b4cbc3fd3f8b548459cd;hp=0b10a8c5ffe9b71c4e8068c7c8b77c30c534ff81;hpb=741614684efcc9abc662ac292e043b1b0723d29e;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/pre-render-callback/pre-render-callback-example.cpp b/examples/pre-render-callback/pre-render-callback-example.cpp index 0b10a8c..57b3bdb 100644 --- a/examples/pre-render-callback/pre-render-callback-example.cpp +++ b/examples/pre-render-callback/pre-render-callback-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 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. @@ -32,10 +32,10 @@ const float TEXT_HEIGHT = 40.0f; void AddText( Control textContainer, std::string text, unsigned int yIndex ) { auto label = TextLabel::New(text); - label.SetParentOrigin( ParentOrigin::TOP_CENTER ); - label.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - label.SetSize( 300,TEXT_HEIGHT ); - label.SetY( yIndex*TEXT_HEIGHT ); + label.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); + label.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + label.SetProperty( Actor::Property::SIZE, Vector2( 300,TEXT_HEIGHT ) ); + label.SetProperty( Actor::Property::POSITION_Y, yIndex*TEXT_HEIGHT ); textContainer.Add( label ); } @@ -49,7 +49,7 @@ public: */ PreRenderCallbackController ( Application& application ) : mApplication( application ), - mStage(), + mWindow(), mTapDetector(), mKeepPreRender(false), mRotateTextCharacter(0), @@ -89,22 +89,19 @@ private: */ void Create( Application& application ) { - mStage = Stage::GetCurrent(); - mStage.SetBackgroundColor( Color::WHITE ); - mStage.KeyEventSignal().Connect( this, &PreRenderCallbackController::OnKeyEvent ); - - // Hide the indicator bar. - mApplication.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); + mWindow = application.GetWindow(); + mWindow.SetBackgroundColor( Color::WHITE ); + mWindow.KeyEventSignal().Connect( this, &PreRenderCallbackController::OnKeyEvent ); // Detect taps on the root layer. mTapDetector = TapGestureDetector::New(); - mTapDetector.Attach( mStage.GetRootLayer() ); + mTapDetector.Attach( mWindow.GetRootLayer() ); mTapDetector.DetectedSignal().Connect( this, &PreRenderCallbackController::OnTap ); CreateAnimatingScene(); auto textContainer = Control::New(); - textContainer.SetAnchorPoint(AnchorPoint::TOP_LEFT); + textContainer.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::TOP_LEFT); AddText(textContainer, "Click to add callback", 1 ); AddText(textContainer, "Press 1 to add callback", 2 ); AddText(textContainer, "Press 2 to clear callback", 3 ); @@ -112,12 +109,12 @@ private: mSpinner = TextLabel::New(""); - mSpinner.SetAnchorPoint( AnchorPoint::TOP_LEFT ); - mSpinner.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mSpinner.SetSize(100,100); + mSpinner.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); + mSpinner.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + mSpinner.SetProperty( Actor::Property::SIZE, Vector2(100,100) ); - mStage.Add(mSpinner); - mStage.Add(textContainer); + mWindow.Add(mSpinner); + mWindow.Add(textContainer); DevelApplication::AddIdleWithReturnValue( application, MakeCallback( this, &PreRenderCallbackController::OnIdle ) ); } @@ -125,8 +122,8 @@ private: void CreateAnimatingScene() { mSceneActor = Layer::New(); - mSceneActor.SetBehavior( Layer::LAYER_3D ); - mSceneActor.SetParentOrigin(ParentOrigin::CENTER); + mSceneActor.SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D ); + mSceneActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); // Create and add images to the scene actor: mImageActor1 = ImageView::New( SCENE_IMAGE_1 ); @@ -137,13 +134,13 @@ private: mImageActor2.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); mImageActor3.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); - mImageActor2.SetParentOrigin(ParentOrigin::CENTER); + mImageActor2.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER); - mImageActor1.SetParentOrigin(ParentOrigin::CENTER_LEFT); - mImageActor1.SetAnchorPoint(AnchorPoint::CENTER_RIGHT); + mImageActor1.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER_LEFT); + mImageActor1.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER_RIGHT); - mImageActor3.SetParentOrigin(ParentOrigin::CENTER_RIGHT); - mImageActor3.SetAnchorPoint(AnchorPoint::CENTER_LEFT); + mImageActor3.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER_RIGHT); + mImageActor3.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER_LEFT); mSceneActor.Add(mImageActor2); mImageActor2.Add(mImageActor1); @@ -168,13 +165,13 @@ private: mSceneAnimation.SetLooping(true); mSceneAnimation.Play(); - mSceneActor.SetSize(250.0f, 250.0f); - mSceneActor.SetPosition(0.0f, 0.0f, 130.0f); + mSceneActor.SetProperty( Actor::Property::SIZE, Vector2(250.0f, 250.0f) ); + mSceneActor.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 130.0f ) ); Quaternion p( Degree( -6.0f ), Vector3::XAXIS ); Quaternion q( Degree( 20.0f ), Vector3::YAXIS ); - mSceneActor.SetOrientation( p * q ); + mSceneActor.SetProperty( Actor::Property::ORIENTATION, p * q ); - mStage.Add( mSceneActor ); + mWindow.Add( mSceneActor ); } void OnTap( Actor /* actor */, const TapGesture& /* tap */ ) @@ -190,21 +187,21 @@ private: */ 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 ) ) { mApplication.Quit(); } - else if( event.keyPressedName.compare("1") == 0) + else if( event.GetKeyName().compare("1") == 0) { Adaptor::Get().SetPreRenderCallback( MakeCallback( this, &PreRenderCallbackController::OnPreRender ) ); } - else if( event.keyPressedName.compare("2") == 0) + else if( event.GetKeyName().compare("2") == 0) { Adaptor::Get().SetPreRenderCallback( NULL ); } - else if( event.keyPressedName.compare("3") == 0) + else if( event.GetKeyName().compare("3") == 0) { mKeepPreRender = !mKeepPreRender; } @@ -234,7 +231,7 @@ private: private: Application& mApplication; - Stage mStage; + Window mWindow; TapGestureDetector mTapDetector; ///< Tap detector to enable the PreRenderCallback bool mKeepPreRender; int mRotateTextCharacter; @@ -253,7 +250,7 @@ private: } // namespace Dali -int main( int argc, char **argv ) +int DALI_EXPORT_API main( int argc, char **argv ) { Dali::Application application = Dali::Application::New( &argc, &argv ); Dali::PreRenderCallbackController controller( application );