MCPcopy Create free account
hub / github.com/axmolengine/axmol / barRendererScaleChangedWithSize

Method barRendererScaleChangedWithSize

core/ui/UILoadingBar.cpp:339–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

337}
338
339void 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
391void LoadingBar::setScale9Scale()
392{

Callers

nothing calls this directly

Calls 7

setPercentMethod · 0.95
setScale9ScaleMethod · 0.95
Vec2Function · 0.50
setScaleMethod · 0.45
setScaleXMethod · 0.45
setScaleYMethod · 0.45
setPositionMethod · 0.45

Tested by

no test coverage detected