Updates the displayed label's scale
| 262 | |
| 263 | // Updates the displayed label's scale |
| 264 | void TextInputNode::updateDisplayedLabelScale() |
| 265 | { |
| 266 | if (!_displayedLabel || !_cursor) |
| 267 | return; |
| 268 | |
| 269 | if (_placeholderScale != 0.0f && _textField->getString().empty()) |
| 270 | { |
| 271 | _displayedLabel->setScale(_placeholderScale); |
| 272 | } |
| 273 | else |
| 274 | { |
| 275 | float newScale = this->getContentSize().width / _displayedLabel->getContentSize().width; |
| 276 | |
| 277 | if (newScale < _maxDisplayLabelScale) |
| 278 | _displayedLabel->setScale(newScale); |
| 279 | else |
| 280 | _displayedLabel->setScale(_maxDisplayLabelScale); |
| 281 | } |
| 282 | |
| 283 | updateCursor(); |
| 284 | } |
| 285 | |
| 286 | // Updates the x-position and scale of the cursor |
| 287 | void TextInputNode::updateCursor() |