diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index c47a615..c68fba7 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -85,6 +85,9 @@ + + + diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index 127c82f..c1b7f6b 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -123,21 +123,21 @@ const float IMAGE_BORDER_BOTTOM = IMAGE_BORDER_LEFT; struct AnimateBubbleConstraint { public: - AnimateBubbleConstraint( const Vector3& initialPos, float scale, float size ) + AnimateBubbleConstraint( const Vector3& initialPos, float scale ) : mInitialX( initialPos.x ), - mScale( scale ), - mShapeSize( size ) + mScale( scale ) { } void operator()( Vector3& position, const PropertyInputContainer& inputs ) { const Vector3& parentSize = inputs[1]->GetVector3(); + const Vector3& childSize = inputs[2]->GetVector3(); // Wrap bubbles verically. - if( position.y + mShapeSize * 0.5f < -parentSize.y * 0.5f ) + if( position.y + childSize.y * 0.5f < -parentSize.y * 0.5f ) { - position.y = parentSize.y * 0.5f + mShapeSize * 0.5f; + position.y = parentSize.y * 0.5f + childSize.y * 0.5f; } // Bubbles X position moves parallax to horizontal @@ -267,7 +267,6 @@ void DaliTableView::Initialize( Application& application ) // scrollview occupying the majority of the screen mScrollView = ScrollView::New(); - mScrollView.SetRelayoutEnabled( true ); mScrollView.SetAnchorPoint( AnchorPoint::CENTER ); mScrollView.SetParentOrigin( ParentOrigin::CENTER ); @@ -297,7 +296,6 @@ void DaliTableView::Initialize( Application& application ) // Populate background and bubbles - needs to be scrollViewLayer so scroll ends show Actor bubbleContainer = Actor::New(); - bubbleContainer.SetRelayoutEnabled( true ); bubbleContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); bubbleContainer.SetAnchorPoint( AnchorPoint::CENTER ); bubbleContainer.SetParentOrigin( ParentOrigin::CENTER ); @@ -324,17 +322,18 @@ void DaliTableView::Initialize( Application& application ) // Remove constraints for inner cube effect ApplyCubeEffectToActors(); - // Set initial orientation - unsigned int degrees = application.GetOrientation().GetDegrees(); - Rotate( degrees ); - Dali::Window winHandle = application.GetWindow(); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT ); winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE ); winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); winHandle.RemoveAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); + // Set initial orientation Dali::Orientation orientation = winHandle.GetOrientation(); + + unsigned int degrees = winHandle.GetOrientation().GetDegrees(); + Rotate( degrees ); + orientation.ChangedSignal().Connect( this, &DaliTableView::OrientationChanged ); winHandle.ShowIndicator( Dali::Window::INVISIBLE ); @@ -491,7 +490,6 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit content.SetName( name ); content.SetAnchorPoint( AnchorPoint::CENTER ); content.SetParentOrigin( ParentOrigin::CENTER ); - content.SetRelayoutEnabled( true ); content.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); content.SetSizeModeFactor( sizeMultiplier ); @@ -745,19 +743,18 @@ void DaliTableView::InitialiseBackgroundActors( Actor actor ) { Actor child = actor.GetChildAt( i ); - const Vector3 childSize = child.GetTargetSize(); - // Calculate a random position Vector3 childPos( Random::Range( -size.x * 0.5f * BACKGROUND_SPREAD_SCALE, size.x * 0.5f * BACKGROUND_SPREAD_SCALE ), - Random::Range( -size.y * 0.5f - childSize.height, size.y * 0.5f + childSize.height ), + Random::Range( -size.y, size.y ), Random::Range( BUBBLE_MIN_Z, BUBBLE_MAX_Z ) ); child.SetPosition( childPos ); // Define bubble horizontal parallax and vertical wrapping - Constraint animConstraint = Constraint::New < Vector3 > ( child, Actor::Property::POSITION, AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ), childSize.height ) ); + Constraint animConstraint = Constraint::New < Vector3 > ( child, Actor::Property::POSITION, AnimateBubbleConstraint( childPos, Random::Range( -0.85f, 0.25f ) ) ); animConstraint.AddSource( Source( mScrollView, ScrollView::Property::SCROLL_POSITION ) ); animConstraint.AddSource( Dali::ParentSource( Dali::Actor::Property::SIZE ) ); + animConstraint.AddSource( Dali::LocalSource( Dali::Actor::Property::SIZE ) ); animConstraint.Apply(); // Kickoff animation @@ -778,7 +775,6 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis Vector4 randColour( hue, hue * 0.5, 0.0f, Random::Range( 0.3f, 0.6f )); ImageActor dfActor = ImageActor::New( distanceField ); - dfActor.SetRelayoutEnabled( false ); dfActor.SetSize( Vector2( randSize, randSize ) ); dfActor.SetParentOrigin( ParentOrigin::CENTER ); @@ -884,7 +880,7 @@ void DaliTableView::PauseAnimation() { Animation anim = *animIter; - anim.Pause(); + anim.Stop(); } mBackgroundAnimsPlaying = false; @@ -1007,8 +1003,6 @@ void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap mVersionPopup.HideTail(); mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup ); mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden ); - - mVersionPopup.MarkDirtyForRelayout(); } mVersionPopup.Show(); diff --git a/examples/animated-shapes/animated-shapes-example.cpp b/examples/animated-shapes/animated-shapes-example.cpp index ba34cea..262f0b5 100644 --- a/examples/animated-shapes/animated-shapes-example.cpp +++ b/examples/animated-shapes/animated-shapes-example.cpp @@ -60,8 +60,7 @@ public: stage.Add( mView ); //Set background image for the view - ImageAttributes attributes; - Image image = ResourceImage::New( BACKGROUND_IMAGE, attributes ); + Image image = ResourceImage::New( BACKGROUND_IMAGE ); Dali::ImageActor backgroundImageActor = Dali::ImageActor::New( image ); diff --git a/examples/blocks/blocks-example.cpp b/examples/blocks/blocks-example.cpp index 972f95c..3d96204 100644 --- a/examples/blocks/blocks-example.cpp +++ b/examples/blocks/blocks-example.cpp @@ -176,8 +176,8 @@ struct WobbleConstraint * * @param[in] deviation The max. deviation of wobble effect in degrees. */ - WobbleConstraint(float deviation) - : mDeviation(Radian(Degree(deviation))) + WobbleConstraint( Degree deviation ) + : mDeviation( deviation ) { } @@ -196,7 +196,7 @@ struct WobbleConstraint current = Quaternion(mDeviation * f, Vector3::ZAXIS); } - const float mDeviation; ///< Deviation factor in radians. + Radian mDeviation; ///< Deviation factor in radians. }; } // unnamed namespace @@ -285,7 +285,7 @@ private: mPaddleImage.SetSize( mPaddleFullSize ); mWobbleProperty = mPaddle.RegisterProperty(WOBBLE_PROPERTY_NAME, 0.0f); - Constraint wobbleConstraint = Constraint::New( mPaddle, Actor::Property::ORIENTATION, WobbleConstraint(10.0f)); + Constraint wobbleConstraint = Constraint::New( mPaddle, Actor::Property::ORIENTATION, WobbleConstraint(Degree( 10.0f ))); wobbleConstraint.AddSource( LocalSource(mWobbleProperty) ); wobbleConstraint.Apply(); @@ -358,8 +358,8 @@ private: mLevelContainer = Actor::New(); mLevelContainer.SetAnchorPoint( AnchorPoint::CENTER ); mLevelContainer.SetParentOrigin( ParentOrigin::CENTER ); - mLevelContainer.SetRelayoutEnabled( true ); mLevelContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mContentLayer.Add( mLevelContainer ); mBrickCount = 0; @@ -524,14 +524,10 @@ private: Vector2 stageSize(Stage::GetCurrent().GetSize()); const Vector2 brickSize(BRICK_SIZE * Vector2(stageSize.x, stageSize.x)); - ImageAttributes attr; - attr.SetSize( 128, 64 ); - attr.SetScalingMode( ImageAttributes::ScaleToFill ); - Image img = ResourceImage::New(BRICK_IMAGE_PATH[type], attr); + Image img = ResourceImage::New( BRICK_IMAGE_PATH[type], Dali::ImageDimensions( 128, 64 ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); ImageActor brick = ImageActor::New(img); brick.SetParentOrigin(ParentOrigin::TOP_LEFT); brick.SetAnchorPoint(AnchorPoint::CENTER); - brick.SetRelayoutEnabled( false ); brick.SetSize( brickSize ); brick.SetPosition( Vector3( position ) ); @@ -563,7 +559,6 @@ private: ImageActor actor = ImageActor::New(img); actor.SetParentOrigin(ParentOrigin::TOP_LEFT); actor.SetAnchorPoint(AnchorPoint::CENTER); - actor.SetRelayoutEnabled( false ); return actor; } diff --git a/examples/bubble-effect/bubble-effect-example.cpp b/examples/bubble-effect/bubble-effect-example.cpp index db2a52e..5f06194 100644 --- a/examples/bubble-effect/bubble-effect-example.cpp +++ b/examples/bubble-effect/bubble-effect-example.cpp @@ -53,19 +53,15 @@ const unsigned int DEFAULT_NUMBER_OF_BUBBLES( 1000 ); /** * @brief Load an image, scaled-down to no more than the stage dimensions. * - * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at + * Uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at * load time to cover the entire stage with pixels with no borders, - * and filter mode ImageAttributes::BoxThenLinear to sample the image with + * and filter mode BOX_THEN_LINEAR to sample the image with * maximum quality. */ ResourceImage LoadStageFillingImage( const char * const imagePath ) { Size stageSize = Stage::GetCurrent().GetSize(); - ImageAttributes attributes; - attributes.SetSize( stageSize.x, stageSize.y ); - attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); - attributes.SetScalingMode( ImageAttributes::ScaleToFill ); - return ResourceImage::New( imagePath, attributes ); + return ResourceImage::New( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); } }// end LOCAL_STUFF diff --git a/examples/builder/examples.cpp b/examples/builder/examples.cpp index 5578d7c..f43ba1e 100644 --- a/examples/builder/examples.cpp +++ b/examples/builder/examples.cpp @@ -287,7 +287,6 @@ public: mFiles.clear(); mItemView = ItemView::New(*this); - mItemView.SetRelayoutEnabled( false ); stage.Add( mItemView ); mItemView.SetParentOrigin(ParentOrigin::CENTER); mItemView.SetAnchorPoint(AnchorPoint::CENTER); @@ -469,9 +468,6 @@ public: } builder.AddActors( layer ); - - // Force relayout on layer - layer.RelayoutRequestTree(); } diff --git a/examples/buttons/buttons-example.cpp b/examples/buttons/buttons-example.cpp index 88aa86f..f5c035a 100644 --- a/examples/buttons/buttons-example.cpp +++ b/examples/buttons/buttons-example.cpp @@ -214,8 +214,8 @@ class ButtonsController: public ConnectionTracker mBigImage3 = ResourceImage::New( BIG_IMAGE_3 ); mImage = ImageActor::New( mBigImage1 ); - mImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); - mImage.SetResizePolicy( ResizePolicy::DIMENSION_DEPENDENCY, Dimension::WIDTH ); + mImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + mImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); radioGroup2Background.AddChild( mImage, Toolkit::TableView::CellPosition( 0, 1, 2, 1 ) ); // The enable/disable radio group @@ -349,7 +349,6 @@ class ButtonsController: public ConnectionTracker contentTable.Add( toggleBackground ); - Toolkit::PushButton toggleButton = Toolkit::PushButton::New(); toggleButton.SetTogglableButton( true ); toggleButton.SetLabel( "Unselected" ); diff --git a/examples/cluster/cluster-example.cpp b/examples/cluster/cluster-example.cpp index c6d97a9..c0f92b1 100644 --- a/examples/cluster/cluster-example.cpp +++ b/examples/cluster/cluster-example.cpp @@ -186,7 +186,7 @@ struct CarouselEffectOrientationConstraint void operator()( Vector2& current, const PropertyInputContainer& inputs ) { Vector3 axis; - float angle; + Radian angle; inputs[0]->GetQuaternion().ToAxisAngle( axis, angle ); current.x = cosf(angle); @@ -242,7 +242,7 @@ struct ShearEffectConstraint // Channel this shear value into either the X or Y axis depending on // the component mask passed in. Vector3 axis; - float angle; + Radian angle; inputs[1]->GetQuaternion().ToAxisAngle( axis, angle ); Vector2 direction( cosf(angle), sinf(angle) ); float yield = direction.x * mComponentMask.x + direction.y * mComponentMask.y; @@ -477,7 +477,6 @@ public: // create and setup the scroll view... mScrollView = ScrollView::New(); - mScrollView.SetRelayoutEnabled( false ); mScrollView.SetSize(stageSize); // attach Wobble Effect to ScrollView @@ -489,7 +488,6 @@ public: mScrollView.SetParentOrigin(ParentOrigin::CENTER); // Scale ScrollView to fit parent (mContentLayer) - mScrollView.SetRelayoutEnabled( true ); mScrollView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Add the scroll view to the content layer @@ -511,32 +509,30 @@ public: /** * Helper to create the cluster actors */ - Cluster CreateClusterActor(ClusterType clusterType, ClusterStyle style) + Cluster CreateClusterActor(ClusterType clusterType, ClusterStyle style, Vector3& clusterSize) { // Create the cluster actor with the given cluster style Cluster clusterActor = Cluster::New(style); clusterActor.SetParentOrigin(ParentOrigin::CENTER); clusterActor.SetAnchorPoint(AnchorPoint::CENTER); - clusterActor.SetRelayoutEnabled( false ); Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); float minStageDimension = std::min(stageSize.x, stageSize.y); - clusterActor.SetSize(minStageDimension * CLUSTER_RELATIVE_SIZE, minStageDimension * CLUSTER_RELATIVE_SIZE, 0.0f); + + clusterSize.x = minStageDimension * CLUSTER_RELATIVE_SIZE; + clusterSize.y = minStageDimension * CLUSTER_RELATIVE_SIZE; + + clusterActor.SetSize( clusterSize ); DALI_ASSERT_ALWAYS(clusterType < CLUSTER_COUNT); const char **paths = IMAGE_GROUPS[clusterType]; DALI_ASSERT_ALWAYS(paths); // Add a background image to the cluster, limiting the loaded size by - // fitting it inside a quarter of the stage area with the conservative Box + // fitting it inside a quarter of the stage area with the conservative BOX // filter mode: - Dali::ImageAttributes backgroundAttributes; - backgroundAttributes.SetSize( Stage::GetCurrent().GetSize() * 0.5f ); - backgroundAttributes.SetFilterMode( Dali::ImageAttributes::Box ); - backgroundAttributes.SetScalingMode( Dali::ImageAttributes::ShrinkToFit ); - Image bg = ResourceImage::New( CLUSTER_BACKGROUND_IMAGE_PATH ); + Image bg = ResourceImage::New( CLUSTER_BACKGROUND_IMAGE_PATH, Dali::ImageDimensions( stageSize.x * 0.5f, stageSize.y * 0.5f ), Dali::FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX ); ImageActor image = ImageActor::New(bg); - image.SetRelayoutEnabled( false ); clusterActor.SetBackgroundImage(image); // Add actors (pictures) as the children of the cluster @@ -563,14 +559,11 @@ public: actor.SetAnchorPoint( AnchorPoint::CENTER ); // Load the thumbnail at quarter of screen width or standard size if that is smaller: - ImageAttributes attribs = ImageAttributes::New(); Size stageQuarter = Stage::GetCurrent().GetSize() * 0.25f; - attribs.SetSize( std::min( stageQuarter.x, CLUSTER_IMAGE_THUMBNAIL_WIDTH), std::min( stageQuarter.y, CLUSTER_IMAGE_THUMBNAIL_HEIGHT ) ); - attribs.SetFilterMode( Dali::ImageAttributes::BoxThenLinear ); - attribs.SetScalingMode(Dali::ImageAttributes::ShrinkToFit ); + const ImageDimensions requestedDims = ImageDimensions( std::min( stageQuarter.x, CLUSTER_IMAGE_THUMBNAIL_WIDTH ), std::min( stageQuarter.y, CLUSTER_IMAGE_THUMBNAIL_HEIGHT ) ); // Add a shadow image child actor - Image shadowImage = ResourceImage::New( CLUSTER_SHADOW_IMAGE_PATH, attribs ); + Image shadowImage = ResourceImage::New( CLUSTER_SHADOW_IMAGE_PATH, requestedDims, Dali::FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX ); ImageActor shadowActor = ImageActor::New(shadowImage); // Shadow is not exactly located on the center of the image, so it is moved to a little @@ -585,7 +578,7 @@ public: actor.Add( shadowActor ); // Add a picture image actor to actor (with equal size to the parent). - Image image = ResourceImage::New( imagePath, attribs ); + Image image = ResourceImage::New( imagePath, requestedDims, Dali::FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX ); ImageActor imageActor = ImageActor::New( image ); imageActor.SetParentOrigin( ParentOrigin::CENTER ); imageActor.SetAnchorPoint( AnchorPoint::CENTER ); @@ -629,19 +622,18 @@ public: mScrollView.Add(pageView); pageView.SetParentOrigin(ParentOrigin::CENTER); pageView.SetPosition(Vector3(stageSize.width * column, 0.0f, 0.0f)); - pageView.SetRelayoutEnabled( true ); pageView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); // Create cluster actors, add them to scroll view, and set the shear effect with the given center point. - Cluster cluster = CreateClusterActor(clusterType, style); + Vector3 clusterSize; + Cluster cluster = CreateClusterActor( clusterType, style, clusterSize ); cluster.SetParentOrigin(ParentOrigin::TOP_LEFT); cluster.SetAnchorPoint(AnchorPoint::TOP_LEFT); cluster.SetPosition( clusterPosition ); pageView.Add(cluster); - Vector3 clusterSize = cluster.GetCurrentSize(); - mClusterInfo.push_back(ClusterInfo( cluster, mClusterCount, clusterPosition, clusterSize )); + mClusterInfo.push_back( ClusterInfo( cluster, mClusterCount, clusterPosition, clusterSize ) ); mClusterCount++; } diff --git a/examples/cube-transition-effect/cube-transition-effect-example.cpp b/examples/cube-transition-effect/cube-transition-effect-example.cpp index 691fe06..abc16d8 100644 --- a/examples/cube-transition-effect/cube-transition-effect-example.cpp +++ b/examples/cube-transition-effect/cube-transition-effect-example.cpp @@ -91,19 +91,15 @@ const int VIEWINGTIME = 2000; // 2 seconds /** * @brief Load an image, scaled-down to no more than the stage dimensions. * - * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at + * Uses image scaling mode SCALE_TO_FILL to resize the image at * load time to cover the entire stage with pixels with no borders, - * and filter mode ImageAttributes::BoxThenLinear to sample the image with + * and filter mode BOX_THEN_LINEAR to sample the image with * maximum quality. */ ResourceImage LoadStageFillingImage( const char * const imagePath ) { Size stageSize = Stage::GetCurrent().GetSize(); - ImageAttributes attributes; - attributes.SetSize( stageSize.x, stageSize.y ); - attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); - attributes.SetScalingMode( ImageAttributes::ScaleToFill ); - return ResourceImage::New( imagePath, attributes ); + return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); } } // namespace @@ -330,7 +326,6 @@ void CubeTransitionApp::GoToNextImage() mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION); mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); - mNextImage.SetRelayoutEnabled( false ); mCurrentEffect.SetTargetImage(mNextImage); if( image.GetLoadingState() == ResourceLoadingSucceeded ) { diff --git a/examples/dissolve-effect/dissolve-effect-example.cpp b/examples/dissolve-effect/dissolve-effect-example.cpp index 59da358..fdada71 100644 --- a/examples/dissolve-effect/dissolve-effect-example.cpp +++ b/examples/dissolve-effect/dissolve-effect-example.cpp @@ -77,19 +77,15 @@ const float INITIAL_DEPTH = -10.0f; /** * @brief Load an image, scaled-down to no more than the stage dimensions. * - * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at + * Uses image scaling mode SCALE_TO_FILL to resize the image at * load time to cover the entire stage with pixels with no borders, - * and filter mode ImageAttributes::BoxThenLinear to sample the image with + * and filter mode BOX_THEN_LINEAR to sample the image with * maximum quality. */ ResourceImage LoadStageFillingImage( const char * const imagePath ) { Size stageSize = Stage::GetCurrent().GetSize(); - ImageAttributes attributes; - attributes.SetSize( stageSize.x, stageSize.y ); - attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); - attributes.SetScalingMode( ImageAttributes::ScaleToFill ); - return ResourceImage::New( imagePath, attributes ); + return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); } } // namespace @@ -254,7 +250,6 @@ void DissolveEffectApp::OnInit( Application& application ) // show the first image mCurrentImage = ImageActor::New( LoadStageFillingImage( IMAGES[mIndex] ) ); - mCurrentImage.SetRelayoutEnabled( false ); mCurrentImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); @@ -285,7 +280,6 @@ void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); mNextImage = ImageActor::New( image ); - mNextImage.SetRelayoutEnabled( false ); mNextImage.SetPositionInheritanceMode(USE_PARENT_POSITION_PLUS_LOCAL_POSITION); mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); diff --git a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp index 8fb6496..d0772a3 100644 --- a/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp +++ b/examples/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp @@ -27,7 +27,7 @@ * The functions CreateImage and CreateImageActor below show how to build an * image using a scaling mode to have %Dali resize it during loading. * - * This demo defaults to the ScaleToFill mode of ImageAttributes which makes + * This demo defaults to the SCALE_TO_FILL mode of ImageAttributes which makes * sure that every pixel in the loaded image is filled with a source colour * from the image's central region while losing the minimum number of pixels * from its periphery. @@ -77,7 +77,7 @@ const unsigned GRID_CELL_PADDING = 4; /** The aspect ratio of cells in the image grid. */ const float CELL_ASPECT_RATIO = 1.33333333333333333333f; -const ImageAttributes::ScalingMode DEFAULT_SCALING_MODE = ImageAttributes::ScaleToFill; +const Dali::FittingMode::Type DEFAULT_SCALING_MODE = Dali::FittingMode::SCALE_TO_FILL; /** The number of times to spin an image on touching, each spin taking a second.*/ const float SPIN_DURATION = 1.0f; @@ -172,19 +172,15 @@ const unsigned NUM_IMAGE_PATHS = sizeof(IMAGE_PATHS) / sizeof(IMAGE_PATHS[0]) - * @param[in] filename The path of the image. * @param[in] width The width of the image in pixels. * @param[in] height The height of the image in pixels. - * @param[in] scalingMode The mode to use when scaling the image to fit the desired dimensions. + * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions. */ -Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, ImageAttributes::ScalingMode scalingMode ) +Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode ) { #ifdef DEBUG_PRINT_DIAGNOSTICS - fprintf( stderr, "CreateImage(%s, %u, %u, scalingMode=%u)\n", filename.c_str(), width, height, unsigned( scalingMode ) ); + fprintf( stderr, "CreateImage(%s, %u, %u, fittingMode=%u)\n", filename.c_str(), width, height, unsigned( fittingMode ) ); #endif - ImageAttributes attributes; + Image image = ResourceImage::New( filename, ImageDimensions( width, height ), fittingMode, Dali::SamplingMode::BOX_THEN_LINEAR ); - attributes.SetSize( width, height ); - attributes.SetScalingMode( scalingMode ); - attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); - Image image = ResourceImage::New( filename, attributes ); return image; } @@ -194,11 +190,11 @@ Image CreateImage(const std::string& filename, unsigned int width, unsigned int * @param[in] filename The path of the image. * @param[in] width The width of the image in pixels. * @param[in] height The height of the image in pixels. - * @param[in] scalingMode The mode to use when scaling the image to fit the desired dimensions. + * @param[in] fittingMode The mode to use when scaling the image to fit the desired dimensions. */ -ImageActor CreateImageActor(const std::string& filename, unsigned int width, unsigned int height, ImageAttributes::ScalingMode scalingMode ) +ImageActor CreateImageActor(const std::string& filename, unsigned int width, unsigned int height, Dali::FittingMode::Type fittingMode ) { - Image img = CreateImage( filename, width, height, scalingMode ); + Image img = CreateImage( filename, width, height, fittingMode ); ImageActor actor = ImageActor::New( img ); actor.SetName( filename ); actor.SetParentOrigin(ParentOrigin::CENTER); @@ -208,22 +204,22 @@ ImageActor CreateImageActor(const std::string& filename, unsigned int width, uns } /** Cycle the scaling mode options. */ -ImageAttributes::ScalingMode NextMode( const ImageAttributes::ScalingMode oldMode ) +Dali::FittingMode::Type NextMode( const Dali::FittingMode::Type oldMode ) { - ImageAttributes::ScalingMode newMode = ImageAttributes::ShrinkToFit; + Dali::FittingMode::Type newMode = FittingMode::SHRINK_TO_FIT; switch ( oldMode ) { - case ImageAttributes::ShrinkToFit: - newMode = ImageAttributes::ScaleToFill; + case FittingMode::SHRINK_TO_FIT: + newMode = FittingMode::SCALE_TO_FILL; break; - case ImageAttributes::ScaleToFill: - newMode = ImageAttributes::FitWidth; + case FittingMode::SCALE_TO_FILL: + newMode = FittingMode::FIT_WIDTH; break; - case ImageAttributes::FitWidth: - newMode = ImageAttributes::FitHeight; + case FittingMode::FIT_WIDTH: + newMode = FittingMode::FIT_HEIGHT; break; - case ImageAttributes::FitHeight: - newMode = ImageAttributes::ShrinkToFit; + case FittingMode::FIT_HEIGHT: + newMode = FittingMode::SHRINK_TO_FIT; break; } return newMode; @@ -273,7 +269,7 @@ public: : mApplication( application ), mScrolling( false ) { - std::cout << "ImageScalingScaleToFillController::ImageScalingScaleToFillController" << std::endl; + std::cout << "ImageScalingIrregularGridController::ImageScalingIrregularGridController" << std::endl; // Connect to the Application's Init signal mApplication.InitSignal().Connect( this, &ImageScalingIrregularGridController::Create ); @@ -289,7 +285,7 @@ public: */ void Create( Application& application ) { - std::cout << "ImageScalingScaleToFillController::Create" << std::endl; + std::cout << "ImageScalingIrregularGridController::Create" << std::endl; DemoHelper::RequestThemeChange(); @@ -326,13 +322,13 @@ public: /** * Build the main part of the application's view. */ - void PopulateContentLayer( const ImageAttributes::ScalingMode scalingMode ) + void PopulateContentLayer( const Dali::FittingMode::Type fittingMode ) { Stage stage = Stage::GetCurrent(); Vector2 stageSize = stage.GetSize(); float fieldHeight; - Actor imageField = BuildImageField( stageSize.x, GRID_WIDTH, GRID_MAX_HEIGHT, scalingMode, fieldHeight ); + Actor imageField = BuildImageField( stageSize.x, GRID_WIDTH, GRID_MAX_HEIGHT, fittingMode, fieldHeight ); mScrollView = ScrollView::New(); @@ -375,7 +371,7 @@ public: Actor BuildImageField( const float fieldWidth, const unsigned gridWidth, const unsigned maxGridHeight, - ImageAttributes::ScalingMode scalingMode, + Dali::FittingMode::Type fittingMode, float & outFieldHeight ) { // Generate the list of image configurations to be fitted into the field: @@ -423,7 +419,6 @@ public: // coordinates in a frame defined by a parent actor: Actor gridActor = Actor::New(); - gridActor.SetRelayoutEnabled( true ); gridActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); gridActor.SetParentOrigin( ParentOrigin::CENTER ); gridActor.SetAnchorPoint( AnchorPoint::CENTER ); @@ -443,11 +438,11 @@ public: const Vector2 imageRegionCorner = gridOrigin + cellSize * Vector2( imageSource.cellX, imageSource.cellY ); const Vector2 imagePosition = imageRegionCorner + Vector2( GRID_CELL_PADDING , GRID_CELL_PADDING ) + imageSize * 0.5f; - ImageActor image = CreateImageActor( imageSource.configuration.path, imageSize.x, imageSize.y, scalingMode ); + ImageActor image = CreateImageActor( imageSource.configuration.path, imageSize.x, imageSize.y, fittingMode ); image.SetPosition( Vector3( imagePosition.x, imagePosition.y, 0 ) ); image.SetSize( imageSize ); image.TouchedSignal().Connect( this, &ImageScalingIrregularGridController::OnTouchImage ); - mScalingModes[image.GetId()] = scalingMode; + mFittingModes[image.GetId()] = fittingMode; mSizes[image.GetId()] = imageSize; gridActor.Add( image ); @@ -475,14 +470,14 @@ public: // Change the scaling mode: const unsigned id = actor.GetId(); - ImageAttributes::ScalingMode newMode = NextMode( mScalingModes[id] ); + Dali::FittingMode::Type newMode = NextMode( mFittingModes[id] ); const Vector2 imageSize = mSizes[actor.GetId()]; ImageActor imageActor = ImageActor::DownCast( actor ); Image oldImage = imageActor.GetImage(); Image newImage = CreateImage( ResourceImage::DownCast(oldImage).GetUrl(), imageSize.width + 0.5f, imageSize.height + 0.5f, newMode ); imageActor.SetImage( newImage ); - mScalingModes[id] = newMode; + mFittingModes[id] = newMode; } } return false; @@ -520,14 +515,14 @@ public: { // Cycle the scaling mode options: const Vector2 imageSize = mSizes[gridImageActor.GetId()]; - ImageAttributes::ScalingMode newMode = NextMode( mScalingModes[gridImageActor.GetId()] ); + Dali::FittingMode::Type newMode = NextMode( mFittingModes[gridImageActor.GetId()] ); Image oldImage = gridImageActor.GetImage(); Image newImage = CreateImage(ResourceImage::DownCast(oldImage).GetUrl(), imageSize.width, imageSize.height, newMode ); gridImageActor.SetImage( newImage ); - mScalingModes[gridImageActor.GetId()] = newMode; + mFittingModes[gridImageActor.GetId()] = newMode; - SetTitle( std::string( newMode == ImageAttributes::ShrinkToFit ? "ShrinkToFit" : newMode == ImageAttributes::ScaleToFill ? "ScaleToFill" : newMode == ImageAttributes::FitWidth ? "FitWidth" : "FitHeight" ) ); + SetTitle( std::string( newMode == FittingMode::SHRINK_TO_FIT ? "SHRINK_TO_FIT" : newMode == FittingMode::SCALE_TO_FILL ? "SCALE_TO_FILL" : newMode == FittingMode::FIT_WIDTH ? "FIT_WIDTH" : "FIT_HEIGHT" ) ); } } return true; @@ -579,7 +574,7 @@ private: Actor mGridActor; ///< The container for the grid of images ScrollView mScrollView; ///< ScrollView UI Component bool mScrolling; ///< ScrollView scrolling state (true = scrolling, false = stationary) - std::map mScalingModes; ///< Stores the current scaling mode of each image, keyed by image actor id. + std::map mFittingModes; ///< Stores the current scaling mode of each image, keyed by image actor id. std::map mSizes; ///< Stores the current size of each image, keyed by image actor id. }; diff --git a/examples/item-view/item-view-example.cpp b/examples/item-view/item-view-example.cpp index a750d4f..9bfbac8 100644 --- a/examples/item-view/item-view-example.cpp +++ b/examples/item-view/item-view-example.cpp @@ -314,7 +314,6 @@ public: // Create the item view actor mImageAtlas = CreateImageAtlas(); mItemView = ItemView::New(*this); - mItemView.SetRelayoutEnabled( false ); mItemView.SetParentOrigin(ParentOrigin::CENTER); mItemView.SetAnchorPoint(AnchorPoint::CENTER); @@ -905,7 +904,6 @@ public: // From ItemFactory // Add a checkbox child actor; invisible until edit-mode is enabled ImageActor checkbox = ImageActor::New( mWhiteImage ); - checkbox.SetRelayoutEnabled( false ); checkbox.SetName( "CheckBox" ); checkbox.SetColor( Vector4(0.0f,0.0f,0.0f,0.6f) ); checkbox.SetParentOrigin( ParentOrigin::TOP_RIGHT ); @@ -922,7 +920,6 @@ public: // From ItemFactory actor.Add( checkbox ); ImageActor tick = ImageActor::New( ResourceImage::New(SELECTED_IMAGE) ); - tick.SetRelayoutEnabled( false ); tick.SetColorMode( USE_OWN_COLOR ); tick.SetName( "Tick" ); tick.SetParentOrigin( ParentOrigin::TOP_RIGHT ); @@ -1010,7 +1007,6 @@ private: slider.Add( text ); Actor textContainer = Actor::New(); - textContainer.SetRelayoutEnabled( true ); textContainer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mAlphaFunctionText = TextLabel::New( ALPHA_FUNCTIONS_TEXT[mAlphaFuncIndex] ); mAlphaFunctionText.SetAnchorPoint( ParentOrigin::CENTER ); @@ -1029,7 +1025,6 @@ private: text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); textContainer.Add( text ); - mMenu.MarkDirtyForRelayout(); mMenu.Show(); mMenuShown = true; } diff --git a/examples/magnifier/magnifier-example.cpp b/examples/magnifier/magnifier-example.cpp index 4c8ea21..791935d 100644 --- a/examples/magnifier/magnifier-example.cpp +++ b/examples/magnifier/magnifier-example.cpp @@ -219,14 +219,12 @@ public: // Create magnifier (controlled by human touch) Layer overlay = Layer::New(); - overlay.SetRelayoutEnabled( false ); overlay.SetSensitive(false); overlay.SetParentOrigin( ParentOrigin::CENTER ); overlay.SetSize(mStageSize); Stage::GetCurrent().Add(overlay); mMagnifier = Toolkit::Magnifier::New(); - mMagnifier.SetRelayoutEnabled( false ); mMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); mMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width mMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); @@ -234,7 +232,7 @@ public: overlay.Add( mMagnifier ); // Apply constraint to animate the position of the magnifier. - Constraint constraint = Constraint::New( mMagnifier, Actor::Property::POSITION, ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT) ); + Constraint constraint = Constraint::New( mMagnifier, Actor::Property::POSITION, ConfinementConstraint(Vector3( 0.5f, 0.5f, 0.0f ), Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT) ); constraint.AddSource( LocalSource(Actor::Property::SIZE) ); constraint.AddSource( LocalSource(Actor::Property::PARENT_ORIGIN) ); constraint.AddSource( LocalSource(Actor::Property::ANCHOR_POINT) ); @@ -244,7 +242,6 @@ public: // Create bouncing magnifier automatically bounces around screen. mBouncingMagnifier = Toolkit::Magnifier::New(); - mBouncingMagnifier.SetRelayoutEnabled( false ); mBouncingMagnifier.SetSourceActor( mView.GetBackgroundLayer() ); mBouncingMagnifier.SetSize( MAGNIFIER_SIZE * mStageSize.width ); // Size of magnifier is in relation to stage width mBouncingMagnifier.SetMagnificationFactor( MAGNIFICATION_FACTOR ); diff --git a/examples/motion-blur/motion-blur-example.cpp b/examples/motion-blur/motion-blur-example.cpp index b1528af..c35f474 100644 --- a/examples/motion-blur/motion-blur-example.cpp +++ b/examples/motion-blur/motion-blur-example.cpp @@ -92,18 +92,14 @@ const float ORIENTATION_DURATION = 0.5f; ///< Time to rotate to /** * @brief Load an image, scaled-down to no more than the dimensions passed in. * - * Uses ImageAttributes::ShrinkToFit which ensures the resulting image is + * Uses SHRINK_TO_FIT which ensures the resulting image is * smaller than or equal to the specified dimensions while preserving its * original aspect ratio. */ ResourceImage LoadImageFittedInBox( const char * const imagePath, uint32_t maxWidth, uint32_t maxHeight ) { // Load the image nicely scaled-down to fit within the specified max width and height: - ImageAttributes attributes; - attributes.SetSize( maxWidth, maxHeight); - attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); - attributes.SetScalingMode( ImageAttributes::ShrinkToFit ); - return ResourceImage::New( imagePath, attributes ); + return ResourceImage::New( imagePath, ImageDimensions( maxWidth, maxHeight ), FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX_THEN_LINEAR ); } } // unnamed namespace @@ -193,8 +189,8 @@ public: winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); // set initial orientation - app.GetOrientation().ChangedSignal().Connect( this, &MotionBlurExampleApp::OnOrientationChanged ); - unsigned int degrees = app.GetOrientation().GetDegrees(); + winHandle.GetOrientation().ChangedSignal().Connect( this, &MotionBlurExampleApp::OnOrientationChanged ); + unsigned int degrees = winHandle.GetOrientation().GetDegrees(); Rotate( static_cast< DeviceOrientation >( degrees ) ); diff --git a/examples/motion-stretch/motion-stretch-example.cpp b/examples/motion-stretch/motion-stretch-example.cpp index 98a8380..ff61118 100644 --- a/examples/motion-stretch/motion-stretch-example.cpp +++ b/examples/motion-stretch/motion-stretch-example.cpp @@ -166,8 +166,8 @@ public: winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); - app.GetOrientation().ChangedSignal().Connect( this, &MotionStretchExampleApp::OnOrientationChanged ); - unsigned int degrees = app.GetOrientation().GetDegrees(); + winHandle.GetOrientation().ChangedSignal().Connect( this, &MotionStretchExampleApp::OnOrientationChanged ); + unsigned int degrees = winHandle.GetOrientation().GetDegrees(); Rotate( static_cast< DeviceOrientation >( degrees ) ); diff --git a/examples/new-window/new-window-example.cpp b/examples/new-window/new-window-example.cpp index 877aa2d..1f918f0 100644 --- a/examples/new-window/new-window-example.cpp +++ b/examples/new-window/new-window-example.cpp @@ -222,8 +222,9 @@ FrameBufferImage NewWindowController::CreateMirrorImage(const char* imageName) ImageActor NewWindowController::CreateBlurredMirrorImage(const char* imageName) { FrameBufferImage fbo; - Image image = ResourceImage::New( imageName ); - Vector2 FBOSize = ResourceImage::GetImageSize(imageName); + Image image = ResourceImage::New(imageName); + Uint16Pair intFboSize = ResourceImage::GetImageSize(imageName); + Vector2 FBOSize = Vector2( intFboSize.GetWidth(), intFboSize.GetHeight() ); fbo = FrameBufferImage::New( FBOSize.width, FBOSize.height, Pixel::RGBA8888); GaussianBlurView gbv = GaussianBlurView::New(5, 2.0f, Pixel::RGBA8888, 0.5f, 0.5f, true); gbv.SetBackgroundColor(Color::TRANSPARENT); @@ -241,7 +242,8 @@ ImageActor NewWindowController::CreateBlurredMirrorImage(const char* imageName) FrameBufferImage NewWindowController::CreateFrameBufferForImage(const char* imageName, Image image, ShaderEffect shaderEffect) { Stage stage = Stage::GetCurrent(); - Vector2 FBOSize = ResourceImage::GetImageSize(imageName); + Uint16Pair intFboSize = ResourceImage::GetImageSize(imageName); + Vector2 FBOSize = Vector2(intFboSize.GetWidth(), intFboSize.GetHeight()); FrameBufferImage framebuffer = FrameBufferImage::New(FBOSize.x, FBOSize.y ); @@ -264,7 +266,6 @@ FrameBufferImage NewWindowController::CreateFrameBufferForImage(const char* imag cameraActor.SetNearClippingPlane(1.0f); cameraActor.SetAspectRatio(FBOSize.width / FBOSize.height); cameraActor.SetType(Dali::Camera::FREE_LOOK); // camera orientation based solely on actor - cameraActor.SetOrientation(Quaternion(M_PI, Vector3::YAXIS)); cameraActor.SetPosition(0.0f, 0.0f, ((FBOSize.height * 0.5f) / tanf(Math::PI * 0.125f))); stage.Add(cameraActor); diff --git a/examples/page-turn-view/page-turn-view-example.cpp b/examples/page-turn-view/page-turn-view-example.cpp index 33498cd..a57b9f4 100644 --- a/examples/page-turn-view/page-turn-view-example.cpp +++ b/examples/page-turn-view/page-turn-view-example.cpp @@ -91,8 +91,6 @@ class PortraitPageFactory : public PageFactory page = ImageActor::New( ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ) ); } - page.SetRelayoutEnabled( false ); - return page; } }; @@ -129,9 +127,6 @@ class LandscapePageFactory : public PageFactory } pageFront.Add(pageBack); - pageFront.SetRelayoutEnabled( false ); - pageBack.SetRelayoutEnabled( false ); - return pageFront; } }; @@ -237,7 +232,6 @@ void PageTurnController::OnInit( Application& app ) // Create default View. mView = View::New(); - mView.SetRelayoutEnabled( false ); stage.Add( mView ); Dali::Window winHandle = app.GetWindow(); @@ -251,7 +245,6 @@ void PageTurnController::OnInit( Application& app ) mView.OrientationAnimationStartedSignal().Connect( this, &PageTurnController::OnOrientationAnimationStarted ); mPageTurnPortraitView = PageTurnPortraitView::New( mPortraitPageFactory, stageSize ); - mPageTurnPortraitView.SetRelayoutEnabled( false ); mPageTurnPortraitView.SetSpineShadowParameter( Vector2(70.f, 30.f) ); mPageTurnPortraitView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); mPageTurnPortraitView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); @@ -260,7 +253,6 @@ void PageTurnController::OnInit( Application& app ) mPageTurnPortraitView.SetPositionInheritanceMode( USE_PARENT_POSITION ); mPageTurnLandscapeView = PageTurnLandscapeView::New( mLandscapePageFactory, Vector2(stageSize.y*0.5f, stageSize.x) ); - mPageTurnLandscapeView.SetRelayoutEnabled( false ); mPageTurnLandscapeView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); mPageTurnLandscapeView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); mPageTurnLandscapeView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan ); diff --git a/examples/path-animation/path-animation.cpp b/examples/path-animation/path-animation.cpp index 18c5140..5566cc9 100644 --- a/examples/path-animation/path-animation.cpp +++ b/examples/path-animation/path-animation.cpp @@ -70,7 +70,6 @@ public: text.SetColor( Vector4(0.0f,0.0f,0.0f,1.0f)); Slider slider = Slider::New(); - slider.SetRelayoutEnabled( false ); slider.SetAnchorPoint( AnchorPoint::CENTER_LEFT); slider.SetParentOrigin( ParentOrigin::CENTER_RIGHT); slider.SetProperty(Slider::Property::LOWER_BOUND, -1.0f ); @@ -102,8 +101,8 @@ public: //TextInput Dali::Layer controlsLayer = Dali::Layer::New(); - controlsLayer.SetRelayoutEnabled( false ); - controlsLayer.SetSize( stage.GetSize().x, stage.GetSize().y*0.3f, 0.0 ); + controlsLayer.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); + controlsLayer.SetSizeModeFactor( Vector3( 1.0f, 0.3f, 1.0f ) ); controlsLayer.SetPosition( 0.0f, stage.GetSize().y*0.8f, 0.0f ); controlsLayer.SetAnchorPoint( AnchorPoint::TOP_LEFT); controlsLayer.SetParentOrigin( ParentOrigin::TOP_LEFT); @@ -202,7 +201,6 @@ public: if( !mControlPoint[index] ) { mControlPoint[index] = Toolkit::CreateSolidColorActor(Vector4(1.0f,1.0f,1.0f,1.0f)); - mControlPoint[index].SetRelayoutEnabled( false ); mControlPoint[index].SetParentOrigin( ParentOrigin::TOP_LEFT); mControlPoint[index].SetAnchorPoint( AnchorPoint::CENTER ); mControlPoint[index].SetSize( 20.0f, 20.0f ); @@ -224,7 +222,6 @@ public: if( !mControlPoint[index]) { mControlPoint[index] = Toolkit::CreateSolidColorActor(Vector4(1.0f,1.0f,1.0f,1.0f)); - mControlPoint[index].SetRelayoutEnabled( false ); mControlPoint[index].SetParentOrigin( ParentOrigin::TOP_LEFT); mControlPoint[index].SetAnchorPoint( AnchorPoint::CENTER ); mControlPoint[index].SetSize( 20.0f, 20.0f ); @@ -470,10 +467,8 @@ public: DrawPath( 200u ); //Actor - ImageAttributes attributes; - Image img = ResourceImage::New(ACTOR_IMAGE, attributes ); + Image img = ResourceImage::New(ACTOR_IMAGE); mActor = ImageActor::New( img ); - mActor.SetRelayoutEnabled( false ); mActor.SetAnchorPoint( AnchorPoint::CENTER ); mActor.SetSize( 100, 50, 1 ); stage.Add( mActor ); diff --git a/examples/radial-menu/radial-menu-example.cpp b/examples/radial-menu/radial-menu-example.cpp index ac735bf..278dddc 100644 --- a/examples/radial-menu/radial-menu-example.cpp +++ b/examples/radial-menu/radial-menu-example.cpp @@ -149,7 +149,9 @@ void RadialMenuExample::OnInit(Application& app) Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_PLAY_PADDING ); - Vector2 imgSize = ResourceImage::GetImageSize(TEST_OUTER_RING_FILENAME); + + const Uint16Pair intImgSize = ResourceImage::GetImageSize(TEST_OUTER_RING_FILENAME); + Vector2 imgSize = Vector2( intImgSize.GetWidth(), intImgSize.GetHeight() ); Vector2 stageSize = stage.GetSize(); float minStageDimension = std::min(stageSize.width, stageSize.height); @@ -248,8 +250,8 @@ RadialSweepView RadialMenuExample::CreateSweepView( std::string imageName, mImageActor.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); // Create the stencil - Vector2 imageSize = ResourceImage::GetImageSize(imageName); - float diameter = std::max(imageSize.width, imageSize.height); + const Uint16Pair imageSize = ResourceImage::GetImageSize(imageName); + float diameter = std::max(imageSize.GetWidth(), imageSize.GetHeight()); RadialSweepView radialSweepView = RadialSweepView::New(); radialSweepView.SetDiameter( diameter ); radialSweepView.SetInitialAngle( initialAngle ); diff --git a/examples/radial-menu/radial-sweep-view-impl.cpp b/examples/radial-menu/radial-sweep-view-impl.cpp index bc9925c..1062406 100644 --- a/examples/radial-menu/radial-sweep-view-impl.cpp +++ b/examples/radial-menu/radial-sweep-view-impl.cpp @@ -26,10 +26,8 @@ namespace * Method to project a point on a circle of radius halfSide at given * angle onto a square of side 2 * halfSide */ -void CircleSquareProjection( Vector3& position, Degree angle, float halfSide ) +void CircleSquareProjection( Vector3& position, Radian angle, float halfSide ) { - Radian angleInRadians(angle); - // 135 90 45 // +--+--+ // | \|/ | @@ -37,25 +35,25 @@ void CircleSquareProjection( Vector3& position, Degree angle, float halfSide ) // | /|\ | // +--+--+ // 225 270 315 - if( angle >= 45.0f && angle < 135.0f ) + if( angle >= Dali::ANGLE_45 && angle < Dali::ANGLE_135 ) { - position.x = halfSide * cosf(angleInRadians) / sinf(angleInRadians); + position.x = halfSide * cosf(angle) / sinf(angle); position.y = -halfSide; } - else if( angle >= 135.0f && angle < 225.0f ) + else if( angle >= Dali::ANGLE_135 && angle < Dali::ANGLE_225 ) { position.x = -halfSide; - position.y = halfSide * sinf(angleInRadians) / cosf(angleInRadians); + position.y = halfSide * sinf(angle) / cosf(angle); } - else if( angle >= 225.0f && angle < 315.0f ) + else if( angle >= Dali::ANGLE_225 && angle < Dali::ANGLE_315 ) { - position.x = -halfSide * cosf(angleInRadians) / sinf(angleInRadians); + position.x = -halfSide * cosf(angle) / sinf(angle); position.y = halfSide; } else { position.x = halfSide; - position.y = -halfSide * sinf(angleInRadians) / cosf(angleInRadians); + position.y = -halfSide * sinf(angle) / cosf(angle); } position.z = 0.0f; @@ -133,7 +131,7 @@ RadialSweepView RadialSweepViewImpl::New( float duration, float diameter, Degree } RadialSweepViewImpl::RadialSweepViewImpl( float duration, float diameter, Degree initialAngle, Degree finalAngle, Degree initialSector, Degree finalSector ) -: Control( CONTROL_BEHAVIOUR_NONE ), +: Control( ControlBehaviour( ACTOR_BEHAVIOUR_NONE ) ), mDuration(duration), mDiameter(diameter), mInitialAngle(initialAngle), @@ -273,7 +271,7 @@ void RadialSweepViewImpl::Activate( Animation anim, float offsetTime, float dura } mStencilActor.SetOrientation( Degree(mInitialAngle), Vector3::ZAXIS ); - mStencilActor.SetProperty( mRotationAngleIndex, static_cast(mInitialSector) ); + mStencilActor.SetProperty( mRotationAngleIndex, mInitialSector.degree ); if( mRotateActors ) { @@ -282,13 +280,13 @@ void RadialSweepViewImpl::Activate( Animation anim, float offsetTime, float dura Actor actor = mLayer.GetChildAt(i); if( actor != mStencilActor ) { - anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mInitialActorAngle ) ), Vector3::ZAXIS ) ); + anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( mInitialActorAngle ), Vector3::ZAXIS ) ); } } } - anim.AnimateTo( Property( mStencilActor, mRotationAngleIndex ), static_cast(mFinalSector), mEasingFunction, TimePeriod( offsetTime, duration ) ); - anim.AnimateTo( Property( mStencilActor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mFinalAngle ) ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); + anim.AnimateTo( Property( mStencilActor, mRotationAngleIndex ), mFinalSector.degree, mEasingFunction, TimePeriod( offsetTime, duration ) ); + anim.AnimateTo( Property( mStencilActor, Actor::Property::ORIENTATION ), Quaternion( Radian( mFinalAngle ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); if( mRotateActorsWithStencil ) { @@ -297,7 +295,7 @@ void RadialSweepViewImpl::Activate( Animation anim, float offsetTime, float dura Actor actor = mLayer.GetChildAt(i); if( actor != mStencilActor ) { - anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mFinalAngle - mInitialAngle ) ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); + anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mFinalAngle.degree - mInitialAngle.degree ) ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); } } } @@ -308,7 +306,7 @@ void RadialSweepViewImpl::Activate( Animation anim, float offsetTime, float dura Actor actor = mLayer.GetChildAt(i); if( actor != mStencilActor ) { - anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( Degree( mFinalActorAngle ) ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); + anim.AnimateTo( Property( actor, Actor::Property::ORIENTATION ), Quaternion( Radian( mFinalActorAngle ), Vector3::ZAXIS ), mEasingFunction, TimePeriod( offsetTime, duration ) ); } } } @@ -357,10 +355,10 @@ void RadialSweepViewImpl::CreateStencil( Degree initialSector ) mStencilActor.SetCullFace(CullNone); // Allow clockwise & anticlockwise faces mStartAngleIndex = mStencilActor.RegisterProperty("start-angle", Property::Value(0.0f)); - mRotationAngleIndex = mStencilActor.RegisterProperty("rotation-angle", Property::Value(initialSector)); + mRotationAngleIndex = mStencilActor.RegisterProperty("rotation-angle", Property::Value(initialSector.degree)); Source srcStart( mStencilActor, mStartAngleIndex ); - Source srcRot( mStencilActor, mRotationAngleIndex ); + Source srcRotation( mStencilActor, mRotationAngleIndex ); // Constrain the vertices of the square mesh to sweep out a sector as the // rotation angle is animated. @@ -371,27 +369,27 @@ void RadialSweepViewImpl::CreateStencil( Degree initialSector ) constraint = Constraint::New( mMesh, mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION), SquareFanConstraint(0) ); constraint.AddSource( srcStart ); - constraint.AddSource( srcRot ); + constraint.AddSource( srcRotation ); constraint.Apply(); constraint = Constraint::New( mMesh, mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION), SquareFanConstraint(1) ); constraint.AddSource( srcStart ); - constraint.AddSource( srcRot ); + constraint.AddSource( srcRotation ); constraint.Apply(); constraint = Constraint::New( mMesh, mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION), SquareFanConstraint(2) ); constraint.AddSource( srcStart ); - constraint.AddSource( srcRot ); + constraint.AddSource( srcRotation ); constraint.Apply(); constraint = Constraint::New( mMesh, mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION), SquareFanConstraint(3) ); constraint.AddSource( srcStart ); - constraint.AddSource( srcRot ); + constraint.AddSource( srcRotation ); constraint.Apply(); constraint = Constraint::New( mMesh, mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION), SquareFanConstraint(4) ); constraint.AddSource( srcStart ); - constraint.AddSource( srcRot ); + constraint.AddSource( srcRotation ); constraint.Apply(); mStencilActor.SetDrawMode( DrawMode::STENCIL ); diff --git a/examples/refraction-effect/refraction-effect-example.cpp b/examples/refraction-effect/refraction-effect-example.cpp index cf43e1f..dfcf9d8 100644 --- a/examples/refraction-effect/refraction-effect-example.cpp +++ b/examples/refraction-effect/refraction-effect-example.cpp @@ -71,19 +71,14 @@ struct LightOffsetConstraint /** * @brief Load an image, scaled-down to no more than the stage dimensions. * - * Uses image scaling mode ImageAttributes::ScaleToFill to resize the image at + * Uses image scaling mode SCALE_TO_FILL to resize the image at * load time to cover the entire stage with pixels with no borders, - * and filter mode ImageAttributes::BoxThenLinear to sample the image with - * maximum quality. + * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality. */ ResourceImage LoadStageFillingImage( const char * const imagePath ) { Size stageSize = Stage::GetCurrent().GetSize(); - ImageAttributes attributes; - attributes.SetSize( stageSize.x, stageSize.y ); - attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); - attributes.SetScalingMode( ImageAttributes::ScaleToFill ); - return ResourceImage::New( imagePath, attributes ); + return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); } } // namespace diff --git a/examples/scroll-view/scroll-view-example.cpp b/examples/scroll-view/scroll-view-example.cpp index 4fa6c22..e499377 100644 --- a/examples/scroll-view/scroll-view-example.cpp +++ b/examples/scroll-view/scroll-view-example.cpp @@ -228,7 +228,6 @@ private: Vector2 stageSize = stage.GetSize(); mScrollView = ScrollView::New(); - mScrollView.SetRelayoutEnabled( false ); mScrollView.SetAnchorPoint(AnchorPoint::CENTER); mScrollView.SetParentOrigin(ParentOrigin::CENTER); mContentLayer.Add( mScrollView ); @@ -301,7 +300,6 @@ private: Actor CreatePage() { Actor page = Actor::New(); - page.SetRelayoutEnabled( true ); page.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); page.SetParentOrigin( ParentOrigin::CENTER ); page.SetAnchorPoint( AnchorPoint::CENTER ); @@ -454,7 +452,6 @@ private: void ApplyEffectToPage(Actor page) { page.RemoveConstraints(); - page.SetRelayoutEnabled( true ); page.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); switch( mEffectMode ) @@ -564,14 +561,9 @@ private: */ ImageActor CreateImage( const std::string& filename, unsigned int width = IMAGE_THUMBNAIL_WIDTH, unsigned int height = IMAGE_THUMBNAIL_HEIGHT ) { - ImageAttributes attributes; + Image img = ResourceImage::New(filename, ImageDimensions( width, height ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); - attributes.SetSize(width, height); - attributes.SetScalingMode(ImageAttributes::ScaleToFill); - attributes.SetFilterMode( ImageAttributes::BoxThenLinear ); - Image img = ResourceImage::New(filename, attributes); ImageActor actor = ImageActor::New(img); - actor.SetRelayoutEnabled( false ); actor.SetName( filename ); actor.SetParentOrigin(ParentOrigin::CENTER); actor.SetAnchorPoint(AnchorPoint::CENTER); diff --git a/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp b/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp index 74b1a88..4a3ca8a 100644 --- a/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp +++ b/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp @@ -33,7 +33,7 @@ const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-default.png" ); const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); const char* APPLICATION_TITLE_PAN_LIGHT( "Lighting: Pan Light" ); -const char* APPLICATION_TITLE_PAN_OBJECT( "Lighting: Pan Object" ); +const char* APPLICATION_TITLE_PAN_OBJECT( "Lighting: Rotate Object" ); const char* APPLICATION_TITLE_PAN_SCENE( "Lighting: Pan Scene" ); const char* APPLICATION_TITLE_ROTATE_SCENE( "Lighting: Rotate Scene" ); const char* CHANGE_EFFECT_IMAGE( DALI_IMAGE_DIR "icon-change.png" ); @@ -43,7 +43,6 @@ const char* SCENE_IMAGE_1( DALI_IMAGE_DIR "gallery-small-10.jpg"); const char* SCENE_IMAGE_2( DALI_IMAGE_DIR "gallery-small-42.jpg"); const char* SCENE_IMAGE_3( DALI_IMAGE_DIR "gallery-small-48.jpg"); -const Quaternion JAUNTY_ROTATION(Math::PI/5.0f, Math::PI/5.0f, 0.0f); // Euler angles const float MIN_PINCH_SCALE( 0.3f ); const float MAX_PINCH_SCALE( 2.05f ); @@ -55,6 +54,11 @@ const Vector3 FRONT_POINT( 0.0f, 0.0f, 20.0f); const Vector2 DEFAULT_STAGE_SIZE( 480.0f, 800.0f ); +const float X_ROTATION_DISPLACEMENT_FACTOR = 60.f; +const float Y_ROTATION_DISPLACEMENT_FACTOR = 60.f; +const float LIGHT_PAN_X_DISPLACEMENT_FACTOR = 180.f; +const float LIGHT_PAN_Y_DISPLACEMENT_FACTOR = 180.f; + } /** @@ -74,12 +78,12 @@ public: : mApp(app), mPaused(false), mTranslation(Vector3::ZERO), - mLongitudinal(15.0f), - mAxisTilt(30.0f), - mLightLongitudinal(0.0f), - mLightAxisTilt(0.0f), - mObjectLongitudinal(0.0f), - mObjectAxisTilt(0.0f), + mSceneYRotation( Dali::ANGLE_30 * 0.5f ), + mSceneXRotation( Dali::ANGLE_30 ), + mLightYRotation(0.0f), + mLightXRotation(0.0f), + mObjectYRotation(0.0f), + mObjectXRotation(0.0f), mPinchScale(0.5f), mScaleAtPinchStart(0.5f), mPanState(PAN_SCENE) @@ -94,18 +98,6 @@ public: } public: - struct PositionInFrontOf - { - PositionInFrontOf() - { - } - - void operator()( Vector3& current, const PropertyInputContainer& inputs ) - { - current = inputs[0]->GetVector3(); - current.z += 1.0f; - } - }; struct RotationConstraint { @@ -116,8 +108,8 @@ public: void operator()( Quaternion& current, const PropertyInputContainer& inputs ) { - Degree angle( inputs[0]->GetFloat() ); - current = Quaternion( Radian(angle) * mSign, Vector3::YAXIS ); + Radian angle( inputs[0]->GetFloat() ); + current = Quaternion( angle * mSign, Vector3::YAXIS ); } float mSign; @@ -176,7 +168,7 @@ public: mView.SetPosition(Vector3(0.0f, 0.0f, -50)); mContents.SetPosition(mTranslation); - mContents.SetOrientation(CalculateWorldRotation(Radian(mLongitudinal), Radian(mAxisTilt))); + mContents.SetOrientation( CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) ); mContents.SetScale(mPinchScale, mPinchScale, mPinchScale); mPanGestureDetector = PanGestureDetector::New(); @@ -200,7 +192,6 @@ public: mShadowView.SetName("Container"); mShadowView.SetParentOrigin(ParentOrigin::CENTER); mShadowView.SetAnchorPoint(AnchorPoint::CENTER); - mShadowView.SetRelayoutEnabled( true ); mShadowView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mShadowView.SetPointLightFieldOfView( Math::PI / 2.0f); mContents.Add(mShadowView); @@ -220,7 +211,7 @@ public: mLightAnchor = Actor::New(); mLightAnchor.SetParentOrigin(ParentOrigin::CENTER); mLightAnchor.SetAnchorPoint(AnchorPoint::CENTER); - mLightAnchor.SetOrientation(CalculateWorldRotation(Radian(mLightLongitudinal), Radian(mLightAxisTilt))); + mLightAnchor.SetOrientation( 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) @@ -271,7 +262,7 @@ public: mImageActor2.Add(mImageActor1); mImageActor2.Add(mImageActor3); - Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value(30.0f)); + Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value( Dali::ANGLE_30 ) ); Source angleSrc( mImageActor2, angleIndex ); Constraint constraint = Constraint::New( mImageActor1, Actor::Property::ORIENTATION, RotationConstraint(-1.0f) ); @@ -286,7 +277,7 @@ public: // Want to animate angle from 30 => -30 and back again smoothly. - mSceneAnimation.AnimateTo( Property( mImageActor2, angleIndex ), Property::Value(-30.0f), AlphaFunctions::Sin ); + mSceneAnimation.AnimateTo( Property( mImageActor2, angleIndex ), Property::Value(-Dali::ANGLE_30), AlphaFunctions::Sin ); mSceneAnimation.SetLooping(true); mSceneAnimation.Play(); @@ -297,10 +288,10 @@ public: } - Quaternion CalculateWorldRotation(Radian longitude, Radian axisTilt ) + Quaternion CalculateWorldRotation( Radian XRotation, Radian YRotation ) { - Quaternion q(longitude, Vector3::YAXIS); - Quaternion p(axisTilt, Vector3::XAXIS); + Quaternion p( XRotation, Vector3::XAXIS ); + Quaternion q( YRotation, Vector3::YAXIS ); return p*q; } @@ -331,10 +322,11 @@ public: { case PAN_LIGHT: { - mLightLongitudinal += gesture.displacement.x/4.0f; - mLightAxisTilt -= gesture.displacement.y/6.0f; - mLightAxisTilt = Clamp(mLightAxisTilt, -90.0f, 90.0f); - mLightAnchor.SetOrientation(CalculateWorldRotation(Radian(mLightLongitudinal), Radian(mLightAxisTilt))); + mLightXRotation = mLightXRotation - gesture.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 = Clamp(mLightYRotation, -Dali::ANGLE_45, Dali::ANGLE_45 ); + mLightAnchor.SetOrientation( CalculateWorldRotation( mLightXRotation, mLightYRotation ) ); break; } @@ -347,19 +339,19 @@ public: case ROTATE_SCENE: { - mLongitudinal += gesture.displacement.x/4.0f; - mAxisTilt -= gesture.displacement.y/6.0f; - mAxisTilt = Clamp(mAxisTilt, -90.0f, 90.0f); - mContents.SetOrientation(CalculateWorldRotation(Radian(mLongitudinal), Radian(mAxisTilt))); + mSceneXRotation = mSceneXRotation - gesture.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 = Clamp( mSceneYRotation, -Dali::ANGLE_90, Dali::ANGLE_90 ); + mContents.SetOrientation( CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) ); break; } - case PAN_OBJECT: + case ROTATE_OBJECT: { - mObjectLongitudinal += gesture.displacement.x/4.0f; - mObjectAxisTilt -= gesture.displacement.y/6.0f; - mObjectAxisTilt = Clamp(mObjectAxisTilt, -90.0f, 90.0f); - mSceneActor.SetOrientation(CalculateWorldRotation(Radian(mObjectLongitudinal), Radian(mObjectAxisTilt))); + 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 + mSceneActor.SetOrientation( CalculateWorldRotation( mObjectXRotation, mObjectYRotation ) ); break; } } @@ -422,10 +414,10 @@ public: mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_LIGHT) ); break; case PAN_LIGHT: - mPanState = PAN_OBJECT; + mPanState = ROTATE_OBJECT; mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_OBJECT) ); break; - case PAN_OBJECT: + case ROTATE_OBJECT: mPanState = PAN_SCENE; mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_PAN_SCENE) ); break; @@ -443,9 +435,9 @@ public: mContents.SetPosition(mTranslation); // Align scene so that light anchor orientation is Z Axis - mAxisTilt = -mLightAxisTilt; - mLongitudinal = -mLightLongitudinal; - mContents.SetOrientation(CalculateWorldRotation(Radian(mLongitudinal), Radian(mAxisTilt))); + mSceneXRotation = -mLightXRotation; + mSceneYRotation = -mLightYRotation; + mContents.SetOrientation( CalculateWorldRotation( mSceneXRotation, mSceneYRotation ) ); return true; } @@ -470,12 +462,12 @@ private: PinchGestureDetector mPinchGestureDetector; TapGestureDetector mTapGestureDetector; Vector3 mTranslation; - Degree mLongitudinal; - Degree mAxisTilt; - Degree mLightLongitudinal; - Degree mLightAxisTilt; - Degree mObjectLongitudinal; - Degree mObjectAxisTilt; + Radian mSceneYRotation; + Radian mSceneXRotation; + Radian mLightYRotation; + Radian mLightXRotation; + Radian mObjectYRotation; + Radian mObjectXRotation; float mPinchScale; float mScaleAtPinchStart; @@ -489,7 +481,7 @@ private: PAN_SCENE, ROTATE_SCENE, PAN_LIGHT, - PAN_OBJECT + ROTATE_OBJECT }; PanState mPanState; diff --git a/examples/text-field/text-field-example.cpp b/examples/text-field/text-field-example.cpp index 0bc8e70..dfcd06a 100644 --- a/examples/text-field/text-field-example.cpp +++ b/examples/text-field/text-field-example.cpp @@ -87,8 +87,10 @@ public: mContainer.Add( field ); field.SetProperty( TextField::Property::TEXT, "Hello" ); + field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( BORDER_WIDTH, BORDER_WIDTH, stageSize.width - BORDER_WIDTH*2, stageSize.height - BORDER_WIDTH*2 ) ); Property::Value fieldText = field.GetProperty( TextField::Property::TEXT ); + std::cout << "Displaying text: " << fieldText.Get< std::string >() << std::endl; } diff --git a/examples/text-message-field/text-message-field-example.cpp b/examples/text-message-field/text-message-field-example.cpp new file mode 100644 index 0000000..37eb6a1 --- /dev/null +++ b/examples/text-message-field/text-message-field-example.cpp @@ -0,0 +1,167 @@ +/* + * Copyright (c) 2015 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +/** + * @file message-field-example.cpp + * @brief Basic usage of TextField control + */ + +// EXTERNAL INCLUDES +#include +#include + +using namespace Dali; +using namespace Dali::Toolkit; + +namespace +{ + const char* DESKTOP_IMAGE( DALI_IMAGE_DIR "woodEffect.jpg" ); + const Vector2 DESKTOP_SIZE( Vector2( 1440, 1600 ) ); + const Vector2 PHOTOBOX_SIZE( Vector2(330.0f, 80.0f ) ); + const float MAX_OFFSCREEN_RENDERING_SIZE = 2048.f; + const float SCREEN_BORDER = 5.0f; // Border around screen that Popups and handles will not exceed +} +/** + * @brief The main class of the demo. + */ +class TextMessageFieldExample : public ConnectionTracker +{ +public: + + TextMessageFieldExample( Application& application ) + : mApplication( application ), + mTargetActorPosition(), + mTargetActorSize() + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &TextMessageFieldExample::Create ); + } + + ~TextMessageFieldExample() + { + // Nothing to do here. + } + + /** + * One-time setup in response to Application InitSignal. + */ + void Create( Application& application ) + { + Stage stage = Stage::GetCurrent(); + mStageSize = stage.GetSize(); + + stage.KeyEventSignal().Connect(this, &TextMessageFieldExample::OnKeyEvent); + + // Create Root actor + Actor rootActor = Actor::New(); + rootActor.SetName("rootActor"); + rootActor.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + rootActor.SetSize( mStageSize ); + rootActor.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + + stage.Add( rootActor ); + + const Size mTargetActorSize( mStageSize.width, DESKTOP_SIZE.height ); + + // Create Desktop + ResourceImage backgroundImage = ResourceImage::New( DESKTOP_IMAGE ); + ImageActor desktop = ImageActor::New( backgroundImage ); + desktop.SetName("desktopActor"); + desktop.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + desktop.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + desktop.SetSize( mTargetActorSize ); + + rootActor.Add( desktop ); // Add desktop (content) to offscreen actor + + // Create Photo Box A + ImageActor photoBoxA = CreateSolidColorActor( Vector4(0,0,0,0), true, Color::WHITE, 1 ); + photoBoxA.SetName("photoBoxA"); + photoBoxA.SetAnchorPoint( AnchorPoint::CENTER ); + photoBoxA.SetParentOrigin( ParentOrigin::CENTER ); + photoBoxA.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + photoBoxA.SetSize( PHOTOBOX_SIZE ); + photoBoxA.SetPosition( 0.0f, -500.0f, 1.0f ); + desktop.Add( photoBoxA ); + + // Create TextField + TextField field = TextField::New(); + field.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); + field.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); + field.SetPadding( Padding( 1.0f, 1.0f, 1.0f, 1.0f ) ); + field.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + field.SetZ( 1.0f ); + field.SetProperty( TextField::Property::TEXT, "Enter Title name" ); + field.SetProperty( TextField::Property::DECORATION_BOUNDING_BOX, Rect( SCREEN_BORDER, SCREEN_BORDER, mStageSize.width - SCREEN_BORDER*2, mStageSize.height - SCREEN_BORDER*2 ) ); + photoBoxA.Add( field ); + + mPanGestureDetector = PanGestureDetector::New(); + mPanGestureDetector.DetectedSignal().Connect(this, &TextMessageFieldExample::OnPanGesture ); + mPanGestureDetector.Attach( desktop ); + } + + /** + * Main key event handler + */ + void OnKeyEvent(const KeyEvent& event) + { + if(event.state == KeyEvent::Down) + { + if( IsKey( event, DALI_KEY_ESCAPE) || IsKey( event, DALI_KEY_BACK ) ) + { + mApplication.Quit(); + } + } + } + + void OnPanGesture( Actor actor, const PanGesture& gesture ) + { + if( gesture.state == Gesture::Continuing ) + { + Vector2 position = Vector2( gesture.displacement ); + mTargetActorPosition.y = mTargetActorPosition.y + position.y; + mTargetActorPosition.y = std::min( mTargetActorPosition.y, -mTargetActorSize.height ); + mTargetActorPosition.y = std::max( mTargetActorPosition.y, ( mTargetActorSize.height - mStageSize.height*0.25f ) ); + actor.SetPosition( 0.0f, mTargetActorPosition.y ); + } + } + +private: + + Application& mApplication; + PanGestureDetector mPanGestureDetector; + + Vector2 mTargetActorPosition; + Vector2 mTargetActorSize; + Vector2 mStageSize; +}; + +void RunTest( Application& application ) +{ + TextMessageFieldExample test( application ); + + application.MainLoop(); +} + +/** Entry point for Linux & Tizen applications */ +int main( int argc, char **argv ) +{ + Application application = Application::New( &argc, &argv ); + + RunTest( application ); + + return 0; +} diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index aa810c8..40d65dc 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.0.38 +Version: 1.0.39 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/resources/images/message-field-box.png b/resources/images/message-field-box.png new file mode 100644 index 0000000..71cddc6 --- /dev/null +++ b/resources/images/message-field-box.png diff --git a/resources/images/woodEffect.jpg b/resources/images/woodEffect.jpg new file mode 100644 index 0000000..cb086be --- /dev/null +++ b/resources/images/woodEffect.jpg diff --git a/resources/scripts/timing.json b/resources/scripts/timing.json index a5d8024..e3864f1 100644 --- a/resources/scripts/timing.json +++ b/resources/scripts/timing.json @@ -113,12 +113,12 @@ ] }, { - "type": "TextView", - "text": "Touch", - "markup-enabled": true, + "type": "TextLabel", + "text": "Touch", "name": "Instruction", "parent-origin": "BOTTOM_CENTER", "anchor-point": "BOTTOM_CENTER", + "text-color": [1, 0, 0, 1], "position": [ 0, 0, diff --git a/shared/view.h b/shared/view.h index f5fa893..d1cca77 100644 --- a/shared/view.h +++ b/shared/view.h @@ -76,8 +76,8 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, toolBarLayer.SetName( "TOOLBAR_LAYER" ); toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); - toolBarLayer.SetSize( 0.0f, style.mToolBarHeight ); toolBarLayer.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::WIDTH ); + toolBarLayer.SetSize( 0.0f, style.mToolBarHeight ); // Raise tool bar layer to the top. toolBarLayer.RaiseToTop(); @@ -139,11 +139,7 @@ Dali::Layer CreateView( Dali::Application& application, // Set background image, loading it at screen resolution: if ( !backgroundImagePath.empty() ) { - Dali::ImageAttributes backgroundAttributes; - backgroundAttributes.SetSize( stage.GetSize() ); - backgroundAttributes.SetFilterMode( Dali::ImageAttributes::BoxThenLinear ); - backgroundAttributes.SetScalingMode( Dali::ImageAttributes::ScaleToFill ); - Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath, backgroundAttributes ); + Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath, Dali::ImageDimensions( stage.GetSize().x, stage.GetSize().y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); Dali::ImageActor backgroundImageActor = Dali::ImageActor::New( backgroundImage ); view.SetBackground( backgroundImageActor ); }