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.

fix: draw button hints correctly if orientation is not portrait (#363)

~~Quick~~ fix for
https://github.com/daveallie/crosspoint-reader/issues/362

(this just applies to the chapter selection menu:)

~~If the orientation is portrait, hints as we know them make sense to
draw. If the orientation is inverted, we'd have to change the order of
the labels (along with everything's position), and if it's one of the
landscape choices, we'd have to render the text and buttons vertically.
All those other cases will be more complicated.~~

~~Punt on this for now by only rendering if portrait.~~

Update: this now draws the hints at the physical button position no
matter what the orientation is, by temporarily changing orientation to
portrait.

---------

Co-authored-by: Maeve Andrews <maeve@git.mail.maeveandrews.com>

authored by

Maeve Andrews
Maeve Andrews
and committed by
GitHub
c98ba142 c1c94c01

+8 -2
+7 -1
lib/GfxRenderer/GfxRenderer.cpp
··· 468 468 } 469 469 470 470 void GfxRenderer::drawButtonHints(const int fontId, const char* btn1, const char* btn2, const char* btn3, 471 - const char* btn4) const { 471 + const char* btn4) { 472 + const Orientation orig_orientation = getOrientation(); 473 + setOrientation(Orientation::Portrait); 474 + 472 475 const int pageHeight = getScreenHeight(); 473 476 constexpr int buttonWidth = 106; 474 477 constexpr int buttonHeight = 40; ··· 481 484 // Only draw if the label is non-empty 482 485 if (labels[i] != nullptr && labels[i][0] != '\0') { 483 486 const int x = buttonPositions[i]; 487 + fillRect(x, pageHeight - buttonY, buttonWidth, buttonHeight, false); 484 488 drawRect(x, pageHeight - buttonY, buttonWidth, buttonHeight); 485 489 const int textWidth = getTextWidth(fontId, labels[i]); 486 490 const int textX = x + (buttonWidth - 1 - textWidth) / 2; 487 491 drawText(fontId, textX, pageHeight - buttonY + textYOffset, labels[i]); 488 492 } 489 493 } 494 + 495 + setOrientation(orig_orientation); 490 496 } 491 497 492 498 void GfxRenderer::drawSideButtonHints(const int fontId, const char* topBtn, const char* bottomBtn) const {
+1 -1
lib/GfxRenderer/GfxRenderer.h
··· 84 84 EpdFontFamily::Style style = EpdFontFamily::REGULAR) const; 85 85 86 86 // UI Components 87 - void drawButtonHints(int fontId, const char* btn1, const char* btn2, const char* btn3, const char* btn4) const; 87 + void drawButtonHints(int fontId, const char* btn1, const char* btn2, const char* btn3, const char* btn4); 88 88 void drawSideButtonHints(int fontId, const char* topBtn, const char* bottomBtn) const; 89 89 90 90 private: