Inst*: proportions fix (audit Dec 2026) — lamps + LEDs
LED block scales with the widget; label 12-15% of LED diameter bold with leads ending above it; panel-lamp disc shrunk so the 16-18 px bold label clears below it; RGB swatches 24 px with 14 px R/G/B labels; Beacon bar lowered, dome clear of it, FLASH rate in white on the bar, BEACON 16 px bold below; StackLight title 16 px bold plus R/A/G segment letters 24 px bold, white on lit / light grey on unlit; LampTestButton text 16 px bold. Default word labels via _label() (C constructor defaults, G2).
This commit is contained in:
1 parent
80a1698f7a
commit
34ff1da9e7
1 file changed
+101
-31
+101
-31
@@ -162,6 +162,29 @@ def _fit_size(cr, widget, text, target_w, size, bold=True):
|
||||
return max(4.0, size)
|
||||
|
||||
|
||||
# C constructor default labels (text_) that are real words, not the
|
||||
# class name (audit G2 blanks only the class-name defaults). A
|
||||
# designer-set text wins; otherwise the word below is drawn.
|
||||
_INST_LABEL = {
|
||||
"AnalogGauge": "Analog", "BarMeter": "Level", "Beacon": "BEACON",
|
||||
"DigitalReadout": "Readout", "FlowMeter": "Flow",
|
||||
"LedBlue": "BLUE", "LedGreen": "GREEN", "LedRed": "RED",
|
||||
"Manometer": "Manometer", "PanelLampAmber": "AMBER",
|
||||
"PanelLampBlue": "BLUE", "PanelLampGreen": "GREEN",
|
||||
"PanelLampRed": "RED", "PanelLampWhite": "WHITE",
|
||||
"PressureGauge": "Pressure", "RgbStatusLed": "RGB",
|
||||
"StackLight": "STACK", "TemperatureGauge": "Temperature",
|
||||
"VuMeter": "VU",
|
||||
}
|
||||
|
||||
|
||||
def _label(widget):
|
||||
"""Display label: designer text, else the C default word."""
|
||||
if widget.text != widget.name:
|
||||
return widget.text
|
||||
return _INST_LABEL.get(widget.pkind, "")
|
||||
|
||||
|
||||
def _screw(cr, x, y, r=4):
|
||||
"""One panel screw: grey disc + dark slot."""
|
||||
cr.save()
|
||||
@@ -1102,8 +1125,9 @@ def _draw_panel_lamp(cr, widget):
|
||||
on = _on(widget)
|
||||
brightness = _brightness(widget)
|
||||
w, h = widget.width, widget.height
|
||||
cx, cy = w / 2, h / 2 - (6 if widget.text != widget.name else 0)
|
||||
r = min(w, h) / 2 - 10
|
||||
# Audit: disc shrunk so the label clears below it (C: R - 30).
|
||||
cx, cy = w / 2, h / 2 - 12
|
||||
r = min(w, h) / 2 - max(10.0, 0.0625 * h)
|
||||
if r < 4:
|
||||
return
|
||||
cr.save()
|
||||
@@ -1125,9 +1149,11 @@ def _draw_panel_lamp(cr, widget):
|
||||
cr.arc(cx - r * 0.3, cy - r * 0.35, r * 0.18, 0, 2 * math.pi)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
if widget.text != widget.name:
|
||||
_wtext(cr, widget, widget.text, cx, h - 6, size=11,
|
||||
align="center", rgb=(0.25, 0.25, 0.25),
|
||||
# Audit: label 16-18 px bold with a clear gap below the disc.
|
||||
lab = _label(widget)
|
||||
if lab:
|
||||
_wtext(cr, widget, lab, cx, h - 10, size=_fs(0.028, h),
|
||||
bold=True, align="center", rgb=(0.25, 0.25, 0.25),
|
||||
max_width=w - 8)
|
||||
|
||||
|
||||
@@ -1140,7 +1166,10 @@ def _draw_led(cr, widget):
|
||||
brightness = _brightness(widget)
|
||||
w, h = widget.width, widget.height
|
||||
cx = w / 2
|
||||
block_w, block_h = min(w - 16, 64), min(h - 30, 54)
|
||||
# Audit: LED block scales with the widget (was capped at 64x54,
|
||||
# so the label rule 12-15% of LED diameter had nothing to scale
|
||||
# from); label 28 px bold at demo scale, leads end above it.
|
||||
block_w, block_h = min(w - 16, 0.32 * w), min(h - 30, 0.45 * h)
|
||||
bx, by = cx - block_w / 2, 10
|
||||
_rounded_box(cr, bx, by, block_w, block_h, dark, dark, radius=6)
|
||||
r = min(block_w, block_h) / 2 - 6
|
||||
@@ -1153,18 +1182,22 @@ def _draw_led(cr, widget):
|
||||
0, 2 * math.pi)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
lead_end = max(by + block_h + 4, h - 0.092 * h)
|
||||
cr.save()
|
||||
_rgb(cr, lead)
|
||||
cr.set_line_width(3)
|
||||
cr.move_to(cx - 10, by + block_h)
|
||||
cr.line_to(cx - 10, h - 6)
|
||||
cr.line_to(cx - 10, lead_end)
|
||||
cr.move_to(cx + 10, by + block_h)
|
||||
cr.line_to(cx + 10, h - 6)
|
||||
cr.line_to(cx + 10, lead_end)
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
if widget.text != widget.name:
|
||||
_wtext(cr, widget, widget.text, cx, h - 4, size=11,
|
||||
align="center", rgb=(0.25, 0.25, 0.25),
|
||||
lab = _label(widget)
|
||||
if lab:
|
||||
# Label 12-15% of the LED diameter, bold, above the leads.
|
||||
_wtext(cr, widget, lab, cx, h - 8,
|
||||
size=_cap_size(0.135 * 2 * r),
|
||||
bold=True, align="center", rgb=(0.25, 0.25, 0.25),
|
||||
max_width=w - 8)
|
||||
|
||||
|
||||
@@ -1186,7 +1219,7 @@ def _draw_rgb_led(cr, widget):
|
||||
blue_on = all_on or _prop_bool(widget, "blue-on", False)
|
||||
w, h = widget.width, widget.height
|
||||
cx = w / 2
|
||||
block_w, block_h = min(w - 16, 64), min(h - 34, 50)
|
||||
block_w, block_h = min(w - 16, 0.30 * w), min(h - 34, 0.40 * h)
|
||||
bx, by = cx - block_w / 2, 8
|
||||
_rounded_box(cr, bx, by, block_w, block_h, dark, dark, radius=6)
|
||||
combined = (
|
||||
@@ -1201,13 +1234,20 @@ def _draw_rgb_led(cr, widget):
|
||||
cr.arc(cx, by + block_h / 2, max(r, 3), 0, 2 * math.pi)
|
||||
cr.fill()
|
||||
cr.restore()
|
||||
sw = 14
|
||||
# Audit: swatches 24 px with 14 px labels.
|
||||
sw = max(8.0, 0.040 * h)
|
||||
sw_cap = 0.023 * h
|
||||
sx = cx - (3 * sw + 2 * 6) / 2
|
||||
sy = by + block_h + 6
|
||||
for on, colour in ((red_on, red_c), (green_on, green_c),
|
||||
(blue_on, blue_c)):
|
||||
for on, colour, ch in ((red_on, red_c, "R"),
|
||||
(green_on, green_c, "G"),
|
||||
(blue_on, blue_c, "B")):
|
||||
_box(cr, sx, sy, sw, sw,
|
||||
colour if on else (30 / 255, 30 / 255, 30 / 255), outline)
|
||||
_wtext(cr, widget, ch, sx + sw / 2, sy + sw + 4
|
||||
+ sw_cap * 0.35, size=_cap_size(sw_cap), bold=True,
|
||||
rgb=(0.25, 0.25, 0.25), align="center",
|
||||
max_width=sw + 8)
|
||||
sx += sw + 6
|
||||
|
||||
|
||||
@@ -1220,23 +1260,37 @@ def _draw_stack_light(cr, widget):
|
||||
outline = _color(widget, "tier-outline-color",
|
||||
(60 / 255, 60 / 255, 60 / 255))
|
||||
all_on = _prop_bool(widget, "all-on", False)
|
||||
tiers = (
|
||||
("red-on", "red-brightness", red),
|
||||
("amber-on", "amber-brightness", amber),
|
||||
("green-on", "green-brightness", green),
|
||||
)
|
||||
w, h = widget.width, widget.height
|
||||
cx = w / 2
|
||||
pole_h = 18
|
||||
tier_h = max(14, (h - pole_h - 26) / 3)
|
||||
# Audit: title 16 px bold on top; segment letters 24 px bold
|
||||
# with contrast (white on lit, light grey on unlit -- the "A"
|
||||
# on dark amber was nearly invisible, G6).
|
||||
title_cap = 0.027 * h
|
||||
title_h = title_cap + 8
|
||||
tier_h = max(14, (h - pole_h - 26 - title_h) / 3)
|
||||
tier_w = min(54, w - 20)
|
||||
x0 = cx - tier_w / 2
|
||||
y = 8
|
||||
for prop, bright_prop, colour in tiers:
|
||||
lab = _label(widget)
|
||||
if lab:
|
||||
_wtext(cr, widget, lab, cx, 8 + title_cap,
|
||||
size=_cap_size(title_cap), bold=True, align="center",
|
||||
rgb=(0.25, 0.25, 0.25), max_width=w - 8)
|
||||
y = 8 + title_h
|
||||
letter_cap = 0.040 * h
|
||||
for prop, bright_prop, colour, ch in (
|
||||
("red-on", "red-brightness", red, "R"),
|
||||
("amber-on", "amber-brightness", amber, "A"),
|
||||
("green-on", "green-brightness", green, "G")):
|
||||
on = all_on or _prop_bool(widget, prop, False)
|
||||
bright = _prop_int(widget, bright_prop, 100)
|
||||
_rounded_box(cr, x0, y, tier_w, tier_h - 3,
|
||||
_lens_rgb(colour, on, bright), outline, radius=6)
|
||||
_wtext(cr, widget, ch, cx, y + (tier_h - 3) / 2
|
||||
+ letter_cap * 0.35, size=_cap_size(letter_cap),
|
||||
bold=True, align="center",
|
||||
rgb=(1.0, 1.0, 1.0) if on else (0.75, 0.75, 0.75),
|
||||
max_width=tier_w - 4)
|
||||
y += tier_h
|
||||
# Pole + base.
|
||||
_box(cr, cx - 3, y, 6, pole_h, dark, dark)
|
||||
@@ -1255,11 +1309,16 @@ def _draw_beacon(cr, widget):
|
||||
lit = on and phase
|
||||
w, h = widget.width, widget.height
|
||||
cx = w / 2
|
||||
base_y = h - 18
|
||||
dome_r = min(w / 2 - 12, (h - 30) / 2)
|
||||
# Audit: bar lowered so the dome clears it, captions inset 16 px
|
||||
# bold (C: base_y y2-72, bar 28, dome 6 px above the bar); the
|
||||
# bar sits above two text lines, so base_y reserves that room.
|
||||
rate_cap = 0.027 * h
|
||||
bar_h = max(10.0, 0.058 * h)
|
||||
base_y = h - bar_h - 2 * rate_cap - 14
|
||||
dome_r = min(w / 2 - 12, (base_y - 12) / 2)
|
||||
if dome_r < 4:
|
||||
return
|
||||
cy = base_y - dome_r
|
||||
cy = base_y - dome_r - 6
|
||||
if lit:
|
||||
cr.save()
|
||||
_rgb(cr, beacon, 0.25)
|
||||
@@ -1283,10 +1342,19 @@ def _draw_beacon(cr, widget):
|
||||
cr.set_line_width(2)
|
||||
cr.stroke()
|
||||
cr.restore()
|
||||
_box(cr, cx - dome_r - 4, base_y, 2 * dome_r + 8, 10, dark, dark)
|
||||
_wtext(cr, widget, "%.1f Hz" % _prop_float(widget, "flash-rate", 2.0),
|
||||
cx, h - 4, size=11, align="center", rgb=(0.25, 0.25, 0.25),
|
||||
max_width=w - 8)
|
||||
# Rate in white on the dark bar, BEACON below it (audit G6/G7).
|
||||
_box(cr, cx - dome_r - 4, base_y, 2 * dome_r + 8, bar_h, dark,
|
||||
dark)
|
||||
rate = "FLASH %g Hz" % _prop_float(widget, "flash-rate", 2.0)
|
||||
_wtext(cr, widget, rate, cx, base_y + bar_h / 2
|
||||
+ rate_cap * 0.35, size=_cap_size(rate_cap), bold=True,
|
||||
align="center", rgb=(1.0, 1.0, 1.0),
|
||||
max_width=2 * dome_r)
|
||||
lab = _label(widget)
|
||||
if lab:
|
||||
_wtext(cr, widget, lab, cx, h - 8, size=_cap_size(rate_cap),
|
||||
bold=True, align="center", rgb=(0.25, 0.25, 0.25),
|
||||
max_width=w - 8)
|
||||
|
||||
|
||||
def _draw_lamp_test_button(cr, widget):
|
||||
@@ -1295,7 +1363,9 @@ def _draw_lamp_test_button(cr, widget):
|
||||
w, h = widget.width, widget.height
|
||||
_rounded_box(cr, 0, 0, w, h, bezel, bezel, radius=6)
|
||||
_rounded_box(cr, 4, 4, w - 8, h - 8, face, bezel, radius=5)
|
||||
_wtext(cr, widget, "TEST", w / 2, h / 2 + 5, size=12, bold=True,
|
||||
# Audit: button text 16 px bold, centred.
|
||||
_wtext(cr, widget, "TEST", w / 2, h / 2 + 0.027 * h * 0.35,
|
||||
size=_fs(0.027, h), bold=True,
|
||||
align="center", rgb=(0.15, 0.15, 0.15), max_width=w - 16)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user