Commit 960290ef8daf5612ff68294f9f86f5fc569b1588

Authored by Victor Cebollada
2 parents 317401ef d486a8ad

[dali_1.3.8] Merge branch 'devel/master'

Change-Id: I7ea90c88287fa7b78dcb58b974c7cd5600757875
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/animated-images/animated-images-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.
... ... @@ -17,260 +17,278 @@
17 17  
18 18 #include <dali-toolkit/dali-toolkit.h>
19 19 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
20   -#include "shared/utility.h"
  20 +#include <dali-toolkit/devel-api/controls/control-devel.h>
  21 +#include <dali-toolkit/devel-api/visuals/animated-image-visual-actions-devel.h>
21 22  
22 23 using namespace Dali;
23 24 using namespace Dali::Toolkit;
24 25  
25 26 namespace
26 27 {
27   -const char * const PLAY_ICON( DEMO_IMAGE_DIR "icon-play.png" );
  28 +const char * const PLAY_ICON_UNSELECTED( DEMO_IMAGE_DIR "icon-play.png" );
28 29 const char * const PLAY_ICON_SELECTED( DEMO_IMAGE_DIR "icon-play-selected.png" );
29 30  
30   -const char* const STATIC_GIF_DOG( DEMO_IMAGE_DIR "dog-static.gif" );
31   -const char* const ANIMATE_GIF_DOG( DEMO_IMAGE_DIR "dog-anim.gif" );
  31 +const unsigned int ANIMATED_IMAGE_COUNT = 2;
32 32  
33   -const char* const STATIC_GIF_LOGO( DEMO_IMAGE_DIR "dali-logo-static.gif" );
34   -const char* const ANIMATE_GIF_LOGO( DEMO_IMAGE_DIR "dali-logo-anim.gif" );
  33 +const char * ANIMATED_GIF_URLS[ ANIMATED_IMAGE_COUNT ] =
  34 +{
  35 + DEMO_IMAGE_DIR "dog-anim.gif",
  36 + DEMO_IMAGE_DIR "dali-logo-anim.gif"
  37 +};
  38 +
  39 +const char * ANIMATED_ARRAY_URL_FORMATS[ ANIMATED_IMAGE_COUNT ] =
  40 +{
  41 + DEMO_IMAGE_DIR "dog-anim-%03d.png", // Images are named dog-anim-001.png, dog-anim-002.png, etc.
  42 + DEMO_IMAGE_DIR "dali-logo-anim-%03d.png" // Images are named dali-logo-anim-001.png, dali-logo-anim-002.png, etc.
  43 +};
35 44  
36   -const char* const ANIMATE_PIXEL_AREA( "Animate PixelArea" );
37   -const char* const ANIMATE_PIXEL_AREA_AND_SCALE( "Animate PixelArea & Scale" );
  45 +int ANIMATED_ARRAY_NUMBER_OF_FRAMES[ ANIMATED_IMAGE_COUNT ] =
  46 +{
  47 + 8,
  48 + 15
  49 +};
38 50  
39   -const char* const STATIC_IMAGE_ARRAY_DOG( DEMO_IMAGE_DIR "dog-anim-001.png" );
40   -const char* const ANIMATE_IMAGE_ARRAY_DOG( DEMO_IMAGE_DIR "dog-anim-%03d.png" );
  51 +const char * GIF_RADIO_BUTTON_NAME( "Gif" );
  52 +const char * ARRAY_RADIO_BUTTON_NAME( "Array" );
41 53  
42   -const char* const STATIC_IMAGE_ARRAY_LOGO( DEMO_IMAGE_DIR "dali-logo-anim-001.png" );
43   -const char* const ANIMATE_IMAGE_ARRAY_LOGO( DEMO_IMAGE_DIR "dali-logo-anim-%03d.png" );
  54 +/// Structure to specify the layout information for the animated images views.
  55 +struct ImageLayoutInfo
  56 +{
  57 + Vector3 anchorPoint;
  58 + Vector3 parentOrigin;
  59 + float yPosition;
  60 +};
44 61  
  62 +ImageLayoutInfo IMAGE_LAYOUT_INFO[ ANIMATED_IMAGE_COUNT ] =
  63 +{
  64 + { AnchorPoint::BOTTOM_CENTER, ParentOrigin::CENTER, -80.0f },
  65 + { AnchorPoint::TOP_CENTER, ParentOrigin::CENTER, 80.0f }
  66 +};
45 67  
46   -const Vector4 DIM_COLOR( 0.85f, 0.85f, 0.85f, 0.85f );
47   -}
  68 +} // unnamed namespace
48 69  
49   -/* This example shows how to display a GIF image.
50   - * First a static GIF image is loaded and then when the user presses on the "Play" icon,
51   - * the static image is replaced by an animated one
  70 +/**
  71 + * @brief This demonstrates how to display and control Animated Images.
  72 + *
  73 + * - It displays two animated images, an animated dog and an animated DALi logo.
  74 + * - The images are loaded paused, a play button is overlayed on top of the images to play the animated image.
  75 + * - Radio buttons at the bottom allow the user to change between Animated GIFs and a collection of Image Arrays.
52 76 */
53   -
54 77 class AnimatedImageController : public ConnectionTracker
55 78 {
56 79 public:
57   - enum ImageType
58   - {
59   - GIF,
60   - IMAGE_ARRAY
61   - };
62   - enum StateType
63   - {
64   - STATIC,
65   - ANIMATED
66   - };
67 80  
  81 + /**
  82 + * @brief Constructor.
  83 + * @param[in] application A reference to the Application class
  84 + */
68 85 AnimatedImageController( Application& application )
69 86 : mApplication( application ),
70   - mImageType(GIF)
  87 + mImageType( ImageType::GIF )
71 88 {
72 89 // Connect to the Application's Init signal
73 90 mApplication.InitSignal().Connect( this, &AnimatedImageController::Create );
74 91 }
75 92  
76   - ~AnimatedImageController()
  93 +private:
  94 +
  95 + /**
  96 + * @brief The image types supported by the application.
  97 + */
  98 + enum class ImageType
77 99 {
78   - // Nothing to do here;
79   - }
  100 + GIF, ///< Displays Animated GIF Files.
  101 + IMAGE_ARRAY ///< Displays an array of URLs that are used as an animated image.
  102 + };
80 103  
81   - // The Init signal is received once (only) during the Application lifetime
  104 + /**
  105 + * @brief Called to initialise the application content.
  106 + * @param[in] application A reference to the Application class
  107 + */
82 108 void Create( Application& application )
83 109 {
84   - // Get a handle to the stage
  110 + // Set the stage background color and connect to the stage's key signal to allow Back and Escape to exit.
85 111 Stage stage = Stage::GetCurrent();
86 112 stage.SetBackgroundColor( Color::WHITE );
87   - // Tie-in input event handlers:
88 113 stage.KeyEventSignal().Connect( this, &AnimatedImageController::OnKeyEvent );
89 114  
90   - CreateStaticImageView( 0 );
91   - CreateStaticImageView( 1 );
  115 + // Create the animated image-views
  116 + CreateAnimatedImageViews();
  117 +
  118 + // Create radio buttons to change between GIF images and Image Arrays
  119 + CreateRadioButtonLayout();
  120 +
  121 + // Create a tap gesture detector to use to pause the animated images
  122 + mTapDetector = TapGestureDetector::New();
  123 + mTapDetector.DetectedSignal().Connect( this, &AnimatedImageController::OnTap );
  124 + }
92 125  
93   - mGifButton = Toolkit::RadioButton::New("Gif");
94   - mGifButton.SetProperty( Button::Property::SELECTED, true );
95   - mArrayButton = Toolkit::RadioButton::New("Array");
96   - mGifButton.ClickedSignal().Connect( this, &AnimatedImageController::OnTypeButtonClicked );
97   - mArrayButton.ClickedSignal().Connect( this, &AnimatedImageController::OnTypeButtonClicked );
  126 + /**
  127 + * @brief Creates and lays out radio buttons to allow changing between the different image types.
  128 + */
  129 + void CreateRadioButtonLayout()
  130 + {
  131 + mGifButton = CreateRadioButton( GIF_RADIO_BUTTON_NAME, true );
  132 + mArrayButton = CreateRadioButton( ARRAY_RADIO_BUTTON_NAME, false );
98 133  
99   - Toolkit::TableView radioButtonLayout = Toolkit::TableView::New(1, 2);
100   - radioButtonLayout.SetName("RadioButtonsLayout");
  134 + Toolkit::TableView radioButtonLayout = Toolkit::TableView::New( 1, 2 );
  135 + radioButtonLayout.SetName( "RadioButtonsLayout" );
101 136 radioButtonLayout.SetResizePolicy( ResizePolicy::FIT_TO_CHILDREN, Dimension::HEIGHT );
102 137 radioButtonLayout.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::WIDTH );
103 138 radioButtonLayout.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
104 139 radioButtonLayout.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
105   - radioButtonLayout.SetFitHeight(0);
106   - radioButtonLayout.AddChild( mGifButton, TableView::CellPosition(0,0) );
107   - radioButtonLayout.AddChild( mArrayButton, TableView::CellPosition(0,1) );
108   - radioButtonLayout.SetCellAlignment( TableView::CellPosition( 0, 0 ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER );
109   - radioButtonLayout.SetCellAlignment( TableView::CellPosition( 0, 1 ), HorizontalAlignment::CENTER, VerticalAlignment::CENTER );
  140 + radioButtonLayout.SetFitHeight( 0 );
  141 + radioButtonLayout.AddChild( mGifButton, TableView::CellPosition( 0, 0 ) );
  142 + radioButtonLayout.AddChild( mArrayButton, TableView::CellPosition( 0, 1 ) );
  143 + radioButtonLayout.SetCellAlignment( TableView::CellPosition( 0, 0 ),
  144 + HorizontalAlignment::CENTER,
  145 + VerticalAlignment::CENTER );
  146 + radioButtonLayout.SetCellAlignment( TableView::CellPosition( 0, 1 ),
  147 + HorizontalAlignment::CENTER,
  148 + VerticalAlignment::CENTER );
110 149 radioButtonLayout.SetY( -10.0f );
111 150  
112   - stage.Add( radioButtonLayout );
113   -
114   - mTapDetector = TapGestureDetector::New();
115   - mTapDetector.DetectedSignal().Connect( this, &AnimatedImageController::OnTap );
  151 + Stage::GetCurrent().Add( radioButtonLayout );
116 152 }
117 153  
118   - void CreateStaticImageView( int index )
  154 + /**
  155 + * @brief Creates a radio button.
  156 + * @param[in] name The name of the button
  157 + * @param[in] selected Whether the button is selected
  158 + * @return The created radio-button
  159 + */
  160 + RadioButton CreateRadioButton( const char * const name, bool selected )
119 161 {
120   - Actor& actor = (index==0) ? mActorDog : mActorLogo;
121   -
122   - Stage stage = Stage::GetCurrent();
123   - if( actor )
124   - {
125   - stage.Remove( actor );
126   - }
127   -
128   - Property::Value viewSetup = SetupViewProperties( mImageType, STATIC, index, false );
129   - actor = CreateImageViewWithPlayButton( viewSetup );
130   - SetLayout(actor, index);
131   - stage.Add( actor );
  162 + RadioButton radioButton = Toolkit::RadioButton::New( name );
  163 + radioButton.SetProperty( Button::Property::SELECTED, selected );
  164 + radioButton.ClickedSignal().Connect( this, &AnimatedImageController::OnRadioButtonClicked );
  165 + return radioButton;
132 166 }
133 167  
134   -
135   - void CreateAnimImageView( int index )
  168 + /**
  169 + * @brief Creates the required animated image views.
  170 + */
  171 + void CreateAnimatedImageViews()
