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

Method needsLayout

extensions/GUI/src/GUI/ControlExtension/ControlSwitch.cpp:214–240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214void ControlSwitchSprite::needsLayout()
215{
216 _onSprite->setPosition(_onSprite->getContentSize().width / 2 + _sliderXPosition,
217 _onSprite->getContentSize().height / 2);
218 _offSprite->setPosition(
219 _onSprite->getContentSize().width + _offSprite->getContentSize().width / 2 + _sliderXPosition,
220 _offSprite->getContentSize().height / 2);
221 _thumbSprite->setPosition(_onSprite->getContentSize().width + _sliderXPosition,
222 _maskTexture->getContentSize().height / 2);
223
224 _clipperStencil->setPosition(_maskTexture->getContentSize().width / 2, _maskTexture->getContentSize().height / 2);
225
226 if (_onLabel)
227 {
228 _onLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
229 _onLabel->setPosition(_onSprite->getPosition().x - _thumbSprite->getContentSize().width / 6,
230 _onSprite->getContentSize().height / 2);
231 }
232 if (_offLabel)
233 {
234 _offLabel->setAnchorPoint(Vec2::ANCHOR_MIDDLE);
235 _offLabel->setPosition(_offSprite->getPosition().x + _thumbSprite->getContentSize().width / 6,
236 _offSprite->getContentSize().height / 2);
237 }
238
239 setFlippedY(true);
240}
241
242void ControlSwitchSprite::setSliderXPosition(float sliderXPosition)
243{

Callers 1

onTouchBeganMethod · 0.45

Calls 4

setPositionMethod · 0.45
getContentSizeMethod · 0.45
setAnchorPointMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected