mirror of
https://github.com/daveallie/crosspoint-reader.git
synced 2025-12-19 07:37:41 +03:00
62 lines
1.5 KiB
C++
62 lines
1.5 KiB
C++
#pragma once
|
|
#include <cstring>
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
#include "../../lib/Epub/Epub/FootnoteEntry.h"
|
|
#include "../Activity.h"
|
|
|
|
class FootnotesData {
|
|
private:
|
|
FootnoteEntry entries[32];
|
|
int count;
|
|
|
|
public:
|
|
FootnotesData() : count(0) {}
|
|
|
|
void addFootnote(const char* number, const char* href) {
|
|
if (count < 32) {
|
|
strncpy(entries[count].number, number, 2);
|
|
entries[count].number[2] = '\0';
|
|
strncpy(entries[count].href, href, 63);
|
|
entries[count].href[63] = '\0';
|
|
count++;
|
|
}
|
|
}
|
|
|
|
void clear() { count = 0; }
|
|
|
|
int getCount() const { return count; }
|
|
|
|
const FootnoteEntry* getEntry(int index) const {
|
|
if (index >= 0 && index < count) {
|
|
return &entries[index];
|
|
}
|
|
return nullptr;
|
|
}
|
|
};
|
|
|
|
class EpubReaderFootnotesActivity final : public Activity {
|
|
const FootnotesData& footnotes;
|
|
const std::function<void()> onGoBack;
|
|
const std::function<void(const char*)> onSelectFootnote;
|
|
int selectedIndex;
|
|
|
|
public:
|
|
EpubReaderFootnotesActivity(GfxRenderer& renderer, InputManager& inputManager, const FootnotesData& footnotes,
|
|
const std::function<void()>& onGoBack,
|
|
const std::function<void(const char*)>& onSelectFootnote)
|
|
: Activity(renderer, inputManager),
|
|
footnotes(footnotes),
|
|
onGoBack(onGoBack),
|
|
onSelectFootnote(onSelectFootnote),
|
|
selectedIndex(0) {}
|
|
|
|
void onEnter() override;
|
|
void onExit() override;
|
|
void loop() override;
|
|
|
|
private:
|
|
void render();
|
|
};
|