Commit 6a3b548331ddab7938735468fae9bb2ac6c3712d
[dali_1.0.33] Merge branch 'tizen'
Change-Id: Ic58d909d660f8809a06af60c13a67315036c9f8e
Showing
20 changed files
with
955 additions
and
101 deletions
README
| @@ -39,7 +39,7 @@ T.O.C. | @@ -39,7 +39,7 @@ T.O.C. | ||
| 39 | 39 | ||
| 40 | To build the repository enter the 'build/tizen' folder: | 40 | To build the repository enter the 'build/tizen' folder: |
| 41 | 41 | ||
| 42 | - cd dali-toolkit/build/tizen | 42 | + cd dali-demo/build/tizen |
| 43 | 43 | ||
| 44 | Then run the following commands: | 44 | Then run the following commands: |
| 45 | 45 |
com.samsung.dali-demo.xml
| @@ -79,4 +79,10 @@ | @@ -79,4 +79,10 @@ | ||
| 79 | <ui-application appid="animated-shapes.example" exec="/usr/apps/com.samsung.dali-demo/bin/animated-shapes.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | 79 | <ui-application appid="animated-shapes.example" exec="/usr/apps/com.samsung.dali-demo/bin/animated-shapes.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 80 | <label>Animated shapes</label> | 80 | <label>Animated shapes</label> |
| 81 | </ui-application> | 81 | </ui-application> |
| 82 | + <ui-application appid="path-animation.example" exec="/usr/apps/com.samsung.dali-demo/bin/path-animation.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ||
| 83 | + <label>Path Animation</label> | ||
| 84 | + </ui-application> | ||
| 85 | + <ui-application appid="atlas.example" exec="/usr/apps/com.samsung.dali-demo/bin/atlas.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | ||
| 86 | + <label>Atlas</label> | ||
| 87 | + </ui-application> | ||
| 82 | </manifest> | 88 | </manifest> |
demo/dali-demo.cpp
| @@ -43,6 +43,7 @@ int main(int argc, char **argv) | @@ -43,6 +43,7 @@ int main(int argc, char **argv) | ||
| 43 | demo.AddExample(Example("image-scaling-irregular-grid.example", "Image Scaling Modes")); | 43 | demo.AddExample(Example("image-scaling-irregular-grid.example", "Image Scaling Modes")); |
| 44 | demo.AddExample(Example("text-view.example", "Text View")); | 44 | demo.AddExample(Example("text-view.example", "Text View")); |
| 45 | demo.AddExample(Example("animated-shapes.example", "Animated Shapes")); | 45 | demo.AddExample(Example("animated-shapes.example", "Animated Shapes")); |
| 46 | + demo.AddExample(Example("path-animation.example", "Path Animation")); | ||
| 46 | app.MainLoop(); | 47 | app.MainLoop(); |
| 47 | 48 | ||
| 48 | return 0; | 49 | return 0; |
demo/dali-table-view.cpp
| @@ -181,11 +181,36 @@ bool CompareByTitle( const Example& lhs, const Example& rhs ) | @@ -181,11 +181,36 @@ bool CompareByTitle( const Example& lhs, const Example& rhs ) | ||
| 181 | } // namespace | 181 | } // namespace |
| 182 | 182 | ||
| 183 | DaliTableView::DaliTableView( Application& application ) | 183 | DaliTableView::DaliTableView( Application& application ) |
| 184 | - : mApplication( application ), | ||
| 185 | - mScrolling( false ), | ||
| 186 | - mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ), | ||
| 187 | - mSortAlphabetically( false ), | ||
| 188 | - mBackgroundAnimsPlaying( false ) | 184 | +: mApplication( application ), |
| 185 | + mBackgroundLayer(), | ||
| 186 | + mRootActor(), | ||
| 187 | + mRotateAnimation(), | ||
| 188 | + mBackground(), | ||
| 189 | + mLogo(), | ||
| 190 | + mPressedAnimation(), | ||
| 191 | + mScrollViewLayer(), | ||
| 192 | + mScrollView(), | ||
| 193 | + mScrollViewEffect(), | ||
| 194 | + mScrollRulerX(), | ||
| 195 | + mScrollRulerY(), | ||
| 196 | + mButtons(), | ||
| 197 | + mPressedActor(), | ||
| 198 | + mAnimationTimer(), | ||
| 199 | + mLogoTapDetector(), | ||
| 200 | + mVersionPopup(), | ||
| 201 | + mButtonsPageRelativeSize(), | ||
| 202 | + mPages(), | ||
| 203 | + mTableViewImages(), | ||
| 204 | + mBackgroundActors(), | ||
| 205 | + mBackgroundAnimations(), | ||
| 206 | + mExampleList(), | ||
| 207 | + mExampleMap(), | ||
| 208 | + mBackgroundImagePath( DEFAULT_BACKGROUND_IMAGE_PATH ), | ||
| 209 | + mTotalPages(), | ||
| 210 | + mScrolling( false ), | ||
| 211 | + mSortAlphabetically( false ), | ||
| 212 | + mBackgroundAnimsPlaying( false ), | ||
| 213 | + mVersionPopupShown( false ) | ||
| 189 | { | 214 | { |
| 190 | application.InitSignal().Connect( this, &DaliTableView::Initialize ); | 215 | application.InitSignal().Connect( this, &DaliTableView::Initialize ); |
| 191 | } | 216 | } |
| @@ -247,6 +272,11 @@ void DaliTableView::Initialize( Application& application ) | @@ -247,6 +272,11 @@ void DaliTableView::Initialize( Application& application ) | ||
| 247 | const float logoHeight = mLogo.GetImage().GetHeight() + logoMargin; | 272 | const float logoHeight = mLogo.GetImage().GetHeight() + logoMargin; |
| 248 | mRootActor.SetFixedHeight( 1, logoHeight ); | 273 | mRootActor.SetFixedHeight( 1, logoHeight ); |
| 249 | 274 | ||
| 275 | + // Show version in a popup when log is tapped | ||
| 276 | + mLogoTapDetector = TapGestureDetector::New(); | ||
| 277 | + mLogoTapDetector.Attach( mLogo ); | ||
| 278 | + mLogoTapDetector.DetectedSignal().Connect( this, &DaliTableView::OnLogoTapped ); | ||
| 279 | + | ||
| 250 | const float bottomMargin = paddingHeight * BOTTOM_PADDING_RATIO; | 280 | const float bottomMargin = paddingHeight * BOTTOM_PADDING_RATIO; |
| 251 | mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, 1.f - ( toolbarHeight + logoHeight + bottomMargin) / stageSize.height, TABLE_RELATIVE_SIZE.z ); | 281 | mButtonsPageRelativeSize = Vector3( TABLE_RELATIVE_SIZE.x, 1.f - ( toolbarHeight + logoHeight + bottomMargin) / stageSize.height, TABLE_RELATIVE_SIZE.z ); |
| 252 | mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height ); | 282 | mRootActor.SetFixedHeight( 2, mButtonsPageRelativeSize.y * stageSize.height ); |
| @@ -262,7 +292,7 @@ void DaliTableView::Initialize( Application& application ) | @@ -262,7 +292,7 @@ void DaliTableView::Initialize( Application& application ) | ||
| 262 | mScrollView.SetParentOrigin( ParentOrigin::CENTER ); | 292 | mScrollView.SetParentOrigin( ParentOrigin::CENTER ); |
| 263 | // Note: Currently, changing mScrollView to use SizeMode RELATIVE_TO_PARENT | 293 | // Note: Currently, changing mScrollView to use SizeMode RELATIVE_TO_PARENT |
| 264 | // will cause scroll ends to appear in the wrong position. | 294 | // will cause scroll ends to appear in the wrong position. |
| 265 | - mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::Property::Size, Dali::ParentSource( Dali::Actor::Property::Size ), Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) ); | 295 | + mScrollView.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::RelativeToConstraint( SCROLLVIEW_RELATIVE_SIZE ) ) ); |
| 266 | mScrollView.SetAxisAutoLock( true ); | 296 | mScrollView.SetAxisAutoLock( true ); |
| 267 | mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); | 297 | mScrollView.ScrollCompletedSignal().Connect( this, &DaliTableView::OnScrollComplete ); |
| 268 | mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); | 298 | mScrollView.ScrollStartedSignal().Connect( this, &DaliTableView::OnScrollStart ); |
| @@ -679,7 +709,14 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) | @@ -679,7 +709,14 @@ void DaliTableView::OnKeyEvent( const KeyEvent& event ) | ||
| 679 | { | 709 | { |
| 680 | if ( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) | 710 | if ( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) |
| 681 | { | 711 | { |
| 682 | - mApplication.Quit(); | 712 | + if ( mVersionPopup && mVersionPopupShown ) |
| 713 | + { | ||
| 714 | + HideVersionPopup(); | ||
| 715 | + } | ||
| 716 | + else | ||
| 717 | + { | ||
| 718 | + mApplication.Quit(); | ||
| 719 | + } | ||
| 683 | } | 720 | } |
| 684 | } | 721 | } |
| 685 | } | 722 | } |
| @@ -733,9 +770,9 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis | @@ -733,9 +770,9 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis | ||
| 733 | dfActor.SetPosition( actorPos ); | 770 | dfActor.SetPosition( actorPos ); |
| 734 | 771 | ||
| 735 | // Define bubble horizontal parallax and vertical wrapping | 772 | // Define bubble horizontal parallax and vertical wrapping |
| 736 | - Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::Position, | 773 | + Constraint animConstraint = Constraint::New < Vector3 > ( Actor::Property::POSITION, |
| 737 | Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ), | 774 | Source( mScrollView, mScrollView.GetPropertyIndex( ScrollView::SCROLL_POSITION_PROPERTY_NAME ) ), |
| 738 | - Dali::ParentSource( Dali::Actor::Property::Size ), | 775 | + Dali::ParentSource( Dali::Actor::Property::SIZE ), |
| 739 | AnimateBubbleConstraint( actorPos, Random::Range( -0.85f, 0.25f ), randSize ) ); | 776 | AnimateBubbleConstraint( actorPos, Random::Range( -0.85f, 0.25f ), randSize ) ); |
| 740 | dfActor.ApplyConstraint( animConstraint ); | 777 | dfActor.ApplyConstraint( animConstraint ); |
| 741 | 778 | ||
| @@ -746,7 +783,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis | @@ -746,7 +783,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis | ||
| 746 | Vector3 toPos( actorPos ); | 783 | Vector3 toPos( actorPos ); |
| 747 | toPos.y -= ( size.y + randSize ); | 784 | toPos.y -= ( size.y + randSize ); |
| 748 | keyframes.Add( 1.0f, toPos ); | 785 | keyframes.Add( 1.0f, toPos ); |
| 749 | - animation.AnimateBetween( Property( dfActor, Actor::Property::Position ), keyframes ); | 786 | + animation.AnimateBetween( Property( dfActor, Actor::Property::POSITION ), keyframes ); |
| 750 | animation.SetLooping( true ); | 787 | animation.SetLooping( true ); |
| 751 | animation.Play(); | 788 | animation.Play(); |
| 752 | mBackgroundAnimations.push_back( animation ); | 789 | mBackgroundAnimations.push_back( animation ); |
| @@ -945,4 +982,45 @@ bool DaliTableView::OnTileHovered( Actor actor, const HoverEvent& event ) | @@ -945,4 +982,45 @@ bool DaliTableView::OnTileHovered( Actor actor, const HoverEvent& event ) | ||
| 945 | return true; | 982 | return true; |
| 946 | } | 983 | } |
| 947 | 984 | ||
| 985 | +void DaliTableView::OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap ) | ||
| 986 | +{ | ||
| 987 | + if ( !mVersionPopupShown ) | ||
| 988 | + { | ||
| 989 | + if ( !mVersionPopup ) | ||
| 990 | + { | ||
| 991 | + std::ostringstream stream; | ||
| 992 | + stream << "DALi Core: " << CORE_MAJOR_VERSION << "." << CORE_MINOR_VERSION << "." << CORE_MICRO_VERSION << std::endl << "(" << CORE_BUILD_DATE << ")" << std::endl << std::endl; | ||
| 993 | + stream << "DALi Adaptor: " << ADAPTOR_MAJOR_VERSION << "." << ADAPTOR_MINOR_VERSION << "." << ADAPTOR_MICRO_VERSION << std::endl << "(" << ADAPTOR_BUILD_DATE << ")" << std::endl << std::endl; | ||
| 994 | + stream << "DALi Toolkit: " << TOOLKIT_MAJOR_VERSION << "." << TOOLKIT_MINOR_VERSION << "." << TOOLKIT_MICRO_VERSION << std::endl << "(" << TOOLKIT_BUILD_DATE << ")"; | ||
| 995 | + | ||
| 996 | + mVersionPopup = Dali::Toolkit::Popup::New(); | ||
| 997 | + mVersionPopup.SetTitle( stream.str() ); | ||
| 998 | + mVersionPopup.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 999 | + mVersionPopup.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 1000 | + mVersionPopup.HideTail(); | ||
| 1001 | + mVersionPopup.OutsideTouchedSignal().Connect( this, &DaliTableView::HideVersionPopup ); | ||
| 1002 | + mVersionPopup.HiddenSignal().Connect( this, &DaliTableView::PopupHidden ); | ||
| 1003 | + | ||
| 1004 | + Dali::Stage::GetCurrent().Add( mVersionPopup ); | ||
| 1005 | + } | ||
| 1006 | + | ||
| 1007 | + mVersionPopup.Show(); | ||
| 1008 | + mVersionPopupShown = true; | ||
| 1009 | + } | ||
| 1010 | +} | ||
| 1011 | + | ||
| 1012 | +void DaliTableView::HideVersionPopup() | ||
| 1013 | +{ | ||
| 1014 | + if ( mVersionPopup ) | ||
| 1015 | + { | ||
| 1016 | + mVersionPopup.Hide(); | ||
| 1017 | + } | ||
| 1018 | +} | ||
| 948 | 1019 | ||
| 1020 | +void DaliTableView::PopupHidden() | ||
| 1021 | +{ | ||
| 1022 | + if ( mVersionPopup ) | ||
| 1023 | + { | ||
| 1024 | + mVersionPopupShown = false; | ||
| 1025 | + } | ||
| 1026 | +} |
demo/dali-table-view.h
| @@ -360,38 +360,59 @@ private: // Application callbacks & implementation | @@ -360,38 +360,59 @@ private: // Application callbacks & implementation | ||
| 360 | */ | 360 | */ |
| 361 | void OnFocusedActorActivated( Dali::Actor activatedActor ); | 361 | void OnFocusedActorActivated( Dali::Actor activatedActor ); |
| 362 | 362 | ||
| 363 | + /** | ||
| 364 | + * Called when the logo is tapped | ||
| 365 | + * | ||
| 366 | + * @param[in] actor The tapped actor | ||
| 367 | + * @param[in] tap The tap information. | ||
| 368 | + */ | ||
| 369 | + void OnLogoTapped( Dali::Actor actor, const Dali::TapGesture& tap ); | ||
| 370 | + | ||
| 371 | + /** | ||
| 372 | + * Hides the popup | ||
| 373 | + */ | ||
| 374 | + void HideVersionPopup(); | ||
| 375 | + | ||
| 376 | + /** | ||
| 377 | + * Called when the popup is completely hidden | ||
| 378 | + */ | ||
| 379 | + void PopupHidden(); | ||
| 380 | + | ||
| 363 | private: | 381 | private: |
| 364 | 382 | ||
| 365 | - Dali::Application& mApplication; ///< Application instance. | ||
| 366 | - Dali::Layer mBackgroundLayer; ///< Background resides on a separate layer. | ||
| 367 | - Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor) | ||
| 368 | - Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor. | ||
| 369 | - Dali::ImageActor mBackground; ///< Background's static image. | ||
| 370 | - Dali::ImageActor mLogo; ///< Logo's static image. | ||
| 371 | - Dali::Animation mPressedAnimation; ///< Button press scaling animation. | ||
| 372 | - Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer. | ||
| 373 | - Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples) | ||
| 374 | - Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view | ||
| 375 | - bool mScrolling; ///< Flag indicating whether view is currently being scrolled | ||
| 376 | - Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler | ||
| 377 | - Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler | ||
| 378 | - Dali::Toolkit::TableView mButtons; ///< Navigation buttons | ||
| 379 | - ExampleList mExampleList; ///< List of examples. | ||
| 380 | - ExampleMap mExampleMap; ///< Map LUT for examples. | ||
| 381 | - Dali::ActorContainer mPages; ///< List of pages. | ||
| 382 | - Dali::Actor mPressedActor; ///< The currently pressed actor. | ||
| 383 | - int mTotalPages; ///< Total pages within scrollview. | ||
| 384 | - std::string mBackgroundImagePath; ///< The path to the background image. | ||
| 385 | - bool mSortAlphabetically; ///< Sort examples alphabetically. | ||
| 386 | - | ||
| 387 | - Dali::ActorContainer mTableViewImages; ///< Offscreen render of tableview | ||
| 388 | - Dali::ActorContainer mBackgroundActors; ///< List of background actors used in the effect | ||
| 389 | - | ||
| 390 | - AnimationList mBackgroundAnimations;///< List of background bubble animations | ||
| 391 | - Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period | ||
| 392 | - bool mBackgroundAnimsPlaying; ///< Are background animations playing | ||
| 393 | - | ||
| 394 | - Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size | 383 | + Dali::Application& mApplication; ///< Application instance. |
| 384 | + Dali::Layer mBackgroundLayer; ///< Background resides on a separate layer. | ||
| 385 | + Dali::Toolkit::TableView mRootActor; ///< All content (excluding background is anchored to this Actor) | ||
| 386 | + Dali::Animation mRotateAnimation; ///< Animation to rotate and resize mRootActor. | ||
| 387 | + Dali::ImageActor mBackground; ///< Background's static image. | ||
| 388 | + Dali::ImageActor mLogo; ///< Logo's static image. | ||
| 389 | + Dali::Animation mPressedAnimation; ///< Button press scaling animation. | ||
| 390 | + Dali::Layer mScrollViewLayer; ///< ScrollView resides on a separate layer. | ||
| 391 | + Dali::Toolkit::ScrollView mScrollView; ///< ScrollView container (for all Examples) | ||
| 392 | + Dali::Toolkit::ScrollViewEffect mScrollViewEffect; ///< Effect to be applied to the scroll view | ||
| 393 | + Dali::Toolkit::RulerPtr mScrollRulerX; ///< ScrollView X (horizontal) ruler | ||
| 394 | + Dali::Toolkit::RulerPtr mScrollRulerY; ///< ScrollView Y (vertical) ruler | ||
| 395 | + Dali::Toolkit::TableView mButtons; ///< Navigation buttons | ||
| 396 | + Dali::Actor mPressedActor; ///< The currently pressed actor. | ||
| 397 | + Dali::Timer mAnimationTimer; ///< Timer used to turn off animation after a specific time period | ||
| 398 | + Dali::TapGestureDetector mLogoTapDetector; ///< To detect taps on the logo | ||
| 399 | + Dali::Toolkit::Popup mVersionPopup; ///< Displays DALi library version information | ||
| 400 | + Dali::Vector3 mButtonsPageRelativeSize; ///< Size of a buttons page relative to the stage size | ||
| 401 | + | ||
| 402 | + Dali::ActorContainer mPages; ///< List of pages. | ||
| 403 | + Dali::ActorContainer mTableViewImages; ///< Offscreen render of tableview | ||
| 404 | + Dali::ActorContainer mBackgroundActors; ///< List of background actors used in the effect | ||
| 405 | + AnimationList mBackgroundAnimations; ///< List of background bubble animations | ||
| 406 | + ExampleList mExampleList; ///< List of examples. | ||
| 407 | + ExampleMap mExampleMap; ///< Map LUT for examples. | ||
| 408 | + | ||
| 409 | + std::string mBackgroundImagePath; ///< The path to the background image. | ||
| 410 | + int mTotalPages; ///< Total pages within scrollview. | ||
| 411 | + | ||
| 412 | + bool mScrolling:1; ///< Flag indicating whether view is currently being scrolled | ||
| 413 | + bool mSortAlphabetically:1; ///< Sort examples alphabetically. | ||
| 414 | + bool mBackgroundAnimsPlaying:1; ///< Are background animations playing | ||
| 415 | + bool mVersionPopupShown:1; ///< Whehter the version popup is shown or not | ||
| 395 | }; | 416 | }; |
| 396 | 417 | ||
| 397 | #endif // __DALI_DEMO_H__ | 418 | #endif // __DALI_DEMO_H__ |
examples/atlas/atlas-example.cpp
0 โ 100644
| 1 | +/* | ||
| 2 | + * Copyright (c) 2015 Samsung Electronics Co., Ltd. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + * | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +#include <dali/dali.h> | ||
| 19 | +#include "shared/view.h" | ||
| 20 | +#include <iostream> | ||
| 21 | +#include <cstdio> | ||
| 22 | + | ||
| 23 | +using namespace Dali; | ||
| 24 | + | ||
| 25 | +class AtlasController; | ||
| 26 | + | ||
| 27 | +namespace | ||
| 28 | +{ | ||
| 29 | +const char * const BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-gradient.jpg" ); | ||
| 30 | +const char * const TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); | ||
| 31 | +const char * const LOSE_CONTEXT_IMAGE( DALI_IMAGE_DIR "icon-cluster-wobble.png" ); | ||
| 32 | + | ||
| 33 | +Application gApplication; | ||
| 34 | +AtlasController* gAtlasController(NULL); | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +class AtlasController : public ConnectionTracker | ||
| 38 | +{ | ||
| 39 | +public: | ||
| 40 | + | ||
| 41 | + AtlasController( Application& application ) | ||
| 42 | + : mApplication( application ) | ||
| 43 | + { | ||
| 44 | + // Connect to the Application's Init signal | ||
| 45 | + mApplication.InitSignal().Connect( this, &AtlasController::Create ); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + ~AtlasController() | ||
| 49 | + { | ||
| 50 | + // Nothing to do here; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + void Create( Application& application ) | ||
| 54 | + { | ||
| 55 | + // Get a handle to the stage | ||
| 56 | + Stage stage = Stage::GetCurrent(); | ||
| 57 | + stage.SetBackgroundColor(Color::YELLOW); | ||
| 58 | + | ||
| 59 | + // Respond to a click anywhere on the stage | ||
| 60 | + stage.KeyEventSignal().Connect(this, &AtlasController::OnKeyEvent); | ||
| 61 | + | ||
| 62 | + mApplication.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); | ||
| 63 | + | ||
| 64 | + mContentLayer = DemoHelper::CreateView( mApplication, | ||
| 65 | + mView, | ||
| 66 | + mToolBar, | ||
| 67 | + BACKGROUND_IMAGE, | ||
| 68 | + TOOLBAR_IMAGE, | ||
| 69 | + "Atlas" ); | ||
| 70 | + | ||
| 71 | + mLoseContextButton = Toolkit::PushButton::New(); | ||
| 72 | + mLoseContextButton.SetBackgroundImage( ResourceImage::New( LOSE_CONTEXT_IMAGE ) ); | ||
| 73 | + mLoseContextButton.ClickedSignal().Connect( this, &AtlasController::OnLoseContextButtonClicked ); | ||
| 74 | + mToolBar.AddControl( mLoseContextButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); | ||
| 75 | + | ||
| 76 | + mAtlas = Atlas::New( 400,300, Pixel::RGBA8888); | ||
| 77 | + mAtlas.Clear(Vector4(0.f,0.5f,0.5f,0.5f)); | ||
| 78 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-change.png", 50, 30 ); | ||
| 79 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-cluster-carousel.png", 100, 30 ); | ||
| 80 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-effects-on.png", 150, 30 ); | ||
| 81 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-effect-cross.png", 100, 80 ); | ||
| 82 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-effect-fold.png", 150, 80 ); | ||
| 83 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-effect-wave.png", 200, 80 ); | ||
| 84 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-item-view-layout-depth.png", 150, 130 ); | ||
| 85 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-item-view-layout-grid.png", 200, 130 ); | ||
| 86 | + mAtlas.Upload( DALI_IMAGE_DIR "icon-item-view-layout-spiral.png", 250, 130 ); | ||
| 87 | + UploadBufferImages(); | ||
| 88 | + | ||
| 89 | + ImageActor imageActor1 = ImageActor::New( mAtlas ); | ||
| 90 | + imageActor1.SetY(-170.f); | ||
| 91 | + imageActor1.SetParentOrigin(ParentOrigin::CENTER); | ||
| 92 | + mContentLayer.Add( imageActor1 ); | ||
| 93 | + | ||
| 94 | + Atlas atlas2 = Atlas::New( 400,400, Pixel::RGB888); | ||
| 95 | + atlas2.Clear( Color::RED ); | ||
| 96 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-1.jpg", 4, 4 ); | ||
| 97 | + atlas2.Clear( Color::BLUE ); | ||
| 98 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-2.jpg", 136, 4 ); | ||
| 99 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-3.jpg", 268, 4 ); | ||
| 100 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-4.jpg", 4, 136 ); | ||
| 101 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-5.jpg", 136, 136 ); | ||
| 102 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-6.jpg", 268, 135 ); | ||
| 103 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-7.jpg", 4, 268 ); | ||
| 104 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-7.jpg", 136, 268 ); | ||
| 105 | + atlas2.Upload( DALI_IMAGE_DIR "gallery-small-7.jpg", 268, 268 ); | ||
| 106 | + | ||
| 107 | + | ||
| 108 | + ImageActor imageActor2 = ImageActor::New( atlas2 ); | ||
| 109 | + imageActor2.SetY(200.f); | ||
| 110 | + imageActor2.SetZ(-1.f); | ||
| 111 | + imageActor2.SetParentOrigin(ParentOrigin::CENTER); | ||
| 112 | + mContentLayer.Add( imageActor2 ); | ||
| 113 | + | ||
| 114 | + mPanGestureDetector = PanGestureDetector::New(); | ||
| 115 | + mPanGestureDetector.DetectedSignal().Connect(this, &AtlasController::OnPanGesture); | ||
| 116 | + mPanGestureDetector.Attach(imageActor1); | ||
| 117 | + mPanGestureDetector.Attach(imageActor2); | ||
| 118 | + | ||
| 119 | + stage.ContextLostSignal().Connect(this, &AtlasController::OnContextLost); | ||
| 120 | + stage.ContextRegainedSignal().Connect(this, &AtlasController::OnContextRegained); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + void UploadBufferImages() | ||
| 124 | + { | ||
| 125 | + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 1.f, 0.5f ), 80, 90 ), 0, 210 ); | ||
| 126 | + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 0.75f, 0.5f ), 80, 80 ), 40, 210 ); | ||
| 127 | + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 0.5f, 0.5f ), 80, 70 ), 80, 210 ); | ||
| 128 | + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 0.25f, 0.5f ), 80, 60 ), 120, 210 ); | ||
| 129 | + mAtlas.Upload( CreateBufferImage( Vector4(1.f, 1.f, 0.f, 0.5f ), 80, 50 ), 160, 210 ); | ||
| 130 | + mAtlas.Upload( CreateBufferImage( Vector4(0.75f, 0.75f, 0.f, 0.5f ), 80, 40 ), 200, 210 ); | ||
| 131 | + mAtlas.Upload( CreateBufferImage( Vector4(0.5f, 0.5f, 0.f, 0.5f ), 80, 30 ), 240, 210 ); | ||
| 132 | + mAtlas.Upload( CreateBufferImage( Vector4(0.25f, 0.25f, 0.f, 0.5f ), 80, 20 ), 280, 210 ); | ||
| 133 | + mAtlas.Upload( CreateBufferImage( Vector4(0.1f, 0.1f, 0.f, 0.5f ), 80, 10 ), 320, 210 ); | ||
| 134 | + BufferImage redBlock = CreateBufferImage( Color::RED, 40, 40 ); | ||
| 135 | + mAtlas.Upload(redBlock, 320, 30); | ||
| 136 | + mAtlas.Upload(redBlock, 320, 80); | ||
| 137 | + mAtlas.Upload(redBlock, 320, 130); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + static void NewWindow(void) | ||
| 141 | + { | ||
| 142 | + PositionSize posSize(0, 0, 720, 1280); | ||
| 143 | + gApplication.ReplaceWindow(posSize, "NewWindow"); // Generates a new window | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + bool OnLoseContextButtonClicked( Toolkit::Button button ) | ||
| 147 | + { | ||
| 148 | + // Add as an idle callback to avoid ProcessEvents being recursively called. | ||
| 149 | + mApplication.AddIdle(MakeCallback( AtlasController::NewWindow )); | ||
| 150 | + return true; | ||
| 151 | + } | ||
| 152 | + | ||
| 153 | + void OnKeyEvent( const KeyEvent& event ) | ||
| 154 | + { | ||
| 155 | + if(event.state == KeyEvent::Down) | ||
| 156 | + { | ||
| 157 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE) || IsKey( event, Dali::DALI_KEY_BACK) ) | ||
| 158 | + { | ||
| 159 | + mApplication.Quit(); | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + void OnPanGesture( Actor actor, const PanGesture& gesture ) | ||
| 165 | + { | ||
| 166 | + if( gesture.state == Gesture::Continuing ) | ||
| 167 | + { | ||
| 168 | + actor.MoveBy( Vector3( gesture.displacement ) ); | ||
| 169 | + } | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + void OnContextLost() | ||
| 173 | + { | ||
| 174 | + printf("Stage reporting context loss\n"); | ||
| 175 | + } | ||
| 176 | + | ||
| 177 | + void OnContextRegained() | ||
| 178 | + { | ||
| 179 | + printf("Stage reporting context regain\n"); | ||
| 180 | + UploadBufferImages(); | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | +private: | ||
| 184 | + | ||
| 185 | + BufferImage CreateBufferImage( const Vector4& color, const unsigned int width, const unsigned int height ) | ||
| 186 | + { | ||
| 187 | + BufferImage imageData = BufferImage::New( width, height, Pixel::RGBA8888 ); | ||
| 188 | + | ||
| 189 | + // Create the image | ||
| 190 | + PixelBuffer* pixbuf = imageData.GetBuffer(); | ||
| 191 | + const unsigned int bitmapSize = width * height; | ||
| 192 | + for( size_t i = 0; i < bitmapSize; ++i ) | ||
| 193 | + { | ||
| 194 | + pixbuf[i*4+0] = 0xFF * color.r; | ||
| 195 | + pixbuf[i*4+1] = 0xFF * color.g; | ||
| 196 | + pixbuf[i*4+2] = 0xFF * color.b; | ||
| 197 | + pixbuf[i*4+3] = 0xFF * color.a; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + imageData.Update(); | ||
| 201 | + | ||
| 202 | + return imageData; | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + | ||
| 206 | +private: | ||
| 207 | + Application& mApplication; | ||
| 208 | + PanGestureDetector mPanGestureDetector; | ||
| 209 | + | ||
| 210 | + Toolkit::View mView; ///< The View instance. | ||
| 211 | + Toolkit::ToolBar mToolBar; ///< The View's Toolbar. | ||
| 212 | + Toolkit::TextView mTitleActor; ///< The Toolbar's Title. | ||
| 213 | + Layer mContentLayer; ///< Content layer (scrolling cluster content) | ||
| 214 | + Toolkit::PushButton mLoseContextButton; | ||
| 215 | + Atlas mAtlas; | ||
| 216 | +}; | ||
| 217 | + | ||
| 218 | +void RunTest( Application& application ) | ||
| 219 | +{ | ||
| 220 | + gAtlasController = new AtlasController(application); | ||
| 221 | + application.MainLoop(Configuration::APPLICATION_DOES_NOT_HANDLE_CONTEXT_LOSS); | ||
| 222 | +} | ||
| 223 | + | ||
| 224 | +// Entry point for Linux & SLP applications | ||
| 225 | +// | ||
| 226 | +int main( int argc, char **argv ) | ||
| 227 | +{ | ||
| 228 | + gApplication = Application::New( &argc, &argv ); | ||
| 229 | + | ||
| 230 | + RunTest( gApplication ); | ||
| 231 | + | ||
| 232 | + return 0; | ||
| 233 | +} |
examples/blocks/blocks-example.cpp
| @@ -346,7 +346,7 @@ private: | @@ -346,7 +346,7 @@ private: | ||
| 346 | mPaddleImage.SetSize( mPaddleFullSize ); | 346 | mPaddleImage.SetSize( mPaddleFullSize ); |
| 347 | 347 | ||
| 348 | mWobbleProperty = mPaddle.RegisterProperty(WOBBLE_PROPERTY_NAME, 0.0f); | 348 | mWobbleProperty = mPaddle.RegisterProperty(WOBBLE_PROPERTY_NAME, 0.0f); |
| 349 | - Constraint wobbleConstraint = Constraint::New<Quaternion>( Actor::Property::Rotation, | 349 | + Constraint wobbleConstraint = Constraint::New<Quaternion>( Actor::Property::ROTATION, |
| 350 | LocalSource(mWobbleProperty), | 350 | LocalSource(mWobbleProperty), |
| 351 | WobbleConstraint(10.0f)); | 351 | WobbleConstraint(10.0f)); |
| 352 | mPaddle.ApplyConstraint(wobbleConstraint); | 352 | mPaddle.ApplyConstraint(wobbleConstraint); |
| @@ -359,16 +359,16 @@ private: | @@ -359,16 +359,16 @@ private: | ||
| 359 | const float margin(BALL_SIZE.width * stageSize.width * 0.5f); | 359 | const float margin(BALL_SIZE.width * stageSize.width * 0.5f); |
| 360 | 360 | ||
| 361 | // Set up notifications for ball's collisions against walls. | 361 | // Set up notifications for ball's collisions against walls. |
| 362 | - PropertyNotification leftNotification = mBall.AddPropertyNotification( Actor::Property::PositionX, LessThanCondition(margin) ); | 362 | + PropertyNotification leftNotification = mBall.AddPropertyNotification( Actor::Property::POSITION_X, LessThanCondition(margin) ); |
| 363 | leftNotification.NotifySignal().Connect( this, &ExampleController::OnHitLeftWall ); | 363 | leftNotification.NotifySignal().Connect( this, &ExampleController::OnHitLeftWall ); |
| 364 | 364 | ||
| 365 | - PropertyNotification rightNotification = mBall.AddPropertyNotification( Actor::Property::PositionX, GreaterThanCondition(stageSize.width - margin) ); | 365 | + PropertyNotification rightNotification = mBall.AddPropertyNotification( Actor::Property::POSITION_X, GreaterThanCondition(stageSize.width - margin) ); |
| 366 | rightNotification.NotifySignal().Connect( this, &ExampleController::OnHitRightWall ); | 366 | rightNotification.NotifySignal().Connect( this, &ExampleController::OnHitRightWall ); |
| 367 | 367 | ||
| 368 | - PropertyNotification topNotification = mBall.AddPropertyNotification( Actor::Property::PositionY, LessThanCondition(margin) ); | 368 | + PropertyNotification topNotification = mBall.AddPropertyNotification( Actor::Property::POSITION_Y, LessThanCondition(margin) ); |
| 369 | topNotification.NotifySignal().Connect( this, &ExampleController::OnHitTopWall ); | 369 | topNotification.NotifySignal().Connect( this, &ExampleController::OnHitTopWall ); |
| 370 | 370 | ||
| 371 | - PropertyNotification bottomNotification = mBall.AddPropertyNotification( Actor::Property::PositionY, GreaterThanCondition(stageSize.height + margin) ); | 371 | + PropertyNotification bottomNotification = mBall.AddPropertyNotification( Actor::Property::POSITION_Y, GreaterThanCondition(stageSize.height + margin) ); |
| 372 | bottomNotification.NotifySignal().Connect( this, &ExampleController::OnHitBottomWall ); | 372 | bottomNotification.NotifySignal().Connect( this, &ExampleController::OnHitBottomWall ); |
| 373 | 373 | ||
| 374 | // Set up notification for ball colliding against paddle. | 374 | // Set up notification for ball colliding against paddle. |
| @@ -376,10 +376,10 @@ private: | @@ -376,10 +376,10 @@ private: | ||
| 376 | stage.Add(delegate); | 376 | stage.Add(delegate); |
| 377 | Property::Index property = delegate.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); | 377 | Property::Index property = delegate.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); |
| 378 | Constraint constraint = Constraint::New<Vector3>( property, | 378 | Constraint constraint = Constraint::New<Vector3>( property, |
| 379 | - Source(mBall, Actor::Property::Position), | ||
| 380 | - Source(mPaddle, Actor::Property::Position), | ||
| 381 | - Source(mBall, Actor::Property::Size), | ||
| 382 | - Source(mPaddle, Actor::Property::Size), | 379 | + Source(mBall, Actor::Property::POSITION), |
| 380 | + Source(mPaddle, Actor::Property::POSITION), | ||
| 381 | + Source(mBall, Actor::Property::SIZE), | ||
| 382 | + Source(mPaddle, Actor::Property::SIZE), | ||
| 383 | CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) )); | 383 | CollisionCircleRectangleConstraint( -Vector3(0.0f, mPaddleHitMargin.height * 0.575f, 0.0f),-Vector3(mPaddleHitMargin) )); |
| 384 | delegate.ApplyConstraint(constraint); | 384 | delegate.ApplyConstraint(constraint); |
| 385 | 385 | ||
| @@ -599,10 +599,10 @@ private: | @@ -599,10 +599,10 @@ private: | ||
| 599 | // Add a constraint on the brick between it and the ball generating a collision-property | 599 | // Add a constraint on the brick between it and the ball generating a collision-property |
| 600 | Property::Index property = brick.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); | 600 | Property::Index property = brick.RegisterProperty(COLLISION_PROPERTY_NAME, Vector3::ZERO); |
| 601 | Constraint constraint = Constraint::New<Vector3>( property, | 601 | Constraint constraint = Constraint::New<Vector3>( property, |
| 602 | - Source(mBall, Actor::Property::Position), | ||
| 603 | - Source(brick, Actor::Property::Position), | ||
| 604 | - Source(mBall, Actor::Property::Size), | ||
| 605 | - Source(brick, Actor::Property::Size), | 602 | + Source(mBall, Actor::Property::POSITION), |
| 603 | + Source(brick, Actor::Property::POSITION), | ||
| 604 | + Source(mBall, Actor::Property::SIZE), | ||
| 605 | + Source(brick, Actor::Property::SIZE), | ||
| 606 | CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN)); | 606 | CollisionCircleRectangleConstraint(BRICK_COLLISION_MARGIN)); |
| 607 | brick.ApplyConstraint(constraint); | 607 | brick.ApplyConstraint(constraint); |
| 608 | 608 | ||
| @@ -639,7 +639,7 @@ private: | @@ -639,7 +639,7 @@ private: | ||
| 639 | } | 639 | } |
| 640 | 640 | ||
| 641 | mBallAnimation = Animation::New(MAX_ANIMATION_DURATION); | 641 | mBallAnimation = Animation::New(MAX_ANIMATION_DURATION); |
| 642 | - mBallAnimation.AnimateBy( Property( mBall, Actor::Property::Position ), mBallVelocity * MAX_ANIMATION_DURATION); | 642 | + mBallAnimation.AnimateBy( Property( mBall, Actor::Property::POSITION ), mBallVelocity * MAX_ANIMATION_DURATION); |
| 643 | mBallAnimation.Play(); | 643 | mBallAnimation.Play(); |
| 644 | } | 644 | } |
| 645 | 645 | ||
| @@ -661,8 +661,8 @@ private: | @@ -661,8 +661,8 @@ private: | ||
| 661 | 661 | ||
| 662 | mDragActor = actor; | 662 | mDragActor = actor; |
| 663 | mDragAnimation = Animation::New(0.25f); | 663 | mDragAnimation = Animation::New(0.25f); |
| 664 | - mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::Scale), Vector3(1.1f, 1.1f, 1.0f), AlphaFunctions::EaseOut); | ||
| 665 | - mDragAnimation.AnimateTo( Property(mPaddleHandle, Actor::Property::Color), Vector4(1.0f, 1.0f, 1.0f, 0.0f), AlphaFunctions::EaseOut); | 664 | + mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::SCALE), Vector3(1.1f, 1.1f, 1.0f), AlphaFunctions::EaseOut); |
| 665 | + mDragAnimation.AnimateTo( Property(mPaddleHandle, Actor::Property::COLOR), Vector4(1.0f, 1.0f, 1.0f, 0.0f), AlphaFunctions::EaseOut); | ||
| 666 | mDragAnimation.Play(); | 666 | mDragAnimation.Play(); |
| 667 | } | 667 | } |
| 668 | } | 668 | } |
| @@ -687,8 +687,8 @@ private: | @@ -687,8 +687,8 @@ private: | ||
| 687 | if(point.state==TouchPoint::Up) // Stop dragging | 687 | if(point.state==TouchPoint::Up) // Stop dragging |
| 688 | { | 688 | { |
| 689 | mDragAnimation = Animation::New(0.25f); | 689 | mDragAnimation = Animation::New(0.25f); |
| 690 | - mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::Scale), Vector3(1.0f, 1.0f, 1.0f), AlphaFunctions::EaseIn); | ||
| 691 | - mDragAnimation.AnimateTo( Property(mPaddleHandle, Actor::Property::Color), Vector4(1.0f, 1.0f, 1.0f, 1.0f), AlphaFunctions::EaseOut); | 690 | + mDragAnimation.AnimateTo( Property(mDragActor, Actor::Property::SCALE), Vector3(1.0f, 1.0f, 1.0f), AlphaFunctions::EaseIn); |
| 691 | + mDragAnimation.AnimateTo( Property(mPaddleHandle, Actor::Property::COLOR), Vector4(1.0f, 1.0f, 1.0f, 1.0f), AlphaFunctions::EaseOut); | ||
| 692 | mDragAnimation.Play(); | 692 | mDragAnimation.Play(); |
| 693 | mDragActor.Reset(); | 693 | mDragActor.Reset(); |
| 694 | } | 694 | } |
| @@ -745,8 +745,8 @@ private: | @@ -745,8 +745,8 @@ private: | ||
| 745 | mBallVelocity = Vector3::ZERO; | 745 | mBallVelocity = Vector3::ZERO; |
| 746 | 746 | ||
| 747 | Animation shrink = Animation::New(0.5f); | 747 | Animation shrink = Animation::New(0.5f); |
| 748 | - shrink.AnimateTo( Property(mPaddle, Actor::Property::SizeWidth), mPaddleFullSize.x * f + mPaddleHitMargin.x); | ||
| 749 | - shrink.AnimateTo( Property(mPaddleImage, Actor::Property::SizeWidth), mPaddleFullSize.x * f ); | 748 | + shrink.AnimateTo( Property(mPaddle, Actor::Property::SIZE_WIDTH), mPaddleFullSize.x * f + mPaddleHitMargin.x); |
| 749 | + shrink.AnimateTo( Property(mPaddleImage, Actor::Property::SIZE_WIDTH), mPaddleFullSize.x * f ); | ||
| 750 | 750 | ||
| 751 | shrink.FinishedSignal().Connect( this, &ExampleController::OnPaddleShrunk ); | 751 | shrink.FinishedSignal().Connect( this, &ExampleController::OnPaddleShrunk ); |
| 752 | shrink.Play(); | 752 | shrink.Play(); |
| @@ -763,7 +763,7 @@ private: | @@ -763,7 +763,7 @@ private: | ||
| 763 | mBall.SetPosition( mBallStartPosition ); | 763 | mBall.SetPosition( mBallStartPosition ); |
| 764 | mBall.SetColor( Vector4(1.0f, 1.0f, 1.0f, 0.1f) ); | 764 | mBall.SetColor( Vector4(1.0f, 1.0f, 1.0f, 0.1f) ); |
| 765 | Animation appear = Animation::New(0.5f); | 765 | Animation appear = Animation::New(0.5f); |
| 766 | - appear.AnimateTo( Property(mBall, Actor::Property::Color), Vector4(1.0f, 1.0f, 1.0f, 1.0f) ); | 766 | + appear.AnimateTo( Property(mBall, Actor::Property::COLOR), Vector4(1.0f, 1.0f, 1.0f, 1.0f) ); |
| 767 | appear.Play(); | 767 | appear.Play(); |
| 768 | 768 | ||
| 769 | if(!mLives) | 769 | if(!mLives) |
| @@ -830,7 +830,7 @@ private: | @@ -830,7 +830,7 @@ private: | ||
| 830 | 830 | ||
| 831 | // fade brick (destroy) | 831 | // fade brick (destroy) |
| 832 | Animation destroyAnimation = Animation::New(0.5f); | 832 | Animation destroyAnimation = Animation::New(0.5f); |
| 833 | - destroyAnimation.AnimateTo( Property( brick, Actor::Property::ColorAlpha ), 0.0f, AlphaFunctions::EaseIn ); | 833 | + destroyAnimation.AnimateTo( Property( brick, Actor::Property::COLOR_ALPHA ), 0.0f, AlphaFunctions::EaseIn ); |
| 834 | destroyAnimation.Play(); | 834 | destroyAnimation.Play(); |
| 835 | destroyAnimation.FinishedSignal().Connect( this, &ExampleController::OnBrickDestroyed ); | 835 | destroyAnimation.FinishedSignal().Connect( this, &ExampleController::OnBrickDestroyed ); |
| 836 | mDestroyAnimationMap[destroyAnimation] = brick; | 836 | mDestroyAnimationMap[destroyAnimation] = brick; |
examples/cluster/cluster-example.cpp
| @@ -707,7 +707,7 @@ public: | @@ -707,7 +707,7 @@ public: | ||
| 707 | Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) ); | 707 | Vector2 shearCenter( Vector2(position.x + size.width * shearAnchor.x, position.y + size.height * shearAnchor.y) ); |
| 708 | Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName()); | 708 | Property::Index centerProperty = shaderEffect.GetPropertyIndex(shaderEffect.GetCenterPropertyName()); |
| 709 | Constraint constraint = Constraint::New<Vector2>( centerProperty, | 709 | Constraint constraint = Constraint::New<Vector2>( centerProperty, |
| 710 | - Source(mView, Actor::Property::Size), | 710 | + Source(mView, Actor::Property::SIZE), |
| 711 | ShearEffectCenterConstraint(stageSize, shearCenter) ); | 711 | ShearEffectCenterConstraint(stageSize, shearCenter) ); |
| 712 | shaderEffect.ApplyConstraint(constraint); | 712 | shaderEffect.ApplyConstraint(constraint); |
| 713 | 713 | ||
| @@ -720,12 +720,12 @@ public: | @@ -720,12 +720,12 @@ public: | ||
| 720 | 720 | ||
| 721 | constraint = Constraint::New<float>( angleXAxisProperty, | 721 | constraint = Constraint::New<float>( angleXAxisProperty, |
| 722 | Source(mScrollView, scrollOvershootProperty), | 722 | Source(mScrollView, scrollOvershootProperty), |
| 723 | - Source(mView, Actor::Property::Rotation), | 723 | + Source(mView, Actor::Property::ROTATION), |
| 724 | ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) ); | 724 | ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::XAXIS) ); |
| 725 | shaderEffect.ApplyConstraint(constraint); | 725 | shaderEffect.ApplyConstraint(constraint); |
| 726 | constraint = Constraint::New<float>( angleYAxisProperty, | 726 | constraint = Constraint::New<float>( angleYAxisProperty, |
| 727 | Source(mScrollView, scrollOvershootProperty), | 727 | Source(mScrollView, scrollOvershootProperty), |
| 728 | - Source(mView, Actor::Property::Rotation), | 728 | + Source(mView, Actor::Property::ROTATION), |
| 729 | ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS) ); | 729 | ShearEffectConstraint(stageSize, SHEAR_EFFECT_MAX_OVERSHOOT, Vector2::YAXIS) ); |
| 730 | shaderEffect.ApplyConstraint(constraint); | 730 | shaderEffect.ApplyConstraint(constraint); |
| 731 | 731 | ||
| @@ -752,7 +752,7 @@ public: | @@ -752,7 +752,7 @@ public: | ||
| 752 | 752 | ||
| 753 | Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( shaderEffect.GetAnglePerUnitPropertyName() ); | 753 | Property::Index anglePerUnit = shaderEffect.GetPropertyIndex( shaderEffect.GetAnglePerUnitPropertyName() ); |
| 754 | shaderEffect.ApplyConstraint( Constraint::New<Vector2>( anglePerUnit, | 754 | shaderEffect.ApplyConstraint( Constraint::New<Vector2>( anglePerUnit, |
| 755 | - Source(mView, Actor::Property::Rotation), | 755 | + Source(mView, Actor::Property::ROTATION), |
| 756 | CarouselEffectOrientationConstraint( angleSweep ) ) ); | 756 | CarouselEffectOrientationConstraint( angleSweep ) ) ); |
| 757 | 757 | ||
| 758 | break; | 758 | break; |
| @@ -779,7 +779,7 @@ public: | @@ -779,7 +779,7 @@ public: | ||
| 779 | // dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc | 779 | // dont apply shader effect to scrollview as it might override internal shaders for bounce effect etc |
| 780 | for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i ) | 780 | for( std::vector<ClusterInfo>::iterator i = mClusterInfo.begin(); i != mClusterInfo.end(); ++i ) |
| 781 | { | 781 | { |
| 782 | - Constraint constraint = Constraint::New<float>(Actor::Property::PositionZ, SphereEffectOffsetConstraint(SPHERE_EFFECT_POSITION_Z)); | 782 | + Constraint constraint = Constraint::New<float>(Actor::Property::POSITION_Z, SphereEffectOffsetConstraint(SPHERE_EFFECT_POSITION_Z)); |
| 783 | constraint.SetRemoveAction(Constraint::Discard); | 783 | constraint.SetRemoveAction(Constraint::Discard); |
| 784 | Cluster cluster = i->mCluster; | 784 | Cluster cluster = i->mCluster; |
| 785 | SetShaderEffectRecursively( cluster, shaderEffect ); | 785 | SetShaderEffectRecursively( cluster, shaderEffect ); |
examples/cube-transition-effect/cube-transition-effect-example.cpp
| @@ -264,7 +264,7 @@ void CubeTransitionApp::OnInit( Application& application ) | @@ -264,7 +264,7 @@ void CubeTransitionApp::OnInit( Application& application ) | ||
| 264 | mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick ); | 264 | mViewTimer.TickSignal().Connect( this, &CubeTransitionApp::OnTimerTick ); |
| 265 | 265 | ||
| 266 | // show the first image | 266 | // show the first image |
| 267 | - mImageConstraint = Constraint::New<Vector3>( Actor::Property::Scale, LocalSource( Actor::Property::Size ), ParentSource( Actor::Property::Size ), ScaleToFitKeepAspectRatioConstraint() ); | 267 | + mImageConstraint = Constraint::New<Vector3>( Actor::Property::SCALE, LocalSource( Actor::Property::SIZE ), ParentSource( Actor::Property::SIZE ), ScaleToFitKeepAspectRatioConstraint() ); |
| 268 | 268 | ||
| 269 | mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) ); | 269 | mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) ); |
| 270 | mCurrentImage.SetPositionInheritanceMode( USE_PARENT_POSITION ); | 270 | mCurrentImage.SetPositionInheritanceMode( USE_PARENT_POSITION ); |
examples/dissolve-effect/dissolve-effect-example.cpp
| @@ -232,7 +232,7 @@ void DissolveEffectApp::OnInit( Application& application ) | @@ -232,7 +232,7 @@ void DissolveEffectApp::OnInit( Application& application ) | ||
| 232 | mParent.SetPositionInheritanceMode( USE_PARENT_POSITION ); | 232 | mParent.SetPositionInheritanceMode( USE_PARENT_POSITION ); |
| 233 | mContent.Add( mParent ); | 233 | mContent.Add( mParent ); |
| 234 | 234 | ||
| 235 | - mSizeConstraint= Constraint::New<Vector3>( Actor::Property::Scale, LocalSource( Actor::Property::Size ), ParentSource( Actor::Property::Size ), ScaleToFitKeepAspectRatioConstraint() ); | 235 | + mSizeConstraint= Constraint::New<Vector3>( Actor::Property::SCALE, LocalSource( Actor::Property::SIZE ), ParentSource( Actor::Property::SIZE ), ScaleToFitKeepAspectRatioConstraint() ); |
| 236 | 236 | ||
| 237 | // show the first image | 237 | // show the first image |
| 238 | mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) ); | 238 | mCurrentImage = ImageActor::New( ResourceImage::New( IMAGES[mIndex] ) ); |
examples/item-view/item-view-example.cpp
| @@ -971,11 +971,11 @@ private: | @@ -971,11 +971,11 @@ private: | ||
| 971 | mMenu.Add( tableView ); | 971 | mMenu.Add( tableView ); |
| 972 | 972 | ||
| 973 | Slider slider = Slider::New(); | 973 | Slider slider = Slider::New(); |
| 974 | - slider.SetProperty( Slider::LOWER_BOUND_PROPERTY, 0.0f ); | ||
| 975 | - slider.SetProperty( Slider::UPPER_BOUND_PROPERTY, 3.0f ); | ||
| 976 | - slider.SetProperty( Slider::VALUE_PROPERTY, mDurationSeconds ); | ||
| 977 | - slider.SetProperty( Slider::VALUE_PRECISION_PROPERTY, 2 ); | ||
| 978 | - slider.SetProperty( Slider::SHOW_POPUP_PROPERTY, true ); | 974 | + slider.SetProperty( Slider::Property::LOWER_BOUND, 0.0f ); |
| 975 | + slider.SetProperty( Slider::Property::UPPER_BOUND, 3.0f ); | ||
| 976 | + slider.SetProperty( Slider::Property::VALUE, mDurationSeconds ); | ||
| 977 | + slider.SetProperty( Slider::Property::VALUE_PRECISION, 2 ); | ||
| 978 | + slider.SetProperty( Slider::Property::SHOW_POPUP, true ); | ||
| 979 | slider.ValueChangedSignal().Connect( this, &ItemViewExample::SliderValueChange ); | 979 | slider.ValueChangedSignal().Connect( this, &ItemViewExample::SliderValueChange ); |
| 980 | tableView.AddChild( slider, TableView::CellPosition( 0, 0 ) ); | 980 | tableView.AddChild( slider, TableView::CellPosition( 0, 0 ) ); |
| 981 | tableView.SetRelativeHeight( 0, 0.5f ); | 981 | tableView.SetRelativeHeight( 0, 0.5f ); |
| @@ -993,7 +993,7 @@ private: | @@ -993,7 +993,7 @@ private: | ||
| 993 | text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); | 993 | text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); |
| 994 | text.SetStyleToCurrentText( defaultTextStyle ); | 994 | text.SetStyleToCurrentText( defaultTextStyle ); |
| 995 | text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); | 995 | text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); |
| 996 | - text.ApplyConstraint( Dali::Constraint::New<float>( Dali::Actor::Property::SizeWidth, Dali::ParentSource( Dali::Actor::Property::SizeWidth ), Dali::EqualToConstraint() ) ); | 996 | + text.ApplyConstraint( Dali::Constraint::New<float>( Dali::Actor::Property::SIZE_WIDTH, Dali::ParentSource( Dali::Actor::Property::SIZE_WIDTH ), Dali::EqualToConstraint() ) ); |
| 997 | text.SetZ( -0.9f ); | 997 | text.SetZ( -0.9f ); |
| 998 | slider.Add( text ); | 998 | slider.Add( text ); |
| 999 | 999 | ||
| @@ -1016,7 +1016,7 @@ private: | @@ -1016,7 +1016,7 @@ private: | ||
| 1016 | text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); | 1016 | text.SetTextAlignment( Dali::Toolkit::Alignment::HorizontalLeft ); |
| 1017 | text.SetStyleToCurrentText( defaultTextStyle ); | 1017 | text.SetStyleToCurrentText( defaultTextStyle ); |
| 1018 | text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); | 1018 | text.SetSize( 0.0f, LABEL_TEXT_SIZE_Y ); |
| 1019 | - text.ApplyConstraint( Dali::Constraint::New<float>( Dali::Actor::Property::SizeWidth, Dali::ParentSource( Dali::Actor::Property::SizeWidth ), Dali::EqualToConstraint() ) ); | 1019 | + text.ApplyConstraint( Dali::Constraint::New<float>( Dali::Actor::Property::SIZE_WIDTH, Dali::ParentSource( Dali::Actor::Property::SIZE_WIDTH ), Dali::EqualToConstraint() ) ); |
| 1020 | textContainer.Add( text ); | 1020 | textContainer.Add( text ); |
| 1021 | 1021 | ||
| 1022 | mMenu.Show(); | 1022 | mMenu.Show(); |
examples/magnifier/magnifier-example.cpp
| @@ -240,11 +240,11 @@ public: | @@ -240,11 +240,11 @@ public: | ||
| 240 | overlay.Add( mMagnifier ); | 240 | overlay.Add( mMagnifier ); |
| 241 | 241 | ||
| 242 | // Apply constraint to animate the position of the magnifier. | 242 | // Apply constraint to animate the position of the magnifier. |
| 243 | - Constraint constraint = Constraint::New<Vector3>(Actor::Property::Position, | ||
| 244 | - LocalSource(Actor::Property::Size), | ||
| 245 | - LocalSource(Actor::Property::ParentOrigin), | ||
| 246 | - LocalSource(Actor::Property::AnchorPoint), | ||
| 247 | - ParentSource(Actor::Property::Size), | 243 | + Constraint constraint = Constraint::New<Vector3>(Actor::Property::POSITION, |
| 244 | + LocalSource(Actor::Property::SIZE), | ||
| 245 | + LocalSource(Actor::Property::PARENT_ORIGIN), | ||
| 246 | + LocalSource(Actor::Property::ANCHOR_POINT), | ||
| 247 | + ParentSource(Actor::Property::SIZE), | ||
| 248 | ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT)); | 248 | ConfinementConstraint(ParentOrigin::CENTER, Vector2::ONE * MAGNIFIER_INDENT, Vector2::ONE * MAGNIFIER_INDENT)); |
| 249 | constraint.SetRemoveAction(Constraint::Discard); | 249 | constraint.SetRemoveAction(Constraint::Discard); |
| 250 | mMagnifier.ApplyConstraint( constraint ); | 250 | mMagnifier.ApplyConstraint( constraint ); |
| @@ -260,15 +260,15 @@ public: | @@ -260,15 +260,15 @@ public: | ||
| 260 | ContinueAnimation(); | 260 | ContinueAnimation(); |
| 261 | 261 | ||
| 262 | // Apply constraint to animate the position of the magnifier. | 262 | // Apply constraint to animate the position of the magnifier. |
| 263 | - constraint = Constraint::New<Vector3>(Actor::Property::Position, | ||
| 264 | - LocalSource(Actor::Property::Size), | 263 | + constraint = Constraint::New<Vector3>(Actor::Property::POSITION, |
| 264 | + LocalSource(Actor::Property::SIZE), | ||
| 265 | LocalSource(mAnimationTimeProperty), | 265 | LocalSource(mAnimationTimeProperty), |
| 266 | MagnifierPathConstraint(mStageSize, mStageSize * 0.5f)); | 266 | MagnifierPathConstraint(mStageSize, mStageSize * 0.5f)); |
| 267 | mBouncingMagnifier.ApplyConstraint( constraint ); | 267 | mBouncingMagnifier.ApplyConstraint( constraint ); |
| 268 | 268 | ||
| 269 | // Apply constraint to animate the source of the magnifier. | 269 | // Apply constraint to animate the source of the magnifier. |
| 270 | constraint = Constraint::New<Vector3>(mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ), | 270 | constraint = Constraint::New<Vector3>(mBouncingMagnifier.GetPropertyIndex( Toolkit::Magnifier::SOURCE_POSITION_PROPERTY_NAME ), |
| 271 | - LocalSource(Actor::Property::Size), | 271 | + LocalSource(Actor::Property::SIZE), |
| 272 | LocalSource(mAnimationTimeProperty), | 272 | LocalSource(mAnimationTimeProperty), |
| 273 | MagnifierPathConstraint(mStageSize)); | 273 | MagnifierPathConstraint(mStageSize)); |
| 274 | mBouncingMagnifier.ApplyConstraint( constraint ); | 274 | mBouncingMagnifier.ApplyConstraint( constraint ); |
| @@ -355,7 +355,7 @@ public: | @@ -355,7 +355,7 @@ public: | ||
| 355 | if(!mMagnifierShown) | 355 | if(!mMagnifierShown) |
| 356 | { | 356 | { |
| 357 | Animation animation = Animation::New(MAGNIFIER_DISPLAY_DURATION); | 357 | Animation animation = Animation::New(MAGNIFIER_DISPLAY_DURATION); |
| 358 | - animation.AnimateTo(Property(mMagnifier, Actor::Property::Scale), Vector3::ONE, AlphaFunctions::EaseIn); | 358 | + animation.AnimateTo(Property(mMagnifier, Actor::Property::SCALE), Vector3::ONE, AlphaFunctions::EaseIn); |
| 359 | animation.Play(); | 359 | animation.Play(); |
| 360 | mMagnifierShown = true; | 360 | mMagnifierShown = true; |
| 361 | } | 361 | } |
| @@ -369,7 +369,7 @@ public: | @@ -369,7 +369,7 @@ public: | ||
| 369 | if(mMagnifierShown) | 369 | if(mMagnifierShown) |
| 370 | { | 370 | { |
| 371 | Animation animation = Animation::New(MAGNIFIER_DISPLAY_DURATION); | 371 | Animation animation = Animation::New(MAGNIFIER_DISPLAY_DURATION); |
| 372 | - animation.AnimateTo(Property(mMagnifier, Actor::Property::Scale), Vector3::ZERO, AlphaFunctions::EaseOut); | 372 | + animation.AnimateTo(Property(mMagnifier, Actor::Property::SCALE), Vector3::ZERO, AlphaFunctions::EaseOut); |
| 373 | animation.Play(); | 373 | animation.Play(); |
| 374 | mMagnifierShown = false; | 374 | mMagnifierShown = false; |
| 375 | } | 375 | } |
examples/motion-blur/motion-blur-example.cpp
| @@ -349,7 +349,7 @@ public: | @@ -349,7 +349,7 @@ public: | ||
| 349 | mActorTapMovementAnimation = Animation::New( animDuration ); | 349 | mActorTapMovementAnimation = Animation::New( animDuration ); |
| 350 | if ( mMotionBlurImageActor ) | 350 | if ( mMotionBlurImageActor ) |
| 351 | { | 351 | { |
| 352 | - mActorTapMovementAnimation.AnimateTo( Property(mMotionBlurImageActor, Actor::Property::Position), destPos, AlphaFunctions::EaseInOutSine, TimePeriod(animDuration) ); | 352 | + mActorTapMovementAnimation.AnimateTo( Property(mMotionBlurImageActor, Actor::Property::POSITION), destPos, AlphaFunctions::EaseInOutSine, TimePeriod(animDuration) ); |
| 353 | } | 353 | } |
| 354 | mActorTapMovementAnimation.SetEndAction( Animation::Bake ); | 354 | mActorTapMovementAnimation.SetEndAction( Animation::Bake ); |
| 355 | mActorTapMovementAnimation.Play(); | 355 | mActorTapMovementAnimation.Play(); |
examples/motion-stretch/motion-stretch-example.cpp
| @@ -261,7 +261,7 @@ public: | @@ -261,7 +261,7 @@ public: | ||
| 261 | mActorTapMovementAnimation = Animation::New( animDuration ); | 261 | mActorTapMovementAnimation = Animation::New( animDuration ); |
| 262 | if ( mMotionStretchImageActor ) | 262 | if ( mMotionStretchImageActor ) |
| 263 | { | 263 | { |
| 264 | - mActorTapMovementAnimation.AnimateTo( Property(mMotionStretchImageActor, Actor::Property::Position), destPos, AlphaFunctions::EaseInOutSine, TimePeriod(animDuration) ); | 264 | + mActorTapMovementAnimation.AnimateTo( Property(mMotionStretchImageActor, Actor::Property::POSITION), destPos, AlphaFunctions::EaseInOutSine, TimePeriod(animDuration) ); |
| 265 | } | 265 | } |
| 266 | mActorTapMovementAnimation.SetEndAction( Animation::Bake ); | 266 | mActorTapMovementAnimation.SetEndAction( Animation::Bake ); |
| 267 | mActorTapMovementAnimation.Play(); | 267 | mActorTapMovementAnimation.Play(); |
examples/path-animation/path-animation.cpp
0 โ 100644
| 1 | +/* | ||
| 2 | + * Copyright (c) 2014 Samsung Electronics Co., Ltd. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + * | ||
| 16 | + */ | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * This example shows how to use path animations in DALi | ||
| 20 | + */ | ||
| 21 | + | ||
| 22 | +// EXTERNAL INCLUDES | ||
| 23 | +#include <dali-toolkit/dali-toolkit.h> | ||
| 24 | + | ||
| 25 | +// INTERNAL INCLUDES | ||
| 26 | +#include "shared/view.h" | ||
| 27 | + | ||
| 28 | +using namespace Dali; | ||
| 29 | +using namespace Dali::Toolkit; | ||
| 30 | + | ||
| 31 | + | ||
| 32 | +namespace | ||
| 33 | +{ | ||
| 34 | +const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-default.png" ); | ||
| 35 | +const char* ACTOR_IMAGE( DALI_IMAGE_DIR "dali-logo.png" ); | ||
| 36 | +const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); | ||
| 37 | +const char* APPLICATION_TITLE( "Path Animation Example" ); | ||
| 38 | +}; //Unnamed namespace | ||
| 39 | + | ||
| 40 | +/** | ||
| 41 | + * @brief The main class of the demo. | ||
| 42 | + */ | ||
| 43 | +class PathController : public ConnectionTracker | ||
| 44 | +{ | ||
| 45 | +public: | ||
| 46 | + | ||
| 47 | + PathController( Application& application ) | ||
| 48 | +: mApplication( application ) | ||
| 49 | +{ | ||
| 50 | + // Connect to the Application's Init signal | ||
| 51 | + mApplication.InitSignal().Connect( this, &PathController::Create ); | ||
| 52 | +} | ||
| 53 | + | ||
| 54 | + ~PathController() | ||
| 55 | + { | ||
| 56 | + // Nothing to do here. | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /* | ||
| 60 | + * Create a control composed of a label and an slider | ||
| 61 | + * @param[in] label The text to be displayed ny the label | ||
| 62 | + * @param[in] size The size of the slider | ||
| 63 | + * @param[in] callback Pointer to the callback function to be called when user moves the slider | ||
| 64 | + */ | ||
| 65 | + Actor CreateVectorComponentControl( const std::string& label, const Vector3& size, bool(PathController::*callback)(Slider,float) ) | ||
| 66 | + { | ||
| 67 | + Dali::TextActor textActor = TextActor::New(label); | ||
| 68 | + textActor.SetColor( Vector4(0.0f,0.0f,0.0f,1.0f)); | ||
| 69 | + textActor.SetSize(size.y,size.y,0.0f); | ||
| 70 | + | ||
| 71 | + Slider slider = Slider::New(); | ||
| 72 | + slider.SetAnchorPoint( AnchorPoint::CENTER_LEFT); | ||
| 73 | + slider.SetParentOrigin( ParentOrigin::CENTER_RIGHT); | ||
| 74 | + slider.SetProperty(Slider::Property::LOWER_BOUND, -1.0f ); | ||
| 75 | + slider.SetProperty(Slider::Property::UPPER_BOUND, 1.0f ); | ||
| 76 | + | ||
| 77 | + Property::Array marks; | ||
| 78 | + float mark = -1.0f; | ||
| 79 | + for(unsigned short i(0); i<21; ++i ) | ||
| 80 | + { | ||
| 81 | + marks.push_back( mark ); | ||
| 82 | + mark += 0.1f; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + slider.SetProperty(Slider::Property::MARKS, marks); | ||
| 86 | + slider.SetProperty(Slider::Property::SNAP_TO_MARKS, true ); | ||
| 87 | + slider.SetSize(size); | ||
| 88 | + slider.SetScale( 0.5f ); | ||
| 89 | + slider.ValueChangedSignal().Connect(this,callback); | ||
| 90 | + textActor.Add( slider ); | ||
| 91 | + return textActor; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + /** | ||
| 95 | + * Crate all the GUI controls | ||
| 96 | + */ | ||
| 97 | + void CreateControls() | ||
| 98 | + { | ||
| 99 | + Stage stage = Stage::GetCurrent(); | ||
| 100 | + | ||
| 101 | + //TextInput | ||
| 102 | + Dali::Layer controlsLayer = Dali::Layer::New(); | ||
| 103 | + controlsLayer.SetSize( stage.GetSize().x, stage.GetSize().y*0.3f, 0.0 ); | ||
| 104 | + controlsLayer.SetPosition( 0.0f, stage.GetSize().y*0.8f, 0.0f ); | ||
| 105 | + controlsLayer.SetAnchorPoint( AnchorPoint::TOP_LEFT); | ||
| 106 | + controlsLayer.SetParentOrigin( ParentOrigin::TOP_LEFT); | ||
| 107 | + controlsLayer.TouchedSignal().Connect(this, &PathController::OnTouchGuiLayer); | ||
| 108 | + stage.Add( controlsLayer ); | ||
| 109 | + | ||
| 110 | + Vector3 textInputSize( stage.GetSize().x, stage.GetSize().y*0.04f, 0.0f ); | ||
| 111 | + Actor control0 = CreateVectorComponentControl("x:", textInputSize, &PathController::OnSliderXValueChange ); | ||
| 112 | + control0.SetY( stage.GetSize().y*0.05f ); | ||
| 113 | + control0.SetAnchorPoint(AnchorPoint::TOP_LEFT); | ||
| 114 | + controlsLayer.Add( control0 ); | ||
| 115 | + | ||
| 116 | + Actor control1 = CreateVectorComponentControl("y:", textInputSize, &PathController::OnSliderYValueChange ); | ||
| 117 | + control1.SetAnchorPoint(AnchorPoint::TOP_LEFT); | ||
| 118 | + control1.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); | ||
| 119 | + control1.SetPosition(0.0f,stage.GetSize().y*0.01,0.0f); | ||
| 120 | + control0.Add( control1 ); | ||
| 121 | + | ||
| 122 | + Actor control2 =CreateVectorComponentControl("z:", textInputSize, &PathController::OnSliderZValueChange ); | ||
| 123 | + control2.SetAnchorPoint(AnchorPoint::TOP_LEFT); | ||
| 124 | + control2.SetParentOrigin( ParentOrigin::BOTTOM_LEFT ); | ||
| 125 | + control2.SetPosition(0.0f,stage.GetSize().y*0.01,0.0f); | ||
| 126 | + control1.Add( control2 ); | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + /** | ||
| 130 | + * Draws the path and the control points for the path | ||
| 131 | + * @param[in] resolution Number of segments for the path. | ||
| 132 | + */ | ||
| 133 | + void DrawPath( unsigned int resolution ) | ||
| 134 | + { | ||
| 135 | + Stage stage = Dali::Stage::GetCurrent(); | ||
| 136 | + | ||
| 137 | + //Create path mesh actor | ||
| 138 | + Dali::MeshData meshData = MeshFactory::NewPath( mPath, resolution ); | ||
| 139 | + Dali::Material material = Material::New("LineMaterial"); | ||
| 140 | + material.SetDiffuseColor( Vector4(0.0f,0.0f,0.0f,1.0f)); | ||
| 141 | + meshData.SetMaterial(material); | ||
| 142 | + Dali::Mesh mesh = Dali::Mesh::New( meshData ); | ||
| 143 | + if( mMeshPath ) | ||
| 144 | + { | ||
| 145 | + stage.Remove( mMeshPath ); | ||
| 146 | + } | ||
| 147 | + mMeshPath = Dali::MeshActor::New( mesh ); | ||
| 148 | + mMeshPath.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | ||
| 149 | + mMeshPath.SetParentOrigin( ParentOrigin::TOP_LEFT ); | ||
| 150 | + stage.Add( mMeshPath ); | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + ////Create mesh connecting interpolation points and control points | ||
| 154 | + std::vector<Dali::MeshData::Vertex> vVertex; | ||
| 155 | + std::vector<unsigned short> vIndex; | ||
| 156 | + size_t pointCount = mPath.GetPointCount(); | ||
| 157 | + size_t controlPointIndex = 0; | ||
| 158 | + for( size_t i(0); i<pointCount; ++i ) | ||
| 159 | + { | ||
| 160 | + vVertex.push_back( MeshData::Vertex(mPath.GetPoint(i),Vector2::ZERO, Vector3::ZERO ) ); | ||
| 161 | + if( i<pointCount-1) | ||
| 162 | + { | ||
| 163 | + vVertex.push_back( MeshData::Vertex(mPath.GetControlPoint(controlPointIndex),Vector2::ZERO, Vector3::ZERO )); | ||
| 164 | + vVertex.push_back( MeshData::Vertex(mPath.GetControlPoint(controlPointIndex+1),Vector2::ZERO, Vector3::ZERO )); | ||
| 165 | + } | ||
| 166 | + controlPointIndex += 2; | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + size_t segmentCount = 2*(pointCount-2)+2; | ||
| 170 | + unsigned short index=0; | ||
| 171 | + for( size_t i(0); i<segmentCount; ++i, ++index ) | ||
| 172 | + { | ||
| 173 | + vIndex.push_back(index); | ||
| 174 | + vIndex.push_back(index+1); | ||
| 175 | + | ||
| 176 | + if( ~i & 1 ) | ||
| 177 | + { | ||
| 178 | + index++; | ||
| 179 | + } | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + meshData.SetLineData( vVertex, vIndex, material ); | ||
| 183 | + meshData.SetMaterial(material); | ||
| 184 | + mesh = Dali::Mesh::New( meshData ); | ||
| 185 | + if( mMeshHandlers ) | ||
| 186 | + { | ||
| 187 | + stage.Remove( mMeshHandlers ); | ||
| 188 | + } | ||
| 189 | + mMeshHandlers = Dali::MeshActor::New( mesh ); | ||
| 190 | + mMeshHandlers.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | ||
| 191 | + mMeshHandlers.SetParentOrigin( ParentOrigin::TOP_LEFT ); | ||
| 192 | + stage.Add( mMeshHandlers ); | ||
| 193 | + | ||
| 194 | + | ||
| 195 | + //Create actors representing interpolation points | ||
| 196 | + index = 0; | ||
| 197 | + for( size_t i(0); i<pointCount; ++i ) | ||
| 198 | + { | ||
| 199 | + if( !mControlPoint[index] ) | ||
| 200 | + { | ||
| 201 | + mControlPoint[index] = Toolkit::CreateSolidColorActor(Vector4(1.0f,1.0f,1.0f,1.0f)); | ||
| 202 | + mControlPoint[index].SetParentOrigin( ParentOrigin::TOP_LEFT); | ||
| 203 | + mControlPoint[index].SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 204 | + mControlPoint[index].SetSize( 20.0f, 20.0f ); | ||
| 205 | + mContentLayer.Add(mControlPoint[index]); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + std::string name( "Knot"); | ||
| 209 | + name.push_back(i); | ||
| 210 | + mControlPoint[index].SetName( name ); | ||
| 211 | + mControlPoint[index].SetPosition( mPath.GetPoint(i) ); | ||
| 212 | + mControlPoint[index].SetColor( Vector4(0.0f,0.0f,0.0f,1.0f)); | ||
| 213 | + ++index; | ||
| 214 | + } | ||
| 215 | + | ||
| 216 | + //Create actors representing control points | ||
| 217 | + size_t controlPointCount=2*(pointCount-1); | ||
| 218 | + for( size_t i(0); i<controlPointCount; ++i ) | ||
| 219 | + { | ||
| 220 | + if( !mControlPoint[index]) | ||
| 221 | + { | ||
| 222 | + mControlPoint[index] = Toolkit::CreateSolidColorActor(Vector4(1.0f,1.0f,1.0f,1.0f)); | ||
| 223 | + mControlPoint[index].SetParentOrigin( ParentOrigin::TOP_LEFT); | ||
| 224 | + mControlPoint[index].SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 225 | + mControlPoint[index].SetSize( 20.0f, 20.0f ); | ||
| 226 | + mContentLayer.Add(mControlPoint[index]); | ||
| 227 | + } | ||
| 228 | + std::string name( "ControlPoint"); | ||
| 229 | + name.push_back(i); | ||
| 230 | + mControlPoint[index].SetName( name ); | ||
| 231 | + mControlPoint[index].SetPosition( mPath.GetControlPoint(i) ); | ||
| 232 | + mControlPoint[index].SetColor( Vector4(1.0f,0.0f,0.0f,1.0f)); | ||
| 233 | + ++index; | ||
| 234 | + } | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + /** | ||
| 238 | + * Create the path animation. | ||
| 239 | + */ | ||
| 240 | + void CreateAnimation() | ||
| 241 | + { | ||
| 242 | + if( !mAnimation ) | ||
| 243 | + { | ||
| 244 | + mAnimation = Animation::New( 2.0f ); | ||
| 245 | + } | ||
| 246 | + else | ||
| 247 | + { | ||
| 248 | + mAnimation.Pause(); | ||
| 249 | + mAnimation.Clear(); | ||
| 250 | + mActor.SetRotation( Quaternion() ); | ||
| 251 | + } | ||
| 252 | + | ||
| 253 | + mAnimation.Animate( mActor, mPath, mForward ); | ||
| 254 | + mAnimation.SetLooping( true ); | ||
| 255 | + mAnimation.Play(); | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + /** | ||
| 259 | + * Get closest control point.void | ||
| 260 | + * @param[in] point Point from where the distance is computed | ||
| 261 | + * @return The closest actor if the distance is beyond 0.5cm or an uninitialized actor otherwise | ||
| 262 | + */ | ||
| 263 | + Actor GetClosestActor(const Vector3& point) | ||
| 264 | + { | ||
| 265 | + size_t pointCount = mPath.GetPointCount(); | ||
| 266 | + size_t controlPointCount = 3*pointCount - 2; | ||
| 267 | + Actor result; | ||
| 268 | + float minDistance = 1.0/0.0; | ||
| 269 | + | ||
| 270 | + for( size_t i(0); i<controlPointCount; ++i ) | ||
| 271 | + { | ||
| 272 | + Vector3 v = mControlPoint[i].GetCurrentPosition() - point; | ||
| 273 | + float distance = v.LengthSquared(); | ||
| 274 | + if( distance < minDistance ) | ||
| 275 | + { | ||
| 276 | + result = mControlPoint[i]; | ||
| 277 | + minDistance = distance; | ||
| 278 | + } | ||
| 279 | + } | ||
| 280 | + | ||
| 281 | + Vector2 dpi = Dali::Stage::GetCurrent().GetDpi(); | ||
| 282 | + float distanceTreshold = 0.2f * dpi.x * 0.2f * dpi.x; | ||
| 283 | + | ||
| 284 | + if( minDistance < distanceTreshold ) | ||
| 285 | + { | ||
| 286 | + return result; | ||
| 287 | + } | ||
| 288 | + else | ||
| 289 | + { | ||
| 290 | + return Actor(); | ||
| 291 | + } | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + /** | ||
| 295 | + * Callback called when the background layer is touched | ||
| 296 | + */ | ||
| 297 | + bool OnTouchLayer(Actor actor, const TouchEvent& event) | ||
| 298 | + { | ||
| 299 | + if(event.GetPointCount()>0) | ||
| 300 | + { | ||
| 301 | + const TouchPoint& point = event.GetPoint(0); | ||
| 302 | + | ||
| 303 | + if(point.state==TouchPoint::Up) | ||
| 304 | + { | ||
| 305 | + //Stop dragging | ||
| 306 | + mDragActor.Reset(); | ||
| 307 | + } | ||
| 308 | + else if(point.state==TouchPoint::Down) | ||
| 309 | + { | ||
| 310 | + Vector3 touchPoint = Vector3(event.GetPoint(0).screen.x, event.GetPoint(0).screen.y, 0.0f); | ||
| 311 | + if(!mDragActor ) | ||
| 312 | + { | ||
| 313 | + mDragActor = GetClosestActor( touchPoint ); | ||
| 314 | + if( !mDragActor && mPath.GetPointCount() < 10 ) | ||
| 315 | + { | ||
| 316 | + // Add new point | ||
| 317 | + Vector3 lastPoint = mPath.GetPoint( mPath.GetPointCount()-1); | ||
| 318 | + mPath.AddPoint( touchPoint ); | ||
| 319 | + Vector3 displacement = (touchPoint-lastPoint)/8; | ||
| 320 | + mPath.AddControlPoint( lastPoint + displacement ); | ||
| 321 | + mPath.AddControlPoint( touchPoint - displacement); | ||
| 322 | + | ||
| 323 | + DrawPath( 200u ); | ||
| 324 | + CreateAnimation(); | ||
| 325 | + } | ||
| 326 | + } | ||
| 327 | + } | ||
| 328 | + else if( mDragActor && point.state==TouchPoint::Motion ) | ||
| 329 | + { | ||
| 330 | + Vector3 touchPoint = Vector3(event.GetPoint(0).screen.x, event.GetPoint(0).screen.y, 0.0f); | ||
| 331 | + std::string actorName(mDragActor.GetName()); | ||
| 332 | + if( actorName.compare(0, 4, "Knot") == 0) | ||
| 333 | + { | ||
| 334 | + int index = actorName[4]; | ||
| 335 | + mPath.GetPoint(index) = touchPoint; | ||
| 336 | + } | ||
| 337 | + else | ||
| 338 | + { | ||
| 339 | + int index = actorName[12]; | ||
| 340 | + mPath.GetControlPoint(index) = touchPoint; | ||
| 341 | + } | ||
| 342 | + | ||
| 343 | + DrawPath( 200u ); | ||
| 344 | + CreateAnimation(); | ||
| 345 | + } | ||
| 346 | + } | ||
| 347 | + | ||
| 348 | + return true; | ||
| 349 | + } | ||
| 350 | + | ||
| 351 | + bool OnTouchGuiLayer(Actor actor, const TouchEvent& event) | ||
| 352 | + { | ||
| 353 | + mDragActor.Reset(); | ||
| 354 | + return false; | ||
| 355 | + } | ||
| 356 | + /** | ||
| 357 | + * Callback called when user changes slider X | ||
| 358 | + * @param[in] slider The slider that has generated the signal | ||
| 359 | + * @param[in] value The new value | ||
| 360 | + */ | ||
| 361 | + bool OnSliderXValueChange( Slider s, float value) | ||
| 362 | + { | ||
| 363 | + if( fabs( value ) - Math::MACHINE_EPSILON_1000 < 0.0f ) | ||
| 364 | + { | ||
| 365 | + mForward.x = 0.0f; | ||
| 366 | + } | ||
| 367 | + else | ||
| 368 | + { | ||
| 369 | + mForward.x = value; | ||
| 370 | + } | ||
| 371 | + | ||
| 372 | + CreateAnimation(); | ||
| 373 | + return true; | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + /** | ||
| 377 | + * Callback called when user changes slider Y | ||
| 378 | + * @param[in] slider The slider that has generated the signal | ||
| 379 | + * @param[in] value The new value | ||
| 380 | + */ | ||
| 381 | + bool OnSliderYValueChange( Slider s, float value) | ||
| 382 | + { | ||
| 383 | + if( fabs( value ) - Math::MACHINE_EPSILON_1000 < 0.0f ) | ||
| 384 | + { | ||
| 385 | + mForward.y = 0.0f; | ||
| 386 | + } | ||
| 387 | + else | ||
| 388 | + { | ||
| 389 | + mForward.y = value; | ||
| 390 | + } | ||
| 391 | + CreateAnimation(); | ||
| 392 | + return true; | ||
| 393 | + } | ||
| 394 | + | ||
| 395 | + /** | ||
| 396 | + * Callback called when user changes slider Z | ||
| 397 | + * @param[in] slider The slider that has generated the signal | ||
| 398 | + * @param[in] value The new value | ||
| 399 | + */ | ||
| 400 | + bool OnSliderZValueChange( Slider s, float value) | ||
| 401 | + { | ||
| 402 | + if( fabs( value ) - Math::MACHINE_EPSILON_1000 < 0.0f ) | ||
| 403 | + { | ||
| 404 | + mForward.z = 0.0f; | ||
| 405 | + } | ||
| 406 | + else | ||
| 407 | + { | ||
| 408 | + mForward.z = value; | ||
| 409 | + } | ||
| 410 | + | ||
| 411 | + CreateAnimation(); | ||
| 412 | + return true; | ||
| 413 | + } | ||
| 414 | + | ||
| 415 | + /** | ||
| 416 | + * Main key event handler. | ||
| 417 | + * Quit on escape key. | ||
| 418 | + */ | ||
| 419 | + void OnKeyEvent(const KeyEvent& event) | ||
| 420 | + { | ||
| 421 | + if( event.state == KeyEvent::Down ) | ||
| 422 | + { | ||
| 423 | + if( IsKey( event, Dali::DALI_KEY_ESCAPE ) || | ||
| 424 | + IsKey( event, Dali::DALI_KEY_BACK ) ) | ||
| 425 | + { | ||
| 426 | + mApplication.Quit(); | ||
| 427 | + } | ||
| 428 | + } | ||
| 429 | + } | ||
| 430 | + | ||
| 431 | + /** | ||
| 432 | + * One-time setup in response to Application InitSignal. | ||
| 433 | + */ | ||
| 434 | + void Create( Application& application ) | ||
| 435 | + { | ||
| 436 | + // Get a handle to the stage: | ||
| 437 | + Stage stage = Stage::GetCurrent(); | ||
| 438 | + | ||
| 439 | + // Connect to input event signals: | ||
| 440 | + stage.KeyEventSignal().Connect(this, &PathController::OnKeyEvent); | ||
| 441 | + | ||
| 442 | + // Create a default view with a default tool bar: | ||
| 443 | + Toolkit::View view; ///< The View instance. | ||
| 444 | + Toolkit::ToolBar toolBar; ///< The View's Toolbar. | ||
| 445 | + mContentLayer = DemoHelper::CreateView( mApplication, | ||
| 446 | + view, | ||
| 447 | + toolBar, | ||
| 448 | + BACKGROUND_IMAGE, | ||
| 449 | + TOOLBAR_IMAGE, | ||
| 450 | + "" ); | ||
| 451 | + | ||
| 452 | + mContentLayer.TouchedSignal().Connect(this, &PathController::OnTouchLayer); | ||
| 453 | + | ||
| 454 | + //Title | ||
| 455 | + TextView title = TextView::New(); | ||
| 456 | + toolBar.AddControl( title, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Alignment::HorizontalCenter ); | ||
| 457 | + Font font = Font::New(); | ||
| 458 | + title.SetText( APPLICATION_TITLE ); | ||
| 459 | + title.SetSize( font.MeasureText( APPLICATION_TITLE ) ); | ||
| 460 | + title.SetStyleToCurrentText(DemoHelper::GetDefaultTextStyle()); | ||
| 461 | + | ||
| 462 | + //Path | ||
| 463 | + mPath = Dali::Path::New(); | ||
| 464 | + mPath.AddPoint( Vector3( 10.0f, stage.GetSize().y*0.5f, 0.0f )); | ||
| 465 | + mPath.AddPoint( Vector3( stage.GetSize().x*0.5f, stage.GetSize().y*0.5f, 0.0f )); | ||
| 466 | + mPath.GenerateControlPoints(0.25f); | ||
| 467 | + DrawPath( 200u ); | ||
| 468 | + | ||
| 469 | + //Actor | ||
| 470 | + ImageAttributes attributes; | ||
| 471 | + Image img = ResourceImage::New(ACTOR_IMAGE, attributes ); | ||
| 472 | + mActor = ImageActor::New( img ); | ||
| 473 | + mActor.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 474 | + mActor.SetSize( 100, 50, 1 ); | ||
| 475 | + stage.Add( mActor ); | ||
| 476 | + | ||
| 477 | + CreateAnimation(); | ||
| 478 | + CreateControls(); | ||
| 479 | + } | ||
| 480 | + | ||
| 481 | +private: | ||
| 482 | + Application& mApplication; | ||
| 483 | + | ||
| 484 | + Layer mContentLayer; ///< The content layer | ||
| 485 | + | ||
| 486 | + Path mPath; ///< The path used in the animation | ||
| 487 | + ImageActor mActor; ///< Actor being animated | ||
| 488 | + Vector3 mForward; ///< Current forward vector | ||
| 489 | + Animation mAnimation; ///< Path animation | ||
| 490 | + | ||
| 491 | + MeshActor mMeshPath; ///< Mesh actor for the path | ||
| 492 | + MeshActor mMeshHandlers; ///< Mesh actor for the handlers of the path | ||
| 493 | + | ||
| 494 | + Actor mControlPoint[28]; ///< ImageActors represeting control points of the path | ||
| 495 | + | ||
| 496 | + Actor mDragActor; ///< Reference to the actor currently being dragged | ||
| 497 | +}; | ||
| 498 | + | ||
| 499 | + | ||
| 500 | +void RunTest( Application& application ) | ||
| 501 | +{ | ||
| 502 | + PathController test( application ); | ||
| 503 | + | ||
| 504 | + application.MainLoop(); | ||
| 505 | +} | ||
| 506 | + | ||
| 507 | +/** Entry point for Linux & Tizen applications */ | ||
| 508 | +int main( int argc, char **argv ) | ||
| 509 | +{ | ||
| 510 | + Application application = Application::New( &argc, &argv ); | ||
| 511 | + | ||
| 512 | + RunTest( application ); | ||
| 513 | + | ||
| 514 | + return 0; | ||
| 515 | +} |
examples/radial-menu/radial-sweep-view-impl.cpp
| @@ -362,17 +362,17 @@ void RadialSweepViewImpl::CreateStencil( Degree initialSector ) | @@ -362,17 +362,17 @@ void RadialSweepViewImpl::CreateStencil( Degree initialSector ) | ||
| 362 | 362 | ||
| 363 | // Constrain the vertices of the square mesh to sweep out a sector as the | 363 | // Constrain the vertices of the square mesh to sweep out a sector as the |
| 364 | // rotation angle is animated. | 364 | // rotation angle is animated. |
| 365 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(1, AnimatableVertex::Property::Position), | 365 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(1, AnimatableVertex::Property::POSITION), |
| 366 | srcStart, srcStart, SquareFanConstraint(0))); | 366 | srcStart, srcStart, SquareFanConstraint(0))); |
| 367 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(2, AnimatableVertex::Property::Position), | 367 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(2, AnimatableVertex::Property::POSITION), |
| 368 | srcStart, srcRot, SquareFanConstraint(0))); | 368 | srcStart, srcRot, SquareFanConstraint(0))); |
| 369 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(3, AnimatableVertex::Property::Position), | 369 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(3, AnimatableVertex::Property::POSITION), |
| 370 | srcStart, srcRot, SquareFanConstraint(1))); | 370 | srcStart, srcRot, SquareFanConstraint(1))); |
| 371 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(4, AnimatableVertex::Property::Position), | 371 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(4, AnimatableVertex::Property::POSITION), |
| 372 | srcStart, srcRot, SquareFanConstraint(2))); | 372 | srcStart, srcRot, SquareFanConstraint(2))); |
| 373 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(5, AnimatableVertex::Property::Position), | 373 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(5, AnimatableVertex::Property::POSITION), |
| 374 | srcStart, srcRot, SquareFanConstraint(3))); | 374 | srcStart, srcRot, SquareFanConstraint(3))); |
| 375 | - mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(6, AnimatableVertex::Property::Position), | 375 | + mMesh.ApplyConstraint(Constraint::New<Vector3>( mMesh.GetPropertyIndex(6, AnimatableVertex::Property::POSITION), |
| 376 | srcStart, srcRot, SquareFanConstraint(4))); | 376 | srcStart, srcRot, SquareFanConstraint(4))); |
| 377 | 377 | ||
| 378 | mStencilActor.SetDrawMode( DrawMode::STENCIL ); | 378 | mStencilActor.SetDrawMode( DrawMode::STENCIL ); |
examples/scroll-view/scroll-view-example.cpp
| @@ -210,7 +210,7 @@ public: | @@ -210,7 +210,7 @@ public: | ||
| 210 | 210 | ||
| 211 | // Hack to force screen refresh. | 211 | // Hack to force screen refresh. |
| 212 | Animation animation = Animation::New(1.0f); | 212 | Animation animation = Animation::New(1.0f); |
| 213 | - animation.AnimateTo(Property(mContentLayer, Actor::Property::Position), Vector3::ZERO ); | 213 | + animation.AnimateTo(Property(mContentLayer, Actor::Property::POSITION), Vector3::ZERO ); |
| 214 | animation.Play(); | 214 | animation.Play(); |
| 215 | } | 215 | } |
| 216 | 216 |
examples/shadow-bone-lighting/shadow-bone-lighting-example.cpp
| @@ -200,7 +200,7 @@ public: | @@ -200,7 +200,7 @@ public: | ||
| 200 | mPinchGestureDetector.Attach( mView ); | 200 | mPinchGestureDetector.Attach( mView ); |
| 201 | mPinchGestureDetector.DetectedSignal().Connect(this, &TestApp::OnPinch); | 201 | mPinchGestureDetector.DetectedSignal().Connect(this, &TestApp::OnPinch); |
| 202 | 202 | ||
| 203 | - mTapGestureDetector = TapGestureDetector::New(1, 1); | 203 | + mTapGestureDetector = TapGestureDetector::New(); |
| 204 | mTapGestureDetector.Attach( mView ); | 204 | mTapGestureDetector.Attach( mView ); |
| 205 | mTapGestureDetector.DetectedSignal().Connect(this, &TestApp::OnTap); | 205 | mTapGestureDetector.DetectedSignal().Connect(this, &TestApp::OnTap); |
| 206 | } | 206 | } |
| @@ -286,9 +286,9 @@ public: | @@ -286,9 +286,9 @@ public: | ||
| 286 | 286 | ||
| 287 | Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value(30.0f)); | 287 | Property::Index angleIndex = mImageActor2.RegisterProperty("angle", Property::Value(30.0f)); |
| 288 | Source angleSrc( mImageActor2, angleIndex ); | 288 | Source angleSrc( mImageActor2, angleIndex ); |
| 289 | - mImageActor1.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::Rotation, angleSrc, | 289 | + mImageActor1.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::ROTATION, angleSrc, |
| 290 | RotationConstraint(-1.0f))); | 290 | RotationConstraint(-1.0f))); |
| 291 | - mImageActor3.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::Rotation, angleSrc, | 291 | + mImageActor3.ApplyConstraint(Constraint::New<Quaternion>( Actor::Property::ROTATION, angleSrc, |
| 292 | RotationConstraint(+1.0f))); | 292 | RotationConstraint(+1.0f))); |
| 293 | 293 | ||
| 294 | mSceneAnimation = Animation::New(2.5f); | 294 | mSceneAnimation = Animation::New(2.5f); |
packaging/com.samsung.dali-demo.spec
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | 2 | ||
| 3 | Name: com.samsung.dali-demo | 3 | Name: com.samsung.dali-demo |
| 4 | Summary: The OpenGLES Canvas Core Demo | 4 | Summary: The OpenGLES Canvas Core Demo |
| 5 | -Version: 1.0.32 | 5 | +Version: 1.0.33 |
| 6 | Release: 1 | 6 | Release: 1 |
| 7 | Group: System/Libraries | 7 | Group: System/Libraries |
| 8 | License: Apache-2.0 | 8 | License: Apache-2.0 |
shared/view.h
| @@ -86,7 +86,7 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, | @@ -86,7 +86,7 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, | ||
| 86 | Dali::Layer toolBarLayer = Dali::Layer::New(); | 86 | Dali::Layer toolBarLayer = Dali::Layer::New(); |
| 87 | toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); | 87 | toolBarLayer.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); |
| 88 | toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); | 88 | toolBarLayer.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); |
| 89 | - toolBarLayer.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::Property::Size, Dali::ParentSource( Dali::Actor::Property::Size ), Dali::SourceWidthFixedHeight( style.mToolBarHeight ) ) ); | 89 | + toolBarLayer.ApplyConstraint( Dali::Constraint::New<Dali::Vector3>( Dali::Actor::Property::SIZE, Dali::ParentSource( Dali::Actor::Property::SIZE ), Dali::SourceWidthFixedHeight( style.mToolBarHeight ) ) ); |
| 90 | toolBarLayer.SetSize( 0.0f, style.mToolBarHeight ); | 90 | toolBarLayer.SetSize( 0.0f, style.mToolBarHeight ); |
| 91 | 91 | ||
| 92 | // Raise tool bar layer to the top. | 92 | // Raise tool bar layer to the top. |