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

Method doHorizontalAlignment

core/ui/UIRichText.cpp:2406–2420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2404} // namespace
2405
2406void RichText::doHorizontalAlignment(const Vector<ax::Node*>& row, float rowWidth)
2407{
2408 const auto alignment = static_cast<HorizontalAlignment>(_defaults.at(KEY_HORIZONTAL_ALIGNMENT).asInt());
2409 if (alignment != HorizontalAlignment::LEFT)
2410 {
2411 const auto diff = stripTrailingWhitespace(row);
2412 const auto leftOver = getContentSize().width - (rowWidth + diff);
2413 const float leftPadding = getPaddingAmount(alignment, leftOver);
2414 const Vec2 offset(leftPadding, 0.f);
2415 for (auto&& node : row)
2416 {
2417 node->setPosition(node->getPosition() + offset);
2418 }
2419 }
2420}
2421
2422namespace
2423{

Callers

nothing calls this directly

Calls 6

stripTrailingWhitespaceFunction · 0.85
asIntMethod · 0.80
getPaddingAmountFunction · 0.70
atMethod · 0.45
setPositionMethod · 0.45
getPositionMethod · 0.45

Tested by

no test coverage detected