136 172 {
137   - Actor& actor = (index==0) ? mActorDog : mActorLogo;
138   -
139   - Stage stage = Stage::GetCurrent();
140   - if( actor )
  173 + for( unsigned int index = 0; index < ANIMATED_IMAGE_COUNT; ++index )
141 174 {
142   - stage.Remove( actor );
143   - }
  175 + Stage stage = Stage::GetCurrent();
144 176  
145   - const char* label = (index==0) ? ANIMATE_PIXEL_AREA_AND_SCALE : ANIMATE_PIXEL_AREA;
  177 + Control& control = ( index == 0 ) ? mActorDog : mActorLogo;
  178 + if( control )
  179 + {
  180 + // Remove the previous control from the stage, it's resources (and children) will be deleted automatically
  181 + control.Unparent();
  182 + }
146 183  
147   - Property::Value viewSetup = SetupViewProperties( mImageType, ANIMATED, index, true );
148   - actor = CreateImageViewWithAnimatePixelAreaButton( viewSetup, label);
149   - SetLayout(actor, index);
  184 + // Create and lay out the image view according to the index
  185 + control = Toolkit::ImageView::New();
  186 + control.SetProperty( Toolkit::ImageView::Property::IMAGE, SetupViewProperties( mImageType, index ) );
  187 + control.SetAnchorPoint( IMAGE_LAYOUT_INFO[ index ].anchorPoint );
  188 + control.SetParentOrigin( IMAGE_LAYOUT_INFO[ index ].parentOrigin );
  189 + control.SetY( IMAGE_LAYOUT_INFO[ index ].yPosition );
150 190  
151   - stage.Add( actor );
  191 + // We do not want the animated image playing when it's added to the stage.
  192 + PauseAnimatedImage( control );
  193 +
  194 + stage.Add( control );
  195 + }
152 196 }
153 197  
154   - void SetLayout( Actor actor, int index )
  198 + /**
  199 + * @brief Plays the passed in animated image.
  200 + * @details Also sets up the control so it can be paused when tapped.
  201 + * @param[in] control The animated image to play
  202 + */
  203 + void PlayAnimatedImage( Control& control )
155 204 {
156   - if( index == 0 )
157   - {
158   - actor.SetAnchorPoint( AnchorPoint::BOTTOM_CENTER );
159   - actor.SetY( -80.f );
160   - }
161   - else
  205 + DevelControl::DoAction( control,
  206 + ImageView::Property::IMAGE,
  207 + DevelAnimatedImageVisual::Action::PLAY,
  208 + Property::Value() );
  209 +
  210 + if( mTapDetector )
162 211 {
163   - actor.SetAnchorPoint( AnchorPoint::TOP_CENTER );
164   - actor.SetY( 80.f );
  212 + mTapDetector.Attach( control );
165 213 }
166 214 }
167 215  
168 216 /**
169   - * Create the gif image view with an overlay play button.
  217 + * @brief Pauses the animated image.
  218 + * @details Adds a Play button to the control and sets both up so that the animated image can be played again when
  219 + * the button is tapped.
  220 + * @param[in] control The animated image to pause
170 221 */
171   - Toolkit::ImageView CreateImageViewWithPlayButton( Property::Value& viewSetup )
  222 + void PauseAnimatedImage( Control& control )
172 223 {
173   - Toolkit::ImageView imageView = Toolkit::ImageView::New();
174   - imageView.SetProperty( ImageView::Property::IMAGE, viewSetup );
175   - imageView.SetParentOrigin( ParentOrigin::CENTER );
  224 + DevelControl::DoAction( control,
  225 + ImageView::Property::IMAGE,
  226 + DevelAnimatedImageVisual::Action::PAUSE,
  227 + Property::Value() );
176 228  
177   - // Create a push button, and add it as child of the image view
  229 + // Create a push button, and add it as child of the control
178 230 Toolkit::PushButton animateButton = Toolkit::PushButton::New();
179   - animateButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, PLAY_ICON );
  231 + animateButton.SetProperty( Toolkit::DevelButton::Property::UNSELECTED_BACKGROUND_VISUAL, PLAY_ICON_UNSELECTED );
