Another review comment
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
#include <HalStorage.h>
|
#include <HalStorage.h>
|
||||||
#include <Logging.h>
|
#include <Logging.h>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -38,6 +39,10 @@ void drawBatteryIcon(const GfxRenderer& renderer, int x, int y, int battWidth, i
|
|||||||
|
|
||||||
// The +1 is to round up, so that we always fill at least one pixel
|
// The +1 is to round up, so that we always fill at least one pixel
|
||||||
const int maxFillWidth = battWidth - 5;
|
const int maxFillWidth = battWidth - 5;
|
||||||
|
const int fillHeight = rectHeight - 4;
|
||||||
|
if (maxFillWidth <= 0 || fillHeight <= 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
int filledWidth = percentage * maxFillWidth / 100 + 1;
|
int filledWidth = percentage * maxFillWidth / 100 + 1;
|
||||||
if (filledWidth > maxFillWidth) {
|
if (filledWidth > maxFillWidth) {
|
||||||
filledWidth = maxFillWidth;
|
filledWidth = maxFillWidth;
|
||||||
@@ -46,10 +51,10 @@ void drawBatteryIcon(const GfxRenderer& renderer, int x, int y, int battWidth, i
|
|||||||
// When charging, ensure minimum fill so lightning bolt is fully visible
|
// When charging, ensure minimum fill so lightning bolt is fully visible
|
||||||
constexpr int minFillForBolt = 8;
|
constexpr int minFillForBolt = 8;
|
||||||
if (charging && filledWidth < minFillForBolt) {
|
if (charging && filledWidth < minFillForBolt) {
|
||||||
filledWidth = minFillForBolt;
|
filledWidth = std::min(minFillForBolt, maxFillWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderer.fillRect(x + 2, y + 2, filledWidth, rectHeight - 4);
|
renderer.fillRect(x + 2, y + 2, filledWidth, fillHeight);
|
||||||
|
|
||||||
// Draw lightning bolt when charging (white/inverted on black fill for visibility)
|
// Draw lightning bolt when charging (white/inverted on black fill for visibility)
|
||||||
if (charging) {
|
if (charging) {
|
||||||
|
|||||||
Reference in New Issue
Block a user