| 155 | } |
| 156 | |
| 157 | void BaseTheme::drawButtonHints(GfxRenderer& renderer, const char* btn1, const char* btn2, const char* btn3, |
| 158 | const char* btn4) const { |
| 159 | const GfxRenderer::Orientation orig_orientation = renderer.getOrientation(); |
| 160 | renderer.setOrientation(GfxRenderer::Orientation::Portrait); |
| 161 | |
| 162 | const int pageHeight = renderer.getScreenHeight(); |
| 163 | constexpr int buttonWidth = 106; |
| 164 | constexpr int buttonHeight = BaseMetrics::values.buttonHintsHeight; |
| 165 | constexpr int buttonY = BaseMetrics::values.buttonHintsHeight; // Distance from bottom |
| 166 | constexpr int textYOffset = 7; // Distance from top of button to text baseline |
| 167 | // X3 has wider screen in portrait (528 vs 480), use more spacing |
| 168 | constexpr int x4ButtonPositions[] = {25, 130, 245, 350}; |
| 169 | constexpr int x3ButtonPositions[] = {38, 154, 268, 384}; |
| 170 | const int* buttonPositions = gpio.deviceIsX3() ? x3ButtonPositions : x4ButtonPositions; |
| 171 | const char* labels[] = {btn1, btn2, btn3, btn4}; |
| 172 | |
| 173 | for (int i = 0; i < 4; i++) { |
| 174 | // Only draw if the label is non-empty |
| 175 | if (labels[i] != nullptr && labels[i][0] != '\0') { |
| 176 | const int x = buttonPositions[i]; |
| 177 | renderer.fillRect(x, pageHeight - buttonY, buttonWidth, buttonHeight, false); |
| 178 | renderer.drawRect(x, pageHeight - buttonY, buttonWidth, buttonHeight); |
| 179 | const int textWidth = renderer.getTextWidth(UI_10_FONT_ID, labels[i]); |
| 180 | const int textX = x + (buttonWidth - 1 - textWidth) / 2; |
| 181 | renderer.drawText(UI_10_FONT_ID, textX, pageHeight - buttonY + textYOffset, labels[i]); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | renderer.setOrientation(orig_orientation); |
| 186 | } |
| 187 | |
| 188 | void BaseTheme::drawSideButtonHints(const GfxRenderer& renderer, const char* topBtn, const char* bottomBtn) const { |
| 189 | const int screenWidth = renderer.getScreenWidth(); |
no test coverage detected