Use series in recents if present
This commit is contained in:
@@ -103,7 +103,7 @@ void RecentBooksActivity::render(RenderLock&&) {
|
|||||||
[this](int index) { return recentBooks[index].title; },
|
[this](int index) { return recentBooks[index].title; },
|
||||||
[this](int index) {
|
[this](int index) {
|
||||||
const auto& book = recentBooks[index];
|
const auto& book = recentBooks[index];
|
||||||
if (!book.author.empty() && !book.series.empty()) return book.author + " \u2022 " + book.series;
|
if (!book.author.empty() && !book.series.empty()) return book.author + "\n" + book.series;
|
||||||
if (!book.series.empty()) return book.series;
|
if (!book.series.empty()) return book.series;
|
||||||
return book.author;
|
return book.author;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -235,8 +235,12 @@ void BaseTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount,
|
|||||||
renderer.drawText(font, rect.x + BaseMetrics::values.contentSidePadding, itemY, item.c_str(), i != selectedIndex);
|
renderer.drawText(font, rect.x + BaseMetrics::values.contentSidePadding, itemY, item.c_str(), i != selectedIndex);
|
||||||
|
|
||||||
if (rowSubtitle != nullptr) {
|
if (rowSubtitle != nullptr) {
|
||||||
// Draw subtitle
|
// Draw subtitle; if the text is newline-separated (author\nseries), join with • for single-line display
|
||||||
std::string subtitleText = rowSubtitle(i);
|
std::string subtitleText = rowSubtitle(i);
|
||||||
|
const auto nl = subtitleText.find('\n');
|
||||||
|
if (nl != std::string::npos) {
|
||||||
|
subtitleText = subtitleText.substr(0, nl) + " \u2022 " + subtitleText.substr(nl + 1);
|
||||||
|
}
|
||||||
auto subtitle = renderer.truncatedText(UI_10_FONT_ID, subtitleText.c_str(), textWidth);
|
auto subtitle = renderer.truncatedText(UI_10_FONT_ID, subtitleText.c_str(), textWidth);
|
||||||
renderer.drawText(UI_10_FONT_ID, rect.x + BaseMetrics::values.contentSidePadding, itemY + 30, subtitle.c_str(),
|
renderer.drawText(UI_10_FONT_ID, rect.x + BaseMetrics::values.contentSidePadding, itemY + 30, subtitle.c_str(),
|
||||||
i != selectedIndex);
|
i != selectedIndex);
|
||||||
|
|||||||
@@ -318,10 +318,18 @@ void LyraTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (rowSubtitle != nullptr) {
|
if (rowSubtitle != nullptr) {
|
||||||
// Draw subtitle
|
|
||||||
std::string subtitleText = rowSubtitle(i);
|
std::string subtitleText = rowSubtitle(i);
|
||||||
auto subtitle = renderer.truncatedText(SMALL_FONT_ID, subtitleText.c_str(), rowTextWidth);
|
const auto nl = subtitleText.find('\n');
|
||||||
renderer.drawText(SMALL_FONT_ID, textX, itemY + 30, subtitle.c_str(), true);
|
if (nl != std::string::npos) {
|
||||||
|
// Two-line subtitle: first line (author) at +24, second line (series) at +40
|
||||||
|
auto line1 = renderer.truncatedText(SMALL_FONT_ID, subtitleText.substr(0, nl).c_str(), rowTextWidth);
|
||||||
|
renderer.drawText(SMALL_FONT_ID, textX, itemY + 24, line1.c_str(), true);
|
||||||
|
auto line2 = renderer.truncatedText(SMALL_FONT_ID, subtitleText.substr(nl + 1).c_str(), rowTextWidth);
|
||||||
|
renderer.drawText(SMALL_FONT_ID, textX, itemY + 40, line2.c_str(), true);
|
||||||
|
} else {
|
||||||
|
auto subtitle = renderer.truncatedText(SMALL_FONT_ID, subtitleText.c_str(), rowTextWidth);
|
||||||
|
renderer.drawText(SMALL_FONT_ID, textX, itemY + 30, subtitle.c_str(), true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw value
|
// Draw value
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ constexpr ThemeMetrics values = {.batteryWidth = 16,
|
|||||||
.verticalSpacing = 16,
|
.verticalSpacing = 16,
|
||||||
.contentSidePadding = 20,
|
.contentSidePadding = 20,
|
||||||
.listRowHeight = 40,
|
.listRowHeight = 40,
|
||||||
.listWithSubtitleRowHeight = 60,
|
.listWithSubtitleRowHeight = 68,
|
||||||
.menuRowHeight = 64,
|
.menuRowHeight = 64,
|
||||||
.menuSpacing = 8,
|
.menuSpacing = 8,
|
||||||
.tabSpacing = 8,
|
.tabSpacing = 8,
|
||||||
|
|||||||
Reference in New Issue
Block a user