Commit 0da9dc4e76c2ffe56b9866a2ce5b8e9611422fc2
[dali_1.3.32] Merge branch 'devel/master'
Change-Id: Ibe903492264178b2aa1a482f50c52945686cb325
Showing
5 changed files
with
120 additions
and
55 deletions
examples/bezier-curve/bezier-curve-example.cpp
| ... | ... | @@ -38,7 +38,8 @@ const char* const ANIMATION_BACKGROUND( DEMO_IMAGE_DIR "slider-skin.9.png" ); |
| 38 | 38 | const char* APPLICATION_TITLE("Bezier curve animation"); |
| 39 | 39 | const float ANIM_LEFT_FACTOR(0.2f); |
| 40 | 40 | const float ANIM_RIGHT_FACTOR(0.8f); |
| 41 | - | |
| 41 | +const int AXIS_LABEL_POINT_SIZE(7); | |
| 42 | +const float AXIS_LINE_SIZE(1.0f); | |
| 42 | 43 | |
| 43 | 44 | const char* CURVE_VERTEX_SHADER = DALI_COMPOSE_SHADER |
| 44 | 45 | ( |
| ... | ... | @@ -193,6 +194,7 @@ public: |
| 193 | 194 | contentLayout.SetCellAlignment(1, HorizontalAlignment::CENTER, VerticalAlignment::CENTER ); |
| 194 | 195 | CreateCubic(mGrid); |
| 195 | 196 | CreateControlPoints( mGrid ); // Control points constrained to double height of grid |
| 197 | + CreateAxisLabels( mGrid ); | |
| 196 | 198 | |
| 197 | 199 | mCoefficientLabel = TextLabel::New(); |
| 198 | 200 | mCoefficientLabel.SetProperty( TextLabel::Property::ENABLE_MARKUP, true ); |
| ... | ... | @@ -375,6 +377,36 @@ public: |
| 375 | 377 | parent.Add( mControlPoint2 ); |
| 376 | 378 | } |
| 377 | 379 | |
| 380 | + void CreateAxisLabels( Actor parent ) | |
| 381 | + { | |
| 382 | + TextLabel progressionLabel = TextLabel::New( "Progression" ); | |
| 383 | + progressionLabel.SetProperty( TextLabel::Property::POINT_SIZE, AXIS_LABEL_POINT_SIZE ); | |
| 384 | + progressionLabel.SetOrientation( Degree(-90.0f), Vector3::ZAXIS ); | |
| 385 | + progressionLabel.SetAnchorPoint( AnchorPoint::BOTTOM_LEFT ); | |
| 386 | + progressionLabel.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); | |
| 387 | + CreateLine( progressionLabel, ParentOrigin::BOTTOM_LEFT ); | |
| 388 | + | |
| 389 | + TextLabel timeLabel = TextLabel::New( "Time" ); | |
| 390 | + timeLabel.SetProperty( TextLabel::Property::POINT_SIZE, AXIS_LABEL_POINT_SIZE ); | |
| 391 | + timeLabel.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 392 | + timeLabel.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); | |
| 393 | + CreateLine( timeLabel, ParentOrigin::TOP_LEFT ); | |
| 394 | + | |
| 395 | + parent.Add( progressionLabel ); | |
| 396 | + parent.Add( timeLabel ); | |
| 397 | + } | |
| 398 | + | |
| 399 | + void CreateLine( Actor parent, const Vector3& parentOrigin ) | |
| 400 | + { | |
| 401 | + Control control = Control::New(); | |
| 402 | + control.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 403 | + control.SetParentOrigin( parentOrigin ); | |
| 404 | + control.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH ); | |
| 405 | + control.SetProperty( Actor::Property::SIZE_HEIGHT, AXIS_LINE_SIZE ); | |
| 406 | + control.SetBackgroundColor( Color::BLACK ); | |
| 407 | + parent.Add( control ); | |
| 408 | + } | |
| 409 | + | |
| 378 | 410 | void SetLabel( Vector2 pos1, Vector2 pos2 ) |
| 379 | 411 | { |
| 380 | 412 | std::ostringstream oss; | ... | ... |
examples/image-view-svg/image-view-svg-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -23,6 +23,7 @@ using namespace Dali; |
| 23 | 23 | |
| 24 | 24 | namespace |
| 25 | 25 | { |
| 26 | +const float MIN_SCALE = 0.6f; | |
| 26 | 27 | const float MAX_SCALE = 6.f; |
| 27 | 28 | |
| 28 | 29 | const char* SVG_IMAGES[] = |
| ... | ... | @@ -37,9 +38,10 @@ const char* SVG_IMAGES[] = |
| 37 | 38 | DEMO_IMAGE_DIR "Kid1.svg" |
| 38 | 39 | }; |
| 39 | 40 | const unsigned int NUM_SVG_IMAGES( sizeof( SVG_IMAGES ) / sizeof( SVG_IMAGES[0] ) ); |
| 40 | -} | |
| 41 | +const unsigned int NUM_IMAGES_DISPLAYED = 4u; | |
| 42 | +} // unnamed namespace | |
| 41 | 43 | |
| 42 | -// This example shows how to display svg images with ImageView | |
| 44 | +// This example shows how to display svg images with ImageView. | |
| 43 | 45 | // |
| 44 | 46 | class ImageSvgController : public ConnectionTracker |
| 45 | 47 | { |
| ... | ... | @@ -48,7 +50,6 @@ public: |
| 48 | 50 | ImageSvgController( Application& application ) |
| 49 | 51 | : mApplication( application ), |
| 50 | 52 | mScale( 1.f ), |
| 51 | - mScaleAtPinchStart( 1.0f ), | |
| 52 | 53 | mIndex( 0 ) |
| 53 | 54 | { |
| 54 | 55 | // Connect to the Application's Init signal |
| ... | ... | @@ -97,7 +98,7 @@ public: |
| 97 | 98 | resetButton.ClickedSignal().Connect( this, &ImageSvgController::OnResetButtonClicked ); |
| 98 | 99 | |
| 99 | 100 | // Create and put imageViews to stage |
| 100 | - for( unsigned int i=0; i<4u; i++) | |
| 101 | + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) | |
| 101 | 102 | { |
| 102 | 103 | mSvgActor[i] = Toolkit::ImageView::New(SVG_IMAGES[mIndex+i]); |
| 103 | 104 | mSvgActor[i].SetSize( mActorSize ); |
| ... | ... | @@ -130,8 +131,8 @@ public: |
| 130 | 131 | // Callback of push button, for changing image set |
| 131 | 132 | bool OnChangeButtonClicked( Toolkit::Button button ) |
| 132 | 133 | { |
| 133 | - mIndex = (mIndex+4) % NUM_SVG_IMAGES; | |
| 134 | - for( unsigned int i=0; i<4u; i++) | |
| 134 | + mIndex = ( mIndex + NUM_IMAGES_DISPLAYED ) % NUM_SVG_IMAGES; | |
| 135 | + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) | |
| 135 | 136 | { |
| 136 | 137 | mSvgActor[i].SetImage(SVG_IMAGES[mIndex+i]); |
| 137 | 138 | } |
| ... | ... | @@ -142,7 +143,7 @@ public: |
| 142 | 143 | // Callback of push button, for resetting image size and position |
| 143 | 144 | bool OnResetButtonClicked( Toolkit::Button button ) |
| 144 | 145 | { |
| 145 | - for( unsigned int i=0; i<4u; i++) | |
| 146 | + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED ; i++ ) | |
| 146 | 147 | { |
| 147 | 148 | mSvgActor[i].SetSize(mActorSize); |
| 148 | 149 | mSvgActor[i].SetPosition( Vector3::ZERO ); |
| ... | ... | @@ -157,7 +158,7 @@ public: |
| 157 | 158 | { |
| 158 | 159 | if( gesture.state == Gesture::Continuing ) |
| 159 | 160 | { |
| 160 | - for( unsigned int i=0; i<4u; i++) | |
| 161 | + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) | |
| 161 | 162 | { |
| 162 | 163 | mSvgActor[i].TranslateBy(Vector3(gesture.displacement)); |
| 163 | 164 | } |
| ... | ... | @@ -167,18 +168,42 @@ public: |
| 167 | 168 | // Callback of pinch gesture, for resizing the actors |
| 168 | 169 | void OnPinch(Actor actor, const PinchGesture& gesture) |
| 169 | 170 | { |
| 170 | - if (gesture.state == Gesture::Started) | |
| 171 | - { | |
| 172 | - mScaleAtPinchStart = mScale; | |
| 173 | - } | |
| 174 | - if( gesture.state == Gesture::Finished ) | |
| 171 | + switch( gesture.state ) | |
| 175 | 172 | { |
| 176 | - mScale = mScaleAtPinchStart * gesture.scale; | |
| 177 | - mScale = mScale > MAX_SCALE ? MAX_SCALE : mScale; | |
| 178 | - for( unsigned int i=0; i<4u; i++) | |
| 173 | + // Only scale the image when we start or continue pinching | |
| 174 | + | |
| 175 | + case Gesture::Started: | |
| 176 | + case Gesture::Continuing: | |
| 177 | + { | |
| 178 | + float scale = std::max( gesture.scale, MIN_SCALE / mScale ); | |
| 179 | + scale = std::min( MAX_SCALE / mScale, scale ); | |
| 180 | + | |
| 181 | + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) | |
| 182 | + { | |
| 183 | + mSvgActor[i].SetScale( scale ); | |
| 184 | + } | |
| 185 | + break; | |
| 186 | + } | |
| 187 | + | |
| 188 | + case Gesture::Finished: | |
| 179 | 189 | { |
| 180 | - mSvgActor[i].SetSize( mActorSize * mScale); | |
| 190 | + // Resize the image when pinching is complete, this will rasterize the SVG to the new size | |
| 191 | + | |
| 192 | + mScale = mScale * gesture.scale; | |
| 193 | + mScale = mScale > MAX_SCALE ? MAX_SCALE : mScale; | |
| 194 | + mScale = mScale < MIN_SCALE ? MIN_SCALE : mScale; | |
| 195 | + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) | |
| 196 | + { | |
| 197 | + mSvgActor[i].SetSize( mActorSize * mScale ); | |
| 198 | + mSvgActor[i].SetScale( 1.0f ); | |
| 199 | + } | |
| 200 | + break; | |
| 181 | 201 | } |
| 202 | + | |
| 203 | + case Gesture::Cancelled: | |
| 204 | + case Gesture::Clear: | |
| 205 | + case Gesture::Possible: | |
| 206 | + break; | |
| 182 | 207 | } |
| 183 | 208 | } |
| 184 | 209 | |
| ... | ... | @@ -198,10 +223,13 @@ public: |
| 198 | 223 | const char* keyName = event.keyPressedName.c_str(); |
| 199 | 224 | if( strcmp(keyName, "Left") == 0 ) |
| 200 | 225 | { |
| 201 | - mScale /= 1.1f; | |
| 202 | - for( unsigned int i=0; i<4u; i++) | |
| 226 | + if( mScale > MIN_SCALE ) | |
| 227 | + { | |
| 228 | + mScale /= 1.1f; | |
| 229 | + } | |
| 230 | + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) | |
| 203 | 231 | { |
| 204 | - mSvgActor[i].SetSize( mActorSize * mScale); | |
| 232 | + mSvgActor[i].SetSize( mActorSize * mScale ); | |
| 205 | 233 | } |
| 206 | 234 | } |
| 207 | 235 | else if( strcmp(keyName, "Right") == 0 ) |
| ... | ... | @@ -210,9 +238,9 @@ public: |
| 210 | 238 | { |
| 211 | 239 | mScale *= 1.1f; |
| 212 | 240 | } |
| 213 | - for( unsigned int i=0; i<4u; i++) | |
| 241 | + for( unsigned int i = 0; i < NUM_IMAGES_DISPLAYED; i++ ) | |
| 214 | 242 | { |
| 215 | - mSvgActor[i].SetSize( mActorSize * mScale); | |
| 243 | + mSvgActor[i].SetSize( mActorSize * mScale ); | |
| 216 | 244 | } |
| 217 | 245 | } |
| 218 | 246 | } |
| ... | ... | @@ -228,7 +256,6 @@ private: |
| 228 | 256 | Toolkit::ImageView mSvgActor[4]; |
| 229 | 257 | Vector2 mActorSize; |
| 230 | 258 | float mScale; |
| 231 | - float mScaleAtPinchStart; | |
| 232 | 259 | unsigned int mIndex; |
| 233 | 260 | }; |
| 234 | 261 | ... | ... |
examples/motion-blur/motion-blur-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -162,6 +162,11 @@ public: |
| 162 | 162 | TOOLBAR_IMAGE, |
| 163 | 163 | APPLICATION_TITLE ); |
| 164 | 164 | |
| 165 | + // Ensure the content layer is a square so the touch area works in all orientations | |
| 166 | + Vector2 stageSize = Stage::GetCurrent().GetSize(); | |
| 167 | + float size = std::max( stageSize.width, stageSize.height ); | |
| 168 | + mContentLayer.SetSize( size, size ); | |
| 169 | + | |
| 165 | 170 | //Add an effects icon on the right of the title |
| 166 | 171 | mActorEffectsButton = Toolkit::PushButton::New(); |
| 167 | 172 | mActorEffectsButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, EFFECTS_OFF_ICON ); |
| ... | ... | @@ -188,11 +193,10 @@ public: |
| 188 | 193 | winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE ); |
| 189 | 194 | winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); |
| 190 | 195 | winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); |
| 196 | + winHandle.ResizedSignal().Connect( this, &MotionBlurExampleApp::OnWindowResized ); | |
| 191 | 197 | |
| 192 | 198 | // set initial orientation |
| 193 | - unsigned int degrees = 0; | |
| 194 | - Rotate( static_cast< DeviceOrientation >( degrees ) ); | |
| 195 | - | |
| 199 | + Rotate( PORTRAIT ); | |
| 196 | 200 | |
| 197 | 201 | /////////////////////////////////////////////////////// |
| 198 | 202 | // |
| ... | ... | @@ -200,7 +204,6 @@ public: |
| 200 | 204 | // |
| 201 | 205 | |
| 202 | 206 | // Scale down actor to fit on very low resolution screens with space to interact: |
| 203 | - Size stageSize = Stage::GetCurrent().GetSize(); | |
| 204 | 207 | mMotionBlurActorSize = Size( std::min( stageSize.x * 0.3f, MOTION_BLUR_ACTOR_WIDTH ), std::min( stageSize.y * 0.3f, MOTION_BLUR_ACTOR_HEIGHT ) ); |
| 205 | 208 | mMotionBlurActorSize = Size( std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ), std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ) ); |
| 206 | 209 | |
| ... | ... | @@ -220,16 +223,21 @@ public: |
| 220 | 223 | |
| 221 | 224 | } |
| 222 | 225 | |
| 226 | + ////////////////////////////////////////////////////////////// | |
| 227 | + // | |
| 228 | + // Device Orientation Support | |
| 229 | + // | |
| 230 | + // | |
| 231 | + | |
| 232 | + void OnWindowResized( Window::WindowSize size ) | |
| 233 | + { | |
| 234 | + Rotate( size.GetWidth() > size.GetHeight() ? LANDSCAPE : PORTRAIT ); | |
| 235 | + } | |
| 236 | + | |
| 223 | 237 | void Rotate( DeviceOrientation orientation ) |
| 224 | 238 | { |
| 225 | 239 | // Resize the root actor |
| 226 | - Vector2 stageSize = Stage::GetCurrent().GetSize(); | |
| 227 | - Vector2 targetSize = stageSize; | |
| 228 | - if( orientation == LANDSCAPE || | |
| 229 | - orientation == LANDSCAPE_INVERSE ) | |
| 230 | - { | |
| 231 | - targetSize = Vector2( stageSize.y, stageSize.x ); | |
| 232 | - } | |
| 240 | + const Vector2 targetSize = Stage::GetCurrent().GetSize(); | |
| 233 | 241 | |
| 234 | 242 | if( mOrientation != orientation ) |
| 235 | 243 | { |
| ... | ... | @@ -240,15 +248,12 @@ public: |
| 240 | 248 | { |
| 241 | 249 | // has parent so we expect it to be on stage, start animation |
| 242 | 250 | mRotateAnimation = Animation::New( ORIENTATION_DURATION ); |
| 243 | - mRotateAnimation.AnimateTo( Property( mView, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -orientation ) ), Vector3::ZAXIS ), AlphaFunction::EASE_OUT ); | |
| 244 | 251 | mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_WIDTH ), targetSize.width ); |
| 245 | 252 | mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_HEIGHT ), targetSize.height ); |
| 246 | 253 | mRotateAnimation.Play(); |
| 247 | 254 | } |
| 248 | 255 | else |
| 249 | 256 | { |
| 250 | - // set the rotation to match the orientation | |
| 251 | - mView.SetOrientation( Degree( -orientation ), Vector3::ZAXIS ); | |
| 252 | 257 | mView.SetSize( targetSize ); |
| 253 | 258 | } |
| 254 | 259 | } | ... | ... |
examples/motion-stretch/motion-stretch-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -141,6 +141,11 @@ public: |
| 141 | 141 | TOOLBAR_IMAGE, |
| 142 | 142 | APPLICATION_TITLE ); |
| 143 | 143 | |
| 144 | + // Ensure the content layer is a square so the touch area works in all orientations | |
| 145 | + Vector2 stageSize = Stage::GetCurrent().GetSize(); | |
| 146 | + float size = std::max( stageSize.width, stageSize.height ); | |
| 147 | + mContentLayer.SetSize( size, size ); | |
| 148 | + | |
| 144 | 149 | //Add an slideshow icon on the right of the title |
| 145 | 150 | mActorEffectsButton = Toolkit::PushButton::New(); |
| 146 | 151 | mActorEffectsButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, EFFECTS_OFF_ICON ); |
| ... | ... | @@ -168,10 +173,10 @@ public: |
| 168 | 173 | winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE ); |
| 169 | 174 | winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); |
| 170 | 175 | winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); |
| 176 | + winHandle.ResizedSignal().Connect( this, &MotionStretchExampleApp::OnWindowResized ); | |
| 171 | 177 | |
| 172 | - unsigned int degrees = 0; | |
| 173 | - Rotate( static_cast< DeviceOrientation >( degrees ) ); | |
| 174 | - | |
| 178 | + // set initial orientation | |
| 179 | + Rotate( PORTRAIT ); | |
| 175 | 180 | |
| 176 | 181 | /////////////////////////////////////////////////////// |
| 177 | 182 | // |
| ... | ... | @@ -197,16 +202,15 @@ public: |
| 197 | 202 | // |
| 198 | 203 | // |
| 199 | 204 | |
| 205 | + void OnWindowResized( Window::WindowSize size ) | |
| 206 | + { | |
| 207 | + Rotate( size.GetWidth() > size.GetHeight() ? LANDSCAPE : PORTRAIT ); | |
| 208 | + } | |
| 209 | + | |
| 200 | 210 | void Rotate( DeviceOrientation orientation ) |
| 201 | 211 | { |
| 202 | 212 | // Resize the root actor |
| 203 | - Vector2 stageSize = Stage::GetCurrent().GetSize(); | |
| 204 | - Vector2 targetSize = stageSize; | |
| 205 | - if( orientation == LANDSCAPE || | |
| 206 | - orientation == LANDSCAPE_INVERSE ) | |
| 207 | - { | |
| 208 | - targetSize = Vector2( stageSize.y, stageSize.x ); | |
| 209 | - } | |
| 213 | + const Vector2 targetSize = Stage::GetCurrent().GetSize(); | |
| 210 | 214 | |
| 211 | 215 | if( mOrientation != orientation ) |
| 212 | 216 | { |
| ... | ... | @@ -217,15 +221,12 @@ public: |
| 217 | 221 | { |
| 218 | 222 | // has parent so we expect it to be on stage, start animation |
| 219 | 223 | mRotateAnimation = Animation::New( ORIENTATION_DURATION ); |
| 220 | - mRotateAnimation.AnimateTo( Property( mView, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( -orientation ) ), Vector3::ZAXIS ), AlphaFunction::EASE_OUT ); | |
| 221 | 224 | mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_WIDTH ), targetSize.width ); |
| 222 | 225 | mRotateAnimation.AnimateTo( Property( mView, Actor::Property::SIZE_HEIGHT ), targetSize.height ); |
| 223 | 226 | mRotateAnimation.Play(); |
| 224 | 227 | } |
| 225 | 228 | else |
| 226 | 229 | { |
| 227 | - // set the rotation to match the orientation | |
| 228 | - mView.SetOrientation( Degree( -orientation ), Vector3::ZAXIS ); | |
| 229 | 230 | mView.SetSize( targetSize ); |
| 230 | 231 | } |
| 231 | 232 | } | ... | ... |