mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2026-02-06 07:37:37 +03:00
format files
This commit is contained in:
parent
c505729558
commit
87873c5d05
@ -14,15 +14,10 @@ constexpr int MAX_RECENT_BOOKS = 10;
|
|||||||
|
|
||||||
RecentBooksStore RecentBooksStore::instance;
|
RecentBooksStore RecentBooksStore::instance;
|
||||||
|
|
||||||
void RecentBooksStore::addBook(
|
void RecentBooksStore::addBook(const std::string& path, const std::string& title, const std::string& author) {
|
||||||
const std::string& path,
|
|
||||||
const std::string& title,
|
|
||||||
const std::string& author) {
|
|
||||||
// Remove existing entry if present
|
// Remove existing entry if present
|
||||||
auto it = std::find_if(
|
auto it =
|
||||||
recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) {
|
std::find_if(recentBooks.begin(), recentBooks.end(), [&](const RecentBook& book) { return book.path == path; });
|
||||||
return book.path == path;
|
|
||||||
});
|
|
||||||
if (it != recentBooks.end()) {
|
if (it != recentBooks.end()) {
|
||||||
recentBooks.erase(it);
|
recentBooks.erase(it);
|
||||||
}
|
}
|
||||||
@ -58,10 +53,7 @@ bool RecentBooksStore::saveToFile() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
outputFile.close();
|
outputFile.close();
|
||||||
Serial.printf(
|
Serial.printf("[%lu] [RBS] Recent books saved to file (%d entries)\n", millis(), count);
|
||||||
"[%lu] [RBS] Recent books saved to file (%d entries)\n",
|
|
||||||
millis(),
|
|
||||||
count);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,10 +80,7 @@ bool RecentBooksStore::loadFromFile() {
|
|||||||
recentBooks.push_back({path, "", ""});
|
recentBooks.push_back({path, "", ""});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Serial.printf(
|
Serial.printf("[%lu] [RBS] Deserialization failed: Unknown version %u\n", millis(), version);
|
||||||
"[%lu] [RBS] Deserialization failed: Unknown version %u\n",
|
|
||||||
millis(),
|
|
||||||
version);
|
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -112,9 +101,6 @@ bool RecentBooksStore::loadFromFile() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inputFile.close();
|
inputFile.close();
|
||||||
Serial.printf(
|
Serial.printf("[%lu] [RBS] Recent books loaded from file (%d entries)\n", millis(), recentBooks.size());
|
||||||
"[%lu] [RBS] Recent books loaded from file (%d entries)\n",
|
|
||||||
millis(),
|
|
||||||
recentBooks.size());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,10 +23,7 @@ class RecentBooksStore {
|
|||||||
static RecentBooksStore& getInstance() { return instance; }
|
static RecentBooksStore& getInstance() { return instance; }
|
||||||
|
|
||||||
// Add a book to the recent list (moves to front if already exists)
|
// Add a book to the recent list (moves to front if already exists)
|
||||||
void addBook(
|
void addBook(const std::string& path, const std::string& title, const std::string& author);
|
||||||
const std::string& path,
|
|
||||||
const std::string& title,
|
|
||||||
const std::string& author);
|
|
||||||
|
|
||||||
// Get the list of recent books (most recent first)
|
// Get the list of recent books (most recent first)
|
||||||
const std::vector<RecentBook>& getBooks() const { return recentBooks; }
|
const std::vector<RecentBook>& getBooks() const { return recentBooks; }
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace {
|
|||||||
constexpr int TAB_BAR_Y = 15;
|
constexpr int TAB_BAR_Y = 15;
|
||||||
constexpr int CONTENT_START_Y = 60;
|
constexpr int CONTENT_START_Y = 60;
|
||||||
constexpr int LINE_HEIGHT = 30;
|
constexpr int LINE_HEIGHT = 30;
|
||||||
constexpr int RECENTS_LINE_HEIGHT = 65; // Increased for two-line items
|
constexpr int RECENTS_LINE_HEIGHT = 65; // Increased for two-line items
|
||||||
constexpr int LEFT_MARGIN = 20;
|
constexpr int LEFT_MARGIN = 20;
|
||||||
constexpr int RIGHT_MARGIN = 40; // Extra space for scroll indicator
|
constexpr int RIGHT_MARGIN = 40; // Extra space for scroll indicator
|
||||||
|
|
||||||
@ -323,8 +323,8 @@ void MyLibraryActivity::renderRecentTab() const {
|
|||||||
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
const auto pageStartIndex = selectorIndex / pageItems * pageItems;
|
||||||
|
|
||||||
// Draw selection highlight
|
// Draw selection highlight
|
||||||
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * RECENTS_LINE_HEIGHT - 2, pageWidth - RIGHT_MARGIN,
|
renderer.fillRect(0, CONTENT_START_Y + (selectorIndex % pageItems) * RECENTS_LINE_HEIGHT - 2,
|
||||||
RECENTS_LINE_HEIGHT);
|
pageWidth - RIGHT_MARGIN, RECENTS_LINE_HEIGHT);
|
||||||
|
|
||||||
// Draw items
|
// Draw items
|
||||||
for (int i = pageStartIndex; i < bookCount && i < pageStartIndex + pageItems; i++) {
|
for (int i = pageStartIndex; i < bookCount && i < pageStartIndex + pageItems; i++) {
|
||||||
@ -346,7 +346,7 @@ void MyLibraryActivity::renderRecentTab() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
auto truncatedTitle = renderer.truncatedText(UI_12_FONT_ID, title.c_str(), pageWidth - LEFT_MARGIN - RIGHT_MARGIN);
|
auto truncatedTitle = renderer.truncatedText(UI_12_FONT_ID, title.c_str(), pageWidth - LEFT_MARGIN - RIGHT_MARGIN);
|
||||||
renderer.drawText(UI_12_FONT_ID, LEFT_MARGIN, y + 3, truncatedTitle.c_str(), i != selectorIndex);
|
renderer.drawText(UI_12_FONT_ID, LEFT_MARGIN, y + 2, truncatedTitle.c_str(), i != selectorIndex);
|
||||||
|
|
||||||
// Line 2: Author
|
// Line 2: Author
|
||||||
if (!book.author.empty()) {
|
if (!book.author.empty()) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user