clang format fix
This commit is contained in:
parent
a4e335f0aa
commit
93ce00aed9
@ -79,94 +79,94 @@ void ScreenComponents::fillPopupProgress(const GfxRenderer& renderer, const Popu
|
|||||||
renderer.displayBuffer(EInkDisplay::FAST_REFRESH);
|
renderer.displayBuffer(EInkDisplay::FAST_REFRESH);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ScreenComponents::drawTabBar(const GfxRenderer& renderer, const int y, const std::vector<TabInfo>& tabs) {
|
int ScreenComponents::drawTabBar(const GfxRenderer& renderer, const int y, const std::vector<TabInfo>& tabs) {
|
||||||
constexpr int tabPadding = 20; // Horizontal padding between tabs
|
constexpr int tabPadding = 20; // Horizontal padding between tabs
|
||||||
constexpr int leftMargin = 20; // Left margin for first tab
|
constexpr int leftMargin = 20; // Left margin for first tab
|
||||||
constexpr int underlineHeight = 2; // Height of selection underline
|
constexpr int underlineHeight = 2; // Height of selection underline
|
||||||
constexpr int underlineGap = 4; // Gap between text and underline
|
constexpr int underlineGap = 4; // Gap between text and underline
|
||||||
|
|
||||||
const int lineHeight = renderer.getLineHeight(UI_12_FONT_ID);
|
const int lineHeight = renderer.getLineHeight(UI_12_FONT_ID);
|
||||||
const int tabBarHeight = lineHeight + underlineGap + underlineHeight;
|
const int tabBarHeight = lineHeight + underlineGap + underlineHeight;
|
||||||
|
|
||||||
int currentX = leftMargin;
|
int currentX = leftMargin;
|
||||||
|
|
||||||
for (const auto& tab : tabs) {
|
for (const auto& tab : tabs) {
|
||||||
const int textWidth =
|
const int textWidth =
|
||||||
renderer.getTextWidth(UI_12_FONT_ID, tab.label, tab.selected ? EpdFontFamily::BOLD : EpdFontFamily::REGULAR);
|
renderer.getTextWidth(UI_12_FONT_ID, tab.label, tab.selected ? EpdFontFamily::BOLD : EpdFontFamily::REGULAR);
|
||||||
|
|
||||||
// Draw tab label
|
// Draw tab label
|
||||||
renderer.drawText(UI_12_FONT_ID, currentX, y, tab.label, true,
|
renderer.drawText(UI_12_FONT_ID, currentX, y, tab.label, true,
|
||||||
tab.selected ? EpdFontFamily::BOLD : EpdFontFamily::REGULAR);
|
tab.selected ? EpdFontFamily::BOLD : EpdFontFamily::REGULAR);
|
||||||
|
|
||||||
// Draw underline for selected tab
|
// Draw underline for selected tab
|
||||||
if (tab.selected) {
|
if (tab.selected) {
|
||||||
renderer.fillRect(currentX, y + lineHeight + underlineGap, textWidth, underlineHeight);
|
renderer.fillRect(currentX, y + lineHeight + underlineGap, textWidth, underlineHeight);
|
||||||
}
|
|
||||||
|
|
||||||
currentX += textWidth + tabPadding;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tabBarHeight;
|
currentX += textWidth + tabPadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenComponents::drawScrollIndicator(const GfxRenderer& renderer, const int currentPage, const int totalPages,
|
return tabBarHeight;
|
||||||
const int contentTop, const int contentHeight) {
|
}
|
||||||
if (totalPages <= 1) {
|
|
||||||
return; // No need for indicator if only one page
|
|
||||||
}
|
|
||||||
|
|
||||||
const int screenWidth = renderer.getScreenWidth();
|
void ScreenComponents::drawScrollIndicator(const GfxRenderer& renderer, const int currentPage, const int totalPages,
|
||||||
constexpr int indicatorWidth = 20;
|
const int contentTop, const int contentHeight) {
|
||||||
constexpr int arrowSize = 6;
|
if (totalPages <= 1) {
|
||||||
constexpr int margin = 15; // Offset from right edge
|
return; // No need for indicator if only one page
|
||||||
|
|
||||||
const int centerX = screenWidth - indicatorWidth / 2 - margin;
|
|
||||||
const int indicatorTop = contentTop + 60; // Offset to avoid overlapping side button hints
|
|
||||||
const int indicatorBottom = contentTop + contentHeight - 30;
|
|
||||||
|
|
||||||
// Draw up arrow at top (^) - narrow point at top, wide base at bottom
|
|
||||||
for (int i = 0; i < arrowSize; ++i) {
|
|
||||||
const int lineWidth = 1 + i * 2;
|
|
||||||
const int startX = centerX - i;
|
|
||||||
renderer.drawLine(startX, indicatorTop + i, startX + lineWidth - 1, indicatorTop + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw down arrow at bottom (v) - wide base at top, narrow point at bottom
|
|
||||||
for (int i = 0; i < arrowSize; ++i) {
|
|
||||||
const int lineWidth = 1 + (arrowSize - 1 - i) * 2;
|
|
||||||
const int startX = centerX - (arrowSize - 1 - i);
|
|
||||||
renderer.drawLine(startX, indicatorBottom - arrowSize + 1 + i, startX + lineWidth - 1,
|
|
||||||
indicatorBottom - arrowSize + 1 + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw page fraction in the middle (e.g., "1/3")
|
|
||||||
const std::string pageText = std::to_string(currentPage) + "/" + std::to_string(totalPages);
|
|
||||||
const int textWidth = renderer.getTextWidth(SMALL_FONT_ID, pageText.c_str());
|
|
||||||
const int textX = centerX - textWidth / 2;
|
|
||||||
const int textY = (indicatorTop + indicatorBottom) / 2 - renderer.getLineHeight(SMALL_FONT_ID) / 2;
|
|
||||||
|
|
||||||
renderer.drawText(SMALL_FONT_ID, textX, textY, pageText.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenComponents::drawProgressBar(const GfxRenderer& renderer, const int x, const int y, const int width,
|
const int screenWidth = renderer.getScreenWidth();
|
||||||
const int height, const size_t current, const size_t total) {
|
constexpr int indicatorWidth = 20;
|
||||||
if (total == 0) {
|
constexpr int arrowSize = 6;
|
||||||
return;
|
constexpr int margin = 15; // Offset from right edge
|
||||||
}
|
|
||||||
|
|
||||||
// Use 64-bit arithmetic to avoid overflow for large files
|
const int centerX = screenWidth - indicatorWidth / 2 - margin;
|
||||||
const int percent = static_cast<int>((static_cast<uint64_t>(current) * 100) / total);
|
const int indicatorTop = contentTop + 60; // Offset to avoid overlapping side button hints
|
||||||
|
const int indicatorBottom = contentTop + contentHeight - 30;
|
||||||
|
|
||||||
// Draw outline
|
// Draw up arrow at top (^) - narrow point at top, wide base at bottom
|
||||||
renderer.drawRect(x, y, width, height);
|
for (int i = 0; i < arrowSize; ++i) {
|
||||||
|
const int lineWidth = 1 + i * 2;
|
||||||
// Draw filled portion
|
const int startX = centerX - i;
|
||||||
const int fillWidth = (width - 4) * percent / 100;
|
renderer.drawLine(startX, indicatorTop + i, startX + lineWidth - 1, indicatorTop + i);
|
||||||
if (fillWidth > 0) {
|
|
||||||
renderer.fillRect(x + 2, y + 2, fillWidth, height - 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw percentage text centered below bar
|
|
||||||
const std::string percentText = std::to_string(percent) + "%";
|
|
||||||
renderer.drawCenteredText(UI_10_FONT_ID, y + height + 15, percentText.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw down arrow at bottom (v) - wide base at top, narrow point at bottom
|
||||||
|
for (int i = 0; i < arrowSize; ++i) {
|
||||||
|
const int lineWidth = 1 + (arrowSize - 1 - i) * 2;
|
||||||
|
const int startX = centerX - (arrowSize - 1 - i);
|
||||||
|
renderer.drawLine(startX, indicatorBottom - arrowSize + 1 + i, startX + lineWidth - 1,
|
||||||
|
indicatorBottom - arrowSize + 1 + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw page fraction in the middle (e.g., "1/3")
|
||||||
|
const std::string pageText = std::to_string(currentPage) + "/" + std::to_string(totalPages);
|
||||||
|
const int textWidth = renderer.getTextWidth(SMALL_FONT_ID, pageText.c_str());
|
||||||
|
const int textX = centerX - textWidth / 2;
|
||||||
|
const int textY = (indicatorTop + indicatorBottom) / 2 - renderer.getLineHeight(SMALL_FONT_ID) / 2;
|
||||||
|
|
||||||
|
renderer.drawText(SMALL_FONT_ID, textX, textY, pageText.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScreenComponents::drawProgressBar(const GfxRenderer& renderer, const int x, const int y, const int width,
|
||||||
|
const int height, const size_t current, const size_t total) {
|
||||||
|
if (total == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use 64-bit arithmetic to avoid overflow for large files
|
||||||
|
const int percent = static_cast<int>((static_cast<uint64_t>(current) * 100) / total);
|
||||||
|
|
||||||
|
// Draw outline
|
||||||
|
renderer.drawRect(x, y, width, height);
|
||||||
|
|
||||||
|
// Draw filled portion
|
||||||
|
const int fillWidth = (width - 4) * percent / 100;
|
||||||
|
if (fillWidth > 0) {
|
||||||
|
renderer.fillRect(x + 2, y + 2, fillWidth, height - 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw percentage text centered below bar
|
||||||
|
const std::string percentText = std::to_string(percent) + "%";
|
||||||
|
renderer.drawCenteredText(UI_10_FONT_ID, y + height + 15, percentText.c_str());
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user