More tweaks
This commit is contained in:
@@ -322,11 +322,19 @@ void LyraCarouselTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect,
|
|||||||
const float tileRatio = static_cast<float>(maxW) / static_cast<float>(maxH);
|
const float tileRatio = static_cast<float>(maxW) / static_cast<float>(maxH);
|
||||||
const float cropX = (bmpRatio > tileRatio) ? (1.0f - tileRatio / bmpRatio) : 0.0f;
|
const float cropX = (bmpRatio > tileRatio) ? (1.0f - tileRatio / bmpRatio) : 0.0f;
|
||||||
renderer.drawBitmap(bitmap, x, y, maxW, maxH, cropX, 0.0f);
|
renderer.drawBitmap(bitmap, x, y, maxW, maxH, cropX, 0.0f);
|
||||||
// White-out the four corners so the rounded outline is not obscured by bitmap pixels.
|
// Clear only the pixels outside the arc in each corner so the rounded
|
||||||
renderer.fillRect(x, y, kCornerRadius, kCornerRadius, false);
|
// outline has white backing. Circle test: pixel (dx,dy) from the arc
|
||||||
renderer.fillRect(x + maxW - kCornerRadius, y, kCornerRadius, kCornerRadius, false);
|
// centre is outside if dx²+dy² > r², where r = kCornerRadius.
|
||||||
renderer.fillRect(x, y + maxH - kCornerRadius, kCornerRadius, kCornerRadius, false);
|
for (int dy = 0; dy < kCornerRadius; ++dy) {
|
||||||
renderer.fillRect(x + maxW - kCornerRadius, y + maxH - kCornerRadius, kCornerRadius, kCornerRadius, false);
|
for (int dx = 0; dx < kCornerRadius; ++dx) {
|
||||||
|
if (dx * dx + dy * dy > kCornerRadius * kCornerRadius) {
|
||||||
|
renderer.drawPixel(x + dx, y + dy, false); // top-left
|
||||||
|
renderer.drawPixel(x + maxW - 1 - dx, y + dy, false); // top-right
|
||||||
|
renderer.drawPixel(x + dx, y + maxH - 1 - dy, false); // bottom-left
|
||||||
|
renderer.drawPixel(x + maxW - 1 - dx, y + maxH - 1 - dy, false); // bottom-right
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
renderer.drawRoundedRect(x, y, maxW, maxH, kThinOutlineW, kCornerRadius, true);
|
renderer.drawRoundedRect(x, y, maxW, maxH, kThinOutlineW, kCornerRadius, true);
|
||||||
hasCover = true;
|
hasCover = true;
|
||||||
}
|
}
|
||||||
@@ -346,10 +354,15 @@ void LyraCarouselTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect,
|
|||||||
if (!coverRendered) {
|
if (!coverRendered) {
|
||||||
lastCarouselSelectorIndex = centerIdx;
|
lastCarouselSelectorIndex = centerIdx;
|
||||||
|
|
||||||
// Clear the full band — cover tile plus the author/title text below it —
|
// Clear from the top of the tile down through the author/title text area.
|
||||||
// so stale pixels from a previous book don't persist on book change.
|
// Use absolute coordinates so the clear covers the text regardless of what
|
||||||
renderer.fillRect(rect.x, rect.y, rect.width,
|
// rect.height HomeActivity computed (it may be smaller than homeCoverTileHeight).
|
||||||
rect.height + renderer.getLineHeight(kTitleFontId) * 2 + kDotSize + 20, false);
|
const int textAreaBottom = centerTileY + kCenterCoverMaxH // bottom of centre cover
|
||||||
|
+ 8 + kDotSize // dots
|
||||||
|
+ 6 + renderer.getLineHeight(kTitleFontId) // author line
|
||||||
|
+ 2 + renderer.getLineHeight(kTitleFontId) // title line
|
||||||
|
+ 4; // small margin
|
||||||
|
renderer.fillRect(rect.x, rect.y, rect.width, textAreaBottom - rect.y, false);
|
||||||
|
|
||||||
// Sides first so centre renders on top.
|
// Sides first so centre renders on top.
|
||||||
// Left side only when there are 3+ books; right side when there are 2+ books.
|
// Left side only when there are 3+ books; right side when there are 2+ books.
|
||||||
@@ -435,7 +448,10 @@ void LyraCarouselTheme::drawButtonMenu(GfxRenderer& renderer, Rect rect, int but
|
|||||||
if (selectedIndex >= 0 && buttonLabel != nullptr) {
|
if (selectedIndex >= 0 && buttonLabel != nullptr) {
|
||||||
const auto& metrics = UITheme::getInstance().getMetrics();
|
const auto& metrics = UITheme::getInstance().getMetrics();
|
||||||
const std::string label = buttonLabel(selectedIndex);
|
const std::string label = buttonLabel(selectedIndex);
|
||||||
drawHeader(renderer, Rect{0, metrics.topPadding, screenW, metrics.homeTopPadding}, label.c_str(), nullptr);
|
const int labelY = metrics.topPadding + 5; // same y as battery / clock
|
||||||
|
const int labelW = renderer.getTextWidth(UI_12_FONT_ID, label.c_str(), EpdFontFamily::BOLD);
|
||||||
|
const int labelX = (screenW - labelW) / 2;
|
||||||
|
renderer.drawText(UI_12_FONT_ID, labelX, labelY, label.c_str(), true, EpdFontFamily::BOLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int slot = 0; slot < visibleCount; ++slot) {
|
for (int slot = 0; slot < visibleCount; ++slot) {
|
||||||
|
|||||||
Reference in New Issue
Block a user