Every node-type mark is white now: ● ▲ ■ ◉ were pink, violet, white, and orange, and the shape already says the type. Each keeps its own type.* style, so one can take a colour back in one place; the unknown ○ keeps its grey. On the map a crowd in one cell used to glow toward white, which a white marker cannot do, so that signal is gone. The border grey goes down to #7c7c7c, which JP picked on a ladder. That sits almost on faint, so the title bar's live clip arrow is now lit like the title instead of taking the border's grey. On the PicoCalc the border is the dark grey slot. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
69 lines
3.3 KiB
Python
69 lines
3.3 KiB
Python
# SPDX-License-Identifier: Apache-2.0
|
|
"""The shared mark constants: node-type glyphs, their colours, and path sentinels.
|
|
|
|
The spatial screens of the app (the map, the path graph, the braille rasters, and the
|
|
node rows) all mark nodes with the same marks in the same hues. Several of them need the
|
|
constants *without* the code around them. Before this module, ``ui.widgets`` put
|
|
``map_render``, ``mapcanvas``, and ``pathgraph`` on the boot path for a few tuples and
|
|
type aliases. This was approximately 60 ms of import time on the PicoCalc. Now the
|
|
constants are here, with no dependencies, and the large modules import *from* the
|
|
constants instead of holding them. ``map_render``, ``mapcanvas``, and ``pathgraph``
|
|
export their old names again, so the code that imports from those modules does not
|
|
change.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Callable
|
|
|
|
#: An ``(r, g, b)`` colour triple, 0 to 255 for each channel (the colour type of a raster
|
|
#: or a canvas).
|
|
RGB = tuple[int, int, int]
|
|
|
|
|
|
def parse_hex(color: str) -> RGB:
|
|
"""Convert ``"#rrggbb"`` (or ``"rrggbb"``) to an ``(r, g, b)`` tuple."""
|
|
c = color.lstrip("#")
|
|
return (int(c[0:2], 16), int(c[2:4], 16), int(c[4:6], 16))
|
|
|
|
|
|
# The palette of markers, shared in the whole app. Each marker is white, and its shape
|
|
# tells what it is (JP, 2026-10-14): a ``●`` for an ordinary node and a ``▲`` for a
|
|
# repeater, in the ``type.*`` white of the theme. They were pink and violet, the hues that
|
|
# a map never has. Our node is the star, in the white of ``you`` (JP, 2026-10-14). It was
|
|
# yellow, and then the hue of our key. A node that was heard but never identified is a
|
|
# light grey ring. Each glyph is in the PicoCalc console font.
|
|
#
|
|
# The colour of a mark is any value that :func:`~meshterm.ui.theme.mark_rgb` takes: a
|
|
# literal hex, or the name of a theme style when the platform must choose the shade. The
|
|
# unknown ring has a name (``node.unknown``), so that the ring and the grey label beside
|
|
# it can never be different. Our star has the name ``you``, the white of our node in each
|
|
# list, and the two type marks have their ``type.*`` names, so that the console chooses
|
|
# its own white.
|
|
SELF_MARK = ("★", "you")
|
|
REPEATER_MARK = ("▲", "type.repeater")
|
|
NODE_MARK = ("●", "type.node")
|
|
UNKNOWN_MARK = ("○", "node.unknown")
|
|
|
|
#: The only concealed character. One bullet replaces one character of a value that the
|
|
#: screen hides: a password that the user types (``ui/tui/prompt.py``), or the BLE pairing
|
|
#: PIN on the Device info page. The concept has one glyph, so a row of these glyphs has the
|
|
#: same meaning where it appears. It is *not* the ``●`` of an unread message or a node, on
|
|
#: purpose. Those marks have a meaning, and this one means "not shown".
|
|
MASK_MARK = "•"
|
|
|
|
#: Sentinels that name the endpoints of a path on the route graph. ``\x00`` never occurs
|
|
#: in a node hash, so the sentinels can share the namespace of node ids and not collide
|
|
#: with an id.
|
|
SRC_NODE = "\x00src"
|
|
DST_NODE = "\x00dst"
|
|
|
|
#: Gives the graph marker of a node id: a ``(glyph, colour)`` pair.
|
|
GlyphOf = Callable[[str], tuple[str, str]]
|
|
|
|
#: The graph label of a node, or ``None`` or ``""`` to leave the marker bare.
|
|
LabelOf = Callable[[str], str | None]
|
|
|
|
#: The colour in which the label of a node is drawn (usually the hue of the node name).
|
|
LabelRgbOf = Callable[[str], RGB]
|