** Function name: drawSubmenu ** Description: Função para desenhar e mostrar as opçoes de contexto ***************************************************************************************/
| 745 | ** Description: Função para desenhar e mostrar as opçoes de contexto |
| 746 | ***************************************************************************************/ |
| 747 | void drawSubmenu(int index, std::vector<Option> &options, const char *title) { |
| 748 | drawStatusBar(); |
| 749 | int menuSize = options.size(); |
| 750 | tft.setTextColor(bruceConfig.priColor, bruceConfig.bgColor); |
| 751 | tft.setTextSize(FP); |
| 752 | tft.drawPixel(0, 0, 0); |
| 753 | tft.fillRect(6, 30, tftWidth - 12, 8 * FP, bruceConfig.bgColor); |
| 754 | tft.drawString(title, 12, 30); |
| 755 | |
| 756 | // middle of the drawing area |
| 757 | int middle = 25 /*status*/ + (tftHeight - 30 /*status + bottom margin*/) / 2; |
| 758 | // drawCentreString uses TC_DATUM, so we need to adjust the Y position |
| 759 | // 42 ensures that title isnt touched( 30 + 8 (LH) + 4(Margin)) |
| 760 | int middle_up = middle - (tftHeight - 42) / 3 - FM * LH / 2 + 4; |
| 761 | int middle_down = middle + (tftHeight - 42) / 3 - FM * LH / 2; |
| 762 | |
| 763 | tft.setTextSize(FM); |
| 764 | #if defined(HAS_TOUCH) |
| 765 | tft.drawCentreString("/\\", tftWidth / 2, middle_up - (FM * LH + 6), 1); |
| 766 | #endif |
| 767 | // Previous item |
| 768 | int firstIndex = index - 1 >= 0 ? index - 1 : menuSize - 1; |
| 769 | const char *firstOption = options[firstIndex].label.c_str(); |
| 770 | tft.setTextColor(options[firstIndex].enabled ? bruceConfig.secColor : TFT_DARKGREY); |
| 771 | tft.fillRect(6, middle_up, tftWidth - 12, 8 * FM, bruceConfig.bgColor); |
| 772 | tft.drawCentreString(firstOption, tftWidth / 2, middle_up, SMOOTH_FONT); |
| 773 | |
| 774 | // Selected item |
| 775 | int selectedTextSize = options[index].label.length() <= tftWidth / (LW * FG) - 1 ? FG : FM; |
| 776 | tft.setTextSize(selectedTextSize); |
| 777 | tft.setTextColor(options[index].enabled ? bruceConfig.priColor : TFT_DARKGREY); |
| 778 | tft.fillRect(6, middle - FG * LH / 2 - 1, tftWidth - 12, FG * LH + 5, bruceConfig.bgColor); |
| 779 | tft.drawCentreString(options[index].label, tftWidth / 2, middle - selectedTextSize * LH / 2, SMOOTH_FONT); |
| 780 | tft.drawFastHLine( |
| 781 | tftWidth / 2 - strlen(options[index].label.c_str()) * selectedTextSize * LW / 2, |
| 782 | middle + selectedTextSize * LH / 2 + 1, |
| 783 | strlen(options[index].label.c_str()) * selectedTextSize * LW, |
| 784 | bruceConfig.priColor |
| 785 | ); |
| 786 | // Next Item |
| 787 | int thirdIndex = index + 1 < menuSize ? index + 1 : 0; |
| 788 | const char *thirdOption = options[thirdIndex].label.c_str(); |
| 789 | tft.setTextSize(FM); |
| 790 | tft.setTextColor(options[thirdIndex].enabled ? bruceConfig.secColor : TFT_DARKGREY); |
| 791 | tft.fillRect(6, middle_down, tftWidth - 12, 8 * FM, bruceConfig.bgColor); |
| 792 | tft.drawCentreString(thirdOption, tftWidth / 2, middle_down, SMOOTH_FONT); |
| 793 | |
| 794 | tft.fillRect(tftWidth - 5, 0, 5, tftHeight, bruceConfig.bgColor); |
| 795 | tft.fillRect(tftWidth - 5, index * tftHeight / menuSize, 5, tftHeight / menuSize, bruceConfig.priColor); |
| 796 | |
| 797 | #if defined(HAS_TOUCH) |
| 798 | tft.drawCentreString("\\/", tftWidth / 2, middle_down + (FM * LH + 6), 1); |
| 799 | tft.setTextColor(getColorVariation(bruceConfig.priColor), bruceConfig.bgColor); |
| 800 | tft.drawString("[ x ]", 7, 7, 1); |
| 801 | TouchFooter(); |
| 802 | #endif |
| 803 | } |
| 804 |
no test coverage detected