MCPcopy Create free account
hub / github.com/bmorcelli/Launcher / drawOptions

Function drawOptions

src/display.cpp:520–789  ·  view source on GitHub ↗

** Function name: drawOptions ** Description: Função para desenhar e mostrar as opçoes de contexto ***************************************************************************************/

Source from the content-addressed store, hash-verified

518** Description: Função para desenhar e mostrar as opçoes de contexto
519***************************************************************************************/
520Opt_Coord drawOptions(
521 int idx, std::vector<Option> &opt, std::vector<MenuOptions> &t_menu, uint16_t fgcolor, uint16_t bgcolor,
522 bool border
523) {
524 int index = idx;
525 uint16_t alcolor = ALCOLOR;
526#ifdef E_PAPER_DISPLAY
527#ifdef USE_EPD_PAINTER
528 if (!border) { tft->fillScreen(BGCOLOR); }
529#endif
530 bgcolor = WHITE; // 0xffff
531 alcolor = BLACK; // 0x0000
532 fgcolor = BLACK;
533#endif
534
535 Opt_Coord coord;
536 coord.bgcolor = bgcolor;
537 coord.fgcolor = fgcolor;
538
539 t_menu.clear();
540 int arraySize = opt.size();
541 if (arraySize == 0) { return coord; }
542
543 if (index < 0) index = 0;
544 if (index >= arraySize) index = arraySize - 1;
545
546 int lineHeight = FM * LH;
547 const int rowSpacing = 4;
548 const int paddingTop = 4;
549 const int paddingBottom = 4;
550 const int paddingSide = 4;
551
552 int contentWidth = border ? static_cast<int>(tftWidth * 0.8f) : tftWidth - 4;
553 if (contentWidth < 1) contentWidth = tftWidth;
554 int boxX = border ? (tftWidth - contentWidth) / 2 : 2;
555
556 int availableHeight = border ? (tftHeight - 20) : (tftHeight - 4);
557 int minHeight = lineHeight + paddingTop + paddingBottom;
558 if (availableHeight < minHeight) availableHeight = minHeight;
559
560 int totalRows = (availableHeight - paddingTop - paddingBottom + rowSpacing) / (lineHeight + rowSpacing);
561 if (totalRows < 1) totalRows = 1;
562
563 int start = 0;
564 int optionCount = 0;
565 bool showPageUp = false;
566 bool showPageDown = false;
567
568#ifdef HAS_TOUCH
569 struct PageInfo {
570 int start;
571 int count;
572 bool pageUp;
573 bool pageDown;
574 };
575
576 std::vector<PageInfo> pages;
577 int remaining = arraySize;

Callers 1

loopOptionsFunction · 0.85

Calls 13

setCoordsMethod · 0.80
printMethod · 0.80
fillScreenMethod · 0.45
clearMethod · 0.45
setTextSizeMethod · 0.45
fillRoundRectMethod · 0.45
drawRoundRectMethod · 0.45
getTextsizeMethod · 0.45
fillRectMethod · 0.45
setCursorMethod · 0.45
setTextColorMethod · 0.45
drawCentreStringMethod · 0.45

Tested by

no test coverage detected