Commit c2cab8a32da3c02eee109ea1ee4481047e221f74
[dali_1.1.20] Merge branch 'devel/master'
Change-Id: I0a6e1b67d86d47360c012adf0dd57716666149f9
| ... | ... | @@ -133,4 +133,7 @@ |
| 133 | 133 | <ui-application appid="image-view-alpha-blending.example" exec="/usr/apps/com.samsung.dali-demo/bin/image-view-alpha-blending.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> |
| 134 | 134 | <label>ImageView Alpha Blending</label> |
| 135 | 135 | </ui-application> |
| 136 | + <ui-application appid="homescreen-benchmark.example" exec="/usr/apps/com.samsung.dali-demo/bin/homescreen-benchmark.example" nodisplay="true" multiple="false" type="c++app" taskmanage="true"> | |
| 137 | + <label>Homescreen Benchmark</label> | |
| 138 | + </ui-application> | |
| 136 | 139 | </manifest> | ... | ... |
| 1 | +/* | |
| 2 | + * Copyright (c) 2014 Samsung Electronics Co., Ltd. | |
| 3 | + * | |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | + * you may not use this file except in compliance with the License. | |
| 6 | + * You may obtain a copy of the License at | |
| 7 | + * | |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | + * | |
| 10 | + * Unless required by applicable law or agreed to in writing, software | |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | + * See the License for the specific language governing permissions and | |
| 14 | + * limitations under the License. | |
| 15 | + * | |
| 16 | + */ | |
| 17 | + | |
| 18 | +#include <dali-toolkit/dali-toolkit.h> | |
| 19 | + | |
| 20 | +#include <iostream> | |
| 21 | + | |
| 22 | +using namespace Dali; | |
| 23 | +using Dali::Toolkit::TextLabel; | |
| 24 | + | |
| 25 | +namespace | |
| 26 | +{ | |
| 27 | +const char* IMAGE_PATH[] = { | |
| 28 | + DEMO_IMAGE_DIR "application-icon-0.png", | |
| 29 | + DEMO_IMAGE_DIR "application-icon-100.png", | |
| 30 | + DEMO_IMAGE_DIR "application-icon-101.png", | |
| 31 | + DEMO_IMAGE_DIR "application-icon-102.png", | |
| 32 | + DEMO_IMAGE_DIR "application-icon-103.png", | |
| 33 | + DEMO_IMAGE_DIR "application-icon-104.png", | |
| 34 | + DEMO_IMAGE_DIR "application-icon-105.png", | |
| 35 | + DEMO_IMAGE_DIR "application-icon-106.png", | |
| 36 | + DEMO_IMAGE_DIR "application-icon-107.png", | |
| 37 | + DEMO_IMAGE_DIR "application-icon-108.png", | |
| 38 | + DEMO_IMAGE_DIR "application-icon-109.png", | |
| 39 | + DEMO_IMAGE_DIR "application-icon-10.png", | |
| 40 | + DEMO_IMAGE_DIR "application-icon-110.png", | |
| 41 | + DEMO_IMAGE_DIR "application-icon-111.png", | |
| 42 | + DEMO_IMAGE_DIR "application-icon-112.png", | |
| 43 | + DEMO_IMAGE_DIR "application-icon-113.png", | |
| 44 | + DEMO_IMAGE_DIR "application-icon-114.png", | |
| 45 | + DEMO_IMAGE_DIR "application-icon-115.png", | |
| 46 | + DEMO_IMAGE_DIR "application-icon-116.png", | |
| 47 | + DEMO_IMAGE_DIR "application-icon-117.png", | |
| 48 | + DEMO_IMAGE_DIR "application-icon-118.png", | |
| 49 | + DEMO_IMAGE_DIR "application-icon-119.png", | |
| 50 | + DEMO_IMAGE_DIR "application-icon-11.png", | |
| 51 | + DEMO_IMAGE_DIR "application-icon-120.png", | |
| 52 | + DEMO_IMAGE_DIR "application-icon-121.png", | |
| 53 | + DEMO_IMAGE_DIR "application-icon-122.png", | |
| 54 | + DEMO_IMAGE_DIR "application-icon-123.png", | |
| 55 | + DEMO_IMAGE_DIR "application-icon-124.png", | |
| 56 | + DEMO_IMAGE_DIR "application-icon-125.png", | |
| 57 | + DEMO_IMAGE_DIR "application-icon-126.png", | |
| 58 | + DEMO_IMAGE_DIR "application-icon-127.png", | |
| 59 | + DEMO_IMAGE_DIR "application-icon-128.png", | |
| 60 | + DEMO_IMAGE_DIR "application-icon-129.png", | |
| 61 | + DEMO_IMAGE_DIR "application-icon-12.png", | |
| 62 | + DEMO_IMAGE_DIR "application-icon-130.png", | |
| 63 | + DEMO_IMAGE_DIR "application-icon-131.png", | |
| 64 | + DEMO_IMAGE_DIR "application-icon-132.png", | |
| 65 | + DEMO_IMAGE_DIR "application-icon-133.png", | |
| 66 | + DEMO_IMAGE_DIR "application-icon-134.png", | |
| 67 | + DEMO_IMAGE_DIR "application-icon-135.png", | |
| 68 | + DEMO_IMAGE_DIR "application-icon-136.png", | |
| 69 | + DEMO_IMAGE_DIR "application-icon-137.png", | |
| 70 | + DEMO_IMAGE_DIR "application-icon-138.png", | |
| 71 | + DEMO_IMAGE_DIR "application-icon-139.png", | |
| 72 | + DEMO_IMAGE_DIR "application-icon-13.png", | |
| 73 | + DEMO_IMAGE_DIR "application-icon-140.png", | |
| 74 | + DEMO_IMAGE_DIR "application-icon-141.png", | |
| 75 | + DEMO_IMAGE_DIR "application-icon-142.png", | |
| 76 | + DEMO_IMAGE_DIR "application-icon-143.png", | |
| 77 | + DEMO_IMAGE_DIR "application-icon-144.png", | |
| 78 | + DEMO_IMAGE_DIR "application-icon-145.png", | |
| 79 | + DEMO_IMAGE_DIR "application-icon-146.png", | |
| 80 | + DEMO_IMAGE_DIR "application-icon-147.png", | |
| 81 | + DEMO_IMAGE_DIR "application-icon-14.png", | |
| 82 | + DEMO_IMAGE_DIR "application-icon-15.png", | |
| 83 | + DEMO_IMAGE_DIR "application-icon-16.png", | |
| 84 | + DEMO_IMAGE_DIR "application-icon-17.png", | |
| 85 | + DEMO_IMAGE_DIR "application-icon-18.png", | |
| 86 | + DEMO_IMAGE_DIR "application-icon-19.png", | |
| 87 | + DEMO_IMAGE_DIR "application-icon-1.png", | |
| 88 | + DEMO_IMAGE_DIR "application-icon-20.png", | |
| 89 | + DEMO_IMAGE_DIR "application-icon-21.png", | |
| 90 | + DEMO_IMAGE_DIR "application-icon-22.png", | |
| 91 | + DEMO_IMAGE_DIR "application-icon-23.png", | |
| 92 | + DEMO_IMAGE_DIR "application-icon-24.png", | |
| 93 | + DEMO_IMAGE_DIR "application-icon-25.png", | |
| 94 | + DEMO_IMAGE_DIR "application-icon-26.png", | |
| 95 | + DEMO_IMAGE_DIR "application-icon-27.png", | |
| 96 | + DEMO_IMAGE_DIR "application-icon-28.png", | |
| 97 | + DEMO_IMAGE_DIR "application-icon-29.png", | |
| 98 | + DEMO_IMAGE_DIR "application-icon-2.png", | |
| 99 | + DEMO_IMAGE_DIR "application-icon-30.png", | |
| 100 | + DEMO_IMAGE_DIR "application-icon-31.png", | |
| 101 | + DEMO_IMAGE_DIR "application-icon-32.png", | |
| 102 | + DEMO_IMAGE_DIR "application-icon-33.png", | |
| 103 | + DEMO_IMAGE_DIR "application-icon-34.png", | |
| 104 | + DEMO_IMAGE_DIR "application-icon-35.png", | |
| 105 | + DEMO_IMAGE_DIR "application-icon-36.png", | |
| 106 | + DEMO_IMAGE_DIR "application-icon-37.png", | |
| 107 | + DEMO_IMAGE_DIR "application-icon-38.png", | |
| 108 | + DEMO_IMAGE_DIR "application-icon-39.png", | |
| 109 | + DEMO_IMAGE_DIR "application-icon-3.png", | |
| 110 | + DEMO_IMAGE_DIR "application-icon-40.png", | |
| 111 | + DEMO_IMAGE_DIR "application-icon-41.png", | |
| 112 | + DEMO_IMAGE_DIR "application-icon-42.png", | |
| 113 | + DEMO_IMAGE_DIR "application-icon-43.png", | |
| 114 | + DEMO_IMAGE_DIR "application-icon-44.png", | |
| 115 | + DEMO_IMAGE_DIR "application-icon-45.png", | |
| 116 | + DEMO_IMAGE_DIR "application-icon-46.png", | |
| 117 | + DEMO_IMAGE_DIR "application-icon-47.png", | |
| 118 | + DEMO_IMAGE_DIR "application-icon-48.png", | |
| 119 | + DEMO_IMAGE_DIR "application-icon-49.png", | |
| 120 | + DEMO_IMAGE_DIR "application-icon-4.png", | |
| 121 | + DEMO_IMAGE_DIR "application-icon-50.png", | |
| 122 | + DEMO_IMAGE_DIR "application-icon-51.png", | |
| 123 | + DEMO_IMAGE_DIR "application-icon-52.png", | |
| 124 | + DEMO_IMAGE_DIR "application-icon-53.png", | |
| 125 | + DEMO_IMAGE_DIR "application-icon-54.png", | |
| 126 | + DEMO_IMAGE_DIR "application-icon-55.png", | |
| 127 | + DEMO_IMAGE_DIR "application-icon-56.png", | |
| 128 | + DEMO_IMAGE_DIR "application-icon-57.png", | |
| 129 | + DEMO_IMAGE_DIR "application-icon-58.png", | |
| 130 | + DEMO_IMAGE_DIR "application-icon-59.png", | |
| 131 | + DEMO_IMAGE_DIR "application-icon-5.png", | |
| 132 | + DEMO_IMAGE_DIR "application-icon-60.png", | |
| 133 | + DEMO_IMAGE_DIR "application-icon-61.png", | |
| 134 | + DEMO_IMAGE_DIR "application-icon-62.png", | |
| 135 | + DEMO_IMAGE_DIR "application-icon-63.png", | |
| 136 | + DEMO_IMAGE_DIR "application-icon-64.png", | |
| 137 | + DEMO_IMAGE_DIR "application-icon-65.png", | |
| 138 | + DEMO_IMAGE_DIR "application-icon-66.png", | |
| 139 | + DEMO_IMAGE_DIR "application-icon-67.png", | |
| 140 | + DEMO_IMAGE_DIR "application-icon-68.png", | |
| 141 | + DEMO_IMAGE_DIR "application-icon-69.png", | |
| 142 | + DEMO_IMAGE_DIR "application-icon-6.png", | |
| 143 | + DEMO_IMAGE_DIR "application-icon-70.png", | |
| 144 | + DEMO_IMAGE_DIR "application-icon-71.png", | |
| 145 | + DEMO_IMAGE_DIR "application-icon-72.png", | |
| 146 | + DEMO_IMAGE_DIR "application-icon-73.png", | |
| 147 | + DEMO_IMAGE_DIR "application-icon-74.png", | |
| 148 | + DEMO_IMAGE_DIR "application-icon-75.png", | |
| 149 | + DEMO_IMAGE_DIR "application-icon-76.png", | |
| 150 | + DEMO_IMAGE_DIR "application-icon-77.png", | |
| 151 | + DEMO_IMAGE_DIR "application-icon-78.png", | |
| 152 | + DEMO_IMAGE_DIR "application-icon-79.png", | |
| 153 | + DEMO_IMAGE_DIR "application-icon-7.png", | |
| 154 | + DEMO_IMAGE_DIR "application-icon-80.png", | |
| 155 | + DEMO_IMAGE_DIR "application-icon-81.png", | |
| 156 | + DEMO_IMAGE_DIR "application-icon-82.png", | |
| 157 | + DEMO_IMAGE_DIR "application-icon-83.png", | |
| 158 | + DEMO_IMAGE_DIR "application-icon-84.png", | |
| 159 | + DEMO_IMAGE_DIR "application-icon-85.png", | |
| 160 | + DEMO_IMAGE_DIR "application-icon-86.png", | |
| 161 | + DEMO_IMAGE_DIR "application-icon-87.png", | |
| 162 | + DEMO_IMAGE_DIR "application-icon-88.png", | |
| 163 | + DEMO_IMAGE_DIR "application-icon-89.png", | |
| 164 | + DEMO_IMAGE_DIR "application-icon-8.png", | |
| 165 | + DEMO_IMAGE_DIR "application-icon-90.png", | |
| 166 | + DEMO_IMAGE_DIR "application-icon-91.png", | |
| 167 | + DEMO_IMAGE_DIR "application-icon-92.png", | |
| 168 | + DEMO_IMAGE_DIR "application-icon-93.png", | |
| 169 | + DEMO_IMAGE_DIR "application-icon-94.png", | |
| 170 | + DEMO_IMAGE_DIR "application-icon-95.png", | |
| 171 | + DEMO_IMAGE_DIR "application-icon-96.png", | |
| 172 | + DEMO_IMAGE_DIR "application-icon-97.png", | |
| 173 | + DEMO_IMAGE_DIR "application-icon-98.png", | |
| 174 | + DEMO_IMAGE_DIR "application-icon-99.png", | |
| 175 | + DEMO_IMAGE_DIR "application-icon-9.png", | |
| 176 | + NULL | |
| 177 | +}; | |
| 178 | + | |
| 179 | +/** | |
| 180 | + * Random words used as unique application names | |
| 181 | + */ | |
| 182 | +const char* DEMO_APPS_NAMES[] = | |
| 183 | +{ | |
| 184 | + "Achdyer", | |
| 185 | + "Achtortor", | |
| 186 | + "Ackirlor", | |
| 187 | + "Ackptin", | |
| 188 | + "Aighte", | |
| 189 | + "Akala", | |
| 190 | + "Alealdny", | |
| 191 | + "Angash", | |
| 192 | + "Anglor", | |
| 193 | + "Anveraugh", | |
| 194 | + "Ardangas", | |
| 195 | + "Ardug", | |
| 196 | + "Ardworu", | |
| 197 | + "Ascerald", | |
| 198 | + "Ash'ach", | |
| 199 | + "Athiund", | |
| 200 | + "Aughm", | |
| 201 | + "Aughtheryer", | |
| 202 | + "Awitad", | |
| 203 | + "Banengon", | |
| 204 | + "Banhinat", | |
| 205 | + "Belrisash", | |
| 206 | + "Bilorm", | |
| 207 | + "Bleustcer", | |
| 208 | + "Bliagelor", | |
| 209 | + "Blorynton", | |
| 210 | + "Booten", | |
| 211 | + "Bripolqua", | |
| 212 | + "Bryray", | |
| 213 | + "Burust", | |
| 214 | + "Cataikel", | |
| 215 | + "Cerilwar", | |
| 216 | + "Cerl", | |
| 217 | + "Certin", | |
| 218 | + "Checerper", | |
| 219 | + "Chegit", | |
| 220 | + "Cheirat", | |
| 221 | + "Che'rak", | |
| 222 | + "Cheves", | |
| 223 | + "Chiperath", | |
| 224 | + "Chralerack", | |
| 225 | + "Chram", | |
| 226 | + "Clyimen", | |
| 227 | + "Coqueang", | |
| 228 | + "Craennther", | |
| 229 | + "Cykage", | |
| 230 | + "Dalek", | |
| 231 | + "Darhkel", | |
| 232 | + "Daril", | |
| 233 | + "Darpban", | |
| 234 | + "Dasrad", | |
| 235 | + "Deeqskel", | |
| 236 | + "Delurnther", | |
| 237 | + "Denalda", | |
| 238 | + "Derynkel", | |
| 239 | + "Deurnos", | |
| 240 | + "Doyaryke", | |
| 241 | + "Draithon", | |
| 242 | + "Drantess", | |
| 243 | + "Druardny", | |
| 244 | + "Dynsaytor", | |
| 245 | + "Dytinris", | |
| 246 | + "Eeni", | |
| 247 | + "Elmryn", | |
| 248 | + "Emgha", | |
| 249 | + "Emiton", | |
| 250 | + "Emworeng", | |
| 251 | + "Endnys", | |
| 252 | + "Enessray", | |
| 253 | + "Engyer", | |
| 254 | + "En'rady", | |
| 255 | + "Enthount", | |
| 256 | + "Enundem", | |
| 257 | + "Essina", | |
| 258 | + "Faughald", | |
| 259 | + "Fiummos", | |
| 260 | + "Garash", | |
| 261 | + "Garight", | |
| 262 | + "Garrynath", | |
| 263 | + "Ghalora", | |
| 264 | + "Ghatan", | |
| 265 | + "Gibanis", | |
| 266 | + "Hatdyn", | |
| 267 | + "Heesban", | |
| 268 | + "Hesub", | |
| 269 | + "Hinkelenth", | |
| 270 | + "Hirryer", | |
| 271 | + "Ideinta", | |
| 272 | + "Im'eld", | |
| 273 | + "Ina'ir", | |
| 274 | + "Ing'moro", | |
| 275 | + "Ingormess", | |
| 276 | + "Ingshy", | |
| 277 | + "Issath", | |
| 278 | + "Issendris", | |
| 279 | + "Issey", | |
| 280 | + "Issum", | |
| 281 | + "Itenthbel", | |
| 282 | + "K'ackves", | |
| 283 | + "Kagdra", | |
| 284 | + "Kalbankim", | |
| 285 | + "Kal'enda", | |
| 286 | + "Kimest", | |
| 287 | + "Kimundeng", | |
| 288 | + "Koachlor", | |
| 289 | + "Kuren", | |
| 290 | + "Kygver", | |
| 291 | + "Kyning", | |
| 292 | + "Laiyach", | |
| 293 | + "Lasuzu", | |
| 294 | + "Lekew", | |
| 295 | + "Lerengom", | |
| 296 | + "Lertan", | |
| 297 | + "Liadem", | |
| 298 | + "Liathar", | |
| 299 | + "Liephden", | |
| 300 | + "Likellor", | |
| 301 | + "Loightmos", | |
| 302 | + "Loromum", | |
| 303 | + "Lorr", | |
| 304 | + "Lortas", | |
| 305 | + "Lyerr", | |
| 306 | + "Maustbur", | |
| 307 | + "Menvor", | |
| 308 | + "Meusten", | |
| 309 | + "Mirodskel", | |
| 310 | + "Morhatrod", | |
| 311 | + "Moserbel", | |
| 312 | + "Mosorrad", | |
| 313 | + "Mosraye", | |
| 314 | + "Mosth", | |
| 315 | + "Neabar", | |
| 316 | + "Neerdem", | |
| 317 | + "Nichqua", | |
| 318 | + "Nudraough", | |
| 319 | + "Nuyim", | |
| 320 | + "Nycha", | |
| 321 | + "Nyia", | |
| 322 | + "Nyjac", | |
| 323 | + "Nystondar", | |
| 324 | + "Okine", | |
| 325 | + "Oldit", | |
| 326 | + "Om'mose", | |
| 327 | + "Onye", | |
| 328 | + "Ososrak", | |
| 329 | + "Pecertin", | |
| 330 | + "Perrd", | |
| 331 | + "Phutorny", | |
| 332 | + "Puizlye", | |
| 333 | + "Quirantai", | |
| 334 | + NULL | |
| 335 | +}; | |
| 336 | + | |
| 337 | +// this code comes from command-line-options.cpp. the reason it's here is to | |
| 338 | +// keep consistent the extra-help formatting when '--help' used | |
| 339 | + | |
| 340 | +void PrintHelp( const char * const opt, const char * const optDescription) | |
| 341 | +{ | |
| 342 | + const std::ios_base::fmtflags flags = std::cout.flags(); | |
| 343 | + std::cout << std::left << " -"; | |
| 344 | + std::cout.width( 18 ); | |
| 345 | + std::cout << opt; | |
| 346 | + std::cout << optDescription; | |
| 347 | + std::cout << std::endl; | |
| 348 | + std::cout.flags( flags ); | |
| 349 | +} | |
| 350 | + | |
| 351 | +const float PAGE_SCALE_FACTOR_X ( 0.95f ); | |
| 352 | +const float PAGE_SCALE_FACTOR_Y ( 0.95f ); | |
| 353 | +const float PAGE_DURATION_SCALE_FACTOR ( 2.0f ); // time-scale factor, larger = animation is slower | |
| 354 | + | |
| 355 | +const float DEFAULT_OPT_ROW_COUNT ( 5 ); | |
| 356 | +const float DEFAULT_OPT_COL_COUNT ( 4 ); | |
| 357 | +const float DEFAULT_OPT_PAGE_COUNT ( 10 ); | |
| 358 | +const bool DEFAULT_OPT_USETABLEVIEW ( false ); | |
| 359 | + | |
| 360 | +} | |
| 361 | + | |
| 362 | +// This example is a benchmark that mimics the paged applications list of the homescreen app | |
| 363 | +// | |
| 364 | +class HomescreenBenchmark : public ConnectionTracker | |
| 365 | +{ | |
| 366 | +public: | |
| 367 | + | |
| 368 | + // Config structure passed to the constructor. It makes easier to increase number | |
| 369 | + // of setup parameters if needed | |
| 370 | + struct Config | |
| 371 | + { | |
| 372 | + Config() : | |
| 373 | + mRows( DEFAULT_OPT_ROW_COUNT ), | |
| 374 | + mCols( DEFAULT_OPT_COL_COUNT ), | |
| 375 | + mPageCount( DEFAULT_OPT_PAGE_COUNT ), | |
| 376 | + mUseTableView( DEFAULT_OPT_USETABLEVIEW ) | |
| 377 | + { | |
| 378 | + } | |
| 379 | + | |
| 380 | + int mRows; | |
| 381 | + int mCols; | |
| 382 | + int mPageCount; | |
| 383 | + bool mUseTableView; | |
| 384 | + }; | |
| 385 | + | |
| 386 | + // animation script data | |
| 387 | + struct ScriptData | |
| 388 | + { | |
| 389 | + ScriptData( int pages, float duration, bool flick ) | |
| 390 | + { | |
| 391 | + mPages = pages; | |
| 392 | + mDuration = duration; | |
| 393 | + mFlick = flick; | |
| 394 | + } | |
| 395 | + | |
| 396 | + int mPages; // number of pages to scroll | |
| 397 | + float mDuration; // duration | |
| 398 | + bool mFlick; // use flick or 'one-by-one' scroll | |
| 399 | + }; | |
| 400 | + | |
| 401 | + HomescreenBenchmark( Application& application, const Config& config ) | |
| 402 | + : mApplication( application ), | |
| 403 | + mConfig( config ), | |
| 404 | + mCurrentPage( 0 ) | |
| 405 | + { | |
| 406 | + // Connect to the Application's Init signal | |
| 407 | + mApplication.InitSignal().Connect( this, &HomescreenBenchmark::Create ); | |
| 408 | + } | |
| 409 | + | |
| 410 | + ~HomescreenBenchmark() | |
| 411 | + { | |
| 412 | + // Nothing to do here; | |
| 413 | + } | |
| 414 | + | |
| 415 | + // The Init signal is received once (only) during the Application lifetime | |
| 416 | + void Create( Application& application ) | |
| 417 | + { | |
| 418 | + // create benchmark script | |
| 419 | + CreateScript(); | |
| 420 | + | |
| 421 | + // Get a handle to the stage | |
| 422 | + Stage stage = Stage::GetCurrent(); | |
| 423 | + | |
| 424 | + mScrollParent = Actor::New(); | |
| 425 | + mScrollParent.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 426 | + mScrollParent.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 427 | + mScrollParent.SetParentOrigin( ParentOrigin::CENTER ); | |
| 428 | + | |
| 429 | + // create background | |
| 430 | + Toolkit::ImageView background = Toolkit::ImageView::New( DEMO_IMAGE_DIR "background-3.jpg"); | |
| 431 | + Stage::GetCurrent().Add(background); | |
| 432 | + background.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 433 | + background.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 434 | + background.SetParentOrigin( ParentOrigin::CENTER ); | |
| 435 | + | |
| 436 | + PopulatePages(); | |
| 437 | + | |
| 438 | + stage.Add(mScrollParent); | |
| 439 | + | |
| 440 | + // Respond to a click anywhere on the stage | |
| 441 | + stage.GetRootLayer().TouchedSignal().Connect( this, &HomescreenBenchmark::OnTouch ); | |
| 442 | + } | |
| 443 | + | |
| 444 | + bool OnTouch( Actor actor, const TouchEvent& touch ) | |
| 445 | + { | |
| 446 | + // quit the application | |
| 447 | + mApplication.Quit(); | |
| 448 | + return true; | |
| 449 | + } | |
| 450 | + | |
| 451 | + Actor AddPage() | |
| 452 | + { | |
| 453 | + // create root page actor | |
| 454 | + Actor pageActor; | |
| 455 | + | |
| 456 | + if( mConfig.mUseTableView ) | |
| 457 | + { | |
| 458 | + Toolkit::TableView tableView = Toolkit::TableView::New( mConfig.mRows, mConfig.mCols ); | |
| 459 | + tableView.SetBackgroundColor( Vector4( 0.0f, 0.0f, 0.0f, 0.5f ) ); | |
| 460 | + pageActor = tableView; | |
| 461 | + } | |
| 462 | + else | |
| 463 | + { | |
| 464 | + pageActor = Toolkit::Control::New(); | |
| 465 | + pageActor.SetProperty( Toolkit::Control::Property::BACKGROUND_COLOR, Vector4( 0.0f, 0.0f, 0.0f, 0.5f ) ); | |
| 466 | + } | |
| 467 | + | |
| 468 | + pageActor.SetParentOrigin( ParentOrigin::CENTER ); | |
| 469 | + pageActor.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 470 | + pageActor.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 471 | + pageActor.SetSizeModeFactor(Vector3( PAGE_SCALE_FACTOR_X, PAGE_SCALE_FACTOR_Y, 1.0f ) ); | |
| 472 | + return pageActor; | |
| 473 | + } | |
| 474 | + | |
| 475 | + void AddIconsToPage(Actor page) | |
| 476 | + { | |
| 477 | + Size stageSize( Stage::GetCurrent().GetSize() ); | |
| 478 | + const float scaledHeight = stageSize.y * PAGE_SCALE_FACTOR_Y; | |
| 479 | + const float scaledWidth = stageSize.x * PAGE_SCALE_FACTOR_X; | |
| 480 | + | |
| 481 | + const float PADDING = stageSize.y / 64.0f; | |
| 482 | + const float ROW_HEIGHT = ( scaledHeight - (PADDING*2.0f) ) / (float)mConfig.mRows; | |
| 483 | + const float COL_WIDTH = ( scaledWidth - (PADDING*2.0f) ) / (float)mConfig.mCols; | |
| 484 | + | |
| 485 | + // the image/label area tries to make sure the positioning will be relative to previous sibling | |
| 486 | + const float IMAGE_AREA = 0.60f; | |
| 487 | + const float LABEL_AREA = 0.50f; | |
| 488 | + | |
| 489 | + static int currentIconIndex = 0; | |
| 490 | + | |
| 491 | + Vector2 dpi = Stage::GetCurrent().GetDpi(); | |
| 492 | + | |
| 493 | + for( int y = 0; y < mConfig.mRows; ++y ) | |
| 494 | + { | |
| 495 | + for( int x = 0; x < mConfig.mCols; ++x ) | |
| 496 | + { | |
| 497 | + // create parent icon view | |
| 498 | + Toolkit::Control iconView = Toolkit::Control::New(); | |
| 499 | + iconView.SetAnchorPoint( AnchorPoint::TOP_LEFT ); | |
| 500 | + iconView.SetParentOrigin( ParentOrigin::TOP_LEFT ); | |
| 501 | + | |
| 502 | + if( !mConfig.mUseTableView ) | |
| 503 | + { | |
| 504 | + float rowX = x * COL_WIDTH + PADDING; | |
| 505 | + float rowY = y * ROW_HEIGHT + PADDING; | |
| 506 | + iconView.SetSize( Vector3( COL_WIDTH, ROW_HEIGHT, 1.0f ) ); | |
| 507 | + iconView.SetPosition( Vector3( rowX, rowY, 0.0f ) ); | |
| 508 | + } | |
| 509 | + else | |
| 510 | + { | |
| 511 | + iconView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 512 | + iconView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); | |
| 513 | + } | |
| 514 | + | |
| 515 | + // create image view | |
| 516 | + Toolkit::ImageView imageView = Toolkit::ImageView::New( IMAGE_PATH[currentIconIndex] ); | |
| 517 | + imageView.SetResizePolicy( ResizePolicy::SIZE_RELATIVE_TO_PARENT, Dimension::ALL_DIMENSIONS ); | |
| 518 | + imageView.SetSizeScalePolicy( SizeScalePolicy::FIT_WITH_ASPECT_RATIO ); | |
| 519 | + imageView.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 520 | + imageView.SetParentOrigin( ParentOrigin::CENTER ); | |
| 521 | + imageView.SetSizeModeFactor( Vector3(IMAGE_AREA, IMAGE_AREA, 1.0f) ); | |
| 522 | + | |
| 523 | + // create label | |
| 524 | + Toolkit::TextLabel textLabel = Toolkit::TextLabel::New( DEMO_APPS_NAMES[currentIconIndex] ); | |
| 525 | + textLabel.SetAnchorPoint( AnchorPoint::TOP_CENTER ); | |
| 526 | + textLabel.SetParentOrigin( ParentOrigin::BOTTOM_CENTER ); | |
| 527 | + | |
| 528 | + textLabel.SetResizePolicy( ResizePolicy::USE_NATURAL_SIZE, Dimension::ALL_DIMENSIONS ); | |
| 529 | + textLabel.SetProperty( Toolkit::TextLabel::Property::TEXT_COLOR, Vector4( 1.0f, 1.0f, 1.0f, 1.0f ) ); | |
| 530 | + textLabel.SetProperty( Toolkit::TextLabel::Property::POINT_SIZE, (((float)( ROW_HEIGHT * LABEL_AREA ) * 72.0f) / (dpi.y))*0.25f ); | |
| 531 | + textLabel.SetProperty( Toolkit::TextLabel::Property::HORIZONTAL_ALIGNMENT, "CENTER" ); | |
| 532 | + textLabel.SetProperty( Toolkit::TextLabel::Property::VERTICAL_ALIGNMENT, "TOP" ); | |
| 533 | + | |
| 534 | + iconView.Add( imageView ); | |
| 535 | + imageView.Add( textLabel ); | |
| 536 | + | |
| 537 | + page.Add(iconView); | |
| 538 | + | |
| 539 | + if( !IMAGE_PATH[ ++currentIconIndex ] ) | |
| 540 | + { | |
| 541 | + currentIconIndex = 0; | |
| 542 | + } | |
| 543 | + } | |
| 544 | + } | |
| 545 | + } | |
| 546 | + | |
| 547 | + void CreateScript() | |
| 548 | + { | |
| 549 | + const int lastPage = mConfig.mPageCount-1; | |
| 550 | + const int halfA = lastPage/2; | |
| 551 | + const int halfB = lastPage/2 + lastPage%2; | |
| 552 | + mScriptFrameData.push_back( ScriptData( lastPage, 1.5f, true)); | |
| 553 | + mScriptFrameData.push_back( ScriptData( -lastPage, 1.5f, true )); | |
| 554 | + mScriptFrameData.push_back( ScriptData( halfA, 1.0f, true )); | |
| 555 | + mScriptFrameData.push_back( ScriptData( halfB, 1.0f, true )); | |
| 556 | + mScriptFrameData.push_back( ScriptData( -lastPage, 0.5f, false )); | |
| 557 | + mScriptFrameData.push_back( ScriptData( halfA, 0.5f, false )); | |
| 558 | + mScriptFrameData.push_back( ScriptData( halfB, 1.0f, true )); | |
| 559 | + mScriptFrameData.push_back( ScriptData( -halfA, 1.0f, true )); | |
| 560 | + mScriptFrameData.push_back( ScriptData( 1, 0.1f, true )); | |
| 561 | + mScriptFrameData.push_back( ScriptData( -1, 0.1f, true )); | |
| 562 | + mScriptFrameData.push_back( ScriptData( 1, 0.1f, true )); | |
| 563 | + mScriptFrameData.push_back( ScriptData( -1, 0.1f, true )); | |
| 564 | + mScriptFrameData.push_back( ScriptData( 1, 0.1f, true )); | |
| 565 | + mScriptFrameData.push_back( ScriptData( -1, 0.1f, true )); | |
| 566 | + mScriptFrameData.push_back( ScriptData( halfA, 1.0f, true )); | |
| 567 | + } | |
| 568 | + | |
| 569 | + void PopulatePages() | |
| 570 | + { | |
| 571 | + Vector3 stageSize( Stage::GetCurrent().GetSize() ); | |
| 572 | + const float SCALED_HEIGHT = stageSize.y * PAGE_SCALE_FACTOR_Y; | |
| 573 | + | |
| 574 | + for( int i = 0; i < mConfig.mPageCount; ++i ) | |
| 575 | + { | |
| 576 | + // create page | |
| 577 | + Actor page = AddPage(); | |
| 578 | + | |
| 579 | + // populate icons | |
| 580 | + AddIconsToPage(page); | |
| 581 | + | |
| 582 | + // move page 'a little bit up' | |
| 583 | + page.SetParentOrigin( ParentOrigin::CENTER ); | |
| 584 | + page.SetAnchorPoint( AnchorPoint::CENTER ); | |
| 585 | + page.SetPosition( Vector3(stageSize.x*i, -0.30f*( stageSize.y-SCALED_HEIGHT ), 0.0f) ); | |
| 586 | + mScrollParent.Add( page ); | |
| 587 | + } | |
| 588 | + | |
| 589 | + mScrollParent.SetOpacity( 0.0f ); | |
| 590 | + mScrollParent.SetScale( Vector3(0.0f, 0.0f, 0.0f) ); | |
| 591 | + | |
| 592 | + // fade in | |
| 593 | + ShowAnimation(); | |
| 594 | + } | |
| 595 | + | |
| 596 | + void ShowAnimation() | |
| 597 | + { | |
| 598 | + mShowAnimation = Animation::New(1.0f); | |
| 599 | + mShowAnimation.AnimateTo( Property(mScrollParent, Actor::Property::COLOR_ALPHA), 1.0f, AlphaFunction::EASE_IN_OUT ); | |
| 600 | + mShowAnimation.AnimateTo( Property(mScrollParent, Actor::Property::SCALE), Vector3(1.0f, 1.0f, 1.0f), AlphaFunction::EASE_IN_OUT ); | |
| 601 | + mShowAnimation.FinishedSignal().Connect( this, &HomescreenBenchmark::OnAnimationEnd ); | |
| 602 | + mShowAnimation.Play(); | |
| 603 | + } | |
| 604 | + | |
| 605 | + void ScrollPages(int pages, float duration, bool flick) | |
| 606 | + { | |
| 607 | + duration *= PAGE_DURATION_SCALE_FACTOR; | |
| 608 | + Vector3 stageSize( Stage::GetCurrent().GetSize() ); | |
| 609 | + mScrollAnimation = Animation::New(duration); | |
| 610 | + if( flick ) | |
| 611 | + { | |
| 612 | + mScrollAnimation.AnimateBy( Property(mScrollParent, Actor::Property::POSITION), Vector3(-stageSize.x*pages, 0.0f, 0.0f), AlphaFunction::EASE_IN_OUT ); | |
| 613 | + } | |
| 614 | + else | |
| 615 | + { | |
| 616 | + for( int i = 0; i < abs(pages); ++i ) | |
| 617 | + { | |
| 618 | + mScrollAnimation.AnimateBy( Property(mScrollParent, Actor::Property::POSITION), Vector3(pages < 0 ? stageSize.x : -stageSize.x, 0.0f, 0.0f), AlphaFunction::EASE_IN_OUT, TimePeriod(duration*i, duration) ); | |
| 619 | + } | |
| 620 | + } | |
| 621 | + mScrollAnimation.FinishedSignal().Connect( this, &HomescreenBenchmark::OnAnimationEnd ); | |
| 622 | + mScrollAnimation.Play(); | |
| 623 | + mCurrentPage += pages; | |
| 624 | + } | |
| 625 | + | |
| 626 | + void OnAnimationEnd( Animation& source ) | |
| 627 | + { | |
| 628 | + if( source == mShowAnimation ) | |
| 629 | + { | |
| 630 | + ScriptData& frame = mScriptFrameData[0]; | |
| 631 | + ScrollPages( frame.mPages, frame.mDuration, frame.mFlick ); | |
| 632 | + mScriptFrame = 1; | |
| 633 | + } | |
| 634 | + else if( mScriptFrame < mScriptFrameData.size() && source == mScrollAnimation ) | |
| 635 | + { | |
| 636 | + ScriptData& frame = mScriptFrameData[mScriptFrame]; | |
| 637 | + ScrollPages( frame.mPages, frame.mDuration, frame.mFlick ); | |
| 638 | + ++mScriptFrame; | |
| 639 | + } | |
| 640 | + else | |
| 641 | + { | |
| 642 | + mApplication.Quit(); | |
| 643 | + } | |
| 644 | + } | |
| 645 | + | |
| 646 | +private: | |
| 647 | + Application& mApplication; | |
| 648 | + | |
| 649 | + Actor mScrollParent; | |
| 650 | + | |
| 651 | + Animation mShowAnimation; | |
| 652 | + Animation mScrollAnimation; | |
| 653 | + | |
| 654 | + Config mConfig; | |
| 655 | + | |
| 656 | + std::vector<ScriptData> mScriptFrameData; | |
| 657 | + size_t mScriptFrame; | |
| 658 | + | |
| 659 | + int mCurrentPage; | |
| 660 | +}; | |
| 661 | + | |
| 662 | +void RunTest( Application& application, const HomescreenBenchmark::Config& config, bool printHelpAndExit ) | |
| 663 | +{ | |
| 664 | + HomescreenBenchmark test( application, config ); | |
| 665 | + | |
| 666 | + if( printHelpAndExit ) | |
| 667 | + { | |
| 668 | + PrintHelp( "c<num>", " Number of columns"); | |
| 669 | + PrintHelp( "r<num>", " Number of rows"); | |
| 670 | + PrintHelp( "p<num>", " Number of pages ( must be greater than 1 )"); | |
| 671 | + PrintHelp( "-use-tableview", " Uses TableView for layouting"); | |
| 672 | + return; | |
| 673 | + } | |
| 674 | + | |
| 675 | + application.MainLoop(); | |
| 676 | +} | |
| 677 | + | |
| 678 | +// Entry point for Linux & Tizen applications | |
| 679 | +// | |
| 680 | +int main( int argc, char **argv ) | |
| 681 | +{ | |
| 682 | + // default settings | |
| 683 | + HomescreenBenchmark::Config config; | |
| 684 | + | |
| 685 | + bool printHelpAndExit = false; | |
| 686 | + | |
| 687 | + for( int i(1) ; i < argc; ++i ) | |
| 688 | + { | |
| 689 | + std::string arg( argv[i] ); | |
| 690 | + if( arg.compare( 0, 2, "-r" ) == 0 ) | |
| 691 | + { | |
| 692 | + config.mRows = atoi( arg.substr( 2 ).c_str() ); | |
| 693 | + } | |
| 694 | + else if( arg.compare( 0, 2, "-c" ) == 0 ) | |
| 695 | + { | |
| 696 | + config.mCols = atoi( arg.substr( 2 ).c_str() ); | |
| 697 | + } | |
| 698 | + else if( arg.compare( 0, 2, "-p" ) == 0 ) | |
| 699 | + { | |
| 700 | + config.mPageCount = atoi( arg.substr( 2 ).c_str() ); | |
| 701 | + } | |
| 702 | + else if( arg.compare( "--use-tableview" ) == 0 ) | |
| 703 | + { | |
| 704 | + config.mUseTableView = true; | |
| 705 | + } | |
| 706 | + else if( arg.compare( "--help" ) == 0 ) | |
| 707 | + { | |
| 708 | + printHelpAndExit = true; | |
| 709 | + } | |
| 710 | + | |
| 711 | + } | |
| 712 | + | |
| 713 | + Application application = Application::New( &argc, &argv ); | |
| 714 | + | |
| 715 | + RunTest( application, config, printHelpAndExit ); | |
| 716 | + | |
| 717 | + return 0; | |
| 718 | +} | ... | ... |
5.34 KB
5.76 KB
5.97 KB
3.14 KB
2.5 KB
4.14 KB
2.15 KB
1.74 KB
2.29 KB
1.86 KB
2.83 KB
3.9 KB
3.9 KB
3.26 KB
2.35 KB
6.24 KB
2.2 KB
8.1 KB
2.45 KB
3 KB
2.79 KB
1.8 KB
2.89 KB
3.12 KB
7.92 KB
1.99 KB
8.95 KB
3.81 KB
9.21 KB
9.21 KB
19.8 KB
4.98 KB
2.53 KB
17.3 KB
7.22 KB
3.31 KB
10.5 KB
10.8 KB
611 Bytes
3.34 KB
590 Bytes
14 KB
5.27 KB
14.8 KB
16.1 KB
4.84 KB
6.55 KB
3.85 KB
4.62 KB
2.96 KB
3.84 KB
4.25 KB
3.62 KB
1.83 KB
5.53 KB
5.36 KB
5.09 KB
4.48 KB
3.3 KB
5.79 KB
5.6 KB
5.56 KB
6.97 KB
3.47 KB
7.73 KB
5.48 KB
9.13 KB
10.1 KB
4.48 KB
8.55 KB
9.18 KB
8.82 KB
5.95 KB
6.74 KB
5.56 KB
4.11 KB
5.91 KB
5.63 KB
9.52 KB
4.55 KB
7.06 KB
3.77 KB
4.05 KB
5.81 KB
5.47 KB
4.45 KB
5.83 KB
9.16 KB
6.32 KB
5.08 KB
5.68 KB
6.21 KB
3.82 KB
6.21 KB
3.87 KB
7.36 KB
6.12 KB
9.51 KB
4.38 KB
8.95 KB
15.1 KB
9.41 KB
9.18 KB
5.23 KB
5.75 KB
11.7 KB
8.89 KB
13.9 KB
2.93 KB
19.8 KB
10.7 KB
18.1 KB
6.56 KB
6.84 KB
4.37 KB
5.4 KB
3.33 KB
2.47 KB
3.17 KB
3.21 KB
3.14 KB
544 Bytes
6.8 KB
2.15 KB
3.24 KB
2.9 KB
4.57 KB
2.52 KB
1.7 KB
2.79 KB
2.41 KB
3.33 KB
2.88 KB
3.18 KB
2.83 KB
1.68 KB
2.62 KB
5.58 KB
3.57 KB
3.16 KB
1.75 KB
3.54 KB
2.71 KB
2.9 KB
4.05 KB
2.61 KB
2.82 KB
3.54 KB