/*
- * 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.
const Vector3 RIGHT_POINT( R3_2, 0.5f, 0.0f);
const Vector3 FRONT_POINT( 0.0f, 0.0f, 20.0f);
-const Vector2 DEFAULT_STAGE_SIZE( 480.0f, 800.0f );
+const Vector2 DEFAULT_WINDOW_SIZE( 480.0f, 800.0f );
const float X_ROTATION_DISPLACEMENT_FACTOR = 60.f;
const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.f;
{
srand(0); // Want repeatable path
- Stage::GetCurrent().KeyEventSignal().Connect(this, &TestApp::OnKeyEvent);
+ app.GetWindow().KeyEventSignal().Connect(this, &TestApp::OnKeyEvent);
CreateToolbarAndView(app);
CreateShadowViewAndLights();
void CreateToolbarAndView(Application& app)
{
// Creates a default view with a default tool bar.
- // The view is added to the stage.
+ // The view is added to the window.
Toolkit::ToolBar toolBar;
mContents = DemoHelper::CreateView( app,
mView,
effectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, CHANGE_EFFECT_IMAGE );
effectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, CHANGE_EFFECT_IMAGE_SELECTED );
effectChangeButton.ClickedSignal().Connect( this, &TestApp::OnEffectButtonClicked );
- toolBar.AddControl( effectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
+ toolBar.AddControl( effectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HORIZONTAL_RIGHT, DemoHelper::DEFAULT_MODE_SWITCH_PADDING );
// Add title to the tool bar.
mTitleActor = DemoHelper::CreateToolBarLabel( "" );
- toolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter );
+ toolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HORIZONTAL_CENTER );
// Set Title text
mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) );
resetButton.SetProperty( Toolkit::Button::Property::UNSELECTED_BACKGROUND_VISUAL, RESET_ICON );
resetButton.SetProperty( Toolkit::Button::Property::SELECTED_BACKGROUND_VISUAL, RESET_ICON_SELECTED );
resetButton.ClickedSignal().Connect( this, &TestApp::OnResetPressed );
- toolBar.AddControl( resetButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING );
+ toolBar.AddControl( resetButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HORIZONTAL_CENTER, DemoHelper::DEFAULT_PLAY_PADDING );
// Setup
mView.SetProperty( Actor::Property::POSITION, Vector3( 0.0f, 0.0f, 0.0f ) );
- mContents.SetBehavior(Layer::LAYER_3D);
+ mContents.SetProperty( Layer::Property::BEHAVIOR, Layer::LAYER_3D );
mContents.SetProperty( Actor::Property::POSITION, mTranslation );
mContents.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
mContents.SetProperty( Actor::Property::SCALE, Vector3( mPinchScale, mPinchScale, mPinchScale ) );
mLightAnchor.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mLightXRotation, mLightYRotation ) );
// Work out a scaling factor as the initial light position was calculated for desktop
- // Need to scale light position as scene actor size is based on stage size (i.e. much bigger on device)
- Vector2 stageSize( Stage::GetCurrent().GetSize() );
- float scaleFactor = stageSize.x / DEFAULT_STAGE_SIZE.x;
+ // Need to scale light position as scene actor size is based on window size (i.e. much bigger on device)
+ Vector2 windowSize( mApp.GetWindow().GetSize() );
+ float scaleFactor = windowSize.x / DEFAULT_WINDOW_SIZE.x;
mCastingLight = Actor::New();
mCastingLight.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER);
void OnPan(Actor actor, const PanGesture& gesture)
{
- switch (gesture.state)
+ switch (gesture.GetState())
{
case Gesture::Continuing:
{
+ const Vector2& displacement = gesture.GetDisplacement();
switch(mPanState)
{
case PAN_LIGHT:
{
- mLightXRotation = mLightXRotation - gesture.displacement.y * LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
+ mLightXRotation = mLightXRotation - displacement.y * LIGHT_PAN_X_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
mLightXRotation = Clamp(mLightXRotation, -Dali::ANGLE_45, Dali::ANGLE_45 );
- mLightYRotation = mLightYRotation + gesture.displacement.x * LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
+ mLightYRotation = mLightYRotation + displacement.x * LIGHT_PAN_Y_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
mLightYRotation = Clamp(mLightYRotation, -Dali::ANGLE_45, Dali::ANGLE_45 );
mLightAnchor.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mLightXRotation, mLightYRotation ) );
break;
case PAN_SCENE:
{
- mTranslation += Vector3(gesture.displacement.x, gesture.displacement.y, 0.f);
+ mTranslation += Vector3(displacement.x, displacement.y, 0.f);
mContents.SetProperty( Actor::Property::POSITION, mTranslation );
break;
}
case ROTATE_SCENE:
{
- mSceneXRotation = mSceneXRotation - gesture.displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
+ mSceneXRotation = mSceneXRotation - displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
mSceneXRotation = Clamp( mSceneXRotation, -Dali::ANGLE_90, Dali::ANGLE_90 );
- mSceneYRotation = mSceneYRotation + gesture.displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
+ mSceneYRotation = mSceneYRotation + displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
mSceneYRotation = Clamp( mSceneYRotation, -Dali::ANGLE_90, Dali::ANGLE_90 );
mContents.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) );
break;
case ROTATE_OBJECT:
{
- mObjectXRotation = mObjectXRotation - gesture.displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
- mObjectYRotation = mObjectYRotation + gesture.displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
+ mObjectXRotation = mObjectXRotation - displacement.y / X_ROTATION_DISPLACEMENT_FACTOR; // X displacement rotates around Y axis
+ mObjectYRotation = mObjectYRotation + displacement.x / Y_ROTATION_DISPLACEMENT_FACTOR; // Y displacement rotates around X axis
mSceneActor.SetProperty( Actor::Property::ORIENTATION, CalculateWorldRotation( mObjectXRotation, mObjectYRotation ) );
break;
}
void OnPinch(Actor actor, const PinchGesture& gesture)
{
- if (gesture.state == Gesture::Started)
+ if (gesture.GetState() == Gesture::Started)
{
mScaleAtPinchStart = mContents.GetCurrentProperty< Vector3 >( Actor::Property::SCALE ).x;
}
- mPinchScale = Clamp(mScaleAtPinchStart * gesture.scale, MIN_PINCH_SCALE, MAX_PINCH_SCALE);
+ mPinchScale = Clamp(mScaleAtPinchStart * gesture.GetScale(), MIN_PINCH_SCALE, MAX_PINCH_SCALE);
mContents.SetProperty( Actor::Property::SCALE, Vector3( mPinchScale, mPinchScale, mPinchScale ) );
}
{
if( mSceneActor )
{
- Stage::GetCurrent().Remove(mSceneActor);
+ mApp.GetWindow().Remove(mSceneActor);
}
if( mView )
{
- Stage::GetCurrent().Remove(mView);
+ mApp.GetWindow().Remove(mView);
}
}
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) )
{