| 352 | } |
| 353 | |
| 354 | void BaseTheme::drawHeader(const GfxRenderer& renderer, Rect rect, const char* title, const char* subtitle) const { |
| 355 | // Hide last battery draw |
| 356 | constexpr int maxBatteryWidth = 80; |
| 357 | renderer.fillRect(rect.x + rect.width - maxBatteryWidth, rect.y + 5, maxBatteryWidth, |
| 358 | BaseMetrics::values.batteryHeight + 10, false); |
| 359 | |
| 360 | const bool showBatteryPercentage = |
| 361 | SETTINGS.hideBatteryPercentage != CrossPointSettings::HIDE_BATTERY_PERCENTAGE::HIDE_ALWAYS; |
| 362 | // Position icon at right edge, drawBatteryRight will place text to the left |
| 363 | const int batteryX = rect.x + rect.width - 12 - BaseMetrics::values.batteryWidth; |
| 364 | drawBatteryRight(renderer, |
| 365 | Rect{batteryX, rect.y + 5, BaseMetrics::values.batteryWidth, BaseMetrics::values.batteryHeight}, |
| 366 | showBatteryPercentage); |
| 367 | |
| 368 | if (title) { |
| 369 | int padding = rect.width - batteryX + BaseMetrics::values.batteryWidth; |
| 370 | auto truncatedTitle = renderer.truncatedText(UI_12_FONT_ID, title, |
| 371 | rect.width - padding * 2 - BaseMetrics::values.contentSidePadding * 2, |
| 372 | EpdFontFamily::BOLD); |
| 373 | renderer.drawCenteredText(UI_12_FONT_ID, rect.y + 5, truncatedTitle.c_str(), true, EpdFontFamily::BOLD); |
| 374 | } |
| 375 | |
| 376 | if (subtitle) { |
| 377 | auto truncatedSubtitle = renderer.truncatedText( |
| 378 | SMALL_FONT_ID, subtitle, rect.width - BaseMetrics::values.contentSidePadding * 2, EpdFontFamily::REGULAR); |
| 379 | int truncatedSubtitleWidth = renderer.getTextWidth(SMALL_FONT_ID, truncatedSubtitle.c_str()); |
| 380 | renderer.drawText(SMALL_FONT_ID, |
| 381 | rect.x + rect.width - BaseMetrics::values.contentSidePadding - truncatedSubtitleWidth, subtitleY, |
| 382 | truncatedSubtitle.c_str(), true); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | void BaseTheme::drawSubHeader(const GfxRenderer& renderer, Rect rect, const char* label, const char* rightLabel) const { |
| 387 | constexpr int maxListValueWidth = 200; |
no test coverage detected