diff --git a/README b/README index e1c2d35..77a178a 100644 --- a/README +++ b/README @@ -39,7 +39,7 @@ T.O.C. To build the repository enter the 'build/tizen' folder: - cd dali-toolkit/build/tizen + cd dali-demo/build/tizen Then run the following commands: diff --git a/com.samsung.dali-demo.xml b/com.samsung.dali-demo.xml index aaf6dd5..028ee55 100644 --- a/com.samsung.dali-demo.xml +++ b/com.samsung.dali-demo.xml @@ -79,4 +79,10 @@ + + + + + + diff --git a/demo/dali-demo.cpp b/demo/dali-demo.cpp index 281fe63..a2741e8 100644 --- a/demo/dali-demo.cpp +++ b/demo/dali-demo.cpp @@ -43,6 +43,7 @@ int main(int argc, char **argv) demo.AddExample(Example("image-scaling-irregular-grid.example", "Image Scaling Modes")); demo.AddExample(Example("text-view.example", "Text View")); demo.AddExample(Example("animated-shapes.example", "Animated Shapes")); + demo.AddExample(Example("path-animation.example", "Path Animation")); app.MainLoop(); return 0; diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index 4ccfd05..bb7bc7c 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -181,11 +181,36 @@ bool CompareByTitle( const Example& lhs, const Example& rhs ) } // namespace DaliTableView::DaliTableView( Application& application ) - : mApplication( application ), - mScrolling( false ), - mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ), - mSortAlphabetically( false ), - mBackgroundAnimsPlaying( false ) +: mApplication( application ), + mBackgroundLayer(), + mRootActor(), + mRotateAnimation(), + mBackground(), + mLogo(), + mPressedAnimation(), + mScrollViewLayer(), + mScrollView(), + mScrollViewEffect(), + mScrollRulerX(), + mScrollRulerY(), + mButtons(), + mPressedActor(), + mAnimationTimer(), + mLogoTapDetector(), + mVersionPopup(), + mButtonsPageRelativeSize(), + mPages(), + mTableViewImages(), + mBackgroundActors(), + mBackgroundAnimations(), + mExampleList(), + mExampleMap(), + mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ), + mTotalPages(), + mScrolling( false ), + mSortAlphabetically( false ), + mBackgroundAnimsPlaying( false ), + mVersionPopupShown( false ) { application.InitSignal().Connect( this, &DaliTableView::Initialize ); } @@ -247,6 +272,11 @@ void DaliTableView::Initialize( Application& application ) const float logoHeight = mLogo.GetImage().GetHeight() + logoMargin; mRootActor.SetFixedHeight( 1, logoHeight ); + // Show version in a popup when log is tapped + mLogoTapDetector = TapGestureDetector::New(); + mLogoTapDetector.Attach( mLogo ); + mLogoTapDetector.DetectedSignal().Connect( this, &DaliTableView::OnLogoTapped ); + const float bottomMargin = paddingHeight * BOTTOM_PADDING_RATIO; mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, 1.f - ( toolbarHeight + logoHeight + bottomMargin) / stageSize.height, TABLE_RELATIVE_SIZE.z ); mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height ); @@ -262,7 +292,7 @@ void DaliTableView::Initialize( Application& application ) mScrollView.SetParentOrigin( ParentOrigin::CENTER ); // Note: Currently, changing mScrollView to use SizeMode RELATIVE_TO_PARENT // will cause scroll ends to appear in the wrong position. - mScrollView.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::Size, Dali::ParentSource( Dali::Actor::Property::Size ), Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) ); + mScrollView.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) ); mScrollView.SetAxisAutoLock( true ); mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); @@ -679,7 +709,14 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) { if ( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) { - mApplication.Quit(); + if ( mVersionPopup && mVersionPopupShown ) + { + HideVersionPopup(); + } + else + { + mApplication.Quit(); + } } } } @@ -733,9 +770,9 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis dfActor.SetPosition( actorPos ); // Define bubble horizontal parallax and vertical wrapping - Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::Position, + Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION, Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ), - Dali::ParentSource( Dali::Actor::Property::Size ), + Dali::ParentSource( Dali::Actor::Property::SIZE ), AnimateBubbleConstraint( actorPos, Random::Range( -0.85f, 0.25f ), randSize ) ); dfActor.ApplyConstraint( animConstraint ); @@ -746,7 +783,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis Vector3 toPos( actorPos ); toPos.y -= ( size.y + randSize ); keyframes.Add( 1.0f, toPos ); - animation.AnimateBetween( Property( dfActor, Actor::Property::Position ), keyframes ); + animation.AnimateBetween( Property( dfActor, Actor::Property::POSITION ), keyframes ); animation.SetLooping( true ); animation.Play(); mBackgroundAnimations.push_back( animation ); @@ -945,4 +982,45 @@ bool DaliTableView::OnTileHovered( Actor actor, const HoverEvent& event ) return true; } +void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap ) +{ + if ( !mVersionPopupShown ) + { + if ( !mVersionPopup ) + { + std::ostringstream stream; + stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")" << std::endl << std::endl; + stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")" << std::endl << std::endl; + stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")"; + + mVersionPopup = Dali::Toolkit::Popup::New(); + mVersionPopup.SetTitle( stream.str() ); + mVersionPopup.SetParentOrigin( ParentOrigin::CENTER ); + mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER ); + mVersionPopup.HideTail(); + mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup ); + mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden ); + + Dali::Stage::GetCurrent().Add( mVersionPopup ); + } + + mVersionPopup.Show(); + mVersionPopupShown = true; + } +} + +void DaliTableView::HideVersionPopup() +{ + if ( mVersionPopup ) + { + mVersionPopup.Hide(); + } +} +void DaliTableView::PopupHidden() +{ + if ( mVersionPopup ) + { + mVersionPopupShown = false; + } +} diff --git a/demo/dali-table-view.h b/demo/dali-table-view.h index bc77fba..fbaa2ea 100644 --- a/demo/dali-table-view.h +++ b/demo/dali-table-view.h @@ -360,38 +360,59 @@ private: // Application callbacks & implementation */ void OnFocusedActorActivated( Dali::Actor activatedActor ); + /** + * Called when the logo is tapped + * + * @param[in] actor The tapped actor + * @param[in] tap The tap information. + */ + void OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap ); + + /** + * Hides the popup + */ + void HideVersionPopup(); + + /** + * Called when the popup is completely hidden + */ + void PopupHidden(); + private: - Dali::Application& mApplication; ///< Application instance. - Dali::Layer mBackgroundLayer; ///< Background resides on a separate layer. - Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor) - Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor. - Dali::ImageActor mBackground; ///< Background's static image. - Dali::ImageActor mLogo; ///< Logo's static image. - Dali::Animation mPressedAnimation; ///< Button press scaling animation. - Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer. - Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples) - Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view - bool mScrolling; ///< Flag indicating whether view is currently being scrolled - Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler - Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler - Dali::Toolkit::TableView mButtons; ///< Navigation buttons - ExampleList mExampleList; ///< List of examples. - ExampleMap mExampleMap; ///< Map LUT for examples. - Dali::ActorContainer mPages; ///< List of pages. - Dali::Actor mPressedActor; ///< The currently pressed actor. - int mTotalPages; ///< Total pages within scrollview. - std::string mBackgroundImagePath; ///< The path to the background image. - bool mSortAlphabetically; ///< Sort examples alphabetically. - - Dali::ActorContainer mTableViewImages; ///< Offscreen render of tableview - Dali::ActorContainer mBackgroundActors; ///< List of background actors used in the effect - - AnimationList mBackgroundAnimations;///< List of background bubble animations - Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period - bool mBackgroundAnimsPlaying; ///< Are background animations playing - - Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size + Dali::Application& mApplication; ///< Application instance. + Dali::Layer mBackgroundLayer; ///< Background resides on a separate layer. + Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor) + Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor. + Dali::ImageActor mBackground; ///< Background's static image. + Dali::ImageActor mLogo; ///< Logo's static image. + Dali::Animation mPressedAnimation; ///< Button press scaling animation. + Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer. + Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples) + Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view + Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler + Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler + Dali::Toolkit::TableView mButtons; ///< Navigation buttons + Dali::Actor mPressedActor; ///< The currently pressed actor. + Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period + Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo + Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information + Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size + + Dali::ActorContainer mPages; ///< List of pages. + Dali::ActorContainer mTableViewImages; ///< Offscreen render of tableview + Dali::ActorContainer mBackgroundActors; ///< List of background actors used in the effect + AnimationList mBackgroundAnimations; ///< List of background bubble animations + ExampleList mExampleList; ///< List of examples. + ExampleMap mExampleMap; ///< Map LUT for examples. + + std::string mBackgroundImagePath; ///< The path to the background image. + int mTotalPages; ///< Total pages within scrollview. + + bool mScrolling:1; ///< Flag indicating whether view is currently being scrolled + bool mSortAlphabetically:1; ///< Sort examples alphabetically. + bool mBackgroundAnimsPlaying:1; ///< Are background animations playing + bool mVersionPopupShown:1; ///< Whehter the version popup is shown or not }; #endif // __DALI_DEMO_H__ diff --git a/examples/atlas/atlas-example.cpp b/examples/atlas/atlas-example.cpp new file mode 100644 index 0000000..cad730d --- /dev/null +++ b/examples/atlas/atlas-example.cpp @@ -0,0 +1,233 @@ +/* + * 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. + * + */ + +#include +#include "shared/view.h" +#include +#include + +using namespace Dali; + +class AtlasController; + +namespace +{ +const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-gradient.jpg" ); +const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); +const char * const LOSE_CONTEXT_IMAGE( DALI_IMAGE_DIR "icon-cluster-wobble.png" ); + +Application gApplication; +AtlasController* gAtlasController(NULL); +} + +class AtlasController : public ConnectionTracker +{ +public: + + AtlasController( Application& application ) + : mApplication( application ) + { + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &AtlasController::Create ); + } + + ~AtlasController() + { + // Nothing to do here; + } + + void Create( Application& application ) + { + // Get a handle to the stage + Stage stage = Stage::GetCurrent(); + stage.SetBackgroundColor(Color::YELLOW); + + // Respond to a click anywhere on the stage + stage.KeyEventSignal().Connect(this, &AtlasController::OnKeyEvent); + + mApplication.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); + + mContentLayer = DemoHelper::CreateView( mApplication, + mView, + mToolBar, + BACKGROUND_IMAGE, + TOOLBAR_IMAGE, + "Atlas" ); + + mLoseContextButton = Toolkit::PushButton::New(); + mLoseContextButton.SetBackgroundImage( ResourceImage::New( LOSE_CONTEXT_IMAGE ) ); + mLoseContextButton.ClickedSignal().Connect( this, &AtlasController::OnLoseContextButtonClicked ); + mToolBar.AddControl( mLoseContextButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); + + mAtlas = Atlas::New( 400,300, Pixel::RGBA8888); + mAtlas.Clear(Vector4(0.f,0.5f,0.5f,0.5f)); + mAtlas.Upload( DALI_IMAGE_DIR "icon-change.png", 50, 30 ); + mAtlas.Upload( DALI_IMAGE_DIR "icon-cluster-carousel.png", 100, 30 ); + mAtlas.Upload( DALI_IMAGE_DIR "icon-effects-on.png", 150, 30 ); + mAtlas.Upload( DALI_IMAGE_DIR "icon-effect-cross.png", 100, 80 ); + mAtlas.Upload( DALI_IMAGE_DIR "icon-effect-fold.png", 150, 80 ); + mAtlas.Upload( DALI_IMAGE_DIR "icon-effect-wave.png", 200, 80 ); + mAtlas.Upload( DALI_IMAGE_DIR "icon-item-view-layout-depth.png", 150, 130 ); + mAtlas.Upload( DALI_IMAGE_DIR "icon-item-view-layout-grid.png", 200, 130 ); + mAtlas.Upload( DALI_IMAGE_DIR "icon-item-view-layout-spiral.png", 250, 130 ); + UploadBufferImages(); + + ImageActor imageActor1 = ImageActor::New( mAtlas ); + imageActor1.SetY(-170.f); + imageActor1.SetParentOrigin(ParentOrigin::CENTER); + mContentLayer.Add( imageActor1 ); + + Atlas atlas2 = Atlas::New( 400,400, Pixel::RGB888); + atlas2.Clear( Color::RED ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-1.jpg", 4, 4 ); + atlas2.Clear( Color::BLUE ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-2.jpg", 136, 4 ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-3.jpg", 268, 4 ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-4.jpg", 4, 136 ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-5.jpg", 136, 136 ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-6.jpg", 268, 135 ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-7.jpg", 4, 268 ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-7.jpg", 136, 268 ); + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-7.jpg", 268, 268 ); + + + ImageActor imageActor2 = ImageActor::New( atlas2 ); + imageActor2.SetY(200.f); + imageActor2.SetZ(-1.f); + imageActor2.SetParentOrigin(ParentOrigin::CENTER); + mContentLayer.Add( imageActor2 ); + + mPanGestureDetector = PanGestureDetector::New(); + mPanGestureDetector.DetectedSignal().Connect(this, &AtlasController::OnPanGesture); + mPanGestureDetector.Attach(imageActor1); + mPanGestureDetector.Attach(imageActor2); + + stage.ContextLostSignal().Connect(this, &AtlasController::OnContextLost); + stage.ContextRegainedSignal().Connect(this, &AtlasController::OnContextRegained); + } + + void UploadBufferImages() + { + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 1.f, 0.5f ), 80, 90 ), 0, 210 ); + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 0.75f, 0.5f ), 80, 80 ), 40, 210 ); + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 0.5f, 0.5f ), 80, 70 ), 80, 210 ); + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 0.25f, 0.5f ), 80, 60 ), 120, 210 ); + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 0.f, 0.5f ), 80, 50 ), 160, 210 ); + mAtlas.Upload( CreateBufferImage( Vector4(0.75f, 0.75f, 0.f, 0.5f ), 80, 40 ), 200, 210 ); + mAtlas.Upload( CreateBufferImage( Vector4(0.5f, 0.5f, 0.f, 0.5f ), 80, 30 ), 240, 210 ); + mAtlas.Upload( CreateBufferImage( Vector4(0.25f, 0.25f, 0.f, 0.5f ), 80, 20 ), 280, 210 ); + mAtlas.Upload( CreateBufferImage( Vector4(0.1f, 0.1f, 0.f, 0.5f ), 80, 10 ), 320, 210 ); + BufferImage redBlock = CreateBufferImage( Color::RED, 40, 40 ); + mAtlas.Upload(redBlock, 320, 30); + mAtlas.Upload(redBlock, 320, 80); + mAtlas.Upload(redBlock, 320, 130); + } + + static void NewWindow(void) + { + PositionSize posSize(0, 0, 720, 1280); + gApplication.ReplaceWindow(posSize, "NewWindow"); // Generates a new window + } + + bool OnLoseContextButtonClicked( Toolkit::Button button ) + { + // Add as an idle callback to avoid ProcessEvents being recursively called. + mApplication.AddIdle(MakeCallback( AtlasController::NewWindow )); + return true; + } + + void OnKeyEvent( const KeyEvent& event ) + { + if(event.state == KeyEvent::Down) + { + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) + { + mApplication.Quit(); + } + } + } + + void OnPanGesture( Actor actor, const PanGesture& gesture ) + { + if( gesture.state == Gesture::Continuing ) + { + actor.MoveBy( Vector3( gesture.displacement ) ); + } + } + + void OnContextLost() + { + printf("Stage reporting context loss\n"); + } + + void OnContextRegained() + { + printf("Stage reporting context regain\n"); + UploadBufferImages(); + } + +private: + + BufferImage CreateBufferImage( const Vector4& color, const unsigned int width, const unsigned int height ) + { + BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 ); + + // Create the image + PixelBuffer* pixbuf = imageData.GetBuffer(); + const unsigned int bitmapSize = width * height; + for( size_t i = 0; i < bitmapSize; ++i ) + { + pixbuf[i*4+0] = 0xFF * color.r; + pixbuf[i*4+1] = 0xFF * color.g; + pixbuf[i*4+2] = 0xFF * color.b; + pixbuf[i*4+3] = 0xFF * color.a; + } + + imageData.Update(); + + return imageData; + } + + +private: + Application& mApplication; + PanGestureDetector mPanGestureDetector; + + Toolkit::View mView; ///< The View instance. + Toolkit::ToolBar mToolBar; ///< The View's Toolbar. + Toolkit::TextView mTitleActor; ///< The Toolbar's Title. + Layer mContentLayer; ///< Content layer (scrolling cluster content) + Toolkit::PushButton mLoseContextButton; + Atlas mAtlas; +}; + +void RunTest( Application& application ) +{ + gAtlasController = new AtlasController(application); + application.MainLoop(Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS); +} + +// Entry point for Linux & SLP applications +// +int main( int argc, char **argv ) +{ + gApplication = Application::New( &argc, &argv ); + + RunTest( gApplication ); + + return 0; +} diff --git a/examples/blocks/blocks-example.cpp b/examples/blocks/blocks-example.cpp index 9cf4395..4f723c4 100644 --- a/examples/blocks/blocks-example.cpp +++ b/examples/blocks/blocks-example.cpp @@ -346,7 +346,7 @@ private: mPaddleImage.SetSize( mPaddleFullSize ); mWobbleProperty = mPaddle.RegisterProperty(WOBBLE_PROPERTY_NAME, 0.0f); - Constraint wobbleConstraint = Constraint::New( Actor::Property::Rotation, + Constraint wobbleConstraint = Constraint::New( Actor::Property::ROTATION, LocalSource(mWobbleProperty), WobbleConstraint(10.0f)); mPaddle.ApplyConstraint(wobbleConstraint); @@ -359,16 +359,16 @@ private: const float margin(BALL_SIZE.width * stageSize.width * 0.5f); // Set up notifications for ball's collisions against walls. - PropertyNotification leftNotification = mBall.AddPropertyNotification( Actor::Property::PositionX, LessThanCondition(margin) ); + PropertyNotification leftNotification = mBall.AddPropertyNotification( Actor::Property::POSITION_X, LessThanCondition(margin) ); leftNotification.NotifySignal().Connect( this, &ExampleController::OnHitLeftWall ); - PropertyNotification rightNotification = mBall.AddPropertyNotification( Actor::Property::PositionX, GreaterThanCondition(stageSize.width - margin) ); + PropertyNotification rightNotification = mBall.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(stageSize.width - margin) ); rightNotification.NotifySignal().Connect( this, &ExampleController::OnHitRightWall ); - PropertyNotification topNotification = mBall.AddPropertyNotification( Actor::Property::PositionY, LessThanCondition(margin) ); + PropertyNotification topNotification = mBall.AddPropertyNotification( Actor::Property::POSITION_Y, LessThanCondition(margin) ); topNotification.NotifySignal().Connect( this, &ExampleController::OnHitTopWall ); - PropertyNotification bottomNotification = mBall.AddPropertyNotification( Actor::Property::PositionY, GreaterThanCondition(stageSize.height + margin) ); + PropertyNotification bottomNotification = mBall.AddPropertyNotification( Actor::Property::POSITION_Y, GreaterThanCondition(stageSize.height + margin) ); bottomNotification.NotifySignal().Connect( this, &ExampleController::OnHitBottomWall ); // Set up notification for ball colliding against paddle. @@ -376,10 +376,10 @@ private: stage.Add(delegate); Property::Index property = delegate.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); Constraint constraint = Constraint::New( property, - Source(mBall, Actor::Property::Position), - Source(mPaddle, Actor::Property::Position), - Source(mBall, Actor::Property::Size), - Source(mPaddle, Actor::Property::Size), + Source(mBall, Actor::Property::POSITION), + Source(mPaddle, Actor::Property::POSITION), + Source(mBall, Actor::Property::SIZE), + Source(mPaddle, Actor::Property::SIZE), CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) )); delegate.ApplyConstraint(constraint); @@ -599,10 +599,10 @@ private: // Add a constraint on the brick between it and the ball generating a collision-property Property::Index property = brick.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); Constraint constraint = Constraint::New( property, - Source(mBall, Actor::Property::Position), - Source(brick, Actor::Property::Position), - Source(mBall, Actor::Property::Size), - Source(brick, Actor::Property::Size), + Source(mBall, Actor::Property::POSITION), + Source(brick, Actor::Property::POSITION), + Source(mBall, Actor::Property::SIZE), + Source(brick, Actor::Property::SIZE), CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN)); brick.ApplyConstraint(constraint); @@ -639,7 +639,7 @@ private: } mBallAnimation = Animation::New(MAX_ANIMATION_DURATION); - mBallAnimation.AnimateBy( Property( mBall, Actor::Property::Position ), mBallVelocity * MAX_ANIMATION_DURATION); + mBallAnimation.AnimateBy( Property( mBall, Actor::Property::POSITION ), mBallVelocity * MAX_ANIMATION_DURATION); mBallAnimation.Play(); } @@ -661,8 +661,8 @@ private: mDragActor = actor; mDragAnimation = Animation::New(0.25f); - mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::Scale), Vector3(1.1f, 1.1f, 1.0f), AlphaFunctions::EaseOut); - mDragAnimation.AnimateTo( Property(mPaddleHandle, Actor::Property::Color), Vector4(1.0f, 1.0f, 1.0f, 0.0f), AlphaFunctions::EaseOut); + mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::SCALE), Vector3(1.1f, 1.1f, 1.0f), AlphaFunctions::EaseOut); + mDragAnimation.AnimateTo( Property(mPaddleHandle, Actor::Property::COLOR), Vector4(1.0f, 1.0f, 1.0f, 0.0f), AlphaFunctions::EaseOut); mDragAnimation.Play(); } } @@ -687,8 +687,8 @@ private: if(point.state==TouchPoint::Up) // Stop dragging { mDragAnimation = Animation::New(0.25f); - mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::Scale), Vector3(1.0f, 1.0f, 1.0f), AlphaFunctions::EaseIn); - mDragAnimation.AnimateTo( Property(mPaddleHandle, Actor::Property::Color), Vector4(1.0f, 1.0f, 1.0f, 1.0f), AlphaFunctions::EaseOut); + mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::SCALE), Vector3(1.0f, 1.0f, 1.0f), AlphaFunctions::EaseIn); + mDragAnimation.AnimateTo( Property(mPaddleHandle, Actor::Property::COLOR), Vector4(1.0f, 1.0f, 1.0f, 1.0f), AlphaFunctions::EaseOut); mDragAnimation.Play(); mDragActor.Reset(); } @@ -745,8 +745,8 @@ private: mBallVelocity = Vector3::ZERO; Animation shrink = Animation::New(0.5f); - shrink.AnimateTo( Property(mPaddle, Actor::Property::SizeWidth), mPaddleFullSize.x * f + mPaddleHitMargin.x); - shrink.AnimateTo( Property(mPaddleImage, Actor::Property::SizeWidth), mPaddleFullSize.x * f ); + shrink.AnimateTo( Property(mPaddle, Actor::Property::SIZE_WIDTH), mPaddleFullSize.x * f + mPaddleHitMargin.x); + shrink.AnimateTo( Property(mPaddleImage, Actor::Property::SIZE_WIDTH), mPaddleFullSize.x * f ); shrink.FinishedSignal().Connect( this, &ExampleController::OnPaddleShrunk ); shrink.Play(); @@ -763,7 +763,7 @@ private: mBall.SetPosition( mBallStartPosition ); mBall.SetColor( Vector4(1.0f, 1.0f, 1.0f, 0.1f) ); Animation appear = Animation::New(0.5f); - appear.AnimateTo( Property(mBall, Actor::Property::Color), Vector4(1.0f, 1.0f, 1.0f, 1.0f) ); + appear.AnimateTo( Property(mBall, Actor::Property::COLOR), Vector4(1.0f, 1.0f, 1.0f, 1.0f) ); appear.Play(); if(!mLives) @@ -830,7 +830,7 @@ private: // fade brick (destroy) Animation destroyAnimation = Animation::New(0.5f); - destroyAnimation.AnimateTo( Property( brick, Actor::Property::ColorAlpha ), 0.0f, AlphaFunctions::EaseIn ); + destroyAnimation.AnimateTo( Property( brick, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunctions::EaseIn ); destroyAnimation.Play(); destroyAnimation.FinishedSignal().Connect( this, &ExampleController::OnBrickDestroyed ); mDestroyAnimationMap[destroyAnimation] = brick; diff --git a/examples/cluster/cluster-example.cpp b/examples/cluster/cluster-example.cpp index 741cf6f..ecc7b06 100644 --- a/examples/cluster/cluster-example.cpp +++ b/examples/cluster/cluster-example.cpp @@ -707,7 +707,7 @@ public: Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) ); Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName()); Constraint constraint = Constraint::New( centerProperty, - Source(mView, Actor::Property::Size), + Source(mView, Actor::Property::SIZE), ShearEffectCenterConstraint(stageSize, shearCenter) ); shaderEffect.ApplyConstraint(constraint); @@ -720,12 +720,12 @@ public: constraint = Constraint::New( angleXAxisProperty, Source(mScrollView, scrollOvershootProperty), - Source(mView, Actor::Property::Rotation), + Source(mView, Actor::Property::ROTATION), ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) ); shaderEffect.ApplyConstraint(constraint); constraint = Constraint::New( angleYAxisProperty, Source(mScrollView, scrollOvershootProperty), - Source(mView, Actor::Property::Rotation), + Source(mView, Actor::Property::ROTATION), ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS) ); shaderEffect.ApplyConstraint(constraint); @@ -752,7 +752,7 @@ public: Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( shaderEffect.GetAnglePerUnitPropertyName() ); shaderEffect.ApplyConstraint( Constraint::New( anglePerUnit, - Source(mView, Actor::Property::Rotation), + Source(mView, Actor::Property::ROTATION), CarouselEffectOrientationConstraint( angleSweep ) ) ); break; @@ -779,7 +779,7 @@ public: // dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc for( std::vector::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i ) { - Constraint constraint = Constraint::New(Actor::Property::PositionZ, SphereEffectOffsetConstraint(SPHERE_EFFECT_POSITION_Z)); + Constraint constraint = Constraint::New(Actor::Property::POSITION_Z, SphereEffectOffsetConstraint(SPHERE_EFFECT_POSITION_Z)); constraint.SetRemoveAction(Constraint::Discard); Cluster cluster = i->mCluster; SetShaderEffectRecursively( cluster, shaderEffect ); diff --git a/examples/cube-transition-effect/cube-transition-effect-example.cpp b/examples/cube-transition-effect/cube-transition-effect-example.cpp index 00a8497..ac2fb2a 100644 --- a/examples/cube-transition-effect/cube-transition-effect-example.cpp +++ b/examples/cube-transition-effect/cube-transition-effect-example.cpp @@ -264,7 +264,7 @@ void CubeTransitionApp::OnInit( Application& application ) mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick ); // show the first image - mImageConstraint = Constraint::New( Actor::Property::Scale, LocalSource( Actor::Property::Size ), ParentSource( Actor::Property::Size ), ScaleToFitKeepAspectRatioConstraint() ); + mImageConstraint = Constraint::New( Actor::Property::SCALE, LocalSource( Actor::Property::SIZE ), ParentSource( Actor::Property::SIZE ), ScaleToFitKeepAspectRatioConstraint() ); mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) ); mCurrentImage.SetPositionInheritanceMode( USE_PARENT_POSITION ); diff --git a/examples/dissolve-effect/dissolve-effect-example.cpp b/examples/dissolve-effect/dissolve-effect-example.cpp index 888a254..374ac96 100644 --- a/examples/dissolve-effect/dissolve-effect-example.cpp +++ b/examples/dissolve-effect/dissolve-effect-example.cpp @@ -232,7 +232,7 @@ void DissolveEffectApp::OnInit( Application& application ) mParent.SetPositionInheritanceMode( USE_PARENT_POSITION ); mContent.Add( mParent ); - mSizeConstraint= Constraint::New( Actor::Property::Scale, LocalSource( Actor::Property::Size ), ParentSource( Actor::Property::Size ), ScaleToFitKeepAspectRatioConstraint() ); + mSizeConstraint= Constraint::New( Actor::Property::SCALE, LocalSource( Actor::Property::SIZE ), ParentSource( Actor::Property::SIZE ), ScaleToFitKeepAspectRatioConstraint() ); // show the first image mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) ); diff --git a/examples/item-view/item-view-example.cpp b/examples/item-view/item-view-example.cpp index f835fbc..a3cd43a 100644 --- a/examples/item-view/item-view-example.cpp +++ b/examples/item-view/item-view-example.cpp @@ -971,11 +971,11 @@ private: mMenu.Add( tableView ); Slider slider = Slider::New(); - slider.SetProperty( Slider::LOWER_BOUND_PROPERTY, 0.0f ); - slider.SetProperty( Slider::UPPER_BOUND_PROPERTY, 3.0f ); - slider.SetProperty( Slider::VALUE_PROPERTY, mDurationSeconds ); - slider.SetProperty( Slider::VALUE_PRECISION_PROPERTY, 2 ); - slider.SetProperty( Slider::SHOW_POPUP_PROPERTY, true ); + slider.SetProperty( Slider::Property::LOWER_BOUND, 0.0f ); + slider.SetProperty( Slider::Property::UPPER_BOUND, 3.0f ); + slider.SetProperty( Slider::Property::VALUE, mDurationSeconds ); + slider.SetProperty( Slider::Property::VALUE_PRECISION, 2 ); + slider.SetProperty( Slider::Property::SHOW_POPUP, true ); slider.ValueChangedSignal().Connect( this, &ItemViewExample::SliderValueChange ); tableView.AddChild( slider, TableView::CellPosition( 0, 0 ) ); tableView.SetRelativeHeight( 0, 0.5f ); @@ -993,7 +993,7 @@ private: text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); text.SetStyleToCurrentText( defaultTextStyle ); text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); - text.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SizeWidth, Dali::ParentSource( Dali::Actor::Property::SizeWidth ), Dali::EqualToConstraint() ) ); + text.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE_WIDTH, Dali::ParentSource( Dali::Actor::Property::SIZE_WIDTH ), Dali::EqualToConstraint() ) ); text.SetZ( -0.9f ); slider.Add( text ); @@ -1016,7 +1016,7 @@ private: text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); text.SetStyleToCurrentText( defaultTextStyle ); text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); - text.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SizeWidth, Dali::ParentSource( Dali::Actor::Property::SizeWidth ), Dali::EqualToConstraint() ) ); + text.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE_WIDTH, Dali::ParentSource( Dali::Actor::Property::SIZE_WIDTH ), Dali::EqualToConstraint() ) ); textContainer.Add( text ); mMenu.Show(); diff --git a/examples/magnifier/magnifier-example.cpp b/examples/magnifier/magnifier-example.cpp index 4186e8a..cb38a87 100644 --- a/examples/magnifier/magnifier-example.cpp +++ b/examples/magnifier/magnifier-example.cpp @@ -240,11 +240,11 @@ public: overlay.Add( mMagnifier ); // Apply constraint to animate the position of the magnifier. - Constraint constraint = Constraint::New(Actor::Property::Position, - LocalSource(Actor::Property::Size), - LocalSource(Actor::Property::ParentOrigin), - LocalSource(Actor::Property::AnchorPoint), - ParentSource(Actor::Property::Size), + Constraint constraint = Constraint::New(Actor::Property::POSITION, + LocalSource(Actor::Property::SIZE), + LocalSource(Actor::Property::PARENT_ORIGIN), + LocalSource(Actor::Property::ANCHOR_POINT), + ParentSource(Actor::Property::SIZE), ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT)); constraint.SetRemoveAction(Constraint::Discard); mMagnifier.ApplyConstraint( constraint ); @@ -260,15 +260,15 @@ public: ContinueAnimation(); // Apply constraint to animate the position of the magnifier. - constraint = Constraint::New(Actor::Property::Position, - LocalSource(Actor::Property::Size), + constraint = Constraint::New(Actor::Property::POSITION, + LocalSource(Actor::Property::SIZE), LocalSource(mAnimationTimeProperty), MagnifierPathConstraint(mStageSize, mStageSize * 0.5f)); mBouncingMagnifier.ApplyConstraint( constraint ); // Apply constraint to animate the source of the magnifier. constraint = Constraint::New(mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ), - LocalSource(Actor::Property::Size), + LocalSource(Actor::Property::SIZE), LocalSource(mAnimationTimeProperty), MagnifierPathConstraint(mStageSize)); mBouncingMagnifier.ApplyConstraint( constraint ); @@ -355,7 +355,7 @@ public: if(!mMagnifierShown) { Animation animation = Animation::New(MAGNIFIER_DISPLAY_DURATION); - animation.AnimateTo(Property(mMagnifier, Actor::Property::Scale), Vector3::ONE, AlphaFunctions::EaseIn); + animation.AnimateTo(Property(mMagnifier, Actor::Property::SCALE), Vector3::ONE, AlphaFunctions::EaseIn); animation.Play(); mMagnifierShown = true; } @@ -369,7 +369,7 @@ public: if(mMagnifierShown) { Animation animation = Animation::New(MAGNIFIER_DISPLAY_DURATION); - animation.AnimateTo(Property(mMagnifier, Actor::Property::Scale), Vector3::ZERO, AlphaFunctions::EaseOut); + animation.AnimateTo(Property(mMagnifier, Actor::Property::SCALE), Vector3::ZERO, AlphaFunctions::EaseOut); animation.Play(); mMagnifierShown = false; } diff --git a/examples/motion-blur/motion-blur-example.cpp b/examples/motion-blur/motion-blur-example.cpp index 82f7ab5..d09c54e 100644 --- a/examples/motion-blur/motion-blur-example.cpp +++ b/examples/motion-blur/motion-blur-example.cpp @@ -349,7 +349,7 @@ public: mActorTapMovementAnimation = Animation::New( animDuration ); if ( mMotionBlurImageActor ) { - mActorTapMovementAnimation.AnimateTo( Property(mMotionBlurImageActor, Actor::Property::Position), destPos, AlphaFunctions::EaseInOutSine, TimePeriod(animDuration) ); + mActorTapMovementAnimation.AnimateTo( Property(mMotionBlurImageActor, Actor::Property::POSITION), destPos, AlphaFunctions::EaseInOutSine, TimePeriod(animDuration) ); } mActorTapMovementAnimation.SetEndAction( Animation::Bake ); mActorTapMovementAnimation.Play(); diff --git a/examples/motion-stretch/motion-stretch-example.cpp b/examples/motion-stretch/motion-stretch-example.cpp index 94b48a8..545c9f2 100644 --- a/examples/motion-stretch/motion-stretch-example.cpp +++ b/examples/motion-stretch/motion-stretch-example.cpp @@ -261,7 +261,7 @@ public: mActorTapMovementAnimation = Animation::New( animDuration ); if ( mMotionStretchImageActor ) { - mActorTapMovementAnimation.AnimateTo( Property(mMotionStretchImageActor, Actor::Property::Position), destPos, AlphaFunctions::EaseInOutSine, TimePeriod(animDuration) ); + mActorTapMovementAnimation.AnimateTo( Property(mMotionStretchImageActor, Actor::Property::POSITION), destPos, AlphaFunctions::EaseInOutSine, TimePeriod(animDuration) ); } mActorTapMovementAnimation.SetEndAction( Animation::Bake ); mActorTapMovementAnimation.Play(); diff --git a/examples/path-animation/path-animation.cpp b/examples/path-animation/path-animation.cpp new file mode 100644 index 0000000..5dea82a --- /dev/null +++ b/examples/path-animation/path-animation.cpp @@ -0,0 +1,515 @@ +/* + * Copyright (c) 2014 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. + * + */ + +/** + * This example shows how to use path animations in DALi + */ + +// EXTERNAL INCLUDES +#include + +// INTERNAL INCLUDES +#include "shared/view.h" + +using namespace Dali; +using namespace Dali::Toolkit; + + +namespace +{ +const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-default.png" ); +const char* ACTOR_IMAGE( DALI_IMAGE_DIR "dali-logo.png" ); +const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); +const char* APPLICATION_TITLE( "Path Animation Example" ); +}; //Unnamed namespace + +/** + * @brief The main class of the demo. + */ +class PathController : public ConnectionTracker +{ +public: + + PathController( Application& application ) +: mApplication( application ) +{ + // Connect to the Application's Init signal + mApplication.InitSignal().Connect( this, &PathController::Create ); +} + + ~PathController() + { + // Nothing to do here. + } + + /* + * Create a control composed of a label and an slider + * @param[in] label The text to be displayed ny the label + * @param[in] size The size of the slider + * @param[in] callback Pointer to the callback function to be called when user moves the slider + */ + Actor CreateVectorComponentControl( const std::string& label, const Vector3& size, bool(PathController::*callback)(Slider,float) ) + { + Dali::TextActor textActor = TextActor::New(label); + textActor.SetColor( Vector4(0.0f,0.0f,0.0f,1.0f)); + textActor.SetSize(size.y,size.y,0.0f); + + Slider slider = Slider::New(); + slider.SetAnchorPoint( AnchorPoint::CENTER_LEFT); + slider.SetParentOrigin( ParentOrigin::CENTER_RIGHT); + slider.SetProperty(Slider::Property::LOWER_BOUND, -1.0f ); + slider.SetProperty(Slider::Property::UPPER_BOUND, 1.0f ); + + Property::Array marks; + float mark = -1.0f; + for(unsigned short i(0); i<21; ++i ) + { + marks.push_back( mark ); + mark += 0.1f; + } + + slider.SetProperty(Slider::Property::MARKS, marks); + slider.SetProperty(Slider::Property::SNAP_TO_MARKS, true ); + slider.SetSize(size); + slider.SetScale( 0.5f ); + slider.ValueChangedSignal().Connect(this,callback); + textActor.Add( slider ); + return textActor; + } + + /** + * Crate all the GUI controls + */ + void CreateControls() + { + Stage stage = Stage::GetCurrent(); + + //TextInput + Dali::Layer controlsLayer = Dali::Layer::New(); + controlsLayer.SetSize( stage.GetSize().x, stage.GetSize().y*0.3f, 0.0 ); + controlsLayer.SetPosition( 0.0f, stage.GetSize().y*0.8f, 0.0f ); + controlsLayer.SetAnchorPoint( AnchorPoint::TOP_LEFT); + controlsLayer.SetParentOrigin( ParentOrigin::TOP_LEFT); + controlsLayer.TouchedSignal().Connect(this, &PathController::OnTouchGuiLayer); + stage.Add( controlsLayer ); + + Vector3 textInputSize( stage.GetSize().x, stage.GetSize().y*0.04f, 0.0f ); + Actor control0 = CreateVectorComponentControl("x:", textInputSize, &PathController::OnSliderXValueChange ); + control0.SetY( stage.GetSize().y*0.05f ); + control0.SetAnchorPoint(AnchorPoint::TOP_LEFT); + controlsLayer.Add( control0 ); + + Actor control1 = CreateVectorComponentControl("y:", textInputSize, &PathController::OnSliderYValueChange ); + control1.SetAnchorPoint(AnchorPoint::TOP_LEFT); + control1.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); + control1.SetPosition(0.0f,stage.GetSize().y*0.01,0.0f); + control0.Add( control1 ); + + Actor control2 =CreateVectorComponentControl("z:", textInputSize, &PathController::OnSliderZValueChange ); + control2.SetAnchorPoint(AnchorPoint::TOP_LEFT); + control2.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); + control2.SetPosition(0.0f,stage.GetSize().y*0.01,0.0f); + control1.Add( control2 ); + } + + /** + * Draws the path and the control points for the path + * @param[in] resolution Number of segments for the path. + */ + void DrawPath( unsigned int resolution ) + { + Stage stage = Dali::Stage::GetCurrent(); + + //Create path mesh actor + Dali::MeshData meshData = MeshFactory::NewPath( mPath, resolution ); + Dali::Material material = Material::New("LineMaterial"); + material.SetDiffuseColor( Vector4(0.0f,0.0f,0.0f,1.0f)); + meshData.SetMaterial(material); + Dali::Mesh mesh = Dali::Mesh::New( meshData ); + if( mMeshPath ) + { + stage.Remove( mMeshPath ); + } + mMeshPath = Dali::MeshActor::New( mesh ); + mMeshPath.SetAnchorPoint( AnchorPoint::TOP_LEFT ); + mMeshPath.SetParentOrigin( ParentOrigin::TOP_LEFT ); + stage.Add( mMeshPath ); + + + ////Create mesh connecting interpolation points and control points + std::vector vVertex; + std::vector vIndex; + size_t pointCount = mPath.GetPointCount(); + size_t controlPointIndex = 0; + for( size_t i(0); i0) + { + const TouchPoint& point = event.GetPoint(0); + + if(point.state==TouchPoint::Up) + { + //Stop dragging + mDragActor.Reset(); + } + else if(point.state==TouchPoint::Down) + { + Vector3 touchPoint = Vector3(event.GetPoint(0).screen.x, event.GetPoint(0).screen.y, 0.0f); + if(!mDragActor ) + { + mDragActor = GetClosestActor( touchPoint ); + if( !mDragActor && mPath.GetPointCount() < 10 ) + { + // Add new point + Vector3 lastPoint = mPath.GetPoint( mPath.GetPointCount()-1); + mPath.AddPoint( touchPoint ); + Vector3 displacement = (touchPoint-lastPoint)/8; + mPath.AddControlPoint( lastPoint + displacement ); + mPath.AddControlPoint( touchPoint - displacement); + + DrawPath( 200u ); + CreateAnimation(); + } + } + } + else if( mDragActor && point.state==TouchPoint::Motion ) + { + Vector3 touchPoint = Vector3(event.GetPoint(0).screen.x, event.GetPoint(0).screen.y, 0.0f); + std::string actorName(mDragActor.GetName()); + if( actorName.compare(0, 4, "Knot") == 0) + { + int index = actorName[4]; + mPath.GetPoint(index) = touchPoint; + } + else + { + int index = actorName[12]; + mPath.GetControlPoint(index) = touchPoint; + } + + DrawPath( 200u ); + CreateAnimation(); + } + } + + return true; + } + + bool OnTouchGuiLayer(Actor actor, const TouchEvent& event) + { + mDragActor.Reset(); + return false; + } + /** + * Callback called when user changes slider X + * @param[in] slider The slider that has generated the signal + * @param[in] value The new value + */ + bool OnSliderXValueChange( Slider s, float value) + { + if( fabs( value ) - Math::MACHINE_EPSILON_1000 < 0.0f ) + { + mForward.x = 0.0f; + } + else + { + mForward.x = value; + } + + CreateAnimation(); + return true; + } + + /** + * Callback called when user changes slider Y + * @param[in] slider The slider that has generated the signal + * @param[in] value The new value + */ + bool OnSliderYValueChange( Slider s, float value) + { + if( fabs( value ) - Math::MACHINE_EPSILON_1000 < 0.0f ) + { + mForward.y = 0.0f; + } + else + { + mForward.y = value; + } + CreateAnimation(); + return true; + } + + /** + * Callback called when user changes slider Z + * @param[in] slider The slider that has generated the signal + * @param[in] value The new value + */ + bool OnSliderZValueChange( Slider s, float value) + { + if( fabs( value ) - Math::MACHINE_EPSILON_1000 < 0.0f ) + { + mForward.z = 0.0f; + } + else + { + mForward.z = value; + } + + CreateAnimation(); + return true; + } + + /** + * Main key event handler. + * Quit on escape key. + */ + void OnKeyEvent(const KeyEvent& event) + { + if( event.state == KeyEvent::Down ) + { + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || + IsKey( event, Dali::DALI_KEY_BACK ) ) + { + mApplication.Quit(); + } + } + } + + /** + * One-time setup in response to Application InitSignal. + */ + void Create( Application& application ) + { + // Get a handle to the stage: + Stage stage = Stage::GetCurrent(); + + // Connect to input event signals: + stage.KeyEventSignal().Connect(this, &PathController::OnKeyEvent); + + // Create a default view with a default tool bar: + Toolkit::View view; ///< The View instance. + Toolkit::ToolBar toolBar; ///< The View's Toolbar. + mContentLayer = DemoHelper::CreateView( mApplication, + view, + toolBar, + BACKGROUND_IMAGE, + TOOLBAR_IMAGE, + "" ); + + mContentLayer.TouchedSignal().Connect(this, &PathController::OnTouchLayer); + + //Title + TextView title = TextView::New(); + toolBar.AddControl( title, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Alignment::HorizontalCenter ); + Font font = Font::New(); + title.SetText( APPLICATION_TITLE ); + title.SetSize( font.MeasureText( APPLICATION_TITLE ) ); + title.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle()); + + //Path + mPath = Dali::Path::New(); + mPath.AddPoint( Vector3( 10.0f, stage.GetSize().y*0.5f, 0.0f )); + mPath.AddPoint( Vector3( stage.GetSize().x*0.5f, stage.GetSize().y*0.5f, 0.0f )); + mPath.GenerateControlPoints(0.25f); + DrawPath( 200u ); + + //Actor + ImageAttributes attributes; + Image img = ResourceImage::New(ACTOR_IMAGE, attributes ); + mActor = ImageActor::New( img ); + mActor.SetAnchorPoint( AnchorPoint::CENTER ); + mActor.SetSize( 100, 50, 1 ); + stage.Add( mActor ); + + CreateAnimation(); + CreateControls(); + } + +private: + Application& mApplication; + + Layer mContentLayer; ///< The content layer + + Path mPath; ///< The path used in the animation + ImageActor mActor; ///< Actor being animated + Vector3 mForward; ///< Current forward vector + Animation mAnimation; ///< Path animation + + MeshActor mMeshPath; ///< Mesh actor for the path + MeshActor mMeshHandlers; ///< Mesh actor for the handlers of the path + + Actor mControlPoint[28]; ///< ImageActors represeting control points of the path + + Actor mDragActor; ///< Reference to the actor currently being dragged +}; + + +void RunTest( Application& application ) +{ + PathController 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/examples/radial-menu/radial-sweep-view-impl.cpp b/examples/radial-menu/radial-sweep-view-impl.cpp index f1efe5d..7486a8a 100644 --- a/examples/radial-menu/radial-sweep-view-impl.cpp +++ b/examples/radial-menu/radial-sweep-view-impl.cpp @@ -362,17 +362,17 @@ void RadialSweepViewImpl::CreateStencil( Degree initialSector ) // Constrain the vertices of the square mesh to sweep out a sector as the // rotation angle is animated. - mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(1, AnimatableVertex::Property::Position), + mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(1, AnimatableVertex::Property::POSITION), srcStart, srcStart, SquareFanConstraint(0))); - mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(2, AnimatableVertex::Property::Position), + mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION), srcStart, srcRot, SquareFanConstraint(0))); - mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(3, AnimatableVertex::Property::Position), + mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION), srcStart, srcRot, SquareFanConstraint(1))); - mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(4, AnimatableVertex::Property::Position), + mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION), srcStart, srcRot, SquareFanConstraint(2))); - mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(5, AnimatableVertex::Property::Position), + mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION), srcStart, srcRot, SquareFanConstraint(3))); - mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(6, AnimatableVertex::Property::Position), + mMesh.ApplyConstraint(Constraint::New( mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION), srcStart, srcRot, SquareFanConstraint(4))); mStencilActor.SetDrawMode( DrawMode::STENCIL ); diff --git a/examples/scroll-view/scroll-view-example.cpp b/examples/scroll-view/scroll-view-example.cpp index 6fa8242..7993519 100644 --- a/examples/scroll-view/scroll-view-example.cpp +++ b/examples/scroll-view/scroll-view-example.cpp @@ -210,7 +210,7 @@ public: // Hack to force screen refresh. Animation animation = Animation::New(1.0f); - animation.AnimateTo(Property(mContentLayer, Actor::Property::Position), Vector3::ZERO ); + animation.AnimateTo(Property(mContentLayer, Actor::Property::POSITION), Vector3::ZERO ); animation.Play(); } diff --git a/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp b/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp index b8989d1..090af52 100644 --- a/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp +++ b/examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp @@ -200,7 +200,7 @@ public: mPinchGestureDetector.Attach( mView ); mPinchGestureDetector.DetectedSignal().Connect(this, &TestApp::OnPinch); - mTapGestureDetector = TapGestureDetector::New(1, 1); + mTapGestureDetector = TapGestureDetector::New(); mTapGestureDetector.Attach( mView ); mTapGestureDetector.DetectedSignal().Connect(this, &TestApp::OnTap); } @@ -286,9 +286,9 @@ public: Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value(30.0f)); Source angleSrc( mImageActor2, angleIndex ); - mImageActor1.ApplyConstraint(Constraint::New( Actor::Property::Rotation, angleSrc, + mImageActor1.ApplyConstraint(Constraint::New( Actor::Property::ROTATION, angleSrc, RotationConstraint(-1.0f))); - mImageActor3.ApplyConstraint(Constraint::New( Actor::Property::Rotation, angleSrc, + mImageActor3.ApplyConstraint(Constraint::New( Actor::Property::ROTATION, angleSrc, RotationConstraint(+1.0f))); mSceneAnimation = Animation::New(2.5f); diff --git a/packaging/com.samsung.dali-demo.spec b/packaging/com.samsung.dali-demo.spec index 89e359a..d32893b 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.32 +Version: 1.0.33 Release: 1 Group: System/Libraries License: Apache-2.0 diff --git a/shared/view.h b/shared/view.h index 584a278..fe73652 100644 --- a/shared/view.h +++ b/shared/view.h @@ -86,7 +86,7 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, Dali::Layer toolBarLayer = Dali::Layer::New(); toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); - toolBarLayer.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::Size, Dali::ParentSource( Dali::Actor::Property::Size ), Dali::SourceWidthFixedHeight( style.mToolBarHeight ) ) ); + toolBarLayer.ApplyConstraint( Dali::Constraint::New( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight ) ) ); toolBarLayer.SetSize( 0.0f, style.mToolBarHeight ); // Raise tool bar layer to the top.