180 232 animateButton.SetProperty( Toolkit::DevelButton::Property::SELECTED_BACKGROUND_VISUAL, PLAY_ICON_SELECTED );
181 233 animateButton.SetParentOrigin( ParentOrigin::CENTER );
182 234 animateButton.SetAnchorPoint( AnchorPoint::CENTER );
183 235 animateButton.ClickedSignal().Connect( this, &AnimatedImageController::OnPlayButtonClicked );
184   - imageView.Add( animateButton );
  236 + control.Add( animateButton );
185 237  
186   - // Apply dim color on the gif view and the play button
187   - imageView.SetColor( DIM_COLOR );
188   -
189   - return imageView;
190   - }
191   -
192   - Toolkit::ImageView CreateImageViewWithAnimatePixelAreaButton( Property::Value& viewSetup, const std::string& buttonLabel )
193   - {
194   - Toolkit::ImageView imageView = Toolkit::ImageView::New();
195   - imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, viewSetup );
196   - imageView.SetParentOrigin( ParentOrigin::CENTER );
197   -
198   - // Create a push button, and add it as child of the image view
199   - Toolkit::PushButton animateButton = Toolkit::PushButton::New();
200   - animateButton.SetProperty( Toolkit::Button::Property::LABEL, buttonLabel );
201   - animateButton.SetParentOrigin( ParentOrigin::BOTTOM_CENTER );
202   - animateButton.SetAnchorPoint( AnchorPoint::TOP_CENTER );
203   - animateButton.SetY( 20.f );
204   -
205   - animateButton.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS );
206   - animateButton.SetProperty( Actor::Property::INHERIT_SCALE, false );
207   - imageView.Add( animateButton );
208   -
209   - mTapDetector.Attach( animateButton );
210   - mTapDetector.Attach( imageView );
211   -
212   - return imageView;
  238 + if( mTapDetector )
  239 + {
  240 + mTapDetector.Detach( control );
  241 + }
213 242 }
214 243  
  244 + /**
  245 + * @brief Called when the play button is clicked.
  246 + * @details This method is used to start playing the parent image-view of the clicked button.
  247 + * @param[in] button The button that has been clicked
  248 + * @return We return true to state that we handled the event
  249 + */
215 250 bool OnPlayButtonClicked( Toolkit::Button button )
216 251 {
217   - Stage stage = Stage::GetCurrent();
  252 + Control control = ( button.GetParent() == mActorDog ) ? mActorDog : mActorLogo;
  253 + PlayAnimatedImage( control );
  254 +
  255 + button.Unparent();
218 256  
219   - // With play button clicked, the static gif is replaced with animated gif.
220   - if( button.GetParent() == mActorDog )
221   - {
222   - // remove the static gif view, the play button is also removed as its child.
223   - CreateAnimImageView( 0 );
224   - }
225   - else // button.GetParent() == mActorLogo
226   - {
227   - // remove the static gif view, the play button is also removed as its child.
228   - CreateAnimImageView( 1 );
229   - }
230 257 return true;
231 258 }
232 259  
233   - void OnTap(Dali::Actor actor, const Dali::TapGesture& tap)
  260 + /**
  261 + * @brief Called when the animated image views are tapped.
  262 + * @details This method is used to pause the tapped animated image view.
  263 + * @param[in] actor The actor that's tapped
  264 + */
  265 + void OnTap( Dali::Actor actor, const Dali::TapGesture& /* tap */ )
