A fork of https://github.com/crosspoint-reader/crosspoint-reader
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Show book title instead of "Select Chapter". (#169)

I think this is nicer ;)

authored by

Jonas Diemer and committed by
GitHub
06065dfd 93226c9f

+17 -7
+11
lib/GfxRenderer/GfxRenderer.cpp
··· 238 238 einkDisplay.displayBuffer(refreshMode); 239 239 } 240 240 241 + std::string GfxRenderer::truncatedText(const int fontId, const char* text, const int maxWidth, 242 + const EpdFontStyle style) const { 243 + std::string item = text; 244 + int itemWidth = getTextWidth(fontId, item.c_str(), style); 245 + while (itemWidth > maxWidth && item.length() > 8) { 246 + item.replace(item.length() - 5, 5, "..."); 247 + itemWidth = getTextWidth(fontId, item.c_str(), style); 248 + } 249 + return item; 250 + } 251 + 241 252 // Note: Internal driver treats screen in command orientation; this library exposes a logical orientation 242 253 int GfxRenderer::getScreenWidth() const { 243 254 switch (orientation) {
+2
lib/GfxRenderer/GfxRenderer.h
··· 75 75 int getSpaceWidth(int fontId) const; 76 76 int getFontAscenderSize(int fontId) const; 77 77 int getLineHeight(int fontId) const; 78 + std::string truncatedText(const int fontId, const char* text, const int maxWidth, 79 + const EpdFontStyle style = REGULAR) const; 78 80 79 81 // UI Components 80 82 void drawButtonHints(int fontId, const char* btn1, const char* btn2, const char* btn3, const char* btn4) const;
+3 -1
src/activities/reader/EpubReaderChapterSelectionActivity.cpp
··· 120 120 121 121 const auto pageWidth = renderer.getScreenWidth(); 122 122 const int pageItems = getPageItems(); 123 - renderer.drawCenteredText(UI_12_FONT_ID, 15, "Select Chapter", true, BOLD); 123 + 124 + std::string title = renderer.truncatedText(UI_12_FONT_ID, epub->getTitle().c_str(), pageWidth - 40, BOLD); 125 + renderer.drawCenteredText(UI_12_FONT_ID, 15, title.c_str(), true, BOLD); 124 126 125 127 const auto pageStartIndex = selectorIndex / pageItems * pageItems; 126 128 renderer.fillRect(0, 60 + (selectorIndex % pageItems) * 30 - 2, pageWidth - 1, 30);
+1 -6
src/activities/reader/FileSelectionActivity.cpp
··· 188 188 const auto pageStartIndex = selectorIndex / PAGE_ITEMS * PAGE_ITEMS; 189 189 renderer.fillRect(0, 60 + (selectorIndex % PAGE_ITEMS) * 30 - 2, pageWidth - 1, 30); 190 190 for (int i = pageStartIndex; i < files.size() && i < pageStartIndex + PAGE_ITEMS; i++) { 191 - auto item = files[i]; 192 - int itemWidth = renderer.getTextWidth(UI_10_FONT_ID, item.c_str()); 193 - while (itemWidth > renderer.getScreenWidth() - 40 && item.length() > 8) { 194 - item.replace(item.length() - 5, 5, "..."); 195 - itemWidth = renderer.getTextWidth(UI_10_FONT_ID, item.c_str()); 196 - } 191 + auto item = renderer.truncatedText(UI_10_FONT_ID, files[i].c_str(), renderer.getScreenWidth() - 40); 197 192 renderer.drawText(UI_10_FONT_ID, 20, 60 + (i % PAGE_ITEMS) * 30, item.c_str(), i != selectorIndex); 198 193 } 199 194