| 403 | } |
| 404 | |
| 405 | void BaseTheme::drawTabBar(const GfxRenderer& renderer, const Rect rect, const std::vector<TabInfo>& tabs, |
| 406 | bool selected) const { |
| 407 | constexpr int underlineHeight = 2; // Height of selection underline |
| 408 | constexpr int underlineGap = 4; // Gap between text and underline |
| 409 | |
| 410 | const int lineHeight = renderer.getLineHeight(UI_12_FONT_ID); |
| 411 | |
| 412 | int currentX = rect.x + BaseMetrics::values.contentSidePadding; |
| 413 | |
| 414 | for (const auto& tab : tabs) { |
| 415 | const int textWidth = |
| 416 | renderer.getTextWidth(UI_12_FONT_ID, tab.label, tab.selected ? EpdFontFamily::BOLD : EpdFontFamily::REGULAR); |
| 417 | |
| 418 | // Draw underline for selected tab |
| 419 | if (tab.selected) { |
| 420 | if (selected) { |
| 421 | renderer.fillRect(currentX - 3, rect.y, textWidth + 6, lineHeight + underlineGap); |
| 422 | } else { |
| 423 | renderer.fillRect(currentX, rect.y + lineHeight + underlineGap, textWidth, underlineHeight); |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | // Draw tab label |
| 428 | renderer.drawText(UI_12_FONT_ID, currentX, rect.y, tab.label, !(tab.selected && selected), |
| 429 | tab.selected ? EpdFontFamily::BOLD : EpdFontFamily::REGULAR); |
| 430 | |
| 431 | currentX += textWidth + BaseMetrics::values.tabSpacing; |
| 432 | } |
| 433 | } |
| 434 | |
| 435 | // Draw the "Recent Book" cover card on the home screen |
| 436 | // TODO: Refactor method to make it cleaner, split into smaller methods |
no test coverage detected