Commit ff961cccdcbf1c30b0f53b0da027df855cde2b63
1 parent
cfc43aa4
Remove ResourceImage usage from demos
Change-Id: I48be2cb5c069cfa59e768291b1c128567d5835e0
Showing
28 changed files
with
293 additions
and
250 deletions
demo/dali-table-view.cpp
| ... | ... | @@ -485,7 +485,6 @@ Actor DaliTableView::CreateTile( const std::string& name, const std::string& tit |
| 485 | 485 | Toolkit::ImageView DaliTableView::NewStencilImage() |
| 486 | 486 | { |
| 487 | 487 | Toolkit::ImageView stencil = ImageView::New( TILE_BACKGROUND_ALPHA ); |
| 488 | - | |
| 489 | 488 | stencil.SetParentOrigin( ParentOrigin::CENTER ); |
| 490 | 489 | stencil.SetAnchorPoint( AnchorPoint::CENTER ); |
| 491 | 490 | stencil.SetDrawMode( DrawMode::STENCIL ); |
| ... | ... | @@ -717,6 +716,7 @@ void DaliTableView::AddBackgroundActors( Actor layer, int count, BufferImage dis |
| 717 | 716 | Dali::Property::Map effect = Toolkit::CreateDistanceFieldEffect(); |
| 718 | 717 | dfActor.SetProperty( Toolkit::ImageView::Property::IMAGE, effect ); |
| 719 | 718 | dfActor.SetColor( BUBBLE_COLOR[ i%NUMBER_OF_BUBBLE_COLOR ] ); |
| 719 | + | |
| 720 | 720 | layer.Add( dfActor ); |
| 721 | 721 | } |
| 722 | 722 | |
| ... | ... | @@ -790,8 +790,7 @@ void DaliTableView::GenerateCircle( const Size& size, std::vector< unsigned char |
| 790 | 790 | |
| 791 | 791 | ImageView DaliTableView::CreateLogo( std::string imagePath ) |
| 792 | 792 | { |
| 793 | - Image image = ResourceImage::New( imagePath ); | |
| 794 | - ImageView logo = ImageView::New( image ); | |
| 793 | + ImageView logo = ImageView::New( imagePath ); | |
| 795 | 794 | |
| 796 | 795 | logo.SetAnchorPoint( AnchorPoint::CENTER ); |
| 797 | 796 | logo.SetParentOrigin( ParentOrigin::CENTER ); | ... | ... |
examples/blocks/blocks-example.cpp
| ... | ... | @@ -362,6 +362,17 @@ private: |
| 362 | 362 | |
| 363 | 363 | mBrickCount = 0; |
| 364 | 364 | |
| 365 | + if( mBrickImageMap.Empty() ) | |
| 366 | + { | |
| 367 | + Vector2 stageSize(Stage::GetCurrent().GetSize()); | |
| 368 | + const Vector2 brickSize(BRICK_SIZE * Vector2(stageSize.x, stageSize.x)); | |
| 369 | + | |
| 370 | + mBrickImageMap["desiredWidth"] = static_cast<int>( brickSize.width ); | |
| 371 | + mBrickImageMap["desiredHeight"] = static_cast<int>( brickSize.height ); | |
| 372 | + mBrickImageMap["fittingMode"] = "SCALE_TO_FILL"; | |
| 373 | + mBrickImageMap["samplingMode"] = "BOX_THEN_LINEAR"; | |
| 374 | + } | |
| 375 | + | |
| 365 | 376 | switch(level%TOTAL_LEVELS) |
| 366 | 377 | { |
| 367 | 378 | case 0: |
| ... | ... | @@ -519,14 +530,11 @@ private: |
| 519 | 530 | */ |
| 520 | 531 | Actor CreateBrick( const Vector2& position, int type ) |
| 521 | 532 | { |
| 522 | - Vector2 stageSize(Stage::GetCurrent().GetSize()); | |
| 523 | - const Vector2 brickSize(BRICK_SIZE * Vector2(stageSize.x, stageSize.x)); | |
| 524 | - | |
| 525 | - Image img = ResourceImage::New( BRICK_IMAGE_PATH[type], Dali::ImageDimensions( 128, 64 ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 526 | - ImageView brick = ImageView::New(img); | |
| 533 | + mBrickImageMap["url"] = BRICK_IMAGE_PATH[type]; | |
| 534 | + ImageView brick = ImageView::New(); | |
| 535 | + brick.SetProperty( ImageView::Property::IMAGE, mBrickImageMap ); | |
| 527 | 536 | brick.SetParentOrigin(ParentOrigin::TOP_LEFT); |
| 528 | 537 | brick.SetAnchorPoint(AnchorPoint::CENTER); |
| 529 | - brick.SetSize( brickSize ); | |
| 530 | 538 | brick.SetPosition( Vector3( position ) ); |
| 531 | 539 | |
| 532 | 540 | // Add a constraint on the brick between it and the ball generating a collision-property |
| ... | ... | @@ -815,6 +823,7 @@ private: |
| 815 | 823 | Animation mWobbleAnimation; ///< Paddle's animation when hit (wobbles) |
| 816 | 824 | Property::Index mWobbleProperty; ///< The wobble property (generated from animation) |
| 817 | 825 | Actor mLevelContainer; ///< The level container (contains bricks) |
| 826 | + Property::Map mBrickImageMap; ///< The property map used to load the brick | |
| 818 | 827 | |
| 819 | 828 | // actor - dragging functionality |
| 820 | 829 | ... | ... |
examples/bubble-effect/bubble-effect-example.cpp
| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | 20 | #include <dali-toolkit/devel-api/controls/bubble-effect/bubble-emitter.h> |
| 21 | 21 | #include "shared/view.h" |
| 22 | +#include "shared/utility.h" | |
| 22 | 23 | |
| 23 | 24 | using namespace Dali; |
| 24 | 25 | |
| ... | ... | @@ -53,20 +54,6 @@ const unsigned int NUM_BUBBLE_SHAPE_IMAGES( sizeof( BUBBLE_SHAPE_IMAGES ) / size |
| 53 | 54 | const Vector2 DEFAULT_BUBBLE_SIZE( 10.f, 30.f ); |
| 54 | 55 | const unsigned int DEFAULT_NUMBER_OF_BUBBLES( 1000 ); |
| 55 | 56 | |
| 56 | -/** | |
| 57 | - * @brief Load an image, scaled-down to no more than the stage dimensions. | |
| 58 | - * | |
| 59 | - * Uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at | |
| 60 | - * load time to cover the entire stage with pixels with no borders, | |
| 61 | - * and filter mode BOX_THEN_LINEAR to sample the image with | |
| 62 | - * maximum quality. | |
| 63 | - */ | |
| 64 | -ResourceImage LoadStageFillingImage( const char * const imagePath ) | |
| 65 | -{ | |
| 66 | - Size stageSize = Stage::GetCurrent().GetSize(); | |
| 67 | - return ResourceImage::New( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 68 | -} | |
| 69 | - | |
| 70 | 57 | }// end LOCAL_STUFF |
| 71 | 58 | |
| 72 | 59 | // This example shows the usage of BubbleEmitter which displays lots of moving bubbles on the stage. |
| ... | ... | @@ -130,10 +117,10 @@ private: |
| 130 | 117 | |
| 131 | 118 | // Create and initialize the BubbleEmitter object |
| 132 | 119 | mBubbleEmitter = Toolkit::BubbleEmitter::New( stageSize, |
| 133 | - ResourceImage::New( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ), | |
| 120 | + DemoHelper::LoadImage( BUBBLE_SHAPE_IMAGES[mCurrentBubbleShapeImageId] ), | |
| 134 | 121 | DEFAULT_NUMBER_OF_BUBBLES, |
| 135 | 122 | DEFAULT_BUBBLE_SIZE); |
| 136 | - mBackgroundImage = LoadStageFillingImage( BACKGROUND_IMAGES[mCurrentBackgroundImageId] ); | |
| 123 | + mBackgroundImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mCurrentBackgroundImageId] ); | |
| 137 | 124 | mBubbleEmitter.SetBackground( mBackgroundImage, mHSVDelta ); |
| 138 | 125 | |
| 139 | 126 | // Get the root actor of all bubbles, and add it to stage. |
| ... | ... | @@ -253,7 +240,7 @@ private: |
| 253 | 240 | { |
| 254 | 241 | if(button == mChangeBackgroundButton) |
| 255 | 242 | { |
| 256 | - mBackgroundImage = LoadStageFillingImage( BACKGROUND_IMAGES[ ++mCurrentBackgroundImageId % NUM_BACKGROUND_IMAGES ] ); | |
| 243 | + mBackgroundImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[ ++mCurrentBackgroundImageId % NUM_BACKGROUND_IMAGES ] ); | |
| 257 | 244 | |
| 258 | 245 | mBubbleEmitter.SetBackground( mBackgroundImage, mHSVDelta ); |
| 259 | 246 | |
| ... | ... | @@ -261,7 +248,7 @@ private: |
| 261 | 248 | } |
| 262 | 249 | else if( button == mChangeBubbleShapeButton ) |
| 263 | 250 | { |
| 264 | - mBubbleEmitter.SetShapeImage( ResourceImage::New( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) ); | |
| 251 | + mBubbleEmitter.SetShapeImage( DemoHelper::LoadImage( BUBBLE_SHAPE_IMAGES[ ++mCurrentBubbleShapeImageId % NUM_BUBBLE_SHAPE_IMAGES ] ) ); | |
| 265 | 252 | } |
| 266 | 253 | return true; |
| 267 | 254 | } | ... | ... |
examples/buttons/buttons-example.cpp
| ... | ... | @@ -157,7 +157,7 @@ class ButtonsController: public ConnectionTracker |
| 157 | 157 | |
| 158 | 158 | // Radio 1 |
| 159 | 159 | { |
| 160 | - Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_1 ) ); | |
| 160 | + Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_1 ); | |
| 161 | 161 | image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); |
| 162 | 162 | |
| 163 | 163 | mRadioButtonImage1 = Dali::Toolkit::RadioButton::New( "1" ); |
| ... | ... | @@ -174,7 +174,7 @@ class ButtonsController: public ConnectionTracker |
| 174 | 174 | { |
| 175 | 175 | radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING; |
| 176 | 176 | |
| 177 | - Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_2 ) ); | |
| 177 | + Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_2 ); | |
| 178 | 178 | image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); |
| 179 | 179 | |
| 180 | 180 | mRadioButtonImage2 = Dali::Toolkit::RadioButton::New( "2" ); |
| ... | ... | @@ -190,7 +190,7 @@ class ButtonsController: public ConnectionTracker |
| 190 | 190 | { |
| 191 | 191 | radioY += RADIO_LABEL_THUMBNAIL_SIZE + RADIO_IMAGE_SPACING; |
| 192 | 192 | |
| 193 | - Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( SMALL_IMAGE_3 ) ); | |
| 193 | + Toolkit::ImageView image = Toolkit::ImageView::New( SMALL_IMAGE_3 ); | |
| 194 | 194 | image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); |
| 195 | 195 | |
| 196 | 196 | mRadioButtonImage3 = Dali::Toolkit::RadioButton::New( "3" ); |
| ... | ... | @@ -213,11 +213,7 @@ class ButtonsController: public ConnectionTracker |
| 213 | 213 | radioGroup2Background.AddChild( mUpdateButton, Toolkit::TableView::CellPosition( 1, 0 ) ); |
| 214 | 214 | |
| 215 | 215 | // ImageView to display selected image |
| 216 | - mBigImage1 = ResourceImage::New( BIG_IMAGE_1 ); | |
| 217 | - mBigImage2 = ResourceImage::New( BIG_IMAGE_2 ); | |
| 218 | - mBigImage3 = ResourceImage::New( BIG_IMAGE_3 ); | |
| 219 | - | |
| 220 | - mImage = Toolkit::ImageView::New( mBigImage1 ); | |
| 216 | + mImage = Toolkit::ImageView::New( BIG_IMAGE_1 ); | |
| 221 | 217 | mImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 222 | 218 | mImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); |
| 223 | 219 | radioGroup2Background.AddChild( mImage, Toolkit::TableView::CellPosition( 0, 1, 2, 1 ) ); |
| ... | ... | @@ -257,7 +253,7 @@ class ButtonsController: public ConnectionTracker |
| 257 | 253 | textLabel.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::HEIGHT ); |
| 258 | 254 | textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "CENTER" ); |
| 259 | 255 | |
| 260 | - Toolkit::ImageView image = Toolkit::ImageView::New( ResourceImage::New( ENABLED_IMAGE ) ); | |
| 256 | + Toolkit::ImageView image = Toolkit::ImageView::New( ENABLED_IMAGE ); | |
| 261 | 257 | image.SetSize( DP(RADIO_LABEL_THUMBNAIL_SIZE), DP(RADIO_LABEL_THUMBNAIL_SIZE) ); |
| 262 | 258 | image.SetPadding( Padding( DP(20.0f), 0.0f, 0.0f, 0.0f ) ); |
| 263 | 259 | tableView.AddChild( image, Toolkit::TableView::CellPosition( 0, 1 ) ); |
| ... | ... | @@ -425,15 +421,15 @@ class ButtonsController: public ConnectionTracker |
| 425 | 421 | { |
| 426 | 422 | if( mRadioButtonImage1.IsSelected() ) |
| 427 | 423 | { |
| 428 | - mImage.SetImage( mBigImage1 ); | |
| 424 | + mImage.SetImage( BIG_IMAGE_1 ); | |
| 429 | 425 | } |
| 430 | 426 | else if( mRadioButtonImage2.IsSelected() ) |
| 431 | 427 | { |
| 432 | - mImage.SetImage( mBigImage2 ); | |
| 428 | + mImage.SetImage( BIG_IMAGE_2 ); | |
| 433 | 429 | } |
| 434 | 430 | else if( mRadioButtonImage3.IsSelected() ) |
| 435 | 431 | { |
| 436 | - mImage.SetImage( mBigImage3 ); | |
| 432 | + mImage.SetImage( BIG_IMAGE_3 ); | |
| 437 | 433 | } |
| 438 | 434 | return true; |
| 439 | 435 | } |
| ... | ... | @@ -500,9 +496,6 @@ private: |
| 500 | 496 | Animation mAnimation; |
| 501 | 497 | float mLastPoint; |
| 502 | 498 | |
| 503 | - Image mBigImage1; | |
| 504 | - Image mBigImage2; | |
| 505 | - Image mBigImage3; | |
| 506 | 499 | Toolkit::ImageView mImage; |
| 507 | 500 | }; |
| 508 | 501 | ... | ... |
examples/cube-transition-effect/cube-transition-effect-example.cpp
| ... | ... | @@ -20,6 +20,7 @@ |
| 20 | 20 | |
| 21 | 21 | // INTERNAL INCLUDES |
| 22 | 22 | #include "shared/view.h" |
| 23 | +#include "shared/utility.h" | |
| 23 | 24 | |
| 24 | 25 | #include <dali/dali.h> |
| 25 | 26 | #include <dali-toolkit/dali-toolkit.h> |
| ... | ... | @@ -98,20 +99,6 @@ const float CUBE_DISPLACEMENT_CROSS(30.f); |
| 98 | 99 | // The duration of the current image staying on screen when slideshow is on |
| 99 | 100 | const int VIEWINGTIME = 2000; // 2 seconds |
| 100 | 101 | |
| 101 | -/** | |
| 102 | - * @brief Load an image, scaled-down to no more than the stage dimensions. | |
| 103 | - * | |
| 104 | - * Uses image scaling mode SCALE_TO_FILL to resize the image at | |
| 105 | - * load time to cover the entire stage with pixels with no borders, | |
| 106 | - * and filter mode BOX_THEN_LINEAR to sample the image with | |
| 107 | - * maximum quality. | |
| 108 | - */ | |
| 109 | -ResourceImage LoadStageFillingImage( const char * const imagePath ) | |
| 110 | -{ | |
| 111 | - Size stageSize = Stage::GetCurrent().GetSize(); | |
| 112 | - return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 113 | -} | |
| 114 | - | |
| 115 | 102 | } // namespace |
| 116 | 103 | |
| 117 | 104 | class CubeTransitionApp : public ConnectionTracker |
| ... | ... | @@ -143,12 +130,6 @@ private: |
| 143 | 130 | */ |
| 144 | 131 | void GoToNextImage(); |
| 145 | 132 | /** |
| 146 | - * Callback function of image resource loading succeed | |
| 147 | - * Start the transition | |
| 148 | - * @param[in] image The image content of the imageActor for transition | |
| 149 | - */ | |
| 150 | - void OnImageLoaded(ResourceImage image); | |
| 151 | - /** | |
| 152 | 133 | * Main key event handler |
| 153 | 134 | */ |
| 154 | 135 | void OnKeyEvent(const KeyEvent& event); |
| ... | ... | @@ -185,8 +166,8 @@ private: |
| 185 | 166 | |
| 186 | 167 | Vector2 mViewSize; |
| 187 | 168 | |
| 188 | - ResourceImage mCurrentImage; | |
| 189 | - ResourceImage mNextImage; | |
| 169 | + Image mCurrentImage; | |
| 170 | + Image mNextImage; | |
| 190 | 171 | unsigned int mIndex; |
| 191 | 172 | bool mIsImageLoading; |
| 192 | 173 | |
| ... | ... | @@ -251,7 +232,7 @@ void CubeTransitionApp::OnInit( Application& application ) |
| 251 | 232 | mViewSize = Stage::GetCurrent().GetSize(); |
| 252 | 233 | |
| 253 | 234 | // show the first image |
| 254 | - mCurrentImage = LoadStageFillingImage( IMAGES[mIndex] ); | |
| 235 | + mCurrentImage = DemoHelper::LoadStageFillingImage( IMAGES[mIndex] ); | |
| 255 | 236 | |
| 256 | 237 | //use small cubes |
| 257 | 238 | mCubeWaveEffect = Toolkit::CubeTransitionWaveEffect::New( NUM_ROWS_WAVE, NUM_COLUMNS_WAVE ); |
| ... | ... | @@ -322,25 +303,11 @@ void CubeTransitionApp::OnPanGesture( Actor actor, const PanGesture& gesture ) |
| 322 | 303 | |
| 323 | 304 | void CubeTransitionApp::GoToNextImage() |
| 324 | 305 | { |
| 325 | - mNextImage = LoadStageFillingImage( IMAGES[ mIndex ] ); | |
| 306 | + mNextImage = DemoHelper::LoadStageFillingImage( IMAGES[ mIndex ] ); | |
| 326 | 307 | mCurrentEffect.SetTargetImage( mNextImage ); |
| 327 | - if( mNextImage.GetLoadingState() == ResourceLoadingSucceeded ) | |
| 328 | - { | |
| 329 | - mIsImageLoading = false; | |
| 330 | - OnImageLoaded( mNextImage ); | |
| 331 | - } | |
| 332 | - else | |
| 333 | - { | |
| 334 | - mIsImageLoading = true; | |
| 335 | - mNextImage.LoadingFinishedSignal().Connect( this, &CubeTransitionApp::OnImageLoaded ); | |
| 336 | - } | |
| 337 | -} | |
| 338 | - | |
| 339 | -void CubeTransitionApp::OnImageLoaded(ResourceImage image) | |
| 340 | -{ | |
| 341 | - mIsImageLoading = false; | |
| 342 | - mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement ); | |
| 343 | - mCurrentImage = mNextImage; | |
| 308 | + mIsImageLoading = false; | |
| 309 | + mCurrentEffect.StartTransition( mPanPosition, mPanDisplacement ); | |
| 310 | + mCurrentImage = mNextImage; | |
| 344 | 311 | } |
| 345 | 312 | |
| 346 | 313 | bool CubeTransitionApp::OnEffectButtonClicked( Toolkit::Button button ) | ... | ... |
examples/dissolve-effect/dissolve-effect-example.cpp
| ... | ... | @@ -80,17 +80,27 @@ const float TRANSITION_DURATION = 2.5f; //2.5 second |
| 80 | 80 | const float INITIAL_DEPTH = 10.0f; |
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * @brief Load an image, scaled-down to no more than the stage dimensions. | |
| 83 | + * @brief Create an image view with an image which would be scaled-down to no more than the stage dimensions. | |
| 84 | 84 | * |
| 85 | 85 | * Uses image scaling mode SCALE_TO_FILL to resize the image at |
| 86 | 86 | * load time to cover the entire stage with pixels with no borders, |
| 87 | - * and filter mode BOX_THEN_LINEAR to sample the image with | |
| 88 | - * maximum quality. | |
| 87 | + * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality. | |
| 89 | 88 | */ |
| 90 | -ResourceImage LoadStageFillingImage( const char * const imagePath ) | |
| 89 | +Toolkit::ImageView CreateStageFillingImageView( const char * const imagePath ) | |
| 91 | 90 | { |
| 92 | 91 | Size stageSize = Stage::GetCurrent().GetSize(); |
| 93 | - return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 92 | + Toolkit::ImageView imageView = Toolkit::ImageView::New(); | |
| 93 | + Property::Map map; | |
| 94 | + map["rendererType"] = "image"; | |
| 95 | + map["url"] = imagePath; | |
| 96 | + map["desiredWidth"] = stageSize.x; | |
| 97 | + map["desiredHeight"] = stageSize.y; | |
| 98 | + map["fittingMode"] = "SCALE_TO_FILL"; | |
| 99 | + map["samplingMode"] = "BOX_THEN_LINEAR"; | |
| 100 | + map["synchronousLoading"] = true; | |
| 101 | + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map ); | |
| 102 | + | |
| 103 | + return imageView; | |
| 94 | 104 | } |
| 95 | 105 | |
| 96 | 106 | } // namespace |
| ... | ... | @@ -181,16 +191,7 @@ private: |
| 181 | 191 | bool mTimerReady; |
| 182 | 192 | unsigned int mCentralLineIndex; |
| 183 | 193 | |
| 184 | - Image mIconPlay; | |
| 185 | - Image mIconPlaySelected; | |
| 186 | - Image mIconStop; | |
| 187 | - Image mIconStopSelected; | |
| 188 | 194 | Toolkit::PushButton mPlayStopButton; |
| 189 | - | |
| 190 | - Image mIconHighP; | |
| 191 | - Image mIconHighPSelected; | |
| 192 | - Image mIconMediumP; | |
| 193 | - Image mIconMediumPSelected; | |
| 194 | 195 | Toolkit::PushButton mEffectChangeButton; |
| 195 | 196 | }; |
| 196 | 197 | |
| ... | ... | @@ -219,13 +220,9 @@ void DissolveEffectApp::OnInit( Application& application ) |
| 219 | 220 | mContent = DemoHelper::CreateView( application, mView,mToolBar, "", TOOLBAR_IMAGE, "" ); |
| 220 | 221 | |
| 221 | 222 | // Add an effect-changing button on the right of the tool bar. |
| 222 | - mIconHighP = ResourceImage::New( EFFECT_HIGHP_IMAGE ); | |
| 223 | - mIconHighPSelected = ResourceImage::New( EFFECT_HIGHP_IMAGE_SELECTED ); | |
| 224 | - mIconMediumP = ResourceImage::New( EFFECT_MEDIUMP_IMAGE ); | |
| 225 | - mIconMediumPSelected = ResourceImage::New( EFFECT_MEDIUMP_IMAGE_SELECTED ); | |
| 226 | 223 | mEffectChangeButton = Toolkit::PushButton::New(); |
| 227 | - mEffectChangeButton.SetButtonImage( mIconHighP ); | |
| 228 | - mEffectChangeButton.SetSelectedImage( mIconHighPSelected ); | |
| 224 | + mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE ); | |
| 225 | + mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE_SELECTED ); | |
| 229 | 226 | mEffectChangeButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnEffectButtonClicked ); |
| 230 | 227 | mToolBar.AddControl( mEffectChangeButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalRight, DemoHelper::DEFAULT_MODE_SWITCH_PADDING ); |
| 231 | 228 | |
| ... | ... | @@ -234,13 +231,9 @@ void DissolveEffectApp::OnInit( Application& application ) |
| 234 | 231 | mToolBar.AddControl( mTitleActor, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarTitlePercentage, Toolkit::Alignment::HorizontalCenter ); |
| 235 | 232 | |
| 236 | 233 | // Add an slide-show button on the right of the title |
| 237 | - mIconPlay = ResourceImage::New( PLAY_ICON ); | |
| 238 | - mIconPlaySelected = ResourceImage::New( PLAY_ICON_SELECTED ); | |
| 239 | - mIconStop = ResourceImage::New( STOP_ICON ); | |
| 240 | - mIconStopSelected = ResourceImage::New( STOP_ICON_SELECTED ); | |
| 241 | 234 | mPlayStopButton = Toolkit::PushButton::New(); |
| 242 | - mPlayStopButton.SetButtonImage( mIconPlay ); | |
| 243 | - mPlayStopButton.SetSelectedImage( mIconPlaySelected ); | |
| 235 | + mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, PLAY_ICON ); | |
| 236 | + mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, PLAY_ICON_SELECTED ); | |
| 244 | 237 | mPlayStopButton.ClickedSignal().Connect( this, &DissolveEffectApp::OnSildeshowButtonClicked ); |
| 245 | 238 | mToolBar.AddControl( mPlayStopButton, DemoHelper::DEFAULT_VIEW_STYLE.mToolBarButtonPercentage, Toolkit::Alignment::HorizontalCenter, DemoHelper::DEFAULT_PLAY_PADDING ); |
| 246 | 239 | |
| ... | ... | @@ -259,7 +252,7 @@ void DissolveEffectApp::OnInit( Application& application ) |
| 259 | 252 | mContent.Add( mParent ); |
| 260 | 253 | |
| 261 | 254 | // show the first image |
| 262 | - mCurrentImage = Toolkit::ImageView::New( LoadStageFillingImage( IMAGES[mIndex] ) ); | |
| 255 | + mCurrentImage = CreateStageFillingImageView( IMAGES[mIndex] ); | |
| 263 | 256 | mCurrentImage.SetParentOrigin( ParentOrigin::CENTER ); |
| 264 | 257 | mCurrentImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 265 | 258 | mCurrentImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); |
| ... | ... | @@ -268,7 +261,8 @@ void DissolveEffectApp::OnInit( Application& application ) |
| 268 | 261 | mPanGestureDetector.Attach( mCurrentImage ); |
| 269 | 262 | |
| 270 | 263 | mDissolveEffect = Dali::Toolkit::CreateDissolveEffect( mUseHighPrecision ); |
| 271 | - mEmptyEffect.Insert( "shader", Property::Value() ); | |
| 264 | + Property::Map emptyShaderMap; | |
| 265 | + mEmptyEffect.Insert( "shader", emptyShaderMap ); | |
| 272 | 266 | } |
| 273 | 267 | |
| 274 | 268 | // signal handler, called when the pan gesture is detected |
| ... | ... | @@ -291,8 +285,7 @@ void DissolveEffectApp::OnPanGesture( Actor actor, const PanGesture& gesture ) |
| 291 | 285 | mIndex = (mIndex + NUM_IMAGES -1)%NUM_IMAGES; |
| 292 | 286 | } |
| 293 | 287 | |
| 294 | - Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); | |
| 295 | - mNextImage = Toolkit::ImageView::New( image ); | |
| 288 | + mNextImage = CreateStageFillingImageView( IMAGES[ mIndex ] ); | |
| 296 | 289 | mNextImage.SetParentOrigin( ParentOrigin::CENTER ); |
| 297 | 290 | mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 298 | 291 | mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); |
| ... | ... | @@ -348,14 +341,14 @@ bool DissolveEffectApp::OnEffectButtonClicked( Toolkit::Button button ) |
| 348 | 341 | if(mUseHighPrecision) |
| 349 | 342 | { |
| 350 | 343 | mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_HIGHP) ); |
| 351 | - mEffectChangeButton.SetButtonImage( mIconHighP ); | |
| 352 | - mEffectChangeButton.SetSelectedImage( mIconHighPSelected ); | |
| 344 | + mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE ); | |
| 345 | + mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_HIGHP_IMAGE_SELECTED ); | |
| 353 | 346 | } |
| 354 | 347 | else |
| 355 | 348 | { |
| 356 | 349 | mTitleActor.SetProperty( TextLabel::Property::TEXT, std::string(APPLICATION_TITLE_MEDIUMP) ); |
| 357 | - mEffectChangeButton.SetButtonImage( mIconMediumP ); | |
| 358 | - mEffectChangeButton.SetSelectedImage( mIconMediumPSelected ); | |
| 350 | + mEffectChangeButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, EFFECT_MEDIUMP_IMAGE ); | |
| 351 | + mEffectChangeButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, EFFECT_MEDIUMP_IMAGE_SELECTED ); | |
| 359 | 352 | } |
| 360 | 353 | |
| 361 | 354 | return true; |
| ... | ... | @@ -366,16 +359,16 @@ bool DissolveEffectApp::OnSildeshowButtonClicked( Toolkit::Button button ) |
| 366 | 359 | mSlideshow = !mSlideshow; |
| 367 | 360 | if( mSlideshow ) |
| 368 | 361 | { |
| 369 | - mPlayStopButton.SetButtonImage( mIconStop ); | |
| 370 | - mPlayStopButton.SetSelectedImage( mIconStopSelected ); | |
| 362 | + mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, STOP_ICON ); | |
| 363 | + mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, STOP_ICON_SELECTED ); | |
| 371 | 364 | mPanGestureDetector.Detach( mParent ); |
| 372 | 365 | mViewTimer.Start(); |
| 373 | 366 | mTimerReady = false; |
| 374 | 367 | } |
| 375 | 368 | else |
| 376 | 369 | { |
| 377 | - mPlayStopButton.SetButtonImage( mIconPlay ); | |
| 378 | - mPlayStopButton.SetSelectedImage( mIconPlaySelected ); | |
| 370 | + mPlayStopButton.SetProperty( Toolkit::Button::Property::UNSELECTED_STATE_IMAGE, PLAY_ICON ); | |
| 371 | + mPlayStopButton.SetProperty( Toolkit::Button::Property::SELECTED_STATE_IMAGE, PLAY_ICON_SELECTED ); | |
| 379 | 372 | mTimerReady = true; |
| 380 | 373 | mPanGestureDetector.Attach( mParent ); |
| 381 | 374 | } |
| ... | ... | @@ -384,7 +377,10 @@ bool DissolveEffectApp::OnSildeshowButtonClicked( Toolkit::Button button ) |
| 384 | 377 | |
| 385 | 378 | void DissolveEffectApp::OnTransitionCompleted( Animation& source ) |
| 386 | 379 | { |
| 387 | - mNextImage.SetProperty( Toolkit::ImageView::Property::IMAGE, mEmptyEffect ); | |
| 380 | + if(mUseHighPrecision) | |
| 381 | + { | |
| 382 | + mNextImage.SetProperty( Toolkit::ImageView::Property::IMAGE, mEmptyEffect ); | |
| 383 | + } | |
| 388 | 384 | mParent.Remove( mCurrentImage ); |
| 389 | 385 | mPanGestureDetector.Detach( mCurrentImage ); |
| 390 | 386 | mCurrentImage = mNextImage; |
| ... | ... | @@ -404,8 +400,7 @@ bool DissolveEffectApp::OnTimerTick() |
| 404 | 400 | if(mSlideshow) |
| 405 | 401 | { |
| 406 | 402 | mIndex = (mIndex + 1)%NUM_IMAGES; |
| 407 | - Image image = LoadStageFillingImage( IMAGES[ mIndex ] ); | |
| 408 | - mNextImage = Toolkit::ImageView::New( image ); | |
| 403 | + mNextImage = CreateStageFillingImageView( IMAGES[ mIndex ] ); | |
| 409 | 404 | mNextImage.SetParentOrigin( ParentOrigin::CENTER ); |
| 410 | 405 | mNextImage.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); |
| 411 | 406 | mNextImage.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); | ... | ... |
examples/image-scaling-and-filtering/image-scaling-and-filtering-example.cpp
| ... | ... | @@ -284,8 +284,7 @@ public: |
| 284 | 284 | |
| 285 | 285 | // Back and next image buttons in corners of stage: |
| 286 | 286 | unsigned int playWidth = std::min( stage.GetSize().x * (1 / 5.0f), 58.0f ); |
| 287 | - Image playImage = ResourceImage::New( DALI_ICON_PLAY, ImageDimensions( playWidth, playWidth ), FittingMode::SHRINK_TO_FIT, SamplingMode::BOX_THEN_LINEAR ); | |
| 288 | - Toolkit::ImageView imagePrevious = Toolkit::ImageView::New( playImage ); | |
| 287 | + Toolkit::ImageView imagePrevious = Toolkit::ImageView::New( DALI_ICON_PLAY, ImageDimensions( playWidth, playWidth ) ); | |
| 289 | 288 | |
| 290 | 289 | // Last image button: |
| 291 | 290 | imagePrevious.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| ... | ... | @@ -298,7 +297,7 @@ public: |
| 298 | 297 | imagePrevious.TouchSignal().Connect( this, &ImageScalingAndFilteringController::OnControlTouched ); |
| 299 | 298 | |
| 300 | 299 | // Next image button: |
| 301 | - Toolkit::ImageView imageNext = Toolkit::ImageView::New( playImage ); | |
| 300 | + Toolkit::ImageView imageNext = Toolkit::ImageView::New( DALI_ICON_PLAY, ImageDimensions( playWidth, playWidth ) ); | |
| 302 | 301 | imageNext.SetAnchorPoint( AnchorPoint::TOP_RIGHT ); |
| 303 | 302 | imageNext.SetY( playWidth * 0.5f ); |
| 304 | 303 | imageNext.SetX( stage.GetSize().x - playWidth * 0.5f ); | ... | ... |
examples/image-view-alpha-blending/image-view-alpha-blending-example.cpp
| ... | ... | @@ -19,6 +19,11 @@ |
| 19 | 19 | |
| 20 | 20 | using namespace Dali; |
| 21 | 21 | |
| 22 | +namespace | |
| 23 | +{ | |
| 24 | +const char* const IMAGE_PATH ( DEMO_IMAGE_DIR "gallery-large-20.jpg" ); | |
| 25 | +} | |
| 26 | + | |
| 22 | 27 | class ImageViewAlphaBlendApp : public ConnectionTracker |
| 23 | 28 | { |
| 24 | 29 | public: |
| ... | ... | @@ -47,10 +52,9 @@ private: |
| 47 | 52 | Vector4 green1 = Vector4( 0.f, 0.25f, 0.f, 0.25f ); |
| 48 | 53 | BufferImage redGreen0 = CreateBufferImage( Color::RED, green0 ); |
| 49 | 54 | BufferImage redGreen1 = CreateBufferImage( Color::RED, green1 ); |
| 50 | - ResourceImage testImage = ResourceImage::New( DEMO_IMAGE_DIR "gallery-large-20.jpg" ); | |
| 51 | 55 | float imageSize = 512.f; |
| 52 | 56 | |
| 53 | - Toolkit::ImageView imageView0 = Toolkit::ImageView::New( testImage ); | |
| 57 | + Toolkit::ImageView imageView0 = Toolkit::ImageView::New( IMAGE_PATH ); | |
| 54 | 58 | imageView0.SetSize(imageSize, imageSize); |
| 55 | 59 | imageView0.SetParentOrigin( ParentOrigin::CENTER ); |
| 56 | 60 | imageView0.SetY( -imageSize*0.5f ); |
| ... | ... | @@ -60,7 +64,7 @@ private: |
| 60 | 64 | imageView1.SetSize(imageSize, imageSize); |
| 61 | 65 | imageView0.Add(imageView1); |
| 62 | 66 | |
| 63 | - Toolkit::ImageView imageView2 = Toolkit::ImageView::New( testImage); | |
| 67 | + Toolkit::ImageView imageView2 = Toolkit::ImageView::New( IMAGE_PATH ); | |
| 64 | 68 | imageView2.SetSize(imageSize, imageSize); |
| 65 | 69 | imageView2.SetParentOrigin( ParentOrigin::CENTER ); |
| 66 | 70 | imageView2.SetY( imageSize*0.5f ); | ... | ... |
examples/mesh-sorting/mesh-sorting-example.cpp
| ... | ... | @@ -24,6 +24,7 @@ |
| 24 | 24 | |
| 25 | 25 | // INTERNAL INCLUDES |
| 26 | 26 | #include "shared/view.h" |
| 27 | +#include "shared/utility.h" | |
| 27 | 28 | |
| 28 | 29 | using namespace Dali; |
| 29 | 30 | |
| ... | ... | @@ -164,9 +165,9 @@ public: |
| 164 | 165 | |
| 165 | 166 | for( unsigned i=0; i<NUMBER_OF_SAMPLES; ++i) |
| 166 | 167 | { |
| 167 | - Image image = ResourceImage::New( IMAGES[i] ); | |
| 168 | + Texture texture = DemoHelper::LoadTexture( IMAGES[i] ); | |
| 168 | 169 | TextureSet textureSet = TextureSet::New(); |
| 169 | - textureSet.SetImage( 0u, image ); | |
| 170 | + textureSet.SetTexture( 0u, texture ); | |
| 170 | 171 | if( i==0 ) { firstTextureSet = textureSet; } |
| 171 | 172 | |
| 172 | 173 | Renderer renderer = Renderer::New( mGeometry, mShader ); | ... | ... |
examples/metaball-explosion/metaball-explosion-example.cpp
| ... | ... | @@ -25,6 +25,7 @@ |
| 25 | 25 | #include <dali-toolkit/dali-toolkit.h> |
| 26 | 26 | |
| 27 | 27 | #include "shared/view.h" |
| 28 | +#include "shared/utility.h" | |
| 28 | 29 | |
| 29 | 30 | using namespace Dali; |
| 30 | 31 | using namespace Dali::Toolkit; |
| ... | ... | @@ -328,7 +329,7 @@ void MetaballExplosionController::Create( Application& app ) |
| 328 | 329 | stage.SetBackgroundColor(Color::BLACK); |
| 329 | 330 | |
| 330 | 331 | //Set background image for the view |
| 331 | - mBackImage = ResourceImage::New( BACKGROUND_IMAGE ); | |
| 332 | + mBackImage = DemoHelper::LoadImage( BACKGROUND_IMAGE ); | |
| 332 | 333 | |
| 333 | 334 | srand((unsigned)time(0)); |
| 334 | 335 | ... | ... |
examples/metaball-refrac/metaball-refrac-example.cpp
| ... | ... | @@ -21,6 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | #include <cstdio> |
| 23 | 23 | #include <string> |
| 24 | +#include "shared/utility.h" | |
| 24 | 25 | |
| 25 | 26 | using namespace Dali; |
| 26 | 27 | using namespace Dali::Toolkit; |
| ... | ... | @@ -270,7 +271,7 @@ void MetaballRefracController::Create( Application& app ) |
| 270 | 271 | stage.SetBackgroundColor(Color::BLACK); |
| 271 | 272 | |
| 272 | 273 | //Set background image for the view |
| 273 | - mBackImage = ResourceImage::New( BACKGROUND_IMAGE ); | |
| 274 | + mBackImage = DemoHelper::LoadImage( BACKGROUND_IMAGE ); | |
| 274 | 275 | |
| 275 | 276 | mGravity = Vector2(GRAVITY_X,GRAVITY_Y); |
| 276 | 277 | mGravityVar = Vector2(0,0); | ... | ... |
examples/model3d-view/model3d-view-example.cpp
| ... | ... | @@ -76,8 +76,7 @@ public: |
| 76 | 76 | Vector2 screenSize = stage.GetSize(); |
| 77 | 77 | |
| 78 | 78 | //Add background |
| 79 | - Image imageBackground = ResourceImage::New( BACKGROUND_IMAGE ); | |
| 80 | - Toolkit::ImageView backView = Toolkit::ImageView::New(imageBackground); | |
| 79 | + Toolkit::ImageView backView = Toolkit::ImageView::New(BACKGROUND_IMAGE); | |
| 81 | 80 | backView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 82 | 81 | stage.Add(backView); |
| 83 | 82 | ... | ... |
examples/motion-blur/motion-blur-example.cpp
| ... | ... | @@ -95,16 +95,24 @@ const float BUTTON_TITLE_LABEL_Y_OFFSET = 0.05f; |
| 95 | 95 | const float ORIENTATION_DURATION = 0.5f; ///< Time to rotate to new orientation. |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | - * @brief Load an image, scaled-down to no more than the dimensions passed in. | |
| 98 | + * @brief Set an image to image view, scaled-down to no more than the dimensions passed in. | |
| 99 | 99 | * |
| 100 | 100 | * Uses SHRINK_TO_FIT which ensures the resulting image is |
| 101 | - * smaller than or equal to the specified dimensions while preserving its | |
| 102 | - * original aspect ratio. | |
| 101 | + * smaller than or equal to the specified dimensions while preserving its original aspect ratio. | |
| 103 | 102 | */ |
| 104 | -ResourceImage LoadImageFittedInBox( const char * const imagePath, uint32_t maxWidth, uint32_t maxHeight ) | |
| 103 | +void SetImageFittedInBox( ImageView& imageView, Property::Map& shaderEffect, const char * const imagePath, int maxWidth, int maxHeight ) | |
| 105 | 104 | { |
| 105 | + Property::Map map; | |
| 106 | + map["rendererType"] = "image"; | |
| 107 | + map["url"] = imagePath; | |
| 106 | 108 | // Load the image nicely scaled-down to fit within the specified max width and height: |
| 107 | - return ResourceImage::New( imagePath, ImageDimensions( maxWidth, maxHeight ), FittingMode::SHRINK_TO_FIT, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 109 | + map["desiredWidth"] = maxWidth; | |
| 110 | + map["desiredHeight"] = maxHeight; | |
| 111 | + map["fittingMode"] = "SHRINK_TO_FIT"; | |
| 112 | + map["samplingMode"] = "BOX_THEN_LINEAR"; | |
| 113 | + map.Merge( shaderEffect ); | |
| 114 | + | |
| 115 | + imageView.SetProperty( ImageView::Property::IMAGE, map ); | |
| 108 | 116 | } |
| 109 | 117 | |
| 110 | 118 | } // unnamed namespace |
| ... | ... | @@ -207,8 +215,9 @@ public: |
| 207 | 215 | mMotionBlurActorSize = Size( std::min( stageSize.x * 0.3f, MOTION_BLUR_ACTOR_WIDTH ), std::min( stageSize.y * 0.3f, MOTION_BLUR_ACTOR_HEIGHT ) ); |
| 208 | 216 | mMotionBlurActorSize = Size( std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ), std::min( mMotionBlurActorSize.x, mMotionBlurActorSize.y ) ); |
| 209 | 217 | |
| 210 | - Image image = LoadImageFittedInBox( MOTION_BLUR_ACTOR_IMAGE1, mMotionBlurActorSize.x, mMotionBlurActorSize.y ); | |
| 211 | - mMotionBlurImageView = ImageView::New(image); | |
| 218 | + mMotionBlurEffect = CreateMotionBlurEffect(); | |
| 219 | + mMotionBlurImageView = ImageView::New(); | |
| 220 | + SetImageFittedInBox( mMotionBlurImageView, mMotionBlurEffect, MOTION_BLUR_ACTOR_IMAGE1, mMotionBlurActorSize.x, mMotionBlurActorSize.y ); | |
| 212 | 221 | mMotionBlurImageView.SetParentOrigin( ParentOrigin::CENTER ); |
| 213 | 222 | mMotionBlurImageView.SetSize(mMotionBlurActorSize.x, mMotionBlurActorSize.y); |
| 214 | 223 | |
| ... | ... | @@ -219,7 +228,6 @@ public: |
| 219 | 228 | |
| 220 | 229 | // set actor shader to the blur one |
| 221 | 230 | Toolkit::SetMotionBlurProperties( mMotionBlurImageView, MOTION_BLUR_NUM_SAMPLES ); |
| 222 | - mMotionBlurImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionBlurEffect ); | |
| 223 | 231 | |
| 224 | 232 | |
| 225 | 233 | #ifdef MULTIPLE_MOTION_BLURRED_ACTORS |
| ... | ... | @@ -483,10 +491,8 @@ public: |
| 483 | 491 | { |
| 484 | 492 | mCurrentImage = 0; |
| 485 | 493 | } |
| 494 | + SetImageFittedInBox( mMotionBlurImageView, mMotionBlurEffect, MOTION_BLUR_ACTOR_IMAGES[mCurrentImage], mMotionBlurActorSize.x, mMotionBlurActorSize.y ); | |
| 486 | 495 | |
| 487 | - Image blurImage = LoadImageFittedInBox( MOTION_BLUR_ACTOR_IMAGES[mCurrentImage], mMotionBlurActorSize.x, mMotionBlurActorSize.y ); | |
| 488 | - | |
| 489 | - mMotionBlurImageView.SetImage(blurImage); | |
| 490 | 496 | #ifdef MULTIPLE_MOTION_BLURRED_ACTORS |
| 491 | 497 | mMotionBlurImageView2.SetImage(blurImage); |
| 492 | 498 | mMotionBlurImageView3.SetImage(blurImage); | ... | ... |
examples/motion-stretch/motion-stretch-example.cpp
| ... | ... | @@ -175,8 +175,10 @@ public: |
| 175 | 175 | // |
| 176 | 176 | // Motion stretched actor |
| 177 | 177 | // |
| 178 | - | |
| 179 | - mMotionStretchImageView = ImageView::New( MOTION_STRETCH_ACTOR_IMAGE1 ); | |
| 178 | + mMotionStretchEffect = Toolkit::CreateMotionStretchEffect(); | |
| 179 | + mMotionStretchEffect["url"] = MOTION_STRETCH_ACTOR_IMAGE1; | |
| 180 | + mMotionStretchImageView = ImageView::New(); | |
| 181 | + mMotionStretchImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionStretchEffect ); | |
| 180 | 182 | mMotionStretchImageView.SetParentOrigin( ParentOrigin::CENTER ); |
| 181 | 183 | mMotionStretchImageView.SetAnchorPoint( AnchorPoint::CENTER ); |
| 182 | 184 | mMotionStretchImageView.SetSize( MOTION_STRETCH_ACTOR_WIDTH, MOTION_STRETCH_ACTOR_HEIGHT ); |
| ... | ... | @@ -184,9 +186,7 @@ public: |
| 184 | 186 | mContentLayer.Add( mMotionStretchImageView ); |
| 185 | 187 | |
| 186 | 188 | // Create shader used for doing motion stretch |
| 187 | - mMotionStretchEffect = Toolkit::CreateMotionStretchEffect(); | |
| 188 | 189 | Toolkit::SetMotionStretchProperties( mMotionStretchImageView ); |
| 189 | - mMotionStretchImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionStretchEffect ); | |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | ////////////////////////////////////////////////////////////// |
| ... | ... | @@ -390,8 +390,8 @@ public: |
| 390 | 390 | mCurrentImage = 0; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | - Image stretchImage = ResourceImage::New( MOTION_STRETCH_ACTOR_IMAGES[mCurrentImage] ); | |
| 394 | - mMotionStretchImageView.SetImage(stretchImage); | |
| 393 | + mMotionStretchEffect["url"] = MOTION_STRETCH_ACTOR_IMAGES[mCurrentImage]; | |
| 394 | + mMotionStretchImageView.SetProperty( Toolkit::ImageView::Property::IMAGE, mMotionStretchEffect ); | |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | ... | ... |
examples/new-window/new-window-example.cpp
| ... | ... | @@ -24,6 +24,7 @@ |
| 24 | 24 | |
| 25 | 25 | // INTERNAL INCLUDES |
| 26 | 26 | #include "shared/view.h" |
| 27 | +#include "shared/utility.h" | |
| 27 | 28 | |
| 28 | 29 | using namespace Dali; |
| 29 | 30 | using namespace Dali::Toolkit; |
| ... | ... | @@ -187,8 +188,7 @@ void NewWindowController::Create( Application& app ) |
| 187 | 188 | "Context recovery" ); |
| 188 | 189 | |
| 189 | 190 | Size stageSize = stage.GetSize(); |
| 190 | - Image backgroundImage = ResourceImage::New( BACKGROUND_IMAGE, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 191 | - ImageView backgroundActor = ImageView::New( backgroundImage ); | |
| 191 | + ImageView backgroundActor = ImageView::New( BACKGROUND_IMAGE, Dali::ImageDimensions( stageSize.x, stageSize.y ) ); | |
| 192 | 192 | backgroundActor.SetParentOrigin( ParentOrigin::CENTER ); |
| 193 | 193 | mContentLayer.Add(backgroundActor); |
| 194 | 194 | |
| ... | ... | @@ -212,16 +212,15 @@ void NewWindowController::Create( Application& app ) |
| 212 | 212 | logoLayoutActor.SetScale(0.5f); |
| 213 | 213 | backgroundActor.Add(logoLayoutActor); |
| 214 | 214 | |
| 215 | - Image image = ResourceImage::New(LOGO_IMAGE); | |
| 216 | - ImageView imageView = ImageView::New(image); | |
| 215 | + ImageView imageView = ImageView::New( LOGO_IMAGE ); | |
| 217 | 216 | imageView.SetName("daliLogo"); |
| 218 | 217 | imageView.SetParentOrigin(ParentOrigin::CENTER); |
| 219 | 218 | imageView.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER); |
| 220 | 219 | logoLayoutActor.Add(imageView); |
| 221 | 220 | |
| 222 | 221 | ImageView mirrorImageView = CreateBlurredMirrorImage(LOGO_IMAGE); |
| 223 | - mirrorImageView.SetParentOrigin(ParentOrigin::CENTER); | |
| 224 | - mirrorImageView.SetAnchorPoint(AnchorPoint::TOP_CENTER); | |
| 222 | + mirrorImageView.SetParentOrigin(ParentOrigin::TOP_CENTER); | |
| 223 | + mirrorImageView.SetAnchorPoint(AnchorPoint::BOTTOM_CENTER); | |
| 225 | 224 | logoLayoutActor.Add(mirrorImageView); |
| 226 | 225 | |
| 227 | 226 | AddBubbles( backgroundActor, stage.GetSize()); |
| ... | ... | @@ -241,10 +240,10 @@ void NewWindowController::Destroy( Application& app ) |
| 241 | 240 | void NewWindowController::AddBubbles( Actor& parentActor, const Vector2& stageSize) |
| 242 | 241 | { |
| 243 | 242 | mEmitter = Toolkit::BubbleEmitter::New( stageSize, |
| 244 | - ResourceImage::New( DEMO_IMAGE_DIR "bubble-ball.png" ), | |
| 243 | + DemoHelper::LoadImage( DEMO_IMAGE_DIR "bubble-ball.png" ), | |
| 245 | 244 | 200, Vector2( 5.0f, 5.0f ) ); |
| 246 | 245 | |
| 247 | - Image background = ResourceImage::New(BACKGROUND_IMAGE); | |
| 246 | + Image background = DemoHelper::LoadImage(BACKGROUND_IMAGE); | |
| 248 | 247 | mEmitter.SetBackground( background, Vector3(0.5f, 0.f,0.5f) ); |
| 249 | 248 | mEmitter.SetBubbleDensity( 9.f ); |
| 250 | 249 | Actor bubbleRoot = mEmitter.GetRootActor(); |
| ... | ... | @@ -275,10 +274,10 @@ void NewWindowController::AddMeshActor( Actor& parentActor ) |
| 275 | 274 | colorMeshActor.SetName("ColorMeshActor"); |
| 276 | 275 | |
| 277 | 276 | // Create a textured mesh |
| 278 | - Image effectImage = ResourceImage::New(EFFECT_IMAGE); | |
| 277 | + Texture effectTexture = DemoHelper::LoadTexture(EFFECT_IMAGE); | |
| 279 | 278 | Shader shaderTextureMesh = Shader::New( VERTEX_TEXTURE_MESH, FRAGMENT_TEXTURE_MESH ); |
| 280 | 279 | TextureSet textureSet = TextureSet::New(); |
| 281 | - textureSet.SetImage( 0u, effectImage ); | |
| 280 | + textureSet.SetTexture( 0u, effectTexture ); | |
| 282 | 281 | Renderer textureMeshRenderer = Renderer::New( meshGeometry, shaderTextureMesh ); |
| 283 | 282 | textureMeshRenderer.SetTextures( textureSet ); |
| 284 | 283 | |
| ... | ... | @@ -320,8 +319,7 @@ void NewWindowController::AddBlendingImageActor( Actor& parentActor ) |
| 320 | 319 | Property::Map map; |
| 321 | 320 | map[ "shader" ] = customShader; |
| 322 | 321 | |
| 323 | - Image baseImage = ResourceImage::New(BASE_IMAGE); | |
| 324 | - ImageView blendActor = ImageView::New( baseImage ); | |
| 322 | + ImageView blendActor = ImageView::New( BASE_IMAGE ); | |
| 325 | 323 | blendActor.SetProperty( ImageView::Property::IMAGE, map ); |
| 326 | 324 | blendActor.RegisterProperty( "alpha", 0.5f ); |
| 327 | 325 | |
| ... | ... | @@ -345,10 +343,9 @@ void NewWindowController::AddTextLabel( Actor& parentActor ) |
| 345 | 343 | |
| 346 | 344 | ImageView NewWindowController::CreateBlurredMirrorImage(const char* imageName) |
| 347 | 345 | { |
| 348 | - Image image = ResourceImage::New(imageName); | |
| 346 | + Image image = DemoHelper::LoadImage(imageName); | |
| 349 | 347 | |
| 350 | - Uint16Pair intFboSize = ResourceImage::GetImageSize(imageName); | |
| 351 | - Vector2 FBOSize = Vector2( intFboSize.GetWidth(), intFboSize.GetHeight() ); | |
| 348 | + Vector2 FBOSize = Vector2( image.GetWidth(), image.GetHeight() ); | |
| 352 | 349 | FrameBufferImage fbo = FrameBufferImage::New( FBOSize.width, FBOSize.height, Pixel::RGBA8888); |
| 353 | 350 | |
| 354 | 351 | GaussianBlurView gbv = GaussianBlurView::New(5, 2.0f, Pixel::RGBA8888, 0.5f, 0.5f, true); | ... | ... |
examples/page-turn-view/page-turn-view-example.cpp
| ... | ... | @@ -18,6 +18,7 @@ |
| 18 | 18 | #include <dali/dali.h> |
| 19 | 19 | #include <dali-toolkit/dali-toolkit.h> |
| 20 | 20 | #include <dali-toolkit/devel-api/image-atlas/image-atlas.h> |
| 21 | +#include <dali/devel-api/images/atlas.h> | |
| 21 | 22 | |
| 22 | 23 | #include <assert.h> |
| 23 | 24 | #include <cstdlib> |
| ... | ... | @@ -25,6 +26,7 @@ |
| 25 | 26 | #include <iostream> |
| 26 | 27 | |
| 27 | 28 | #include "shared/view.h" |
| 29 | +#include "shared/utility.h" | |
| 28 | 30 | |
| 29 | 31 | using namespace Dali; |
| 30 | 32 | using namespace Dali::Toolkit; |
| ... | ... | @@ -39,9 +41,9 @@ const char* const CHANGE_IMAGE_ICON_SELECTED( DEMO_IMAGE_DIR "icon-change-select |
| 39 | 41 | // set a ratio to modify the current page number when the rotation is changed |
| 40 | 42 | const float PAGE_NUMBER_CORRESPONDING_RATIO(1.25f); |
| 41 | 43 | |
| 42 | -const char* BOOK_COVER_PORTRAIT = ( DEMO_IMAGE_DIR "book-portrait-cover.jpg" ); | |
| 43 | -const char* BOOK_COVER_LANDSCAPE = ( DEMO_IMAGE_DIR "book-landscape-cover.jpg" ); | |
| 44 | -const char* BOOK_COVER_BACK_LANDSCAPE = ( DEMO_IMAGE_DIR "book-landscape-cover-back.jpg" ); | |
| 44 | +const char* BOOK_COVER_PORTRAIT( DEMO_IMAGE_DIR "book-portrait-cover.jpg" ); | |
| 45 | +const char* BOOK_COVER_LANDSCAPE( DEMO_IMAGE_DIR "book-landscape-cover.jpg" ); | |
| 46 | +const char* BOOK_COVER_BACK_LANDSCAPE( DEMO_IMAGE_DIR "book-landscape-cover-back.jpg" ); | |
| 45 | 47 | |
| 46 | 48 | const char* PAGE_IMAGES_PORTRAIT[] = |
| 47 | 49 | { |
| ... | ... | @@ -66,6 +68,21 @@ const char* PAGE_IMAGES_LANDSCAPE[] = |
| 66 | 68 | }; |
| 67 | 69 | const unsigned int NUMBER_OF_LANDSCAPE_IMAGE( sizeof(PAGE_IMAGES_LANDSCAPE) / sizeof(PAGE_IMAGES_LANDSCAPE[0]) ); |
| 68 | 70 | |
| 71 | +Atlas LoadImages( const char*imagePath1, const char* imagePath2 ) | |
| 72 | +{ | |
| 73 | + PixelData pixelData1 = DemoHelper::LoadPixelData( imagePath1, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT ); | |
| 74 | + PixelData pixelData2 = DemoHelper::LoadPixelData( imagePath2, ImageDimensions(), FittingMode::DEFAULT, SamplingMode::DEFAULT ); | |
| 75 | + | |
| 76 | + unsigned int width = pixelData1.GetWidth()+pixelData2.GetWidth(); | |
| 77 | + unsigned int height = pixelData1.GetHeight() > pixelData2.GetHeight() ? pixelData1.GetHeight() : pixelData2.GetHeight(); | |
| 78 | + | |
| 79 | + Atlas image = Atlas::New( width, height ); | |
| 80 | + image.Upload( pixelData1, 0u, 0u ); | |
| 81 | + image.Upload( pixelData2, pixelData1.GetWidth(), 0u ); | |
| 82 | + | |
| 83 | + return image; | |
| 84 | +} | |
| 85 | + | |
| 69 | 86 | }// end LOCAL STUFF |
| 70 | 87 | |
| 71 | 88 | class PortraitPageFactory : public PageFactory |
| ... | ... | @@ -85,15 +102,15 @@ class PortraitPageFactory : public PageFactory |
| 85 | 102 | */ |
| 86 | 103 | virtual Image NewPage( unsigned int pageId ) |
| 87 | 104 | { |
| 88 | - Image page; | |
| 105 | + Atlas page; | |
| 89 | 106 | |
| 90 | 107 | if( pageId == 0 ) |
| 91 | 108 | { |
| 92 | - page = ResourceImage::New( BOOK_COVER_PORTRAIT ); | |
| 109 | + page = DemoHelper::LoadImage( BOOK_COVER_PORTRAIT ); | |
| 93 | 110 | } |
| 94 | 111 | else |
| 95 | 112 | { |
| 96 | - page = ResourceImage::New( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ); | |
| 113 | + page = DemoHelper::LoadImage( PAGE_IMAGES_PORTRAIT[ (pageId-1) % NUMBER_OF_PORTRAIT_IMAGE ] ); | |
| 97 | 114 | } |
| 98 | 115 | |
| 99 | 116 | return page; |
| ... | ... | @@ -118,29 +135,20 @@ class LandscapePageFactory : public PageFactory |
| 118 | 135 | */ |
| 119 | 136 | virtual Image NewPage( unsigned int pageId ) |
| 120 | 137 | { |
| 121 | - if( mImageSize.GetWidth() == 0u || mImageSize.GetHeight() == 0u ) | |
| 122 | - { | |
| 123 | - mImageSize = ResourceImage::GetImageSize(BOOK_COVER_LANDSCAPE); | |
| 124 | - } | |
| 125 | 138 | |
| 126 | - ImageAtlas atlas = ImageAtlas::New( mImageSize.GetWidth()*2u, mImageSize.GetHeight(), Pixel::RGB888 ); | |
| 127 | - Vector4 textureRect; | |
| 139 | + Atlas page; | |
| 128 | 140 | if( pageId == 0 ) |
| 129 | 141 | { |
| 130 | - atlas.Upload( textureRect, BOOK_COVER_LANDSCAPE, mImageSize ); | |
| 131 | - atlas.Upload( textureRect, BOOK_COVER_BACK_LANDSCAPE, mImageSize ); | |
| 142 | + page = LoadImages( BOOK_COVER_LANDSCAPE, BOOK_COVER_BACK_LANDSCAPE ); | |
| 132 | 143 | } |
| 133 | 144 | else |
| 134 | 145 | { |
| 135 | 146 | unsigned int imageId = (pageId-1)*2; |
| 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 ); | |
| 147 | + page = LoadImages( PAGE_IMAGES_LANDSCAPE[ imageId % NUMBER_OF_LANDSCAPE_IMAGE ], PAGE_IMAGES_LANDSCAPE[ (imageId+1) % NUMBER_OF_LANDSCAPE_IMAGE ] ); | |
| 138 | 148 | } |
| 139 | 149 | |
| 140 | - return atlas.GetAtlas(); | |
| 150 | + return page; | |
| 141 | 151 | } |
| 142 | - | |
| 143 | - ImageDimensions mImageSize; | |
| 144 | 152 | }; |
| 145 | 153 | |
| 146 | 154 | /** | ... | ... |
examples/perf-scroll/perf-scroll.cpp
| ... | ... | @@ -23,6 +23,8 @@ |
| 23 | 23 | #include <dali/integration-api/debug.h> |
| 24 | 24 | #include <iostream> |
| 25 | 25 | |
| 26 | +#include "shared/utility.h" | |
| 27 | + | |
| 26 | 28 | using namespace Dali; |
| 27 | 29 | using namespace Dali::Toolkit; |
| 28 | 30 | |
| ... | ... | @@ -225,10 +227,10 @@ Renderer CreateRenderer( unsigned int index ) |
| 225 | 227 | Shader shader = Shader::New( VERTEX_SHADER_TEXTURE, FRAGMENT_SHADER_TEXTURE ); |
| 226 | 228 | |
| 227 | 229 | const char* imagePath = !gNinePatch ? IMAGE_PATH[index] : NINEPATCH_IMAGE_PATH[index]; |
| 228 | - Image image = ResourceImage::New( imagePath ); | |
| 230 | + Texture texture = DemoHelper::LoadTexture( imagePath ); | |
| 229 | 231 | |
| 230 | 232 | TextureSet textureSet = TextureSet::New(); |
| 231 | - textureSet.SetImage( 0u, image ); | |
| 233 | + textureSet.SetTexture( 0u, texture ); | |
| 232 | 234 | renderers[index] = Renderer::New( QuadMesh(), shader ); |
| 233 | 235 | renderers[index].SetTextures( textureSet ); |
| 234 | 236 | renderers[index].SetProperty( Renderer::Property::BLEND_MODE, BlendMode::OFF ); | ... | ... |
examples/point-mesh/point-mesh-example.cpp
| ... | ... | @@ -21,6 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | // INTERNAL INCLUDES |
| 23 | 23 | #include "shared/view.h" |
| 24 | +#include "shared/utility.h" | |
| 24 | 25 | |
| 25 | 26 | using namespace Dali; |
| 26 | 27 | |
| ... | ... | @@ -152,14 +153,14 @@ public: |
| 152 | 153 | // Hide the indicator bar |
| 153 | 154 | application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); |
| 154 | 155 | |
| 155 | - Image image0 = ResourceImage::New( MATERIAL_SAMPLE ); | |
| 156 | - Image image1 = ResourceImage::New( MATERIAL_SAMPLE2 ); | |
| 156 | + Texture texture0 = DemoHelper::LoadTexture( MATERIAL_SAMPLE ); | |
| 157 | + Texture texture1 = DemoHelper::LoadTexture( MATERIAL_SAMPLE2 ); | |
| 157 | 158 | |
| 158 | 159 | Shader shader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); |
| 159 | 160 | |
| 160 | 161 | TextureSet textureSet = TextureSet::New(); |
| 161 | - textureSet.SetImage( 0u, image0 ); | |
| 162 | - textureSet.SetImage( 1u, image1 ); | |
| 162 | + textureSet.SetTexture( 0u, texture0 ); | |
| 163 | + textureSet.SetTexture( 1u, texture1 ); | |
| 163 | 164 | |
| 164 | 165 | Geometry geometry = CreateGeometry(); |
| 165 | 166 | ... | ... |
examples/popup/popup-example.cpp
| ... | ... | @@ -712,11 +712,6 @@ private: |
| 712 | 712 | bool mContextual; ///< True if currently using the contextual popup mode. |
| 713 | 713 | bool mAnimationFade; ///< True if currently using the fade animation. |
| 714 | 714 | |
| 715 | - ResourceImage mContextButtonDisabledImage; ///< The disabled context button icon. | |
| 716 | - ResourceImage mContextButtonEnabledImage; ///< The enabled context button icon. | |
| 717 | - ResourceImage mAnimationButtonZoomImage; ///< The zoom animation button icon. | |
| 718 | - ResourceImage mAnimationButtonFadeImage; ///< The fade animation button icon. | |
| 719 | - | |
| 720 | 715 | Toolkit::Popup mPopup; ///< The current example popup. |
| 721 | 716 | |
| 722 | 717 | Toolkit::ItemView mItemView; ///< ItemView to hold test images | ... | ... |
examples/radial-menu/radial-menu-example.cpp
| ... | ... | @@ -172,8 +172,7 @@ void RadialMenuExample::OnInit(Application& app) |
| 172 | 172 | mRadialSweepView3.SetInitialActorAngle(Degree(-110)); |
| 173 | 173 | mRadialSweepView3.SetFinalActorAngle(Degree(0)); |
| 174 | 174 | |
| 175 | - Image dial = ResourceImage::New( TEST_DIAL_FILENAME ); | |
| 176 | - mDialView = ImageView::New( dial ); | |
| 175 | + mDialView = ImageView::New( TEST_DIAL_FILENAME ); | |
| 177 | 176 | mDialView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); |
| 178 | 177 | mDialView.SetParentOrigin( ParentOrigin::CENTER ); |
| 179 | 178 | mDialView.SetScale(scale); |
| ... | ... | @@ -254,8 +253,7 @@ RadialSweepView RadialMenuExample::CreateSweepView( std::string imageName, |
| 254 | 253 | Degree finalAngle) |
| 255 | 254 | { |
| 256 | 255 | // Create the image |
| 257 | - Image image = ResourceImage::New(imageName); | |
| 258 | - mImageView = ImageView::New(image); | |
| 256 | + mImageView = ImageView::New(imageName); | |
| 259 | 257 | mImageView.SetParentOrigin(ParentOrigin::CENTER); |
| 260 | 258 | mImageView.SetAnchorPoint(AnchorPoint::CENTER); |
| 261 | 259 | mImageView.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); | ... | ... |
examples/refraction-effect/refraction-effect-example.cpp
| ... | ... | @@ -26,6 +26,7 @@ |
| 26 | 26 | |
| 27 | 27 | // INTERNAL INCLUDES |
| 28 | 28 | #include "shared/view.h" |
| 29 | +#include "shared/utility.h" | |
| 29 | 30 | |
| 30 | 31 | using namespace Dali; |
| 31 | 32 | |
| ... | ... | @@ -74,19 +75,6 @@ struct LightOffsetConstraint |
| 74 | 75 | }; |
| 75 | 76 | |
| 76 | 77 | /** |
| 77 | - * @brief Load an image, scaled-down to no more than the stage dimensions. | |
| 78 | - * | |
| 79 | - * Uses image scaling mode SCALE_TO_FILL to resize the image at | |
| 80 | - * load time to cover the entire stage with pixels with no borders, | |
| 81 | - * and filter mode BOX_THEN_LINEAR to sample the image with maximum quality. | |
| 82 | - */ | |
| 83 | -ResourceImage LoadStageFillingImage( const char * const imagePath ) | |
| 84 | -{ | |
| 85 | - Size stageSize = Stage::GetCurrent().GetSize(); | |
| 86 | - return ResourceImage::New( imagePath, ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 87 | -} | |
| 88 | - | |
| 89 | -/** | |
| 90 | 78 | * structure of the vertex in the mesh |
| 91 | 79 | */ |
| 92 | 80 | struct Vertex |
| ... | ... | @@ -280,9 +268,9 @@ private: |
| 280 | 268 | mShaderFlat = Shader::New( VERTEX_SHADER_FLAT, FRAGMENT_SHADER_FLAT ); |
| 281 | 269 | mGeometry = CreateGeometry( MESH_FILES[mCurrentMeshId] ); |
| 282 | 270 | |
| 283 | - Image texture = LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] ); | |
| 271 | + Texture texture = DemoHelper::LoadStageFillingTexture( TEXTURE_IMAGES[mCurrentTextureId] ); | |
| 284 | 272 | mTextureSet = TextureSet::New(); |
| 285 | - mTextureSet.SetImage( 0u, texture ); | |
| 273 | + mTextureSet.SetTexture( 0u, texture ); | |
| 286 | 274 | |
| 287 | 275 | mRenderer = Renderer::New( mGeometry, mShaderFlat ); |
| 288 | 276 | mRenderer.SetTextures( mTextureSet ); |
| ... | ... | @@ -343,8 +331,8 @@ private: |
| 343 | 331 | bool OnChangeTexture( Toolkit::Button button ) |
| 344 | 332 | { |
| 345 | 333 | mCurrentTextureId = ( mCurrentTextureId + 1 ) % NUM_TEXTURE_IMAGES; |
| 346 | - Image texture = LoadStageFillingImage( TEXTURE_IMAGES[mCurrentTextureId] ); | |
| 347 | - mTextureSet.SetImage( 0u, texture ); | |
| 334 | + Texture texture = DemoHelper::LoadStageFillingTexture( TEXTURE_IMAGES[mCurrentTextureId] ); | |
| 335 | + mTextureSet.SetTexture( 0u, texture ); | |
| 348 | 336 | return true; |
| 349 | 337 | } |
| 350 | 338 | ... | ... |
examples/scroll-view/scroll-view-example.cpp
| ... | ... | @@ -450,11 +450,18 @@ private: |
| 450 | 450 | * @param[in] width the width of the image in texels |
| 451 | 451 | * @param[in] height the height of the image in texels. |
| 452 | 452 | */ |
| 453 | - ImageView CreateImage( const std::string& filename, unsigned int width = IMAGE_THUMBNAIL_WIDTH, unsigned int height = IMAGE_THUMBNAIL_HEIGHT ) | |
| 453 | + ImageView CreateImage( const std::string& filename, int width = IMAGE_THUMBNAIL_WIDTH, int height = IMAGE_THUMBNAIL_HEIGHT ) | |
| 454 | 454 | { |
| 455 | - Image img = ResourceImage::New(filename, ImageDimensions( width, height ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 455 | + ImageView actor = ImageView::New(); | |
| 456 | + Property::Map map; | |
| 457 | + map["rendererType"] = "image"; | |
| 458 | + map["url"] = filename; | |
| 459 | + map["desiredWidth"] = width; | |
| 460 | + map["desiredHeight"] = height; | |
| 461 | + map["fittingMode"] = "SCALE_TO_FILL"; | |
| 462 | + map["samplingMode"] = "BOX_THEN_LINEAR"; | |
| 463 | + actor.SetProperty( ImageView::Property::IMAGE, map ); | |
| 456 | 464 | |
| 457 | - ImageView actor = ImageView::New(img); | |
| 458 | 465 | actor.SetName( filename ); |
| 459 | 466 | actor.SetParentOrigin(ParentOrigin::CENTER); |
| 460 | 467 | actor.SetAnchorPoint(AnchorPoint::CENTER); | ... | ... |
examples/super-blur-bloom/super-blur-bloom-example.cpp
| ... | ... | @@ -19,6 +19,7 @@ |
| 19 | 19 | #include <dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h> |
| 20 | 20 | #include <dali-toolkit/devel-api/controls/bloom-view/bloom-view.h> |
| 21 | 21 | #include "shared/view.h" |
| 22 | +#include "shared/utility.h" | |
| 22 | 23 | |
| 23 | 24 | using namespace Dali; |
| 24 | 25 | |
| ... | ... | @@ -42,20 +43,7 @@ const char* BACKGROUND_IMAGES[]= |
| 42 | 43 | DEMO_IMAGE_DIR "background-magnifier.jpg", |
| 43 | 44 | }; |
| 44 | 45 | const unsigned int NUM_BACKGROUND_IMAGES( sizeof( BACKGROUND_IMAGES ) / sizeof( BACKGROUND_IMAGES[0] ) ); |
| 45 | -} | |
| 46 | 46 | |
| 47 | -/** | |
| 48 | - * @brief Load an image, scaled-down to no more than the stage dimensions. | |
| 49 | - * | |
| 50 | - * Uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at | |
| 51 | - * load time to cover the entire stage with pixels with no borders, | |
| 52 | - * and filter mode BOX_THEN_LINEAR to sample the image with | |
| 53 | - * maximum quality. | |
| 54 | - */ | |
| 55 | -ResourceImage LoadStageFillingImage( const char * const imagePath ) | |
| 56 | -{ | |
| 57 | - Size stageSize = Stage::GetCurrent().GetSize(); | |
| 58 | - return ResourceImage::New( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 59 | 47 | } |
| 60 | 48 | |
| 61 | 49 | class BlurExample : public ConnectionTracker |
| ... | ... | @@ -116,7 +104,7 @@ private: |
| 116 | 104 | mSuperBlurView.SetParentOrigin( ParentOrigin::CENTER ); |
| 117 | 105 | mSuperBlurView.SetAnchorPoint( AnchorPoint::CENTER ); |
| 118 | 106 | mSuperBlurView.BlurFinishedSignal().Connect(this, &BlurExample::OnBlurFinished); |
| 119 | - mCurrentImage = LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] ); | |
| 107 | + mCurrentImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] ); | |
| 120 | 108 | mSuperBlurView.SetImage( mCurrentImage ); |
| 121 | 109 | mBackground.Add( mSuperBlurView ); |
| 122 | 110 | mIsBlurring = true; |
| ... | ... | @@ -215,7 +203,7 @@ private: |
| 215 | 203 | } |
| 216 | 204 | |
| 217 | 205 | mImageIndex = (mImageIndex+1u)%NUM_BACKGROUND_IMAGES; |
| 218 | - mCurrentImage = LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] ); | |
| 206 | + mCurrentImage = DemoHelper::LoadStageFillingImage( BACKGROUND_IMAGES[mImageIndex] ); | |
| 219 | 207 | |
| 220 | 208 | if( mSuperBlurView.OnStage() ) |
| 221 | 209 | { | ... | ... |
examples/text-field/text-field-example.cpp
| ... | ... | @@ -87,8 +87,8 @@ public: |
| 87 | 87 | button.SetSelectedImage( FOLDER_OPEN_ICON_IMAGE ); |
| 88 | 88 | button.SetAnchorPoint( AnchorPoint::TOP_LEFT ); |
| 89 | 89 | button.SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); |
| 90 | - ResourceImage imageClosed = ResourceImage::New( FOLDER_ICON_IMAGE ); | |
| 91 | - button.SetSize( imageClosed.GetWidth(), imageClosed.GetHeight() ); | |
| 90 | + ImageDimensions imageSize = ResourceImage::GetImageSize( FOLDER_ICON_IMAGE ); | |
| 91 | + button.SetSize( imageSize.GetWidth(), imageSize.GetHeight() ); | |
| 92 | 92 | |
| 93 | 93 | return button; |
| 94 | 94 | } | ... | ... |
examples/text-label/text-label-example.cpp
| ... | ... | @@ -111,11 +111,10 @@ public: |
| 111 | 111 | stage.Add( mContainer ); |
| 112 | 112 | |
| 113 | 113 | // Resize the center layout when the corner is grabbed |
| 114 | - mGrabCorner = Control::New(); | |
| 114 | + mGrabCorner = ImageView::New( BACKGROUND_IMAGE ); | |
| 115 | 115 | mGrabCorner.SetName( "GrabCorner" ); |
| 116 | 116 | mGrabCorner.SetAnchorPoint( AnchorPoint::TOP_CENTER ); |
| 117 | 117 | mGrabCorner.SetParentOrigin( ParentOrigin::BOTTOM_RIGHT ); |
| 118 | - mGrabCorner.SetBackgroundImage( ResourceImage::New( BACKGROUND_IMAGE ) ); | |
| 119 | 118 | mGrabCorner.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); |
| 120 | 119 | mContainer.Add( mGrabCorner ); |
| 121 | 120 | ... | ... |
examples/textured-mesh/textured-mesh-example.cpp
| ... | ... | @@ -21,6 +21,7 @@ |
| 21 | 21 | |
| 22 | 22 | // INTERNAL INCLUDES |
| 23 | 23 | #include "shared/view.h" |
| 24 | +#include "shared/utility.h" | |
| 24 | 25 | |
| 25 | 26 | using namespace Dali; |
| 26 | 27 | |
| ... | ... | @@ -140,15 +141,15 @@ public: |
| 140 | 141 | // Hide the indicator bar |
| 141 | 142 | application.GetWindow().ShowIndicator( Dali::Window::INVISIBLE ); |
| 142 | 143 | |
| 143 | - mImage = ResourceImage::New( MATERIAL_SAMPLE ); | |
| 144 | - Image image = ResourceImage::New( MATERIAL_SAMPLE2 ); | |
| 144 | + Texture texture1 = DemoHelper::LoadTexture( MATERIAL_SAMPLE ); | |
| 145 | + Texture texture2 = DemoHelper::LoadTexture( MATERIAL_SAMPLE2 ); | |
| 145 | 146 | |
| 146 | 147 | mShader = Shader::New( VERTEX_SHADER, FRAGMENT_SHADER ); |
| 147 | 148 | mTextureSet1 = TextureSet::New(); |
| 148 | - mTextureSet1.SetImage( 0u, mImage ); | |
| 149 | + mTextureSet1.SetTexture( 0u, texture1 ); | |
| 149 | 150 | |
| 150 | 151 | mTextureSet2 = TextureSet::New(); |
| 151 | - mTextureSet2.SetImage( 0u, image ); | |
| 152 | + mTextureSet2.SetTexture( 0u, texture2 ); | |
| 152 | 153 | |
| 153 | 154 | mGeometry = CreateGeometry(); |
| 154 | 155 | |
| ... | ... | @@ -258,7 +259,6 @@ private: |
| 258 | 259 | Application& mApplication; ///< Application instance |
| 259 | 260 | Vector3 mStageSize; ///< The size of the stage |
| 260 | 261 | |
| 261 | - Image mImage; | |
| 262 | 262 | Shader mShader; |
| 263 | 263 | TextureSet mTextureSet1; |
| 264 | 264 | TextureSet mTextureSet2; | ... | ... |
shared/utility.h
0 โ 100644
| 1 | +#ifndef __DALI_DEMO_UTILITY_H__ | |
| 2 | +#define __DALI_DEMO_UTILITY_H__ | |
| 3 | + | |
| 4 | +/* | |
| 5 | + * Copyright (c) 2014 Samsung Electronics Co., Ltd. | |
| 6 | + * | |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 8 | + * you may not use this file except in compliance with the License. | |
| 9 | + * You may obtain a copy of the License at | |
| 10 | + * | |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 12 | + * | |
| 13 | + * Unless required by applicable law or agreed to in writing, software | |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 16 | + * See the License for the specific language governing permissions and | |
| 17 | + * limitations under the License. | |
| 18 | + * | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#include <dali/dali.h> | |
| 22 | +#include <dali/devel-api/images/atlas.h> | |
| 23 | +#include <dali/devel-api/rendering/texture.h> | |
| 24 | +#include <dali/devel-api/adaptor-framework/bitmap-loader.h> | |
| 25 | + | |
| 26 | +namespace DemoHelper | |
| 27 | +{ | |
| 28 | + | |
| 29 | +Dali::PixelData LoadPixelData( const char* imagePath, | |
| 30 | + Dali::ImageDimensions size, | |
| 31 | + Dali::FittingMode::Type fittingMode, | |
| 32 | + Dali::SamplingMode::Type samplingMode ) | |
| 33 | +{ | |
| 34 | + Dali::BitmapLoader loader = Dali::BitmapLoader::New( imagePath, size, fittingMode, samplingMode ); | |
| 35 | + loader.Load(); | |
| 36 | + return loader.GetPixelData(); | |
| 37 | +} | |
| 38 | + | |
| 39 | + | |
| 40 | +Dali::Atlas LoadImage( const char* imagePath, | |
| 41 | + Dali::ImageDimensions size = Dali::ImageDimensions(), | |
| 42 | + Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT, | |
| 43 | + Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT ) | |
| 44 | +{ | |
| 45 | + Dali::PixelData pixelData = LoadPixelData(imagePath, size, fittingMode, samplingMode); | |
| 46 | + Dali::Atlas image =Dali:: Atlas::New( pixelData.GetWidth(), pixelData.GetHeight(), pixelData.GetPixelFormat() ); | |
| 47 | + image.Upload( pixelData, 0u, 0u ); | |
| 48 | + | |
| 49 | + return image; | |
| 50 | +} | |
| 51 | + | |
| 52 | +Dali::Texture LoadTexture( const char* imagePath, | |
| 53 | + Dali::ImageDimensions size = Dali::ImageDimensions(), | |
| 54 | + Dali::FittingMode::Type fittingMode = Dali::FittingMode::DEFAULT, | |
| 55 | + Dali::SamplingMode::Type samplingMode = Dali::SamplingMode::DEFAULT ) | |
| 56 | +{ | |
| 57 | + Dali::PixelData pixelData = LoadPixelData(imagePath, size, fittingMode, samplingMode); | |
| 58 | + Dali::Texture texture = Dali::Texture::New( Dali::TextureType::TEXTURE_2D, | |
| 59 | + pixelData.GetPixelFormat(), | |
| 60 | + pixelData.GetWidth(), | |
| 61 | + pixelData.GetHeight() ); | |
| 62 | + texture.Upload( pixelData ); | |
| 63 | + | |
| 64 | + return texture; | |
| 65 | +} | |
| 66 | + | |
| 67 | +/** | |
| 68 | + * @brief Load an bitmap resource. | |
| 69 | + * | |
| 70 | + * If it is required to scaled-down to no more than the stage dimensions, | |
| 71 | + * uses image scaling mode FittingMode::SCALE_TO_FILL to resize the image at | |
| 72 | + * load time to cover the entire stage with pixels with no borders, | |
| 73 | + * and filter mode BOX_THEN_LINEAR to sample the image with | |
| 74 | + * maximum quality. | |
| 75 | + */ | |
| 76 | + | |
| 77 | +Dali::Atlas LoadStageFillingImage( const char* imagePath ) | |
| 78 | +{ | |
| 79 | + Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); | |
| 80 | + return LoadImage( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 81 | +} | |
| 82 | + | |
| 83 | +Dali::Texture LoadStageFillingTexture( const char* imagePath ) | |
| 84 | +{ | |
| 85 | + Dali::Vector2 stageSize = Dali::Stage::GetCurrent().GetSize(); | |
| 86 | + return LoadTexture( imagePath, Dali::ImageDimensions( stageSize.x, stageSize.y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 87 | +} | |
| 88 | + | |
| 89 | +} // DemoHelper | |
| 90 | + | |
| 91 | +#endif // __DALI_DEMO_HELPER_VIEW_H__ | ... | ... |
shared/view.h
| ... | ... | @@ -77,10 +77,11 @@ Dali::Layer CreateToolbar( Dali::Toolkit::ToolBar& toolBar, |
| 77 | 77 | toolBarLayer.RaiseToTop(); |
| 78 | 78 | |
| 79 | 79 | // Tool bar |
| 80 | - Dali::Image image = Dali::ResourceImage::New( toolbarImagePath ); | |
| 81 | 80 | toolBar = Dali::Toolkit::ToolBar::New(); |
| 82 | 81 | toolBar.SetName( "TOOLBAR" ); |
| 83 | - toolBar.SetBackgroundImage( image ); | |
| 82 | + Dali::Property::Map background; | |
| 83 | + background["url"] = toolbarImagePath; | |
| 84 | + toolBar.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, background ); | |
| 84 | 85 | toolBar.SetParentOrigin( Dali::ParentOrigin::TOP_CENTER ); |
| 85 | 86 | toolBar.SetAnchorPoint( Dali::AnchorPoint::TOP_CENTER ); |
| 86 | 87 | toolBar.SetResizePolicy( Dali::ResizePolicy::FILL_TO_PARENT, Dali::Dimension::ALL_DIMENSIONS ); |
| ... | ... | @@ -129,8 +130,15 @@ Dali::Layer CreateView( Dali::Application& application, |
| 129 | 130 | // Set background image, loading it at screen resolution: |
| 130 | 131 | if ( !backgroundImagePath.empty() ) |
| 131 | 132 | { |
| 132 | - Dali::Image backgroundImage = Dali::ResourceImage::New( backgroundImagePath, Dali::ImageDimensions( stage.GetSize().x, stage.GetSize().y ), Dali::FittingMode::SCALE_TO_FILL, Dali::SamplingMode::BOX_THEN_LINEAR ); | |
| 133 | - view.SetBackgroundImage( backgroundImage ); | |
| 133 | + Dali::Property::Map map; | |
| 134 | + map["rendererType"] = "image"; | |
| 135 | + map["url"] = backgroundImagePath; | |
| 136 | + map["desiredWidth"] = stage.GetSize().x; | |
| 137 | + map["desiredHeight"] = stage.GetSize().y; | |
| 138 | + map["fittingMode"] = "SCALE_TO_FILL"; | |
| 139 | + map["samplingMode"] = "BOX_THEN_LINEAR"; | |
| 140 | + map["synchronousLoading"] = true; | |
| 141 | + view.SetProperty( Dali::Toolkit::Control::Property::BACKGROUND, map ); | |
| 134 | 142 | } |
| 135 | 143 | |
| 136 | 144 | // FIXME | ... | ... |