mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-04 14:47:37 +03:00
Crop home page covers
This commit is contained in:
parent
781a01a6ef
commit
f5508f291e
@ -263,7 +263,7 @@ void HomeActivity::render() {
|
||||
if (hasContinueReading) {
|
||||
if (recentsLoaded) {
|
||||
recentsDisplayed = true;
|
||||
UITheme::drawRecentBookCover(renderer, Rect{0, metrics.homeTopPadding, pageWidth, metrics.homeCoverHeight},
|
||||
UITheme::drawRecentBookCover(renderer, Rect{0, metrics.homeTopPadding, pageWidth, metrics.homeCoverTileHeight},
|
||||
recentBooks, selectorIndex, coverRendered, coverBufferStored, bufferRestored,
|
||||
std::bind(&HomeActivity::storeCoverBuffer, this));
|
||||
} else if (!recentsLoading && firstRenderDone) {
|
||||
@ -282,7 +282,7 @@ void HomeActivity::render() {
|
||||
|
||||
UITheme::drawButtonMenu(
|
||||
renderer,
|
||||
Rect{0, metrics.homeTopPadding + metrics.homeCoverHeight + metrics.verticalSpacing, pageWidth,
|
||||
Rect{0, metrics.homeTopPadding + metrics.homeCoverTileHeight + metrics.verticalSpacing, pageWidth,
|
||||
pageHeight - (metrics.headerHeight + metrics.homeTopPadding + metrics.verticalSpacing * 2 +
|
||||
metrics.buttonHintsHeight)},
|
||||
static_cast<int>(menuItems.size()), selectorIndex - recentBooks.size(),
|
||||
|
||||
@ -45,6 +45,7 @@ struct ThemeMetrics {
|
||||
|
||||
int homeTopPadding;
|
||||
int homeCoverHeight;
|
||||
int homeCoverTileHeight;
|
||||
int homeRecentBooksCount;
|
||||
|
||||
int buttonHintsHeight;
|
||||
|
||||
@ -29,6 +29,7 @@ constexpr ThemeMetrics values = {.batteryWidth = 15,
|
||||
.scrollBarRightOffset = 5,
|
||||
.homeTopPadding = 20,
|
||||
.homeCoverHeight = 400,
|
||||
.homeCoverTileHeight = 400,
|
||||
.homeRecentBooksCount = 1,
|
||||
.buttonHintsHeight = 40,
|
||||
.sideButtonHintsWidth = 30,
|
||||
|
||||
@ -250,7 +250,7 @@ void LyraTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect,
|
||||
std::function<bool()> storeCoverBuffer) {
|
||||
const int tileWidth = (rect.width - 2 * LyraMetrics::values.contentSidePadding) / 3;
|
||||
const int tileHeight = rect.height;
|
||||
const int bookTitleHeight = 53;
|
||||
const int bookTitleHeight = tileHeight - LyraMetrics::values.homeCoverHeight - hPaddingInSelection;
|
||||
const int tileY = rect.y;
|
||||
const bool hasContinueReading = !recentBooks.empty();
|
||||
|
||||
@ -274,9 +274,15 @@ void LyraTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect,
|
||||
if (SdMan.openFileForRead("HOME", coverBmpPath, file)) {
|
||||
Bitmap bitmap(file);
|
||||
if (bitmap.parseHeaders() == BmpReaderError::Ok) {
|
||||
float coverHeight = static_cast<float>(bitmap.getHeight());
|
||||
float coverWidth = static_cast<float>(bitmap.getWidth());
|
||||
float ratio = coverWidth / coverHeight;
|
||||
const float tileRatio = static_cast<float>(tileWidth - 2 * hPaddingInSelection) /
|
||||
static_cast<float>(LyraMetrics::values.homeCoverHeight);
|
||||
float cropX = 1.0f - (tileRatio / ratio);
|
||||
|
||||
renderer.drawBitmap(bitmap, tileX + hPaddingInSelection, tileY + hPaddingInSelection,
|
||||
tileWidth - 2 * hPaddingInSelection,
|
||||
tileHeight - bookTitleHeight - hPaddingInSelection);
|
||||
tileWidth - 2 * hPaddingInSelection, LyraMetrics::values.homeCoverHeight, cropX);
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
@ -298,10 +304,10 @@ void LyraTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect,
|
||||
renderer.fillRoundedRect(tileX, tileY, tileWidth, hPaddingInSelection, cornerRadius, true, true, false, false,
|
||||
COLOR_LIGHT_GRAY);
|
||||
renderer.fillRectDither(tileX, tileY + hPaddingInSelection, hPaddingInSelection,
|
||||
tileHeight - hPaddingInSelection, COLOR_LIGHT_GRAY);
|
||||
LyraMetrics::values.homeCoverHeight, COLOR_LIGHT_GRAY);
|
||||
renderer.fillRectDither(tileX + tileWidth - hPaddingInSelection, tileY + hPaddingInSelection,
|
||||
hPaddingInSelection, tileHeight - hPaddingInSelection, COLOR_LIGHT_GRAY);
|
||||
renderer.fillRoundedRect(tileX, tileY + tileHeight + hPaddingInSelection - bookTitleHeight, tileWidth,
|
||||
hPaddingInSelection, LyraMetrics::values.homeCoverHeight, COLOR_LIGHT_GRAY);
|
||||
renderer.fillRoundedRect(tileX, tileY + LyraMetrics::values.homeCoverHeight + hPaddingInSelection, tileWidth,
|
||||
bookTitleHeight, cornerRadius, false, false, true, true, COLOR_LIGHT_GRAY);
|
||||
}
|
||||
renderer.drawText(UI_10_FONT_ID, tileX + hPaddingInSelection,
|
||||
|
||||
@ -21,7 +21,8 @@ constexpr ThemeMetrics values = {.batteryWidth = 16,
|
||||
.scrollBarWidth = 4,
|
||||
.scrollBarRightOffset = 5,
|
||||
.homeTopPadding = 56,
|
||||
.homeCoverHeight = 266,
|
||||
.homeCoverHeight = 226,
|
||||
.homeCoverTileHeight = 327,
|
||||
.homeRecentBooksCount = 3,
|
||||
.buttonHintsHeight = 40,
|
||||
.sideButtonHintsWidth = 19,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user