Commit 8da6b8a945b6a24dfa03f55ae4f2ad36e4bdf6f8
[dali_1.1.1] Merge branch 'devel/master'
Change-Id: Ie82817e14cd7ae8a260538acd8b7c9584675f27e
Showing
2 changed files
with
67 additions
and
65 deletions
examples/page-turn-view/page-turn-view-example.cpp
| @@ -17,10 +17,6 @@ | @@ -17,10 +17,6 @@ | ||
| 17 | 17 | ||
| 18 | #include <dali/dali.h> | 18 | #include <dali/dali.h> |
| 19 | #include <dali-toolkit/dali-toolkit.h> | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | -#include <dali-toolkit/devel-api/controls/page-turn-view/page-factory.h> | ||
| 21 | -#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-landscape-view.h> | ||
| 22 | -#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-portrait-view.h> | ||
| 23 | -#include <dali-toolkit/devel-api/controls/page-turn-view/page-turn-view.h> | ||
| 24 | 20 | ||
| 25 | #include <assert.h> | 21 | #include <assert.h> |
| 26 | #include <cstdlib> | 22 | #include <cstdlib> |
| @@ -35,6 +31,9 @@ using namespace Dali::Toolkit; | @@ -35,6 +31,9 @@ using namespace Dali::Toolkit; | ||
| 35 | // LOCAL STUFF | 31 | // LOCAL STUFF |
| 36 | namespace | 32 | namespace |
| 37 | { | 33 | { |
| 34 | +const char* const CHANGE_IMAGE_ICON(DALI_IMAGE_DIR "icon-change.png"); | ||
| 35 | +const char* const CHANGE_IMAGE_ICON_SELECTED( DALI_IMAGE_DIR "icon-change-selected.png" ); | ||
| 36 | + | ||
| 38 | // The content amount of one page between portrait and landscape view are different | 37 | // The content amount of one page between portrait and landscape view are different |
| 39 | // set a ratio to modify the current page number when the rotation is changed | 38 | // set a ratio to modify the current page number when the rotation is changed |
| 40 | const float PAGE_NUMBER_CORRESPONDING_RATIO(1.25f); | 39 | const float PAGE_NUMBER_CORRESPONDING_RATIO(1.25f); |
| @@ -76,7 +75,7 @@ class PortraitPageFactory : public PageFactory | @@ -76,7 +75,7 @@ class PortraitPageFactory : public PageFactory | ||
| 76 | */ | 75 | */ |
| 77 | virtual unsigned int GetNumberOfPages() | 76 | virtual unsigned int GetNumberOfPages() |
| 78 | { | 77 | { |
| 79 | - return 5*NUMBER_OF_PORTRAIT_IMAGE + 1; | 78 | + return 10*NUMBER_OF_PORTRAIT_IMAGE + 1; |
| 80 | } | 79 | } |
| 81 | /** | 80 | /** |
| 82 | * Create an image actor to represent a page. | 81 | * Create an image actor to represent a page. |
| @@ -108,7 +107,7 @@ class LandscapePageFactory : public PageFactory | @@ -108,7 +107,7 @@ class LandscapePageFactory : public PageFactory | ||
| 108 | */ | 107 | */ |
| 109 | virtual unsigned int GetNumberOfPages() | 108 | virtual unsigned int GetNumberOfPages() |
| 110 | { | 109 | { |
| 111 | - return 5*NUMBER_OF_LANDSCAPE_IMAGE / 2 + 1; | 110 | + return 10*NUMBER_OF_LANDSCAPE_IMAGE / 2 + 1; |
| 112 | } | 111 | } |
| 113 | /** | 112 | /** |
| 114 | * Create an image actor to represent a page. | 113 | * Create an image actor to represent a page. |
| @@ -156,10 +155,9 @@ public: | @@ -156,10 +155,9 @@ public: | ||
| 156 | private: | 155 | private: |
| 157 | 156 | ||
| 158 | /** | 157 | /** |
| 159 | - * This method gets called when the screen is rotated, switch between portrait and landscape views | ||
| 160 | - * param [in] orientation The current screen orientation | 158 | + * This method gets called when the button is clicked, switch between portrait and landscape views |
| 161 | */ | 159 | */ |
| 162 | - void OnOrientationAnimationStarted( Orientation orientation ); | 160 | + bool OnButtonClicked(Toolkit::Button button); |
| 163 | 161 | ||
| 164 | /** | 162 | /** |
| 165 | * Main key event handler | 163 | * Main key event handler |
| @@ -199,7 +197,7 @@ private: | @@ -199,7 +197,7 @@ private: | ||
| 199 | private: | 197 | private: |
| 200 | 198 | ||
| 201 | Application& mApplication; | 199 | Application& mApplication; |
| 202 | - Actor mView; | 200 | + Layer mButtonLayer; |
| 203 | 201 | ||
| 204 | PageTurnView mPageTurnPortraitView; | 202 | PageTurnView mPageTurnPortraitView; |
| 205 | PageTurnView mPageTurnLandscapeView; | 203 | PageTurnView mPageTurnLandscapeView; |
| @@ -231,75 +229,79 @@ void PageTurnController::OnInit( Application& app ) | @@ -231,75 +229,79 @@ void PageTurnController::OnInit( Application& app ) | ||
| 231 | Stage stage = Stage::GetCurrent(); | 229 | Stage stage = Stage::GetCurrent(); |
| 232 | Vector2 stageSize = stage.GetSize(); | 230 | Vector2 stageSize = stage.GetSize(); |
| 233 | 231 | ||
| 234 | - // Create default View. | ||
| 235 | - mView = Actor::New(); | ||
| 236 | - mView.SetAnchorPoint( Dali::AnchorPoint::CENTER ); | ||
| 237 | - mView.SetParentOrigin( Dali::ParentOrigin::CENTER ); | ||
| 238 | - mView.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | ||
| 239 | - stage.Add( mView ); | ||
| 240 | - | ||
| 241 | - Dali::Window winHandle = app.GetWindow(); | ||
| 242 | - winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT ); | ||
| 243 | - winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE ); | ||
| 244 | - winHandle.AddAvailableOrientation( Dali::Window::PORTRAIT_INVERSE ); | ||
| 245 | - winHandle.AddAvailableOrientation( Dali::Window::LANDSCAPE_INVERSE ); | ||
| 246 | - | ||
| 247 | - // view will response to orientation change to display portrait or landscape views | ||
| 248 | - //app.GetWindow().GetOrientation().ChangedSignal().Connect( this, &PageTurnController::OnOrientationAnimationStarted ); | ||
| 249 | - | ||
| 250 | - mPageTurnPortraitView = PageTurnPortraitView::New( mPortraitPageFactory, stageSize ); | ||
| 251 | - mPageTurnPortraitView.SetSpineShadowParameter( Vector2(70.f, 30.f) ); | 232 | + mButtonLayer = Layer::New(); |
| 233 | + mButtonLayer.SetAnchorPoint( Dali::AnchorPoint::CENTER ); | ||
| 234 | + mButtonLayer.SetParentOrigin( Dali::ParentOrigin::CENTER ); | ||
| 235 | + mButtonLayer.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | ||
| 236 | + Toolkit::PushButton button = Toolkit::PushButton::New(); | ||
| 237 | + button.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); | ||
| 238 | + button.SetParentOrigin( ParentOrigin::TOP_RIGHT ); | ||
| 239 | + button.SetUnselectedImage( CHANGE_IMAGE_ICON ); | ||
| 240 | + button.SetSelectedImage( CHANGE_IMAGE_ICON_SELECTED ); | ||
| 241 | + button.SetLeaveRequired( true ); | ||
| 242 | + button.SetScale(1.5f); | ||
| 243 | + button.PressedSignal().Connect( this, &PageTurnController::OnButtonClicked ); | ||
| 244 | + stage.Add( mButtonLayer ); | ||
| 245 | + mButtonLayer.Add(button); | ||
| 246 | + | ||
| 247 | + Vector2 bookSize( stageSize.x > stageSize.y ? stageSize.y : stageSize.x, | ||
| 248 | + stageSize.x > stageSize.y ? stageSize.x : stageSize.y ); | ||
| 249 | + | ||
| 250 | + mPageTurnPortraitView = PageTurnPortraitView::New( mPortraitPageFactory, bookSize ); | ||
| 251 | + mPageTurnPortraitView.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 252 | + mPageTurnPortraitView.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 253 | + mPageTurnPortraitView.SetProperty( PageTurnView::Property::SPINE_SHADOW, Vector2(70.f, 30.f) ); | ||
| 252 | mPageTurnPortraitView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); | 254 | mPageTurnPortraitView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); |
| 253 | mPageTurnPortraitView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); | 255 | mPageTurnPortraitView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); |
| 254 | mPageTurnPortraitView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan ); | 256 | mPageTurnPortraitView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan ); |
| 255 | mPageTurnPortraitView.PagePanFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedPan ); | 257 | mPageTurnPortraitView.PagePanFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedPan ); |
| 256 | - mPageTurnPortraitView.SetPositionInheritanceMode( USE_PARENT_POSITION ); | ||
| 257 | 258 | ||
| 258 | - mPageTurnLandscapeView = PageTurnLandscapeView::New( mLandscapePageFactory, Vector2(stageSize.y*0.5f, stageSize.x) ); | 259 | + mPageTurnLandscapeView = PageTurnLandscapeView::New( mLandscapePageFactory, Vector2(bookSize.y*0.5f, bookSize.x) ); |
| 260 | + mPageTurnLandscapeView.SetParentOrigin( ParentOrigin::CENTER ); | ||
| 261 | + mPageTurnLandscapeView.SetAnchorPoint( AnchorPoint::CENTER ); | ||
| 259 | mPageTurnLandscapeView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); | 262 | mPageTurnLandscapeView.PageTurnStartedSignal().Connect( this, &PageTurnController::OnPageStartedTurn ); |
| 260 | mPageTurnLandscapeView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); | 263 | mPageTurnLandscapeView.PageTurnFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedTurn ); |
| 261 | mPageTurnLandscapeView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan ); | 264 | mPageTurnLandscapeView.PagePanStartedSignal().Connect( this, &PageTurnController::OnPageStartedPan ); |
| 262 | mPageTurnLandscapeView.PagePanFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedPan ); | 265 | mPageTurnLandscapeView.PagePanFinishedSignal().Connect( this, &PageTurnController::OnPageFinishedPan ); |
| 263 | - mPageTurnLandscapeView.SetPositionInheritanceMode( USE_PARENT_POSITION ); | ||
| 264 | 266 | ||
| 265 | - mView.Add(mPageTurnPortraitView); | 267 | + if( stageSize.x > stageSize.y ) |
| 268 | + { | ||
| 269 | + stage.Add(mPageTurnLandscapeView); | ||
| 270 | + mPageTurnPortraitView.SetOrientation(Degree(90.f), Vector3::ZAXIS); | ||
| 271 | + mIsPortrait = false; | ||
| 272 | + } | ||
| 273 | + else | ||
| 274 | + { | ||
| 275 | + stage.Add(mPageTurnPortraitView); | ||
| 276 | + mPageTurnLandscapeView.SetOrientation(Degree(90.f), Vector3::ZAXIS); | ||
| 277 | + mIsPortrait = true; | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + mButtonLayer.RaiseToTop(); | ||
| 266 | } | 281 | } |
| 267 | 282 | ||
| 268 | -void PageTurnController::OnOrientationAnimationStarted( Orientation orientation ) | 283 | +bool PageTurnController::OnButtonClicked(Toolkit::Button button) |
| 269 | { | 284 | { |
| 270 | - switch( orientation.GetDegrees() ) | 285 | + if( mIsPortrait ) |
| 271 | { | 286 | { |
| 272 | - // portrait view, display page in the right side only | ||
| 273 | - case 0: | ||
| 274 | - case 180: | ||
| 275 | - { | ||
| 276 | - if( !mIsPortrait ) | ||
| 277 | - { | ||
| 278 | - mView.Remove( mPageTurnLandscapeView ); | ||
| 279 | - mView.Add( mPageTurnPortraitView ); | ||
| 280 | - int currentPage = floor( static_cast<float>(mPageTurnLandscapeView.GetCurrentPage()) * PAGE_NUMBER_CORRESPONDING_RATIO ); | ||
| 281 | - mPageTurnPortraitView.GoToPage( currentPage ); | ||
| 282 | - mIsPortrait = true; | ||
| 283 | - } | ||
| 284 | - break; | ||
| 285 | - } | ||
| 286 | - // display pages in both sides | ||
| 287 | - case 90: | ||
| 288 | - case 270: | ||
| 289 | - { | ||
| 290 | - if( mIsPortrait ) | ||
| 291 | - { | ||
| 292 | - mView.Remove( mPageTurnPortraitView ); | ||
| 293 | - mView.Add( mPageTurnLandscapeView ); | ||
| 294 | - int currentPage = ceil( static_cast<float>(mPageTurnPortraitView.GetCurrentPage()) / PAGE_NUMBER_CORRESPONDING_RATIO ); | ||
| 295 | - mPageTurnLandscapeView.GoToPage( currentPage ); | ||
| 296 | - mIsPortrait = false; | ||
| 297 | - } | ||
| 298 | - break; | ||
| 299 | - } | ||
| 300 | - default: | ||
| 301 | - break; | 287 | + mPageTurnPortraitView.Unparent(); |
| 288 | + Stage::GetCurrent().Add( mPageTurnLandscapeView ); | ||
| 289 | + int pageId = mPageTurnPortraitView.GetProperty( PageTurnView::Property::CURRENT_PAGE_ID ).Get<int>(); | ||
| 290 | + int currentPage = ceil( static_cast<float>(pageId) / PAGE_NUMBER_CORRESPONDING_RATIO ); | ||
| 291 | + mPageTurnLandscapeView.SetProperty(PageTurnView::Property::CURRENT_PAGE_ID, currentPage ); | ||
| 292 | + } | ||
| 293 | + else | ||
| 294 | + { | ||
| 295 | + mPageTurnLandscapeView.Unparent(); | ||
| 296 | + Stage::GetCurrent().Add( mPageTurnPortraitView ); | ||
| 297 | + int pageId = mPageTurnLandscapeView.GetProperty( PageTurnView::Property::CURRENT_PAGE_ID ).Get<int>(); | ||
| 298 | + int currentPage = floor(pageId * PAGE_NUMBER_CORRESPONDING_RATIO ); | ||
| 299 | + mPageTurnPortraitView.SetProperty(PageTurnView::Property::CURRENT_PAGE_ID, currentPage ); | ||
| 302 | } | 300 | } |
| 301 | + | ||
| 302 | + mIsPortrait = !mIsPortrait; | ||
| 303 | + mButtonLayer.RaiseToTop(); | ||
| 304 | + return true; | ||
| 303 | } | 305 | } |
| 304 | 306 | ||
| 305 | /** | 307 | /** |
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.1.0 | 5 | +Version: 1.1.1 |
| 6 | Release: 1 | 6 | Release: 1 |
| 7 | Group: System/Libraries | 7 | Group: System/Libraries |
| 8 | License: Apache-2.0 | 8 | License: Apache-2.0 |