| 315 | *****************************************************************************/ |
| 316 | |
| 317 | int16_t TextWidget::alignTextHorizontal(YAGfx& gfx, const String& text, Alignment::Horizontal hAlign) const |
| 318 | { |
| 319 | int16_t xPos = 0; |
| 320 | |
| 321 | /* Horizontal alignment is supported for |
| 322 | * - Static text |
| 323 | * - Text scrolling from bottom to top |
| 324 | */ |
| 325 | if ((false == m_scrollCtrl.isEnabled()) || |
| 326 | ((true == m_scrollCtrl.isEnabled()) && (ScrollController::DIRECTION_VERTICAL == m_scrollCtrl.getDirection()))) |
| 327 | { |
| 328 | uint16_t textBoxWidth = 0U; |
| 329 | uint16_t textBoxHeight = 0U; |
| 330 | |
| 331 | if (true == m_gfxText.getTextBoundingBox(gfx.getWidth(), text.c_str(), textBoxWidth, textBoxHeight)) |
| 332 | { |
| 333 | UTIL_NOT_USED(textBoxHeight); |
| 334 | |
| 335 | switch (hAlign) |
| 336 | { |
| 337 | case Alignment::Horizontal::HORIZONTAL_LEFT: |
| 338 | xPos = 0; |
| 339 | break; |
| 340 | |
| 341 | case Alignment::Horizontal::HORIZONTAL_CENTER: |
| 342 | xPos = (m_canvas.getWidth() - textBoxWidth) / 2; |
| 343 | break; |
| 344 | |
| 345 | case Alignment::Horizontal::HORIZONTAL_RIGHT: |
| 346 | xPos = m_canvas.getWidth() - textBoxWidth; |
| 347 | break; |
| 348 | |
| 349 | default: |
| 350 | break; |
| 351 | } |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | return xPos; |
| 356 | } |
| 357 | |
| 358 | void TextWidget::alignTextVertical() |
| 359 | { |
nothing calls this directly
no test coverage detected