MCPcopy Create free account
hub / github.com/BruceDevices/firmware / drawOptions

Function drawOptions

src/core/display.cpp:677–741  ·  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

675** Description: Função para desenhar e mostrar as opçoes de contexto
676***************************************************************************************/
677Opt_Coord drawOptions(
678 int index, std::vector<Option> &options, uint16_t fgcolor, uint16_t selcolor, uint16_t bgcolor,
679 bool firstRender
680) {
681 Opt_Coord coord;
682 int menuSize = options.size();
683 if (options.size() > MAX_MENU_SIZE) { menuSize = MAX_MENU_SIZE; }
684
685 // Uncomment to update the statusBar (causes flickering)
686 // drawStatusBar();
687
688 int32_t optionsTopY = tftHeight / 2 - menuSize * (FM * 8 + 4) / 2 - 5;
689 tft.drawPixel(0, 0, bruceConfig.bgColor);
690 if (firstRender) {
691 tft.fillRoundRect(
692 tftWidth * 0.10, optionsTopY, tftWidth * 0.8, (FM * 8 + 4) * menuSize + 10, 5, bgcolor
693 );
694 tft.drawRoundRect(
695 tftWidth * 0.10,
696 tftHeight / 2 - menuSize * (FM * 8 + 4) / 2 - 5,
697 tftWidth * 0.8,
698 (FM * 8 + 4) * menuSize + 10,
699 5,
700 fgcolor
701 );
702 }
703
704 tft.setTextColor(fgcolor, bgcolor);
705 tft.setTextSize(FM);
706 tft.setCursor(tftWidth * 0.10 + 5, tftHeight / 2 - menuSize * (FM * 8 + 4) / 2);
707
708 int i = 0;
709 int init = 0;
710 int cont = 1;
711 menuSize = options.size();
712 if (index >= MAX_MENU_SIZE) init = index - MAX_MENU_SIZE + 1;
713 for (i = 0; i < menuSize; i++) {
714 if (i >= init) {
715 if (options[i].selected) tft.setTextColor(selcolor, bgcolor); // if selected, change Text color
716 else tft.setTextColor(fgcolor, bgcolor);
717 if (!options[i].enabled) tft.setTextColor(TFT_DARKGREY, bgcolor);
718
719 String text = "";
720 if (i == index) {
721 text += ">";
722 coord.x = tftWidth * 0.10 + 5 + FM * LW;
723 coord.y = tft.getCursorY() + 4;
724 coord.size = (tftWidth * 0.8 - 10) / (LW * FM) - 1;
725 coord.fgcolor = fgcolor;
726 coord.bgcolor = bgcolor;
727 } else text += " ";
728 text += String(options[i].label) + " ";
729 tft.setCursor(tftWidth * 0.10 + 5, tft.getCursorY() + 4);
730 tft.println(text.substring(0, (tftWidth * 0.8 - 10) / (LW * FM) - 1));
731 cont++;
732 }
733 if (cont > MAX_MENU_SIZE) goto Exit;
734 }

Callers 1

loopOptionsFunction · 0.85

Calls 10

TouchFooterFunction · 0.85
sizeMethod · 0.80
drawPixelMethod · 0.45
fillRoundRectMethod · 0.45
drawRoundRectMethod · 0.45
setTextColorMethod · 0.45
setTextSizeMethod · 0.45
setCursorMethod · 0.45
getCursorYMethod · 0.45
printlnMethod · 0.45

Tested by

no test coverage detected