234 266 {
235   - if( actor.GetParent() == mActorDog ) // "Animate Pixel Area" button is clicked
236   - {
237   - Animation animation = Animation::New( 3.f );
238   - animation.AnimateTo( Property( mActorDog, ImageView::Property::PIXEL_AREA ), Vector4( -1.0, 0.0, 3.f, 1.f ), AlphaFunction::SIN );
239   - animation.AnimateTo( Property( mActorDog, Actor::Property::SCALE_X ), 3.f, AlphaFunction::SIN );
240   - animation.Play();
241   - }
242   - else if( actor.GetParent() == mActorLogo ) // "Animate Pixel Area" button is clicked
243   - {
244   - Animation animation = Animation::New( 3.f );
245   - animation.AnimateTo( Property( mActorLogo, ImageView::Property::PIXEL_AREA ), Vector4( 0.0, 1.0, 1.f, 1.f ), AlphaFunction::SIN );
246   - animation.Play();
247   - }
248   - else if( actor == mActorDog ) // stop the animated gif, switch to static view
249   - {
250   - CreateStaticImageView( 0 );
251   - }
252   - else if( actor == mActorLogo ) // stop the animated gif, switch to static view
253   - {
254   - CreateStaticImageView( 1 );
255   - }
  267 + Control control = ( actor == mActorDog ) ? mActorDog : mActorLogo;
  268 + PauseAnimatedImage( control );
256 269 }
257 270  
258   - bool OnTypeButtonClicked( Toolkit::Button button )
  271 + /**
  272 + * @brief Called when a radio button is clicked.
  273 + * @details This method is used to change between the different image types.
  274 + * @param[in] button The clicked radio-button
  275 + * @return We return true to state that we handled the event.
  276 + *
  277 + */
  278 + bool OnRadioButtonClicked( Toolkit::Button button )
259 279 {
260   - if( button == mGifButton )
261   - {
262   - mImageType = GIF;
263   - }
264   - else
265   - {
266   - mImageType = IMAGE_ARRAY;
267   - }
268   - Stage stage = Stage::GetCurrent();
269   - CreateStaticImageView( 0 );
270   - CreateStaticImageView( 1 );
  280 + mImageType = ( button == mGifButton ) ? ImageType::GIF : ImageType::IMAGE_ARRAY;
  281 +
  282 + CreateAnimatedImageViews();
271 283 return true;
272 284 }
273 285  
  286 + /**
  287 + * @brief Called when any key event is received.
  288 + *
  289 + * Will use this to quit the application if Back or the Escape key is received
  290 + * @param[in] event The key event information
  291 + */
274 292 void OnKeyEvent(const KeyEvent& event)
275 293 {
276 294 if(event.state == KeyEvent::Down)
... ... @@ -282,82 +300,60 @@ public:
282 300 }
283 301 }
284 302  
285   - Property::Value SetupViewProperties( ImageType type, StateType state, int index, bool wrap )
  303 + /**
  304 + * @brief Sets up the view properties appropriately.
  305 + * @param[in] type The Image type
  306 + * @param[in] index The index
  307 + * @return The set up property value
  308 + */
  309 + Property::Value SetupViewProperties( ImageType type, int index )
286 310 {
287 311 Property::Map map;
288 312  
289   - AddUrl( map, type, state, index );
290   - AddWrap( map, wrap && state != 0, index );
  313 + AddUrl( map, type, index );
291 314 AddCache( map, type, index );
292 315 return Property::Value(map);
293 316 }
294 317  
295   - void AddUrl( Property::Map& map, ImageType type, StateType state, int index )
  318 + /**
  319 + * @brief Adds the URL to the given map appropriately.
  320 + * @param[in/out] map The map to add the URL details to
  321 + * @param[in] type The Image type
  322 + * @param[in] index The index
  323 + */
  324 + void AddUrl( Property::Map& map, ImageType type, int index )
