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

Method drawStatusBar

src/components/themes/BaseTheme.cpp:750–886  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

748}
749
750void BaseTheme::drawStatusBar(GfxRenderer& renderer, const float bookProgress, const int currentPage,
751 const int pageCount, std::string title, const int paddingBottom, const int textYOffset,
752 const bool fillMargin, const bool isPageBookmarked) const {
753 auto metrics = UITheme::getInstance().getMetrics();
754 int orientedMarginTop, orientedMarginRight, orientedMarginBottom, orientedMarginLeft;
755 renderer.getOrientedViewableTRBL(&orientedMarginTop, &orientedMarginRight, &orientedMarginBottom,
756 &orientedMarginLeft);
757 const bool showStatusBarTextLane = statusBarTextLaneVisible();
758
759 // Draw Progress Text
760 const auto screenHeight = renderer.getScreenHeight();
761 auto textY = screenHeight - UITheme::getInstance().getStatusBarHeight() - orientedMarginBottom - paddingBottom - 4;
762
763 const int leftClusterX = metrics.statusBarHorizontalMargin + orientedMarginLeft + 1;
764 const int rightClusterX = renderer.getScreenWidth() - metrics.statusBarHorizontalMargin - orientedMarginRight;
765 int leftClusterWidth = 0;
766 int rightClusterWidth = 0;
767
768 if (SETTINGS.statusBarBookProgressPercentage || SETTINGS.statusBarChapterPageCount) {
769 // Right aligned text for progress counter
770 char progressStr[32];
771
772 if (SETTINGS.statusBarBookProgressPercentage && SETTINGS.statusBarChapterPageCount) {
773 snprintf(progressStr, sizeof(progressStr), "%d/%d %.0f%%", currentPage, pageCount, bookProgress);
774 } else if (SETTINGS.statusBarBookProgressPercentage) {
775 snprintf(progressStr, sizeof(progressStr), "%.0f%%", bookProgress);
776 } else {
777 snprintf(progressStr, sizeof(progressStr), "%d/%d", currentPage, pageCount);
778 }
779
780 int progressTextWidth = renderer.getTextWidth(SMALL_FONT_ID, progressStr);
781 renderer.drawText(SMALL_FONT_ID, rightClusterX - progressTextWidth, textY, progressStr);
782
783 rightClusterWidth += progressTextWidth;
784 }
785
786 // Draw Progress Bar
787 if (SETTINGS.statusBarProgressBar != CrossPointSettings::STATUS_BAR_PROGRESS_BAR::HIDE_PROGRESS) {
788 const int barMarginLeft = fillMargin ? 0 : orientedMarginLeft;
789 const int barMarginRight = fillMargin ? 0 : orientedMarginRight;
790 const int progressBarMaxWidth = renderer.getScreenWidth() - barMarginLeft - barMarginRight;
791 const int progressBarY = renderer.getScreenHeight() - orientedMarginBottom -
792 ((SETTINGS.statusBarProgressBarThickness + 1) * 2) - paddingBottom + (fillMargin ? 1 : 0);
793 size_t progress;
794 if (SETTINGS.statusBarProgressBar == CrossPointSettings::STATUS_BAR_PROGRESS_BAR::BOOK_PROGRESS) {
795 progress = static_cast<size_t>(bookProgress);
796 } else {
797 // Chapter progress
798 progress = (pageCount > 0) ? (static_cast<float>(currentPage) / pageCount) * 100 : 0;
799 }
800 const int barWidth = progressBarMaxWidth * progress / 100;
801 const int barHeight =
802 ((SETTINGS.statusBarProgressBarThickness + 1) * 2) + (fillMargin ? orientedMarginBottom - 1 : 0);
803 renderer.fillRect(barMarginLeft, progressBarY, barWidth, barHeight, true);
804 }
805
806 // Draw Battery
807 const bool showBatteryPercentage =

Callers 4

renderStatusBarMethod · 0.80
renderStatusBarMethod · 0.80
renderMethod · 0.80

Calls 15

statusBarTextLaneVisibleFunction · 0.85
drawBookmarkStatusIconFunction · 0.85
getScreenHeightMethod · 0.80
getStatusBarHeightMethod · 0.80
getScreenWidthMethod · 0.80
getTextWidthMethod · 0.80
drawTextMethod · 0.80
fillRectMethod · 0.80
drawBatteryLeftMethod · 0.80
getBatteryPercentageMethod · 0.80
formatTimeMethod · 0.80

Tested by

no test coverage detected