Commit f22c4ec4fc3e7ae6e746d747fc9f49736565840d
1 parent
c69a61d5
Change fitting mode to match previous behaviour.
Change-Id: I8565e62b924324bba6116b4a3c1706ad3fc9d771
Showing
6 changed files
with
72 additions
and
31 deletions
examples/animated-gradient-card-active/animated-gradient-card-active.cpp
| 1 | 1 | /* |
| 2 | -* Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | +* Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -141,8 +141,16 @@ public: |
| 141 | 141 | |
| 142 | 142 | mImageUrl[k] = CARD_IMAGE_LIST[k]; |
| 143 | 143 | |
| 144 | + // Create an image view for this item | |
| 144 | 145 | mCard[k] = ImageView::New(); |
| 145 | - mCard[k].SetImage( mImageUrl[k] ); | |
| 146 | + { | |
| 147 | + Property::Map propertyMap; | |
| 148 | + propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE); | |
| 149 | + propertyMap.Insert(ImageVisual::Property::URL, mImageUrl[k]); | |
| 150 | + propertyMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FILL); | |
| 151 | + mCard[k].SetProperty(Toolkit::ImageView::Property::IMAGE, propertyMap); | |
| 152 | + } | |
| 153 | + | |
| 146 | 154 | mCard[k].SetParentOrigin( ParentOrigin::CENTER ); |
| 147 | 155 | mCard[k].SetAnchorPoint( AnchorPoint::CENTER ); |
| 148 | 156 | mCard[k].SetSize( mSize.x, mSize.y ); | ... | ... |
examples/blocks/blocks-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -23,6 +23,7 @@ |
| 23 | 23 | |
| 24 | 24 | #include <dali/dali.h> |
| 25 | 25 | #include <dali-toolkit/dali-toolkit.h> |
| 26 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | |
| 26 | 27 | #include "shared/view.h" |
| 27 | 28 | |
| 28 | 29 | using namespace Dali; |
| ... | ... | @@ -586,7 +587,12 @@ private: |
| 586 | 587 | */ |
| 587 | 588 | ImageView CreateImage(const std::string& filename) |
| 588 | 589 | { |
| 589 | - ImageView actor = ImageView::New(filename); | |
| 590 | + Property::Map propertyMap; | |
| 591 | + propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE); | |
| 592 | + propertyMap.Insert(ImageVisual::Property::URL, filename); | |
| 593 | + propertyMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FILL); | |
| 594 | + ImageView actor = ImageView::New(); | |
| 595 | + actor.SetProperty(Toolkit::ImageView::Property::IMAGE, propertyMap); | |
| 590 | 596 | actor.SetParentOrigin(ParentOrigin::TOP_LEFT); |
| 591 | 597 | actor.SetAnchorPoint(AnchorPoint::CENTER); |
| 592 | 598 | return actor; | ... | ... |
examples/clipping/clipping-item-factory.cpp
| ... | ... | @@ -107,7 +107,7 @@ Actor ClippingItemFactory::NewItem( unsigned int itemId ) |
| 107 | 107 | Property::Map propertyMap; |
| 108 | 108 | propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE); |
| 109 | 109 | propertyMap.Insert(ImageVisual::Property::URL, IMAGE_PATHS[ itemId % NUM_IMAGES ] ); |
| 110 | - propertyMap.Insert(DevelVisual::Property::FITTING_MODE, DevelVisual::FILL); | |
| 110 | + propertyMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FILL); | |
| 111 | 111 | ImageView actor = ImageView::New(); |
| 112 | 112 | actor.SetProperty(Toolkit::ImageView::Property::IMAGE, propertyMap); |
| 113 | 113 | ... | ... |
examples/image-view-alpha-blending/image-view-alpha-blending-example.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,6 +16,8 @@ |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | +#include <dali-toolkit/devel-api/image-loader/texture-manager.h> | |
| 20 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | |
| 19 | 21 | |
| 20 | 22 | using namespace Dali; |
| 21 | 23 | |
| ... | ... | @@ -48,28 +50,28 @@ private: |
| 48 | 50 | Stage stage = Stage::GetCurrent(); |
| 49 | 51 | stage.KeyEventSignal().Connect(this, &ImageViewAlphaBlendApp::OnKeyEvent); |
| 50 | 52 | |
| 51 | - Vector4 green0 = Vector4( 0.f, 1.f, 0.f, 0.25f ); | |
| 52 | - Vector4 green1 = Vector4( 0.f, 0.25f, 0.f, 0.25f ); | |
| 53 | - BufferImage redGreen0 = CreateBufferImage( Color::RED, green0 ); | |
| 54 | - BufferImage redGreen1 = CreateBufferImage( Color::RED, green1 ); | |
| 53 | + auto green0 = Vector4( 0.f, 1.f, 0.f, 0.25f ); | |
| 54 | + auto green1 = Vector4( 0.f, 0.25f, 0.f, 0.25f ); | |
| 55 | + auto redGreen0 = CreateTexture( Color::RED, green0 ); | |
| 56 | + auto redGreen1 = CreateTexture( Color::RED, green1 ); | |
| 55 | 57 | float imageSize = 512.f; |
| 56 | 58 | |
| 57 | - Toolkit::ImageView imageView0 = Toolkit::ImageView::New( IMAGE_PATH ); | |
| 59 | + Toolkit::ImageView imageView0 = CreateImageView( IMAGE_PATH ); | |
| 58 | 60 | imageView0.SetSize(imageSize, imageSize); |
| 59 | 61 | imageView0.SetParentOrigin( ParentOrigin::CENTER ); |
| 60 | 62 | imageView0.SetY( -imageSize*0.5f ); |
| 61 | 63 | stage.Add(imageView0); |
| 62 | - Toolkit::ImageView imageView1 = Toolkit::ImageView::New( redGreen0 ); | |
| 64 | + Toolkit::ImageView imageView1 = CreateImageView( redGreen0 ); | |
| 63 | 65 | imageView1.SetParentOrigin( ParentOrigin::CENTER ); |
| 64 | 66 | imageView1.SetSize(imageSize, imageSize); |
| 65 | 67 | imageView0.Add(imageView1); |
| 66 | 68 | |
| 67 | - Toolkit::ImageView imageView2 = Toolkit::ImageView::New( IMAGE_PATH ); | |
| 69 | + Toolkit::ImageView imageView2 = CreateImageView( IMAGE_PATH ); | |
| 68 | 70 | imageView2.SetSize(imageSize, imageSize); |
| 69 | 71 | imageView2.SetParentOrigin( ParentOrigin::CENTER ); |
| 70 | 72 | imageView2.SetY( imageSize*0.5f ); |
| 71 | 73 | stage.Add(imageView2); |
| 72 | - Toolkit::ImageView imageView3 = Toolkit::ImageView::New( redGreen1); | |
| 74 | + Toolkit::ImageView imageView3 = CreateImageView( redGreen1); | |
| 73 | 75 | imageView3.SetParentOrigin( ParentOrigin::CENTER ); |
| 74 | 76 | imageView3.SetSize(imageSize, imageSize); |
| 75 | 77 | imageView2.Add(imageView3); |
| ... | ... | @@ -95,22 +97,41 @@ private: |
| 95 | 97 | } |
| 96 | 98 | } |
| 97 | 99 | |
| 98 | - BufferImage CreateBufferImage( const Vector4& color1, const Vector4& color2 ) | |
| 100 | + std::string CreateTexture( const Vector4& color1, const Vector4& color2 ) | |
| 99 | 101 | { |
| 100 | - BufferImage image = BufferImage::New( 2, 1, Pixel::RGBA8888 ); | |
| 101 | - PixelBuffer* pixelBuffer = image.GetBuffer(); | |
| 102 | - pixelBuffer[0]=0xFF * color1.x; | |
| 103 | - pixelBuffer[1]=0xFF * color1.y; | |
| 104 | - pixelBuffer[2]=0xFF * color1.z; | |
| 105 | - pixelBuffer[3]=0xFF * color1.w; | |
| 106 | - pixelBuffer[4]=0xFF * color2.x; | |
| 107 | - pixelBuffer[5]=0xFF * color2.y; | |
| 108 | - pixelBuffer[6]=0xFF * color2.z; | |
| 109 | - pixelBuffer[7]=0xFF * color2.w; | |
| 110 | - image.Update(); | |
| 111 | - return image; | |
| 102 | + const auto width = 2u; | |
| 103 | + const auto height = 1u; | |
| 104 | + auto size = width * height * 4; | |
| 105 | + auto pixelBuffer = new unsigned char[size]; | |
| 106 | + pixelBuffer[0] = 0xFF * color1.x; | |
| 107 | + pixelBuffer[1] = 0xFF * color1.y; | |
| 108 | + pixelBuffer[2] = 0xFF * color1.z; | |
| 109 | + pixelBuffer[3] = 0xFF * color1.w; | |
| 110 | + pixelBuffer[4] = 0xFF * color2.x; | |
| 111 | + pixelBuffer[5] = 0xFF * color2.y; | |
| 112 | + pixelBuffer[6] = 0xFF * color2.z; | |
| 113 | + pixelBuffer[7] = 0xFF * color2.w; | |
| 114 | + | |
| 115 | + auto pixelData = PixelData::New(pixelBuffer, size, width, height, Pixel::RGBA8888, PixelData::ReleaseFunction::DELETE_ARRAY); | |
| 116 | + auto texture = Texture::New( TextureType::TEXTURE_2D, Pixel::RGBA8888, width, height ); | |
| 117 | + texture.Upload(pixelData); | |
| 118 | + | |
| 119 | + return Toolkit::TextureManager::AddTexture(texture); | |
| 112 | 120 | } |
| 113 | 121 | |
| 122 | + template<typename TextT> | |
| 123 | + Toolkit::ImageView CreateImageView(TextT&& filename) | |
| 124 | + { | |
| 125 | + auto imageView = Toolkit::ImageView::New(); | |
| 126 | + | |
| 127 | + Property::Map propertyMap; | |
| 128 | + propertyMap.Insert(Toolkit::ImageVisual::Property::URL, std::forward<TextT>(filename)); | |
| 129 | + propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE); | |
| 130 | + propertyMap.Insert(Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL); | |
| 131 | + imageView.SetProperty(Toolkit::ImageView::Property::IMAGE, propertyMap ); | |
| 132 | + | |
| 133 | + return imageView; | |
| 134 | + } | |
| 114 | 135 | |
| 115 | 136 | private: |
| 116 | 137 | Application& mApplication; | ... | ... |
examples/item-view/item-view-example.cpp
| ... | ... | @@ -870,7 +870,7 @@ public: // From ItemFactory |
| 870 | 870 | Property::Map propertyMap; |
| 871 | 871 | propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE); |
| 872 | 872 | propertyMap.Insert(ImageVisual::Property::URL, IMAGE_PATHS[ itemId % NUM_IMAGES ] ); |
| 873 | - propertyMap.Insert(DevelVisual::Property::FITTING_MODE, DevelVisual::FILL); | |
| 873 | + propertyMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FILL); | |
| 874 | 874 | ImageView actor = ImageView::New(); |
| 875 | 875 | actor.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap ); |
| 876 | 876 | actor.SetZ( 0.0f ); | ... | ... |
examples/perf-scroll/perf-scroll.cpp
| 1 | 1 | /* |
| 2 | - * Copyright (c) 2017 Samsung Electronics Co., Ltd. | |
| 2 | + * Copyright (c) 2018 Samsung Electronics Co., Ltd. | |
| 3 | 3 | * |
| 4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | 5 | * you may not use this file except in compliance with the License. |
| ... | ... | @@ -16,7 +16,7 @@ |
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | #include <dali-toolkit/dali-toolkit.h> |
| 19 | - | |
| 19 | +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h> | |
| 20 | 20 | #include "shared/utility.h" |
| 21 | 21 | |
| 22 | 22 | using namespace Dali; |
| ... | ... | @@ -278,7 +278,13 @@ public: |
| 278 | 278 | |
| 279 | 279 | for( size_t i(0); i<actorCount; ++i ) |
| 280 | 280 | { |
| 281 | - mImageView[i] = ImageView::New( ImagePath(i) ); | |
| 281 | + mImageView[i] = ImageView::New(); | |
| 282 | + Property::Map propertyMap; | |
| 283 | + propertyMap.Insert(Toolkit::ImageVisual::Property::URL, ImagePath(i)); | |
| 284 | + propertyMap.Insert(Toolkit::Visual::Property::TYPE, Toolkit::Visual::IMAGE); | |
| 285 | + propertyMap.Insert(Toolkit::DevelVisual::Property::VISUAL_FITTING_MODE, Toolkit::DevelVisual::FILL); | |
| 286 | + mImageView[i].SetProperty(Toolkit::ImageView::Property::IMAGE, propertyMap); | |
| 287 | + | |
| 282 | 288 | mImageView[i].SetSize( Vector3(0.0f,0.0f,0.0f) ); |
| 283 | 289 | mImageView[i].SetResizePolicy( ResizePolicy::FIXED, Dimension::ALL_DIMENSIONS ); |
| 284 | 290 | mParent.Add( mImageView[i] ); | ... | ... |