** Function name: drawOptions ** Description: Função para desenhar e mostrar as opçoes de contexto ***************************************************************************************/
| 518 | ** Description: Função para desenhar e mostrar as opçoes de contexto |
| 519 | ***************************************************************************************/ |
| 520 | Opt_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; |
no test coverage detected