Commit 77bb81b94c59d605969796730a1e31bc36333b7f
Committed by
Gerrit Code Review
Merge "Update PageTurnView Demo" into devel/master
Showing
1 changed file
with
25 additions
and
17 deletions
examples/page-turn-view/page-turn-view-example.cpp
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 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/image-atlas/image-atlas.h> | ||
| 20 | 21 | ||
| 21 | #include <assert.h> | 22 | #include <assert.h> |
| 22 | #include <cstdlib> | 23 | #include <cstdlib> |
| @@ -78,21 +79,21 @@ class PortraitPageFactory : public PageFactory | @@ -78,21 +79,21 @@ class PortraitPageFactory : public PageFactory | ||
| 78 | return 10*NUMBER_OF_PORTRAIT_IMAGE + 1; | 79 | return 10*NUMBER_OF_PORTRAIT_IMAGE + 1; |
| 79 | } | 80 | } |
| 80 | /** | 81 | /** |
| 81 | - * Create an image actor to represent a page. | 82 | + * Create an image to represent a page. |
| 82 | * @param[in] pageId The ID of the page to create. | 83 | * @param[in] pageId The ID of the page to create. |
| 83 | - * @return An image actor, or an uninitialized pointer if the ID is out of range. | 84 | + * @return An image, or an uninitialized pointer if the ID is out of range. |
| 84 | */ | 85 | */ |
| 85 | - virtual Actor NewPage( unsigned int pageId ) | 86 | + virtual Image NewPage( unsigned int pageId ) |
| 86 | { | 87 | { |
| 87 | - ImageActor page; | 88 | + Image page; |
| 88 | 89 | ||
| 89 | if( pageId == 0 ) | 90 | if( pageId == 0 ) |
| 90 | { | 91 | { |
| 91 | - page = ImageActor::New( ResourceImage::New( BOOK_COVER_PORTRAIT ) ); | 92 | + page = ResourceImage::New( BOOK_COVER_PORTRAIT ); |
| 92 | } | 93 | } |
| 93 | else | 94 | else |
| 94 | { | 95 | { |
| 95 | - page = ImageActor::New( ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ) ); | 96 | + page = ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ); |
| 96 | } | 97 | } |
| 97 | 98 | ||
| 98 | return page; | 99 | return page; |
| @@ -101,6 +102,7 @@ class PortraitPageFactory : public PageFactory | @@ -101,6 +102,7 @@ class PortraitPageFactory : public PageFactory | ||
| 101 | 102 | ||
| 102 | class LandscapePageFactory : public PageFactory | 103 | class LandscapePageFactory : public PageFactory |
| 103 | { | 104 | { |
| 105 | + | ||
| 104 | /** | 106 | /** |
| 105 | * Query the number of pages available from the factory. | 107 | * Query the number of pages available from the factory. |
| 106 | * The maximum available page has an ID of GetNumberOfPages()-1. | 108 | * The maximum available page has an ID of GetNumberOfPages()-1. |
| @@ -110,29 +112,35 @@ class LandscapePageFactory : public PageFactory | @@ -110,29 +112,35 @@ class LandscapePageFactory : public PageFactory | ||
| 110 | return 10*NUMBER_OF_LANDSCAPE_IMAGE / 2 + 1; | 112 | return 10*NUMBER_OF_LANDSCAPE_IMAGE / 2 + 1; |
| 111 | } | 113 | } |
| 112 | /** | 114 | /** |
| 113 | - * Create an image actor to represent a page. | 115 | + * Create an image to represent a page. |
| 114 | * @param[in] pageId The ID of the page to create. | 116 | * @param[in] pageId The ID of the page to create. |
| 115 | - * @return An image actor, or an uninitialized pointer if the ID is out of range. | 117 | + * @return An image, or an uninitialized pointer if the ID is out of range. |
| 116 | */ | 118 | */ |
| 117 | - virtual Actor NewPage( unsigned int pageId ) | 119 | + virtual Image NewPage( unsigned int pageId ) |
| 118 | { | 120 | { |
| 119 | - ImageActor pageFront; | ||
| 120 | - ImageActor pageBack; | 121 | + if( mImageSize.GetWidth() == 0u || mImageSize.GetHeight() == 0u ) |
| 122 | + { | ||
| 123 | + mImageSize = ResourceImage::GetImageSize(BOOK_COVER_LANDSCAPE); | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + ImageAtlas atlas = ImageAtlas::New( mImageSize.GetWidth()*2u, mImageSize.GetHeight(), Pixel::RGB888 ); | ||
| 127 | + Vector4 textureRect; | ||
| 121 | if( pageId == 0 ) | 128 | if( pageId == 0 ) |
| 122 | { | 129 | { |
| 123 | - pageFront = ImageActor::New( ResourceImage::New( BOOK_COVER_LANDSCAPE ) ); | ||
| 124 | - pageBack = ImageActor::New( ResourceImage::New( BOOK_COVER_BACK_LANDSCAPE ) ); | 130 | + atlas.Upload( textureRect, BOOK_COVER_LANDSCAPE, mImageSize ); |
| 131 | + atlas.Upload( textureRect, BOOK_COVER_BACK_LANDSCAPE, mImageSize ); | ||
| 125 | } | 132 | } |
| 126 | else | 133 | else |
| 127 | { | 134 | { |
| 128 | unsigned int imageId = (pageId-1)*2; | 135 | unsigned int imageId = (pageId-1)*2; |
| 129 | - pageFront = ImageActor::New( ResourceImage::New( PAGE_IMAGES_LANDSCAPE[ imageId % NUMBER_OF_LANDSCAPE_IMAGE ] ) ); | ||
| 130 | - pageBack = ImageActor::New( ResourceImage::New( PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ] ) ); | 136 | + atlas.Upload( textureRect, PAGE_IMAGES_LANDSCAPE[ imageId % NUMBER_OF_LANDSCAPE_IMAGE ], mImageSize ); |
| 137 | + atlas.Upload( textureRect, PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ], mImageSize ); | ||
| 131 | } | 138 | } |
| 132 | - pageFront.Add(pageBack); | ||
| 133 | 139 | ||
| 134 | - return pageFront; | 140 | + return atlas.GetAtlas(); |
| 135 | } | 141 | } |
| 142 | + | ||
| 143 | + ImageDimensions mImageSize; | ||
| 136 | }; | 144 | }; |
| 137 | 145 | ||
| 138 | /** | 146 | /** |