MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / render

Method render

src/activities/reader/EpubReaderActivity.cpp:792–979  ·  view source on GitHub ↗

TODO: Failure handling

Source from the content-addressed store, hash-verified

790
791// TODO: Failure handling
792void EpubReaderActivity::render(RenderLock&& lock) {
793 if (!epub) {
794 return;
795 }
796
797 const auto showPendingSyncSaveError = [this]() {
798 if (!pendingSyncSaveError) return;
799 pendingSyncSaveError = false;
800 GUI.drawPopup(renderer, tr(STR_SAVE_PROGRESS_FAILED));
801 };
802
803 // edge case handling for sub-zero spine index
804 if (currentSpineIndex < 0) {
805 currentSpineIndex = 0;
806 }
807 // based bounds of book, show end of book screen
808 if (currentSpineIndex > epub->getSpineItemsCount()) {
809 currentSpineIndex = epub->getSpineItemsCount();
810 }
811
812 // Show end of book screen
813 if (currentSpineIndex == epub->getSpineItemsCount()) {
814 renderer.clearScreen();
815 renderer.drawCenteredText(UI_12_FONT_ID, 300, tr(STR_END_OF_BOOK), true, EpdFontFamily::BOLD);
816 renderer.displayBuffer();
817 automaticPageTurnActive = false;
818 showPendingSyncSaveError();
819 return;
820 }
821
822 // Apply screen viewable areas and additional padding
823 int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
824 renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
825 &orientedMarginLeft);
826 orientedMarginTop += SETTINGS.screenMargin;
827 orientedMarginLeft += SETTINGS.screenMargin;
828 orientedMarginRight += SETTINGS.screenMargin;
829
830 const uint8_t statusBarHeight = UITheme::getInstance().getStatusBarHeight();
831
832 // reserves space for automatic page turn indicator when no status bar or progress bar only
833 if (automaticPageTurnActive &&
834 (statusBarHeight == 0 || statusBarHeight == UITheme::getInstance().getProgressBarHeight())) {
835 orientedMarginBottom +=
836 std::max(SETTINGS.screenMargin,
837 static_cast<uint8_t>(statusBarHeight + UITheme::getInstance().getMetrics().statusBarVerticalMargin));
838 } else {
839 orientedMarginBottom += std::max(SETTINGS.screenMargin, statusBarHeight);
840 }
841
842 const uint16_t viewportWidth = renderer.getScreenWidth() - orientedMarginLeft - orientedMarginRight;
843 const uint16_t viewportHeight = renderer.getScreenHeight() - orientedMarginTop - orientedMarginBottom;
844
845 if (!section) {
846 const auto filepath = epub->getSpineItem(currentSpineIndex).href;
847 LOG_DBG("ERS", "Loading file: %s, index: %d", filepath.c_str(), currentSpineIndex);
848 section = std::unique_ptr<Section>(new Section(epub, currentSpineIndex, renderer));
849

Callers 1

renderContentsMethod · 0.45

Calls 15

saveProgressFunction · 0.85
drawPopupMethod · 0.80
getSpineItemsCountMethod · 0.80
getStatusBarHeightMethod · 0.80
getProgressBarHeightMethod · 0.80
getScreenWidthMethod · 0.80
getScreenHeightMethod · 0.80
getSpineItemMethod · 0.80
loadSectionFileMethod · 0.80
getReaderFontIdMethod · 0.80

Tested by

no test coverage detected