diff --git a/examples/bezier-curve/bezier-curve-example.cpp b/examples/bezier-curve/bezier-curve-example.cpp index 459f3bb..f06f942 100644 --- a/examples/bezier-curve/bezier-curve-example.cpp +++ b/examples/bezier-curve/bezier-curve-example.cpp @@ -38,7 +38,8 @@ const char* const ANIMATION_BACKGROUND( DEMO_IMAGE_DIR "slider-skin.9.png" ); const char* APPLICATION_TITLE("Bezier curve animation"); const float ANIM_LEFT_FACTOR(0.2f); const float ANIM_RIGHT_FACTOR(0.8f); - +const int AXIS_LABEL_POINT_SIZE(7); +const float AXIS_LINE_SIZE(1.0f); const char* CURVE_VERTEX_SHADER = DALI_COMPOSE_SHADER ( @@ -193,6 +194,7 @@ public: contentLayout.SetCellAlignment(1, HorizontalAlignment::CENTER, VerticalAlignment::CENTER ); CreateCubic(mGrid); CreateControlPoints( mGrid ); // Control points constrained to double height of grid + CreateAxisLabels( mGrid ); mCoefficientLabel = TextLabel::New(); mCoefficientLabel.SetProperty( TextLabel::Property::ENABLE_MARKUP, true ); @@ -375,6 +377,36 @@ public: parent.Add( mControlPoint2 ); } + void CreateAxisLabels( Actor parent ) + { + TextLabel progressionLabel = TextLabel::New( "Progression" ); + progressionLabel.SetProperty( TextLabel::Property::POINT_SIZE, AXIS_LABEL_POINT_SIZE ); + progressionLabel.SetOrientation( Degree(-90.0f), Vector3::ZAXIS ); + progressionLabel.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT ); + progressionLabel.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); + CreateLine( progressionLabel, ParentOrigin::BOTTOM_LEFT ); + + TextLabel timeLabel = TextLabel::New( "Time" ); + timeLabel.SetProperty( TextLabel::Property::POINT_SIZE, AXIS_LABEL_POINT_SIZE ); + timeLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + timeLabel.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); + CreateLine( timeLabel, ParentOrigin::TOP_LEFT ); + + parent.Add( progressionLabel ); + parent.Add( timeLabel ); + } + + void CreateLine( Actor parent, const Vector3& parentOrigin ) + { + Control control = Control::New(); + control.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + control.SetParentOrigin( parentOrigin ); + control.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); + control.SetProperty( Actor::Property::SIZE_HEIGHT, AXIS_LINE_SIZE ); + control.SetBackgroundColor( Color::BLACK ); + parent.Add( control ); + } + void SetLabel( Vector2 pos1, Vector2 pos2 ) { std::ostringstream oss; diff --git a/examples/image-view-svg/image-view-svg-example.cpp b/examples/image-view-svg/image-view-svg-example.cpp index 62cde6e..13ba31d 100644 --- a/examples/image-view-svg/image-view-svg-example.cpp +++ b/examples/image-view-svg/image-view-svg-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -23,6 +23,7 @@ using namespace Dali; namespace { +const float MIN_SCALE = 0.6f; const float MAX_SCALE = 6.f; const char* SVG_IMAGES[] = @@ -37,9 +38,10 @@ const char* SVG_IMAGES[] = DEMO_IMAGE_DIR "Kid1.svg" }; const unsigned int NUM_SVG_IMAGES( sizeof( SVG_IMAGES ) / sizeof( SVG_IMAGES[0] ) ); -} +const unsigned int NUM_IMAGES_DISPLAYED = 4u; +} // unnamed namespace -// This example shows how to display svg images with ImageView +// This example shows how to display svg images with ImageView. // class ImageSvgController : public ConnectionTracker { @@ -48,7 +50,6 @@ public: ImageSvgController( Application& application ) : mApplication( application ), mScale( 1.f ), - mScaleAtPinchStart( 1.0f ), mIndex( 0 ) { // Connect to the Application's Init signal @@ -97,7 +98,7 @@ public: resetButton.ClickedSignal().Connect( this, &ImageSvgController::OnResetButtonClicked ); // Create and put imageViews to stage - for( unsigned int i=0; i<4u; i++) + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) { mSvgActor[i] = Toolkit::ImageView::New(SVG_IMAGES[mIndex+i]); mSvgActor[i].SetSize( mActorSize ); @@ -130,8 +131,8 @@ public: // Callback of push button, for changing image set bool OnChangeButtonClicked( Toolkit::Button button ) { - mIndex = (mIndex+4) % NUM_SVG_IMAGES; - for( unsigned int i=0; i<4u; i++) + mIndex = ( mIndex + NUM_IMAGES_DISPLAYED ) % NUM_SVG_IMAGES; + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) { mSvgActor[i].SetImage(SVG_IMAGES[mIndex+i]); } @@ -142,7 +143,7 @@ public: // Callback of push button, for resetting image size and position bool OnResetButtonClicked( Toolkit::Button button ) { - for( unsigned int i=0; i<4u; i++) + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED ; i++ ) { mSvgActor[i].SetSize(mActorSize); mSvgActor[i].SetPosition( Vector3::ZERO ); @@ -157,7 +158,7 @@ public: { if( gesture.state == Gesture::Continuing ) { - for( unsigned int i=0; i<4u; i++) + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) { mSvgActor[i].TranslateBy(Vector3(gesture.displacement)); } @@ -167,18 +168,42 @@ public: // Callback of pinch gesture, for resizing the actors void OnPinch(Actor actor, const PinchGesture& gesture) { - if (gesture.state == Gesture::Started) - { - mScaleAtPinchStart = mScale; - } - if( gesture.state == Gesture::Finished ) + switch( gesture.state ) { - mScale = mScaleAtPinchStart * gesture.scale; - mScale = mScale > MAX_SCALE ? MAX_SCALE : mScale; - for( unsigned int i=0; i<4u; i++) + // Only scale the image when we start or continue pinching + + case Gesture::Started: + case Gesture::Continuing: + { + float scale = std::max( gesture.scale, MIN_SCALE / mScale ); + scale = std::min( MAX_SCALE / mScale, scale ); + + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) + { + mSvgActor[i].SetScale( scale ); + } + break; + } + + case Gesture::Finished: { - mSvgActor[i].SetSize( mActorSize * mScale); + // Resize the image when pinching is complete, this will rasterize the SVG to the new size + + mScale = mScale * gesture.scale; + mScale = mScale > MAX_SCALE ? MAX_SCALE : mScale; + mScale = mScale < MIN_SCALE ? MIN_SCALE : mScale; + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) + { + mSvgActor[i].SetSize( mActorSize * mScale ); + mSvgActor[i].SetScale( 1.0f ); + } + break; } + + case Gesture::Cancelled: + case Gesture::Clear: + case Gesture::Possible: + break; } } @@ -198,10 +223,13 @@ public: const char* keyName = event.keyPressedName.c_str(); if( strcmp(keyName, "Left") == 0 ) { - mScale /= 1.1f; - for( unsigned int i=0; i<4u; i++) + if( mScale > MIN_SCALE ) + { + mScale /= 1.1f; + } + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) { - mSvgActor[i].SetSize( mActorSize * mScale); + mSvgActor[i].SetSize( mActorSize * mScale ); } } else if( strcmp(keyName, "Right") == 0 ) @@ -210,9 +238,9 @@ public: { mScale *= 1.1f; } - for( unsigned int i=0; i<4u; i++) + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) { - mSvgActor[i].SetSize( mActorSize * mScale); + mSvgActor[i].SetSize( mActorSize * mScale ); } } } @@ -228,7 +256,6 @@ private: Toolkit::ImageView mSvgActor[4]; Vector2 mActorSize; float mScale; - float mScaleAtPinchStart; unsigned int mIndex; }; diff --git a/examples/motion-blur/motion-blur-example.cpp b/examples/motion-blur/motion-blur-example.cpp index cce7410..08f5fea 100644 --- a/examples/motion-blur/motion-blur-example.cpp +++ b/examples/motion-blur/motion-blur-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -162,6 +162,11 @@ public: TOOLBAR_IMAGE, APPLICATION_TITLE ); + // Ensure the content layer is a square so the touch area works in all orientations + Vector2 stageSize = Stage::GetCurrent().GetSize(); + float size = std::max( stageSize.width, stageSize.height ); + mContentLayer.SetSize( size, size ); + //Add an effects icon on the right of the title mActorEffectsButton = Toolkit::PushButton::New(); mActorEffectsButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, EFFECTS_OFF_ICON ); @@ -188,11 +193,10 @@ public: winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE ); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); + winHandle.ResizedSignal().Connect( this, &MotionBlurExampleApp::OnWindowResized ); // set initial orientation - unsigned int degrees = 0; - Rotate( static_cast< DeviceOrientation >( degrees ) ); - + Rotate( PORTRAIT ); /////////////////////////////////////////////////////// // @@ -200,7 +204,6 @@ public: // // Scale down actor to fit on very low resolution screens with space to interact: - Size stageSize = Stage::GetCurrent().GetSize(); mMotionBlurActorSize = Size( std::min( stageSize.x * 0.3f, MOTION_BLUR_ACTOR_WIDTH ), std::min( stageSize.y * 0.3f, MOTION_BLUR_ACTOR_HEIGHT ) ); mMotionBlurActorSize = Size( std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ), std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ) ); @@ -220,16 +223,21 @@ public: } + ////////////////////////////////////////////////////////////// + // + // Device Orientation Support + // + // + + void OnWindowResized( Window::WindowSize size ) + { + Rotate( size.GetWidth() > size.GetHeight() ? LANDSCAPE : PORTRAIT ); + } + void Rotate( DeviceOrientation orientation ) { // Resize the root actor - Vector2 stageSize = Stage::GetCurrent().GetSize(); - Vector2 targetSize = stageSize; - if( orientation == LANDSCAPE || - orientation == LANDSCAPE_INVERSE ) - { - targetSize = Vector2( stageSize.y, stageSize.x ); - } + const Vector2 targetSize = Stage::GetCurrent().GetSize(); if( mOrientation != orientation ) { @@ -240,15 +248,12 @@ public: { // has parent so we expect it to be on stage, start animation mRotateAnimation = Animation::New( ORIENTATION_DURATION ); - mRotateAnimation.AnimateTo( Property( mView, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -orientation ) ), Vector3::ZAXIS ), AlphaFunction::EASE_OUT ); mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_WIDTH ), targetSize.width ); mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_HEIGHT ), targetSize.height ); mRotateAnimation.Play(); } else { - // set the rotation to match the orientation - mView.SetOrientation( Degree( -orientation ), Vector3::ZAXIS ); mView.SetSize( targetSize ); } } diff --git a/examples/motion-stretch/motion-stretch-example.cpp b/examples/motion-stretch/motion-stretch-example.cpp index a059723..1ac866b 100644 --- a/examples/motion-stretch/motion-stretch-example.cpp +++ b/examples/motion-stretch/motion-stretch-example.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -141,6 +141,11 @@ public: TOOLBAR_IMAGE, APPLICATION_TITLE ); + // Ensure the content layer is a square so the touch area works in all orientations + Vector2 stageSize = Stage::GetCurrent().GetSize(); + float size = std::max( stageSize.width, stageSize.height ); + mContentLayer.SetSize( size, size ); + //Add an slideshow icon on the right of the title mActorEffectsButton = Toolkit::PushButton::New(); mActorEffectsButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, EFFECTS_OFF_ICON ); @@ -168,10 +173,10 @@ public: winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE ); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); + winHandle.ResizedSignal().Connect( this, &MotionStretchExampleApp::OnWindowResized ); - unsigned int degrees = 0; - Rotate( static_cast< DeviceOrientation >( degrees ) ); - + // set initial orientation + Rotate( PORTRAIT ); /////////////////////////////////////////////////////// // @@ -197,16 +202,15 @@ public: // // + void OnWindowResized( Window::WindowSize size ) + { + Rotate( size.GetWidth() > size.GetHeight() ? LANDSCAPE : PORTRAIT ); + } + void Rotate( DeviceOrientation orientation ) { // Resize the root actor - Vector2 stageSize = Stage::GetCurrent().GetSize(); - Vector2 targetSize = stageSize; - if( orientation == LANDSCAPE || - orientation == LANDSCAPE_INVERSE ) - { - targetSize = Vector2( stageSize.y, stageSize.x ); - } + const Vector2 targetSize = Stage::GetCurrent().GetSize(); if( mOrientation != orientation ) { @@ -217,15 +221,12 @@ public: { // has parent so we expect it to be on stage, start animation mRotateAnimation = Animation::New( ORIENTATION_DURATION ); - mRotateAnimation.AnimateTo( Property( mView, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -orientation ) ), Vector3::ZAXIS ), AlphaFunction::EASE_OUT ); mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_WIDTH ), targetSize.width ); mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_HEIGHT ), targetSize.height ); mRotateAnimation.Play(); } else { - // set the rotation to match the orientation - mView.SetOrientation( Degree( -orientation ), Vector3::ZAXIS ); mView.SetSize( targetSize ); } } diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index 895479d..61634cb 100755 --- a/packaging/com.samsung.dali-demo.spec +++ b/packaging/com.samsung.dali-demo.spec @@ -2,7 +2,7 @@ Name: com.samsung.dali-demo Summary: The OpenGLES Canvas Core Demo -Version: 1.3.31 +Version: 1.3.32 Release: 1 Group: System/Libraries License: Apache-2.0