296 325 {
297   - const char* urls[2][2] =
298   - { { STATIC_GIF_DOG, STATIC_GIF_LOGO },
299   - { ANIMATE_GIF_DOG, ANIMATE_GIF_LOGO }
300   - };
301   - const char* urlFormats[2][2] =
302   - { { STATIC_IMAGE_ARRAY_DOG, STATIC_IMAGE_ARRAY_LOGO } ,
303   - { ANIMATE_IMAGE_ARRAY_DOG, ANIMATE_IMAGE_ARRAY_LOGO } };
304   -
305   - int numFrames[2] = { 8, 15 };
306   -
307   - if( type == GIF )
  326 + if( type == ImageType::GIF )
308 327 {
309   - map.Add( Toolkit::ImageVisual::Property::URL, Property::Value( urls[state][index] ) );
  328 + map.Add( Toolkit::ImageVisual::Property::URL, Property::Value( ANIMATED_GIF_URLS[ index ] ) );
310 329 }
311 330 else
312 331 {
313   - if( state == STATIC )
  332 + Property::Array frameUrls;
  333 + for( int i = 1; i <= ANIMATED_ARRAY_NUMBER_OF_FRAMES[ index ]; ++i )
314 334 {
315   - Property::Array frameUrls;
316   - frameUrls.Add(Property::Value( urlFormats[0][index] ));
317   - map.Add( Toolkit::ImageVisual::Property::URL, frameUrls );
318   - }
319   - else
320   - {
321   - Property::Array frameUrls;
322   - for( int i=1; i<= numFrames[index]; ++i )
  335 + char* buffer;
  336 + int len = asprintf( &buffer, ANIMATED_ARRAY_URL_FORMATS[ index ], i );
  337 + if( len > 0 )
323 338 {
324   - char* buffer;
325   - int len = asprintf( &buffer, urlFormats[1][index], i);
326   - if( len > 0 )
327   - {
328   - std::string frameUrl(buffer);
329   - free(buffer);
330   - frameUrls.Add( Property::Value( frameUrl ) );
331   - }
  339 + std::string frameUrl( buffer );
  340 + free( buffer );
  341 + frameUrls.Add( Property::Value( frameUrl ) );
332 342 }
333   - map.Add( Toolkit::ImageVisual::Property::URL, Property::Value( frameUrls ) );
334 343 }
  344 + map.Add( Toolkit::ImageVisual::Property::URL, Property::Value( frameUrls ) );
335 345 }
336 346 }
337 347  
338   - void AddWrap( Property::Map& map, bool wrap, int index )
339   - {
340   - WrapMode::Type wrapModes[2][2] = {
341   - { WrapMode::REPEAT, WrapMode::DEFAULT },
342   - { WrapMode::DEFAULT, WrapMode::MIRRORED_REPEAT } };
343   -
344   - if( wrap )
345   - {
346   - map
347   - .Add( Toolkit::ImageVisual::Property::WRAP_MODE_U, wrapModes[index][0] )
348   - .Add( Toolkit::ImageVisual::Property::WRAP_MODE_V, wrapModes[index][1] );
349   - }
350   - else
351   - {
352   - map
353   - .Add( Toolkit::ImageVisual::Property::WRAP_MODE_U, WrapMode::DEFAULT )
354   - .Add( Toolkit::ImageVisual::Property::WRAP_MODE_V, WrapMode::DEFAULT );
355   - }
356   - }
357   -
  348 + /**
  349 + * @brief Adds the cache properties, if required to the map.
  350 + * @param[in/out] map The map to add the URL details to
  351 + * @param[in] type The Image type
  352 + * @param[in] index The index
  353 + */
