Files
Muse 81a9693d71 Fix monitor-widget proportions: dynamic graph margins, scaled fonts, tach numerals
- Graphs (History/Net/Temp): dynamic left margin from the widest Y
  label (fixes Y labels overflowing the plot), legend on top, 5 Y
  labels, humanised units in NetGraph, TempHistory threshold label
  above the line ("80 C limit"), top/bottom Y labels hang clear of
  the title and the strip below the plot. History gains -60s/now.
- XTachometer: numerals 7.5% of dial diameter bold just inside the
  tick ring, RPM bold centred in-dial below the top numerals (its
  baseline hangs below the top numeral so it cannot collide with
  the 3200/4800 numerals on small dials), readout "value (peak N)"
  enlarged below the hub, redline numerals in red.
- All 14 audit widgets: font sizes derived from widget dimensions
  per the proportions audit (titles 16px bold, hero values 24-48px
  bold, body/legend 13-16px, min 11px); CoreGrid keeps 4x2; UsageBar
  labels outside the bar on a dark panel; StackBar title+total
  header (adaptive: omitted at 48px where it would push the legend
  out) with centred block; VerticalBar value inside the bar, peak
  label with shrink-to-fit; ArcGauge centre 40-48px + endpoints;
  DonutGauge centre 36-44px, ring 8-10% of diameter, duplicate
  title dropped, centre label is the value name; ProcessList 13px
  rows, bold header with sort indicator, "N procs"; LoadBadge
  centred two-line block with scaled values; MonitorButton scaled
  label/dot/status + detail line; MonitorGrid ceil(sqrt(n)) columns,
  name+status+detail design with wrapped detail; SysBox hero
  28-32px + max + bar %.
- New _fpx() clamp helper; XStackBar gains the "unit" prop
  (props_monitor.py) for its "total <sum> <unit>" header.
- Demos: button/grid labels "SSH :22" -> "sshd :22", tach label
  "Engine" -> "RPM", stackbar demo 320x48 -> 320x120 (title+bar+
  legend cannot fit in 48px), verticalbar demo 60 -> 160 wide
  (the "peak 82" label cannot fit in a 60px widget).
- Deviations from the audit spec: UsageBar label capped at 40px
  (the literal 0.45x rule gives 209px in a 464px-tall bar); SysBox
  hero uses 10% of height clamped 20-32px (spec 6-7% conflicts
  with the audited-correct PY value of 10.3%); PY LoadBadge gets
  no 1/5/15 sub-labels (the audit calls the PY layout correct;
  the sub-labels were directed at Rust).
Full suite: 363 tests OK (44 skipped). All 15 demos shot + verified.
2026-12-05 21:32:36 +00:00

150 lines
3.8 KiB
Python

"""Property tables for the X* monitor family (15 widgets).
Hand-written (there is no C source for these widgets to generate
from): each kind's own props below, registered with
register_custom_table -- the same hook Phase 6 uses for the Stock /
Instrumentation families. Generic set first (from
lightgui.props.props_for), then each widget's own props. Every prop
here is honoured by the draw code in lightgui/xframe/monitor.py
and live-applies; none is model-only.
"""
from lightgui.props import PropDef, register_custom_table
def _label(default=""):
return PropDef("label", "Str", default, 0, 0, (), (),
"Caption", False)
def _value(default="0"):
return PropDef("value", "Double", default, 0, 0, (), (),
"Value", False)
def _minimum(default="0"):
return PropDef("minimum", "Double", default, 0, 0, (), (),
"Minimum", False)
def _maximum(default="100"):
return PropDef("maximum", "Double", default, 0, 0, (), (),
"Maximum", False)
def _window(default="60"):
return PropDef("window", "Int", default, 0, 0, (), (),
"Window", False)
def _unit(default=""):
return PropDef("unit", "Str", default, 0, 0, (), (), "Unit", False)
# kind (registry name) -> custom props.
MONITOR_TABLES = {
"XHistoryGraph": (
_label(),
_window(),
_minimum(),
_maximum(),
PropDef("series-count", "Int", "2", 0, 0, (), (),
"SeriesCount", False),
PropDef("series-names", "Str", "", 0, 0, (), (),
"SeriesNames", False),
PropDef("show-legend", "Bool", "true", 0, 0, (), (),
"ShowLegend", False),
),
"XCoreGrid": (
_label(),
_window(),
PropDef("cores", "Int", "0", 0, 0, (), (),
"Cores", False),
),
"XNetGraph": (
_label(),
_window(),
),
"XTempHistory": (
_label(),
_window(),
_minimum(),
_maximum(),
PropDef("threshold", "Double", "80", 0, 0, (), (),
"Threshold", False),
),
"XUsageBar": (
_label(),
_value(),
_minimum(),
_maximum(),
),
"XStackBar": (
_label(),
PropDef("segments", "Str", "", 0, 0, (), (),
"Segments", False),
# Unit for the "total <sum> <unit>" header (e.g. GiB).
_unit(),
),
"XVerticalBar": (
_label(),
_value(),
_minimum(),
_maximum(),
),
"XTachometer": (
_label(),
_value(),
_minimum(),
_maximum("8000"),
PropDef("redline", "Double", "6400", 0, 0, (), (),
"Redline", False),
_unit(),
),
"XArcGauge": (
_label(),
_value(),
_minimum(),
_maximum(),
_unit("usage"),
),
"XDonutGauge": (
_label(),
_value(),
_minimum(),
_maximum(),
_unit(),
),
"XProcessList": (
_label(),
PropDef("sort-by", "Enum", "0", 0, 0,
("CPU", "Memory", "PID", "Name"), (0, 1, 2, 3),
"SortBy", False),
PropDef("sort-desc", "Bool", "true", 0, 0, (), (),
"SortDesc", False),
),
"XLoadBadge": (
_label(),
),
"XMonitorButton": (
_label(),
PropDef("check-type", "Enum", "0", 0, 0,
("Process", "Unit", "Port"), (0, 1, 2),
"CheckType", False),
PropDef("target", "Str", "", 0, 0, (), (), "Target", False),
),
"XMonitorGrid": (
_label(),
),
"XSysBox": (
_label(),
_value(),
_minimum(),
_maximum(),
_unit("%"),
),
}
for _kind, _props in MONITOR_TABLES.items():
register_custom_table(_kind, _props)