Commit 2288fe80d8c0a5055d365fc176ac58b4faf550ad

Authored by Agnelo Vaz
1 parent a4b20502

homescreen benchmark can use buttons

Added ability for benchmark tool to use checkbox buttons by providing --use-checkbox command line argument

Change-Id: I7ac8c50a3ea594a548b447b3f3b3ec1be6da9bfd
examples/homescreen-benchmark/homescreen-benchmark.cpp
... ... @@ -25,6 +25,11 @@ using Dali::Toolkit::TextLabel;
25 25  
26 26 namespace
27 27 {
  28 +enum IconType
  29 +{
  30 + IMAGEVIEW,
  31 + CHECKBOX
  32 +};
28 33  
29 34 const char* IMAGE_PATH_PREFIX ( DEMO_IMAGE_DIR "application-icon-" );
30 35 const char* IMAGE_PATH_POSTFIX ( ".png" );
... ... @@ -41,11 +46,14 @@ const float DEFAULT_OPT_PAGE_COUNT ( 10 );
41 46 const bool DEFAULT_OPT_USE_TABLEVIEW ( true );
42 47 const bool DEFAULT_OPT_BATCHING_ENABLED ( true );
43 48 const bool DEFAULT_OPT_ICON_LABELS ( true );
  49 +const IconType DEFAULT_OPT_ICON_TYPE ( IMAGEVIEW );
44 50  
45 51 // The image/label area tries to make sure the positioning will be relative to previous sibling
46 52 const float IMAGE_AREA ( 0.60f );
47 53 const float LABEL_AREA ( 0.50f );
48 54  
  55 +
  56 +
49 57 /**
50 58 * Random words used as unique application names.
51 59 * The number matches the value of TOTAL_ICON_DEFINITIONS.
... ... @@ -103,7 +111,8 @@ public:
103 111 mPageCount( DEFAULT_OPT_PAGE_COUNT ),
104 112 mTableViewEnabled( DEFAULT_OPT_USE_TABLEVIEW ),
105 113 mBatchingEnabled( DEFAULT_OPT_BATCHING_ENABLED ),
106   - mIconLabelsEnabled( DEFAULT_OPT_ICON_LABELS )
  114 + mIconLabelsEnabled( DEFAULT_OPT_ICON_LABELS ),
  115 + mIconType( DEFAULT_OPT_ICON_TYPE )
107 116 {
108 117 }
109 118  
... ... @@ -113,6 +122,7 @@ public:
113 122 bool mTableViewEnabled;
114 123 bool mBatchingEnabled;
115 124 bool mIconLabelsEnabled;
  125 + IconType mIconType;
116 126 };
117 127  
118 128 // animation script data
... ... @@ -206,6 +216,42 @@ public:
206 216 return pageActor;
207 217 }
208 218  
  219 + Toolkit::ImageView CreateImageView( const unsigned int currentIconIndex )
  220 + {
  221 + // Create empty image to avoid early renderer creation
  222 + Toolkit::ImageView imageView = Toolkit::ImageView::New();
  223 +
  224 + // Auto-generate the Icons image URL.
  225 + Property::Map map;
  226 + std::stringstream imagePath;
  227 + imagePath << IMAGE_PATH_PREFIX << currentIconIndex << IMAGE_PATH_POSTFIX;
  228 + map[ Dali::Toolkit::ImageVisual::Property::URL ] = imagePath.str();
  229 +
  230 + // Enable/disable batching
  231 + map[ Toolkit::ImageVisual::Property::BATCHING_ENABLED ] = mConfig.mBatchingEnabled;
  232 +
  233 + imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
  234 + imageView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
  235 + imageView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
  236 + imageView.SetAnchorPoint( AnchorPoint::CENTER );
  237 + imageView.SetParentOrigin( ParentOrigin::CENTER );
  238 + imageView.SetSizeModeFactor( Vector3( IMAGE_AREA, IMAGE_AREA, 1.0f ) );
  239 +
  240 + return imageView;
  241 + }
  242 +
  243 + Toolkit::Button CreateButton( const unsigned int currentIconIndex )
  244 + {
  245 + Toolkit::CheckBoxButton button = Toolkit::CheckBoxButton::New();
  246 + button.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
  247 + button.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
  248 + button.SetAnchorPoint( AnchorPoint::CENTER );
  249 + button.SetParentOrigin( ParentOrigin::CENTER );
  250 + button.SetProperty( Toolkit::Button::Property::SELECTED, ( currentIconIndex % 2 == 0 ) ); // Select half the button
  251 +
  252 + return button;
  253 + }
  254 +
209 255 void AddIconsToPage( Actor page )
210 256 {
211 257 Size stageSize( Stage::GetCurrent().GetSize() );
... ... @@ -241,24 +287,21 @@ public:
241 287 iconView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
242 288 }
243 289  
244   - // Create empty image to avoid early renderer creation
245   - Toolkit::ImageView imageView = Toolkit::ImageView::New();
246   -
247   - // Auto-generate the Icons image URL.
248   - Property::Map map;
249   - std::stringstream imagePath;
250   - imagePath << IMAGE_PATH_PREFIX << currentIconIndex << IMAGE_PATH_POSTFIX;
251   - map[ Dali::Toolkit::ImageVisual::Property::URL ] = imagePath.str();
252   -
253   - // Enable/disable batching
254   - map[ Toolkit::ImageVisual::Property::BATCHING_ENABLED ] = mConfig.mBatchingEnabled;
  290 + Actor icon;
255 291  
256   - imageView.SetProperty( Toolkit::ImageView::Property::IMAGE, map );
257   - imageView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS );
258   - imageView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO );
259   - imageView.SetAnchorPoint( AnchorPoint::CENTER );
260   - imageView.SetParentOrigin( ParentOrigin::CENTER );
261   - imageView.SetSizeModeFactor( Vector3( IMAGE_AREA, IMAGE_AREA, 1.0f ) );
  292 + switch( mConfig.mIconType )
  293 + {
  294 + case CHECKBOX:
  295 + {
  296 + icon = CreateButton( currentIconIndex );
  297 + break;
  298 + }
  299 + case IMAGEVIEW:
  300 + {
  301 + icon = CreateImageView( currentIconIndex );
  302 + break;
  303 + }
  304 + }
262 305  
263 306 if( mConfig.mIconLabelsEnabled )
264 307 {
... ... @@ -271,10 +314,10 @@ public:
271 314 textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, ( ( static_cast<float>( ROW_HEIGHT * LABEL_AREA ) * 72.0f ) / dpi.y ) * 0.25f );
272 315 textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" );
273 316 textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP" );
274   - imageView.Add( textLabel );
  317 + icon.Add( textLabel );
275 318 }
276 319  
277   - iconView.Add( imageView );
  320 + iconView.Add( icon );
278 321 page.Add( iconView );
279 322  
280 323 // We only have images and names for a certain number of icons.
... ... @@ -409,6 +452,7 @@ void RunTest( Application&amp; application, const HomescreenBenchmark::Config&amp; confi
409 452 PrintHelp( "-disable-tableview", " Disables the use of TableView for layouting (must be enabled for batching)" );
410 453 PrintHelp( "-disable-batching", " Disables geometry batching" );
411 454 PrintHelp( "-disable-icon-labels", " Disables labels for each icon" );
  455 + PrintHelp( "-use-checkbox", " Uses checkboxes for icons" );
412 456 return;
413 457 }
414 458  
... ... @@ -450,7 +494,11 @@ int DALI_EXPORT_API main( int argc, char **argv )
450 494 {
451 495 config.mIconLabelsEnabled = false;
452 496 }
453   - else if( arg.compare( "--help" ) == 0 )
  497 + else if( arg.compare( "--use-checkbox" ) == 0 )
  498 + {
  499 + config.mIconType = CHECKBOX;
  500 + }
  501 + else if ( arg.compare( "--help" ) == 0 )
454 502 {
455 503 printHelpAndExit = true;
456 504 }
... ...