358 354 void AddCache( Property::Map& map, ImageType type, int index )
359 355 {
360   - if( type == IMAGE_ARRAY )
  356 + if( type == ImageType::IMAGE_ARRAY )
361 357 {
362 358 map
363 359 .Add( Toolkit::ImageVisual::Property::BATCH_SIZE, 4 )
... ... @@ -367,16 +363,19 @@ public:
367 363 }
368 364  
369 365 private:
370   - Application& mApplication;
371   - Toolkit::ImageView mActorDog;
372   - Toolkit::ImageView mActorLogo;
373   - Toolkit::RadioButton mGifButton;
374   - Toolkit::RadioButton mArrayButton;
375   - TapGestureDetector mTapDetector;
376   - ImageType mImageType;
  366 + Application& mApplication; ///< A reference to the application.
  367 +
  368 + Toolkit::ImageView mActorDog; ///< The current dog image view.
  369 + Toolkit::ImageView mActorLogo; ///< The current logo image view.
  370 +
  371 + Toolkit::RadioButton mGifButton; ///< The Gif Radio Button.
  372 + Toolkit::RadioButton mArrayButton; ///< The Array Radio Button.
  373 +
  374 + TapGestureDetector mTapDetector; ///< The tap detector.
  375 +
  376 + ImageType mImageType; ///< The current Image type.
377 377 };
378 378  
379   -//
380 379 int DALI_EXPORT_API main( int argc, char **argv )
381 380 {
382 381 Application application = Application::New( &argc, &argv );
... ...
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
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,8 @@
23 23 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
24 24 #include <dali-toolkit/public-api/visuals/border-visual-properties.h>
25 25 #include <dali-toolkit/public-api/visuals/visual-properties.h>
  26 +#include <dali-toolkit/public-api/visuals/image-visual-properties.h>
  27 +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
26 28  
27 29 using namespace Dali;
28 30 using namespace Dali::Toolkit;
... ... @@ -102,7 +104,12 @@ unsigned int ClippingItemFactory::GetNumberOfItems()
102 104 Actor ClippingItemFactory::NewItem( unsigned int itemId )
103 105 {
104 106 // Create an image view for this item
105   - ImageView actor = ImageView::New( IMAGE_PATHS[ itemId % NUM_IMAGES ] );
  107 + Property::Map propertyMap;
  108 + propertyMap.Insert(Visual::Property::TYPE, Visual::IMAGE);
  109 + propertyMap.Insert(ImageVisual::Property::URL, IMAGE_PATHS[ itemId % NUM_IMAGES ] );
  110 + propertyMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FILL);
  111 + ImageView actor = ImageView::New();
  112 + actor.SetProperty(Toolkit::ImageView::Property::IMAGE, propertyMap);
106 113  
107 114 // Add a border image child actor
108 115 ImageView borderActor = ImageView::New();
... ...
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
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.
... ... @@ -21,6 +21,7 @@
21 21 #include <dali/dali.h>
22 22 #include <dali-toolkit/dali-toolkit.h>
23 23 #include <dali-toolkit/devel-api/controls/buttons/button-devel.h>
  24 +#include <dali-toolkit/devel-api/visuals/visual-properties-devel.h>
24 25  
25 26 using namespace Dali;
26 27 using namespace Dali::Toolkit;
... ... @@ -866,7 +867,12 @@ public: // From ItemFactory
866 867 virtual Actor NewItem(unsigned int itemId)
867 868 {
868 869 // Create an image view for this item
869   - ImageView actor = ImageView::New( IMAGE_PATHS[ itemId % NUM_IMAGES ] );
  870 + Property::Map propertyMap;
  871 + propertyMap.Insert(Toolkit::Visual::Property::TYPE, Visual::IMAGE);
  872 + propertyMap.Insert(ImageVisual::Property::URL, IMAGE_PATHS[ itemId % NUM_IMAGES ] );
  873 + propertyMap.Insert(DevelVisual::Property::VISUAL_FITTING_MODE, DevelVisual::FILL);
  874 + ImageView actor = ImageView::New();
  875 + actor.SetProperty( Toolkit::ImageView::Property::IMAGE, propertyMap );
870 876 actor.SetZ( 0.0f );
871 877 actor.SetPosition( INITIAL_OFFSCREEN_POSITION );
872 878  
... ...
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] );
... ...
packaging/com.samsung.dali-demo.spec
... ... @@ -2,7 +2,7 @@
2 2  
3 3 Name: com.samsung.dali-demo
4 4 Summary: The OpenGLES Canvas Core Demo
5   -Version: 1.3.7
  5 +Version: 1.3.8
6 6 Release: 1
7 7 Group: System/Libraries
8 8 License: Apache-2.0
... ...