| 337 | } |
| 338 | |
| 339 | void LoadingBar::barRendererScaleChangedWithSize() |
| 340 | { |
| 341 | if (_unifySize) |
| 342 | { |
| 343 | //_barRenderer->setPreferredSize(_contentSize); |
| 344 | _totalLength = _contentSize.width; |
| 345 | this->setPercent(_percent); |
| 346 | } |
| 347 | else if (_ignoreSize) |
| 348 | { |
| 349 | if (!_scale9Enabled) |
| 350 | { |
| 351 | _totalLength = _barRendererTextureSize.width; |
| 352 | _barRenderer->setScale(1.0f); |
| 353 | } |
| 354 | } |
| 355 | else |
| 356 | { |
| 357 | _totalLength = _contentSize.width; |
| 358 | if (_scale9Enabled) |
| 359 | { |
| 360 | this->setScale9Scale(); |
| 361 | _barRenderer->setScale(1.0f); |
| 362 | } |
| 363 | else |
| 364 | { |
| 365 | |
| 366 | Vec2 textureSize = _barRendererTextureSize; |
| 367 | if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) |
| 368 | { |
| 369 | _barRenderer->setScale(1.0f); |
| 370 | return; |
| 371 | } |
| 372 | float scaleX = _contentSize.width / textureSize.width; |
| 373 | float scaleY = _contentSize.height / textureSize.height; |
| 374 | _barRenderer->setScaleX(scaleX); |
| 375 | _barRenderer->setScaleY(scaleY); |
| 376 | } |
| 377 | } |
| 378 | switch (_direction) |
| 379 | { |
| 380 | case Direction::LEFT: |
| 381 | _barRenderer->setPosition(Vec2(0.0f, _contentSize.height * 0.5f)); |
| 382 | break; |
| 383 | case Direction::RIGHT: |
| 384 | _barRenderer->setPosition(Vec2(_totalLength, _contentSize.height * 0.5f)); |
| 385 | break; |
| 386 | default: |
| 387 | break; |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | void LoadingBar::setScale9Scale() |
| 392 | { |
nothing calls this directly
no test coverage detected