mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-05 23:27:38 +03:00
Shorten continueLabel to actual screen width. (#151)
Some checks are pending
CI / build (push) Waiting to run
Some checks are pending
CI / build (push) Waiting to run
This commit is contained in:
parent
1bfe694807
commit
b01eb50325
@ -122,12 +122,16 @@ void HomeActivity::render() const {
|
|||||||
if (bookName.length() > 5 && bookName.substr(bookName.length() - 5) == ".epub") {
|
if (bookName.length() > 5 && bookName.substr(bookName.length() - 5) == ".epub") {
|
||||||
bookName.resize(bookName.length() - 5);
|
bookName.resize(bookName.length() - 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Truncate if too long
|
// Truncate if too long
|
||||||
if (bookName.length() > 25) {
|
|
||||||
bookName.resize(22);
|
|
||||||
bookName += "...";
|
|
||||||
}
|
|
||||||
std::string continueLabel = "Continue: " + bookName;
|
std::string continueLabel = "Continue: " + bookName;
|
||||||
|
int itemWidth = renderer.getTextWidth(UI_FONT_ID, continueLabel.c_str());
|
||||||
|
while (itemWidth > renderer.getScreenWidth() - 40 && continueLabel.length() > 8) {
|
||||||
|
continueLabel.replace(continueLabel.length() - 5, 5, "...");
|
||||||
|
itemWidth = renderer.getTextWidth(UI_FONT_ID, continueLabel.c_str());
|
||||||
|
Serial.printf("[%lu] [HOM] width: %lu, pageWidth: %lu\n", millis(), itemWidth, pageWidth);
|
||||||
|
}
|
||||||
|
|
||||||
renderer.drawText(UI_FONT_ID, 20, menuY, continueLabel.c_str(), selectorIndex != menuIndex);
|
renderer.drawText(UI_FONT_ID, 20, menuY, continueLabel.c_str(), selectorIndex != menuIndex);
|
||||||
menuY += 30;
|
menuY += 30;
|
||||||
menuIndex++;
|
menuIndex++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user