Commit f0f39a7447b57c1657abe8a1b49989f0bb050e65
Committed by
Gerrit Code Review
Merge "homescreen benchmark can use buttons" into devel/master
Showing
1 changed file
with
69 additions
and
21 deletions
examples/homescreen-benchmark/homescreen-benchmark.cpp
| @@ -25,6 +25,11 @@ using Dali::Toolkit::TextLabel; | @@ -25,6 +25,11 @@ using Dali::Toolkit::TextLabel; | ||
| 25 | 25 | ||
| 26 | namespace | 26 | namespace |
| 27 | { | 27 | { |
| 28 | +enum IconType | ||
| 29 | +{ | ||
| 30 | + IMAGEVIEW, | ||
| 31 | + CHECKBOX | ||
| 32 | +}; | ||
| 28 | 33 | ||
| 29 | const char* IMAGE_PATH_PREFIX ( DEMO_IMAGE_DIR "application-icon-" ); | 34 | const char* IMAGE_PATH_PREFIX ( DEMO_IMAGE_DIR "application-icon-" ); |
| 30 | const char* IMAGE_PATH_POSTFIX ( ".png" ); | 35 | const char* IMAGE_PATH_POSTFIX ( ".png" ); |
| @@ -41,11 +46,14 @@ const float DEFAULT_OPT_PAGE_COUNT ( 10 ); | @@ -41,11 +46,14 @@ const float DEFAULT_OPT_PAGE_COUNT ( 10 ); | ||
| 41 | const bool DEFAULT_OPT_USE_TABLEVIEW ( true ); | 46 | const bool DEFAULT_OPT_USE_TABLEVIEW ( true ); |
| 42 | const bool DEFAULT_OPT_BATCHING_ENABLED ( true ); | 47 | const bool DEFAULT_OPT_BATCHING_ENABLED ( true ); |
| 43 | const bool DEFAULT_OPT_ICON_LABELS ( true ); | 48 | const bool DEFAULT_OPT_ICON_LABELS ( true ); |
| 49 | +const IconType DEFAULT_OPT_ICON_TYPE ( IMAGEVIEW ); | ||
| 44 | 50 | ||
| 45 | // The image/label area tries to make sure the positioning will be relative to previous sibling | 51 | // The image/label area tries to make sure the positioning will be relative to previous sibling |
| 46 | const float IMAGE_AREA ( 0.60f ); | 52 | const float IMAGE_AREA ( 0.60f ); |
| 47 | const float LABEL_AREA ( 0.50f ); | 53 | const float LABEL_AREA ( 0.50f ); |
| 48 | 54 | ||
| 55 | + | ||
| 56 | + | ||
| 49 | /** | 57 | /** |
| 50 | * Random words used as unique application names. | 58 | * Random words used as unique application names. |
| 51 | * The number matches the value of TOTAL_ICON_DEFINITIONS. | 59 | * The number matches the value of TOTAL_ICON_DEFINITIONS. |
| @@ -103,7 +111,8 @@ public: | @@ -103,7 +111,8 @@ public: | ||
| 103 | mPageCount( DEFAULT_OPT_PAGE_COUNT ), | 111 | mPageCount( DEFAULT_OPT_PAGE_COUNT ), |
| 104 | mTableViewEnabled( DEFAULT_OPT_USE_TABLEVIEW ), | 112 | mTableViewEnabled( DEFAULT_OPT_USE_TABLEVIEW ), |
| 105 | mBatchingEnabled( DEFAULT_OPT_BATCHING_ENABLED ), | 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,6 +122,7 @@ public: | ||
| 113 | bool mTableViewEnabled; | 122 | bool mTableViewEnabled; |
| 114 | bool mBatchingEnabled; | 123 | bool mBatchingEnabled; |
| 115 | bool mIconLabelsEnabled; | 124 | bool mIconLabelsEnabled; |
| 125 | + IconType mIconType; | ||
| 116 | }; | 126 | }; |
| 117 | 127 | ||
| 118 | // animation script data | 128 | // animation script data |
| @@ -206,6 +216,42 @@ public: | @@ -206,6 +216,42 @@ public: | ||
| 206 | return pageActor; | 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 | void AddIconsToPage( Actor page ) | 255 | void AddIconsToPage( Actor page ) |
| 210 | { | 256 | { |
| 211 | Size stageSize( Stage::GetCurrent().GetSize() ); | 257 | Size stageSize( Stage::GetCurrent().GetSize() ); |
| @@ -241,24 +287,21 @@ public: | @@ -241,24 +287,21 @@ public: | ||
| 241 | iconView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); | 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 | if( mConfig.mIconLabelsEnabled ) | 306 | if( mConfig.mIconLabelsEnabled ) |
| 264 | { | 307 | { |
| @@ -271,10 +314,10 @@ public: | @@ -271,10 +314,10 @@ public: | ||
| 271 | textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, ( ( static_cast<float>( ROW_HEIGHT * LABEL_AREA ) * 72.0f ) / dpi.y ) * 0.25f ); | 314 | textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, ( ( static_cast<float>( ROW_HEIGHT * LABEL_AREA ) * 72.0f ) / dpi.y ) * 0.25f ); |
| 272 | textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); | 315 | textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); |
| 273 | textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP" ); | 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 | page.Add( iconView ); | 321 | page.Add( iconView ); |
| 279 | 322 | ||
| 280 | // We only have images and names for a certain number of icons. | 323 | // We only have images and names for a certain number of icons. |
| @@ -409,6 +452,7 @@ void RunTest( Application& application, const HomescreenBenchmark::Config& confi | @@ -409,6 +452,7 @@ void RunTest( Application& application, const HomescreenBenchmark::Config& confi | ||
| 409 | PrintHelp( "-disable-tableview", " Disables the use of TableView for layouting (must be enabled for batching)" ); | 452 | PrintHelp( "-disable-tableview", " Disables the use of TableView for layouting (must be enabled for batching)" ); |
| 410 | PrintHelp( "-disable-batching", " Disables geometry batching" ); | 453 | PrintHelp( "-disable-batching", " Disables geometry batching" ); |
| 411 | PrintHelp( "-disable-icon-labels", " Disables labels for each icon" ); | 454 | PrintHelp( "-disable-icon-labels", " Disables labels for each icon" ); |
| 455 | + PrintHelp( "-use-checkbox", " Uses checkboxes for icons" ); | ||
| 412 | return; | 456 | return; |
| 413 | } | 457 | } |
| 414 | 458 | ||
| @@ -450,7 +494,11 @@ int DALI_EXPORT_API main( int argc, char **argv ) | @@ -450,7 +494,11 @@ int DALI_EXPORT_API main( int argc, char **argv ) | ||
| 450 | { | 494 | { |
| 451 | config.mIconLabelsEnabled = false; | 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 | printHelpAndExit = true; | 503 | printHelpAndExit = true; |
| 456 | } | 504 | } |