MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / drawBatteryRight

Method drawBatteryRight

src/components/themes/BaseTheme.cpp:116–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

114}
115
116void BaseTheme::drawBatteryRight(const GfxRenderer& renderer, Rect rect, const bool showPercentage) const {
117 // Right aligned: percentage on left, icon on right (UI headers)
118 // rect.x is already positioned for the icon (drawHeader calculated it)
119 const uint16_t percentage = powerManager.getBatteryPercentage();
120 const int y = rect.y + 6;
121
122 if (showPercentage) {
123 const auto percentageText = std::to_string(percentage) + "%";
124 const int textWidth = renderer.getTextWidth(SMALL_FONT_ID, percentageText.c_str());
125 renderer.drawText(SMALL_FONT_ID, rect.x - textWidth - batteryPercentSpacing, rect.y, percentageText.c_str());
126 }
127
128 const Rect iconRect{rect.x, y, rect.width, rect.height};
129 drawBatteryOutline(renderer, rect.x, y, rect.width, rect.height);
130 fillBatteryIcon(renderer, iconRect, percentage);
131}
132
133void BaseTheme::drawProgressBar(const GfxRenderer& renderer, Rect rect, const size_t current,
134 const size_t total) const {

Callers

nothing calls this directly

Calls 3

getBatteryPercentageMethod · 0.80
getTextWidthMethod · 0.80
drawTextMethod · 0.80

Tested by

no test coverage detected