X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Fmesh-visual%2Fmesh-visual-example.cpp;h=affde27c19af1acda93999240f41c11863f085f1;hb=1a473d5189ca7e7d55aca3a64a8a4ff2dc3b6c67;hp=4a039df6f788dbfb08064c30d9cf7da6fd78920f;hpb=9879c76252b384906ea35422547840350a72019c;p=platform%2Fcore%2Fuifw%2Fdali-demo.git diff --git a/examples/mesh-visual/mesh-visual-example.cpp b/examples/mesh-visual/mesh-visual-example.cpp index 4a039df..affde27 100644 --- a/examples/mesh-visual/mesh-visual-example.cpp +++ b/examples/mesh-visual/mesh-visual-example.cpp @@ -63,7 +63,7 @@ const int MODEL_TAG = 0; const int LIGHT_TAG = 1; const int LAYER_TAG = 2; -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 } // unnamed namespace @@ -92,14 +92,14 @@ public: // The Init signal is received once (only) during the Application lifetime void Create( Application& application ) { - // Get a handle to the stage - Stage stage = Stage::GetCurrent(); - stage.SetBackgroundColor( STAGE_COLOR ); + // Get a handle to the window + Window window = application.GetWindow(); + window.SetBackgroundColor( WINDOW_COLOR ); //Set up root layer to receive touch gestures. - Layer rootLayer = stage.GetRootLayer(); + Layer rootLayer = window.GetRootLayer(); rootLayer.RegisterProperty( "Tag", LAYER_TAG ); //Used to differentiate between different kinds of actor. - rootLayer.TouchSignal().Connect( this, &MeshVisualController::OnTouch ); + rootLayer.TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); //Place models on the scene. SetupModels( rootLayer ); @@ -111,7 +111,7 @@ public: SetupLight( rootLayer ); //Allow for exiting of the application via key presses. - stage.KeyEventSignal().Connect( this, &MeshVisualController::OnKeyEvent ); + window.KeyEventSignal().Connect( this, &MeshVisualController::OnKeyEvent ); } //Loads and adds the models to the scene, inside containers for hit detection. @@ -124,21 +124,21 @@ public: mContainers[i].SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); mContainers[i].RegisterProperty( "Tag", MODEL_TAG ); //Used to differentiate between different kinds of actor. mContainers[i].RegisterProperty( "Model", Property::Value( i ) ); //Used to index into the model. - mContainers[i].TouchSignal().Connect( this, &MeshVisualController::OnTouch ); + mContainers[i].TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); layer.Add( mContainers[i] ); } //Position each container individually on screen //Main, central model - mContainers[0].SetSizeModeFactor( Vector3( MODEL_SCALE, MODEL_SCALE, 0.0f ) ); - mContainers[0].SetParentOrigin( ParentOrigin::CENTER ); - mContainers[0].SetAnchorPoint( AnchorPoint::CENTER ); + mContainers[0].SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( MODEL_SCALE, MODEL_SCALE, 0.0f ) ); + mContainers[0].SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + mContainers[0].SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); //Top left model - mContainers[1].SetSizeModeFactor( Vector3( MODEL_SCALE / 3.0f, MODEL_SCALE / 3.0f, 0.0f ) ); - mContainers[1].SetParentOrigin( Vector3( 0.05, 0.03, 0.5 ) ); //Offset from top left - mContainers[1].SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mContainers[1].SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( MODEL_SCALE / 3.0f, MODEL_SCALE / 3.0f, 0.0f ) ); + mContainers[1].SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.05, 0.03, 0.5 ) ); //Offset from top left + mContainers[1].SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT ); //Set up models for( int i = 0; i < NUM_MESHES; i++ ) @@ -146,8 +146,8 @@ public: //Create control to display model Control control = Control::New(); control.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - control.SetParentOrigin( ParentOrigin::CENTER ); - control.SetAnchorPoint( AnchorPoint::CENTER ); + control.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + control.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); mContainers[i].Add( control ); //Make model spin to demonstrate 3D @@ -174,16 +174,16 @@ public: { //Actor for positioning model and shading mode buttons. Actor positionActorModel = Actor::New(); - positionActorModel.SetParentOrigin( Vector3( BUTTONS_OFFSET_SIDE, 1.0 - BUTTONS_OFFSET_BOTTOM, 0.5 ) ); - positionActorModel.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); + positionActorModel.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( BUTTONS_OFFSET_SIDE, 1.0 - BUTTONS_OFFSET_BOTTOM, 0.5 ) ); + positionActorModel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER ); layer.Add( positionActorModel ); //Create button for model changing. PushButton modelButton = Toolkit::PushButton::New(); modelButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); modelButton.ClickedSignal().Connect( this, &MeshVisualController::OnChangeModelClicked ); - modelButton.SetParentOrigin( ParentOrigin::TOP_CENTER ); - modelButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); + modelButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); + modelButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER ); modelButton.SetProperty( Toolkit::Button::Property::LABEL, "Model" ); positionActorModel.Add( modelButton ); @@ -191,8 +191,8 @@ public: PushButton shadingModeButton = Toolkit::PushButton::New(); shadingModeButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); shadingModeButton.ClickedSignal().Connect( this, &MeshVisualController::OnChangeShadingModeClicked ); - shadingModeButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); - shadingModeButton.SetAnchorPoint( AnchorPoint::TOP_CENTER ); + shadingModeButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER ); + shadingModeButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER ); shadingModeButton.SetProperty( Toolkit::Button::Property::LABEL, "Shading Mode" ); positionActorModel.Add( shadingModeButton ); @@ -200,31 +200,31 @@ public: TextLabel changeTitleLabel = TextLabel::New( "Change" ); changeTitleLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); changeTitleLabel.SetProperty( TextLabel::Property::UNDERLINE, "{\"thickness\":\"2.0\"}" ); - changeTitleLabel.SetParentOrigin( ParentOrigin::TOP_CENTER ); - changeTitleLabel.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); + changeTitleLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); + changeTitleLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER ); modelButton.Add( changeTitleLabel ); //Create button for pausing animations. PushButton pauseButton = Toolkit::PushButton::New(); pauseButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); pauseButton.ClickedSignal().Connect( this, &MeshVisualController::OnPauseClicked ); - pauseButton.SetParentOrigin( Vector3( 0.5, 1.0 - BUTTONS_OFFSET_BOTTOM, 0.5 ) ); - pauseButton.SetAnchorPoint( AnchorPoint::CENTER ); + pauseButton.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 0.5, 1.0 - BUTTONS_OFFSET_BOTTOM, 0.5 ) ); + pauseButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); pauseButton.SetProperty( Toolkit::Button::Property::LABEL, PAUSE ); layer.Add( pauseButton ); //Actor for positioning light position buttons. Actor positionActorLight = Actor::New(); - positionActorLight.SetParentOrigin( Vector3( 1.0 - BUTTONS_OFFSET_SIDE, 1.0 - BUTTONS_OFFSET_BOTTOM, 0.5 ) ); - positionActorLight.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); + positionActorLight.SetProperty( Actor::Property::PARENT_ORIGIN, Vector3( 1.0 - BUTTONS_OFFSET_SIDE, 1.0 - BUTTONS_OFFSET_BOTTOM, 0.5 ) ); + positionActorLight.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER ); layer.Add( positionActorLight ); //Create button for switching between manual and fixed light position. PushButton lightModeButton = Toolkit::PushButton::New(); lightModeButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); lightModeButton.ClickedSignal().Connect( this, &MeshVisualController::OnChangeLightModeClicked ); - lightModeButton.SetParentOrigin( ParentOrigin::TOP_CENTER ); - lightModeButton.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); + lightModeButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); + lightModeButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER ); lightModeButton.SetProperty( Toolkit::Button::Property::LABEL, FIXED ); positionActorLight.Add( lightModeButton ); @@ -232,8 +232,8 @@ public: PushButton lightSideButton = Toolkit::PushButton::New(); lightSideButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); lightSideButton.ClickedSignal().Connect( this, &MeshVisualController::OnChangeLightSideClicked ); - lightSideButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); - lightSideButton.SetAnchorPoint( AnchorPoint::TOP_CENTER ); + lightSideButton.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::BOTTOM_CENTER ); + lightSideButton.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_CENTER ); lightSideButton.SetProperty( Toolkit::Button::Property::LABEL, FRONT ); positionActorLight.Add( lightSideButton ); @@ -241,8 +241,8 @@ public: TextLabel lightTitleLabel = TextLabel::New( "Light Position" ); lightTitleLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); lightTitleLabel.SetProperty( TextLabel::Property::UNDERLINE, "{\"thickness\":\"2.0\"}" ); - lightTitleLabel.SetParentOrigin( ParentOrigin::TOP_CENTER ); - lightTitleLabel.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER ); + lightTitleLabel.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_CENTER ); + lightTitleLabel.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::BOTTOM_CENTER ); lightModeButton.Add( lightTitleLabel ); } @@ -254,38 +254,39 @@ public: mLightSource.RegisterProperty( "Tag", LIGHT_TAG ); //Set size of control based on screen dimensions. - Stage stage = Stage::GetCurrent(); - if( stage.GetSize().width < stage.GetSize().height ) + Window window = mApplication.GetWindow(); + Vector2 windowSize = window.GetSize(); + if( windowSize.width < windowSize.height ) { //Scale to width. mLightSource.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::WIDTH ); mLightSource.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::HEIGHT ); - mLightSource.SetSizeModeFactor( Vector3( LIGHT_SCALE, 0.0f, 0.0f ) ); + mLightSource.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( LIGHT_SCALE, 0.0f, 0.0f ) ); } else { //Scale to height. mLightSource.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::HEIGHT ); mLightSource.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::WIDTH ); - mLightSource.SetSizeModeFactor( Vector3( 0.0f, LIGHT_SCALE, 0.0f ) ); + mLightSource.SetProperty( Actor::Property::SIZE_MODE_FACTOR, Vector3( 0.0f, LIGHT_SCALE, 0.0f ) ); } //Set position relative to top left, as the light source property is also relative to the top left. - mLightSource.SetParentOrigin( ParentOrigin::TOP_LEFT ); - mLightSource.SetAnchorPoint( AnchorPoint::CENTER ); - mLightSource.SetPosition( Stage::GetCurrent().GetSize().x * 0.85f, Stage::GetCurrent().GetSize().y * 0.125 ); + mLightSource.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::TOP_LEFT ); + mLightSource.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); + mLightSource.SetProperty( Actor::Property::POSITION, Vector2( windowSize.width * 0.85f, windowSize.height * 0.125 )); //Supply an image to represent the light. SetLightImage(); //Connect to touch signal for dragging. - mLightSource.TouchSignal().Connect( this, &MeshVisualController::OnTouch ); + mLightSource.TouchedSignal().Connect( this, &MeshVisualController::OnTouch ); //Place the light source on a layer above the base, so that it is rendered above everything else. Layer upperLayer = Layer::New(); upperLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); - upperLayer.SetParentOrigin( ParentOrigin::CENTER ); - upperLayer.SetAnchorPoint( AnchorPoint::CENTER ); + upperLayer.SetProperty( Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER ); + upperLayer.SetProperty( Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER ); baseLayer.Add( upperLayer ); upperLayer.Add( mLightSource ); @@ -348,16 +349,16 @@ public: } } - //Make the models use a fixed, invisible light above the center of the stage. + //Make the models use a fixed, invisible light above the center of the window. void UseFixedLight() { //Hide draggable source - mLightSource.SetVisible( false ); + mLightSource.SetProperty( Actor::Property::VISIBLE, false ); - //Use stage dimensions to place light at center, offset in z axis. - Stage stage = Stage::GetCurrent(); - float width = stage.GetSize().width; - float height = stage.GetSize().height; + //Use window dimensions to place light at center, offset in z axis. + Window window = mApplication.GetWindow(); + float width = window.GetSize().GetWidth(); + float height = window.GetSize().GetHeight(); Vector3 lightPosition = Vector3( width / 2.0f, height / 2.0f, ( mLightFront ? 1 : -1 ) * std::max( width, height ) * 5.0f ); @@ -372,7 +373,7 @@ public: void UseManualLight() { //Show draggable source - mLightSource.SetVisible( true ); + mLightSource.SetProperty( Actor::Property::VISIBLE, true ); //Update to switch light position of models to that of the source. UpdateLight(); @@ -382,9 +383,9 @@ public: void UpdateLight() { //Set light position to the x and y of the light control, offset into/out of the screen. - Vector3 controlPosition = mLightSource.GetCurrentPosition(); + Vector3 controlPosition = mLightSource.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); Vector3 lightPosition = Vector3( controlPosition.x, controlPosition.y, - ( mLightFront ? 1 : -1 ) * Stage::GetCurrent().GetSize().x / 2.0f ); + ( mLightFront ? 1 : -1 ) * mApplication.GetWindow().GetSize().GetWidth() / 2.0f ); for( int i = 0; i < NUM_MESHES; ++i ) { @@ -394,7 +395,7 @@ public: //If the light source is touched, move it by dragging it. //If a model is touched, rotate it by panning around. - bool OnTouch( Actor actor, const TouchData& touch ) + bool OnTouch( Actor actor, const TouchEvent& touch ) { switch( touch.GetState( 0 ) ) { @@ -433,14 +434,14 @@ public: Quaternion( Radian( mModels[mSelectedModelIndex].rotation.y ), Vector3::YAXIS); //Apply rotation. - mModels[mSelectedModelIndex].control.SetOrientation( rotation ); + mModels[mSelectedModelIndex].control.SetProperty( Actor::Property::ORIENTATION, rotation ); break; } case LIGHT_TAG: //Drag light { //Set light source to new position and update the models accordingly. - mLightSource.SetPosition( Vector3( touch.GetScreenPosition( 0 ) ) ); + mLightSource.SetProperty( Actor::Property::POSITION, Vector3( touch.GetScreenPosition( 0 ) ) ); UpdateLight(); break; @@ -571,7 +572,7 @@ public: //If escape or the back button is pressed, quit the application (and return to the launcher) void OnKeyEvent( const KeyEvent& event ) { - if( event.state == KeyEvent::Down ) + if( event.GetState() == KeyEvent::DOWN ) { if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) {