Skip to content

Commit cb3ce1b

Browse files
committed
proper centering and rounder hops labels
1 parent 2ad5281 commit cb3ce1b

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

src/graphics/niche/InkHUD/Applets/Bases/Map/MapApplet.cpp

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ void InkHUD::MapApplet::onRender()
1313
return;
1414
}
1515

16+
// Helper: draw rounded rectangle centered at x,y
17+
auto fillRoundedRect = [&](int16_t cx, int16_t cy, int16_t w, int16_t h, int16_t r, uint16_t color) {
18+
int16_t x = cx - (w / 2);
19+
int16_t y = cy - (h / 2);
20+
21+
// center rects
22+
fillRect(x + r, y, w - 2 * r, h, color);
23+
fillRect(x, y + r, r, h - 2 * r, color);
24+
fillRect(x + w - r, y + r, r, h - 2 * r, color);
25+
26+
// corners
27+
fillCircle(x + r, y + r, r, color);
28+
fillCircle(x + w - r - 1, y + r, r, color);
29+
fillCircle(x + r, y + h - r - 1, r, color);
30+
fillCircle(x + w - r - 1, y + h - r - 1, r, color);
31+
};
32+
1633
// Find center of map
1734
getMapCenter(&latCenter, &lngCenter);
1835
calculateAllMarkers();
@@ -25,37 +42,32 @@ void InkHUD::MapApplet::onRender()
2542
int16_t y = Y(0.5) - (m.northMeters * metersToPx);
2643

2744
// Add white halo outline first
28-
constexpr int outlinePad = 1; // size of white outline padding
29-
int boxSize;
30-
if ((m.hasHopsAway && m.hopsAway > config.lora.hop_limit) || !m.hasHopsAway) {
31-
boxSize = 12;
32-
} else {
33-
boxSize = 10;
34-
}
35-
fillRect(x - (boxSize / 2) - outlinePad, y - (boxSize / 2) - outlinePad, boxSize + (outlinePad * 2),
36-
boxSize + (outlinePad * 2), WHITE);
45+
constexpr int outlinePad = 1;
46+
int boxSize = 11;
47+
int radius = 2; // rounded corner radius
48+
49+
// White halo background
50+
fillRoundedRect(x, y, boxSize + (outlinePad * 2), boxSize + (outlinePad * 2), radius + 1, WHITE);
51+
52+
// Draw inner box
53+
fillRoundedRect(x, y, boxSize, boxSize, radius, BLACK);
54+
55+
// Text inside
56+
setFont(fontSmall);
57+
setTextColor(WHITE);
3758

3859
// Draw actual marker on top
3960
if (m.hasHopsAway && m.hopsAway > config.lora.hop_limit) {
40-
fillRect(x - boxSize / 2, y - boxSize / 2, boxSize, boxSize, BLACK);
41-
setFont(fontSmall);
42-
setTextColor(WHITE);
43-
printAt(x, y, "X", CENTER, MIDDLE);
61+
printAt(x + 1, y + 1, "X", CENTER, MIDDLE);
4462
} else if (!m.hasHopsAway) {
45-
fillRect(x - boxSize / 2, y - boxSize / 2, boxSize, boxSize, BLACK);
46-
setFont(fontSmall);
47-
setTextColor(WHITE);
48-
printAt(x, y, "?", CENTER, MIDDLE);
63+
printAt(x + 1, y + 1, "?", CENTER, MIDDLE);
4964
} else {
50-
fillRect(x - boxSize / 2, y - boxSize / 2, boxSize, boxSize, BLACK);
5165
char hopStr[4];
5266
snprintf(hopStr, sizeof(hopStr), "%d", m.hopsAway);
53-
setFont(fontSmall);
54-
setTextColor(WHITE);
55-
printAt(x, y, hopStr, CENTER, MIDDLE);
67+
printAt(x, y + 1, hopStr, CENTER, MIDDLE);
5668
}
5769

58-
// Restore default font and color (safety for rest of UI)
70+
// Restore default font and color
5971
setFont(fontSmall);
6072
setTextColor(BLACK);
6173
}

0 commit comments

Comments
 (0)