/*
- * Copyright (c) 2018 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 <dali-toolkit/dali-toolkit.h>
-#include <dali/integration-api/adaptors/adaptor.h>
+#include <dali/integration-api/adaptor-framework/adaptor.h>
#include <dali/devel-api/adaptor-framework/application-devel.h>
-#include <dali-toolkit/devel-api/layouting/linear-layout.h>
#include <dali-toolkit/devel-api/controls/control-devel.h>
using namespace Dali::Toolkit;
const char* SCENE_IMAGE_2( DEMO_IMAGE_DIR "gallery-small-42.jpg");
const char* SCENE_IMAGE_3( DEMO_IMAGE_DIR "gallery-small-48.jpg");
const char* ROTATE_TEXT("-\\|/");
+const float TEXT_HEIGHT = 40.0f;
-void AddText( Control textContainer, std::string text )
+void AddText( Control textContainer, std::string text, unsigned int yIndex )
{
auto label = TextLabel::New(text);
- label.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- textContainer.Add(label);
+ 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 );
}
class PreRenderCallbackController : public ConnectionTracker
*/
PreRenderCallbackController ( Application& application )
: mApplication( application ),
- mStage(),
+ mWindow(),
mTapDetector(),
mKeepPreRender(false),
mRotateTextCharacter(0),
*/
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 vbox = LinearLayout::New();
- vbox.SetOrientation(LinearLayout::Orientation::VERTICAL);
- vbox.SetAlignment( LinearLayout::Alignment::TOP | LinearLayout::Alignment::CENTER_HORIZONTAL );
auto textContainer = Control::New();
- textContainer.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- DevelControl::SetLayout( textContainer, vbox );
- AddText(textContainer, "Click to add callback");
- AddText(textContainer, "Press 1 to add callback");
- AddText(textContainer, "Press 2 to clear callback");
- AddText(textContainer, "Press 3 to toggle keep alive");
-
- auto vbox2 = LinearLayout::New();
- vbox2.SetOrientation(LinearLayout::Orientation::VERTICAL);
- vbox2.SetAlignment( LinearLayout::Alignment::BOTTOM | LinearLayout::Alignment::CENTER_HORIZONTAL );
- auto textContainer2 = Control::New();
- textContainer2.SetAnchorPoint(AnchorPoint::TOP_LEFT);
- DevelControl::SetLayout( textContainer2, vbox2 );
+ 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 );
+ AddText(textContainer, "Press 3 to toggle keep alive", 4 );
+
+
mSpinner = TextLabel::New("");
- mSpinner.SetAnchorPoint( AnchorPoint::TOP_LEFT );
- textContainer2.Add(mSpinner);
+ 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(textContainer);
- mStage.Add(textContainer2);
+ mWindow.Add(mSpinner);
+ mWindow.Add(textContainer);
DevelApplication::AddIdleWithReturnValue( application, MakeCallback( this, &PreRenderCallbackController::OnIdle ) );
}
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 );
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);
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 */ )
*/
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;
}
private:
Application& mApplication;
- Stage mStage;
+ Window mWindow;
TapGestureDetector mTapDetector; ///< Tap detector to enable the PreRenderCallback
bool mKeepPreRender;
int mRotateTextCharacter;
} // 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 );