Map: highlight the X/Y legend for the cursor's cell, fix subgrid color

- Column/row legend labels: the one matching the hovered cell gets an
  underline and a blue accent color (not yellow, which was already the
  overlay/placement-preview color elsewhere on the map and would have
  meant two unrelated things looked the same).
- SUBGRID_LINE (the fine per-cell lines added earlier) was accidentally
  given a distinct blue hue on the first attempt at fixing its
  visibility, overcorrecting: the actual ask was a shade sitting
  between the background and the main grid line's white, not a
  different color altogether. Now a neutral warm gray instead.

Verified with a rendered screenshot showing both together: the K/6
legend in blue with an underline, the subgrid a visibly distinct but
still neutral gray, not competing hues on the same map.
This commit is contained in:
Dominik Moritz Roth 2026-08-09 20:52:57 +02:00
parent 558e9d117a
commit fcf29ad574

View File

@ -63,6 +63,8 @@ SCOUT_FLIGHT = (0.70, 0.45, 0.92)
BG = (0.13, 0.12, 0.10)
GRID_LINE = (1.0, 1.0, 1.0, 0.20)
SUBGRID_LINE = (0.72, 0.70, 0.65, 0.35) # a shade between BG and GRID_LINE's white, not a hue change
HOVER_LEGEND = (0.45, 0.65, 0.95) # blue, not yellow, for the highlighted X/Y legend label
LABEL = (0.88, 0.86, 0.80)
COORD_LABEL = (0.60, 0.58, 0.54)
YELLOW = (0.95, 0.85, 0.20)
@ -541,17 +543,40 @@ class GridCanvas(Gtk.DrawingArea):
# Column/row labels: one per whole large-cell that's at least
# partly visible (its own span overlaps the viewport), not
# pegged to the gridline boundaries above, a partially-visible
# edge cell still gets its letter/number shown.
cr.set_source_rgb(*LABEL)
# edge cell still gets its letter/number shown. Whichever
# column/row the cursor is actually over gets called out
# (accent color + underline), an easy way to read the current
# cell off the legend at a glance instead of counting gridlines.
hover_col, hover_row = self._hover_cell if self._hover_cell is not None else (None, None)
cr.set_font_size(11)
for i in range(max(math.floor(view.ox), 0), min(math.ceil(view.ox + view.vis_cols), COLS)):
x, _ = self._km_to_px(view, (i + 0.5, 0))
cr.move_to(x - 4, MARGIN_TOP + view.pad_y - 10)
label_x, label_y = x - 4, MARGIN_TOP + view.pad_y - 10
is_hover = i == hover_col
cr.set_source_rgb(*(HOVER_LEGEND if is_hover else LABEL))
cr.move_to(label_x, label_y)
cr.show_text(LARGE_X[i])
if is_hover:
text_w = cr.text_extents(LARGE_X[i]).width
cr.new_path()
cr.set_line_width(1.5)
cr.move_to(label_x, label_y + 3)
cr.line_to(label_x + max(text_w, 6), label_y + 3)
cr.stroke()
for r in range(max(math.floor(view.oy), 0), min(math.ceil(view.oy + view.vis_rows), ROWS)):
_, y = self._km_to_px(view, (0, r + 0.5))
cr.move_to(4, y + 4)
label_x, label_y = 4, y + 4
is_hover = r == hover_row
cr.set_source_rgb(*(HOVER_LEGEND if is_hover else LABEL))
cr.move_to(label_x, label_y)
cr.show_text(str(r + 1))
if is_hover:
text_w = cr.text_extents(str(r + 1)).width
cr.new_path()
cr.set_line_width(1.5)
cr.move_to(label_x, label_y + 3)
cr.line_to(label_x + max(text_w, 6), label_y + 3)
cr.stroke()
# Everything below projects a km position to a pixel one with no
# inherent bound, an entity that's genuinely elsewhere on the
@ -624,8 +649,7 @@ class GridCanvas(Gtk.DrawingArea):
if self._hover_cell is None:
return
cell_col, cell_row = self._hover_cell
r, g, b, a = GRID_LINE
cr.set_source_rgba(r, g, b, a * 0.6) # fainter than the plain grid lines, not louder
cr.set_source_rgba(*SUBGRID_LINE)
cr.set_line_width(1)
x0, y0 = self._km_to_px(view, (cell_col, cell_row))
x1, y1 = self._km_to_px(view, (cell_col + 1, cell_row + 1))