| 256 | } |
| 257 | |
| 258 | void BaseTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount, int selectedIndex, |
| 259 | const std::function<std::string(int index)>& rowTitle, |
| 260 | const std::function<std::string(int index)>& rowSubtitle, |
| 261 | const std::function<UIIcon(int index)>& rowIcon, |
| 262 | const std::function<std::string(int index)>& rowValue, bool highlightValue, |
| 263 | const std::function<bool(int index)>& rowDimmed) const { |
| 264 | int rowHeight = |
| 265 | (rowSubtitle != nullptr) ? BaseMetrics::values.listWithSubtitleRowHeight : BaseMetrics::values.listRowHeight; |
| 266 | int pageItems = rect.height / rowHeight; |
| 267 | |
| 268 | const int totalPages = (itemCount + pageItems - 1) / pageItems; |
| 269 | if (totalPages > 1) { |
| 270 | constexpr int indicatorWidth = 20; |
| 271 | constexpr int arrowSize = 6; |
| 272 | constexpr int margin = 15; // Offset from right edge |
| 273 | |
| 274 | const int centerX = rect.x + rect.width - indicatorWidth / 2 - margin; |
| 275 | const int indicatorTop = rect.y; // Offset to avoid overlapping side button hints |
| 276 | const int indicatorBottom = rect.y + rect.height - arrowSize; |
| 277 | |
| 278 | // Draw up arrow at top (^) - narrow point at top, wide base at bottom |
| 279 | for (int i = 0; i < arrowSize; ++i) { |
| 280 | const int lineWidth = 1 + i * 2; |
| 281 | const int startX = centerX - i; |
| 282 | renderer.drawLine(startX, indicatorTop + i, startX + lineWidth - 1, indicatorTop + i); |
| 283 | } |
| 284 | |
| 285 | // Draw down arrow at bottom (v) - wide base at top, narrow point at bottom |
| 286 | for (int i = 0; i < arrowSize; ++i) { |
| 287 | const int lineWidth = 1 + (arrowSize - 1 - i) * 2; |
| 288 | const int startX = centerX - (arrowSize - 1 - i); |
| 289 | renderer.drawLine(startX, indicatorBottom - arrowSize + 1 + i, startX + lineWidth - 1, |
| 290 | indicatorBottom - arrowSize + 1 + i); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | // Draw selection |
| 295 | int contentWidth = rect.width - 5; |
| 296 | if (selectedIndex >= 0) { |
| 297 | renderer.fillRect(rect.x, rect.y + selectedIndex % pageItems * rowHeight - 2, rect.width, rowHeight); |
| 298 | } |
| 299 | constexpr int minValueGap = 10; |
| 300 | |
| 301 | // Draw all items |
| 302 | const auto pageStartIndex = selectedIndex / pageItems * pageItems; |
| 303 | for (int i = pageStartIndex; i < itemCount && i < pageStartIndex + pageItems; i++) { |
| 304 | const int itemY = rect.y + (i % pageItems) * rowHeight; |
| 305 | |
| 306 | int rowTextWidth = contentWidth - BaseMetrics::values.contentSidePadding * 2; |
| 307 | std::string valueText; |
| 308 | if (rowValue != nullptr) { |
| 309 | valueText = rowValue(i); |
| 310 | if (!valueText.empty()) { |
| 311 | int maxValW = std::max(0, rowTextWidth - 40 - minValueGap); |
| 312 | valueText = renderer.truncatedText(UI_10_FONT_ID, valueText.c_str(), maxValW); |
| 313 | int valueWidth = renderer.getTextWidth(UI_10_FONT_ID, valueText.c_str()) + minValueGap; |
| 314 | rowTextWidth -= valueWidth; |
| 315 | } |
no test coverage detected