GUI round 11 (batch 1): default columns, control-board split cleanup, Stock/Env fixes, relative sort, consistent zebra + focus-dimming, hashboard/light dots, access icon
build-test-release / release (push) Failing after 10m39s

Table/model (Rust):
- #12: default columns are now IP, Model, Errors, Hashrate, Power, Chip temp,
  Firmware, CPU, Boards, Access, in that display order (initial ViewState and the
  built-in "Default" preset both updated).
- #14: removed the Control board column (CPU + Board replace it); the underlying
  control-board string stays on MinerRow for the SSH PIC probe.
- #6 (part 1): firmware family strips the vendor word asic-rs prepends on stock
  firmware ("AntMiner Stock" -> "Stock"), moving it into FW Version.
- #17: air-cooled miners' ambient reading routes to a new "Env temp" column
  instead of "Fluid temp" (asic-rs reports ambient in its fluid field and has no
  cooling-type flag; cooling type is inferred from the model name).
- #16: relative-hashrate (actual/expected) sort -- the Hashrate header cycles
  absolute-asc/desc then relative-asc/desc, with right-click menu entries;
  HashrateRel is a sort-only pseudo-column.

Rendering (wx-rs SegmentRenderer bridge, mirrored to patches/0003 per ADR 0003):
- #3: the per-row zebra background now fills the whole column-wide cell (wx
  shrinks a custom renderer's rect to the content size, so the earlier fill
  covered only the text; Render now fills GetOwner()->GetWidth() and wxGTK clips
  it to the cell).
- #1/#7: uncoloured segments (combined-cell slashes, "Stock" firmware) take the
  tree widget's themed text colour at its live GTK state, so they dim on
  window-backdrop like the native cells.
- #10: the Boards column renders per-hashboard status dots (green hashing / red
  faulted / grey undetected, board 1 rightmost); the Light column renders a
  yellow locate dot while flashing.
- #13: the Access column renders a padlock icon (green open = writable, red
  closed = view-only) instead of "locked"/"unlocked" text.

Shapes draw from control-char sentinels (never emoji/pictographs), font-
independent. Self-test verifies the icon columns structurally. 82 unit tests
pass.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
This commit is contained in:
2026-09-18 17:24:09 -06:00
co-authored by Claude Opus 4.8
parent 86638e870f
commit f87e519959
8 changed files with 595 additions and 84 deletions
+130 -12
View File
@@ -1,6 +1,6 @@
--- a/cpp_src/widgets_bridge.cpp
+++ b/cpp_src/widgets_bridge.cpp
@@ -0,0 +1,1148 @@
@@ -0,0 +1,1266 @@
+// widgets_bridge.cpp — alkane-toolkit extension to wx-rs
+// Adds the widget/event surface the toolkit UI needs on top of the upstream
+// render-callback bridge (which is kept untouched).
@@ -149,6 +149,57 @@
+ return segs;
+}
+
+// Shape sentinels a segment's text may carry instead of glyphs (round 11
+// #10/#13): a single control char selects a small vector icon drawn in the
+// segment's colour. These are control characters (never emoji/pictographs) so
+// they are safe in source and independent of the font's glyph coverage.
+const wxUniChar SHAPE_DOT = 0x07; // filled status dot (hashboards, locate light)
+const wxUniChar SHAPE_LOCK = 0x02; // closed padlock (locked / view-only)
+const wxUniChar SHAPE_UNLOCK = 0x03; // open padlock (unlocked / writable)
+const int SHAPE_ADVANCE = 15; // horizontal space one shape occupies
+
+bool IsShapeSentinel(const wxString& s, wxUniChar& out) {
+ if (s.length() != 1) return false;
+ wxUniChar c = s[0];
+ if (c == SHAPE_DOT || c == SHAPE_LOCK || c == SHAPE_UNLOCK) {
+ out = c;
+ return true;
+ }
+ return false;
+}
+
+// Draw one shape sentinel, centred in the SHAPE_ADVANCE-wide slot at x.
+void DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell, const wxColour& colour) {
+ int cy = cell.y + cell.height / 2;
+ int cx = x + SHAPE_ADVANCE / 2;
+ if (shape == SHAPE_DOT) {
+ dc->SetPen(*wxTRANSPARENT_PEN);
+ dc->SetBrush(wxBrush(colour));
+ dc->DrawCircle(cx, cy, 4);
+ return;
+ }
+ // Padlock: a filled body with a staple shackle above. The colour carries the
+ // state (green = unlocked, red = locked); the shackle is drawn ajar when open.
+ bool open = (shape == SHAPE_UNLOCK);
+ int bw = 9, bh = 7;
+ int bx = cx - bw / 2;
+ int by = cy - bh / 2 + 1;
+ dc->SetPen(*wxTRANSPARENT_PEN);
+ dc->SetBrush(wxBrush(colour));
+ dc->DrawRoundedRectangle(bx, by, bw, bh, 1.5);
+ dc->SetBrush(*wxTRANSPARENT_BRUSH);
+ dc->SetPen(wxPen(colour, 2));
+ int sr = 3;
+ int legTop = by - sr - 1;
+ int lx = cx - sr, rx = cx + sr;
+ dc->DrawLine(lx, by, lx, legTop); // left leg
+ dc->DrawLine(lx, legTop, rx, legTop); // top bar
+ if (open)
+ dc->DrawLine(rx, legTop, rx, legTop + sr); // ajar: right leg lifted
+ else
+ dc->DrawLine(rx, legTop, rx, by); // closed: right leg to body
+}
+
+} // namespace
+
+class SegmentRenderer : public wxDataViewCustomRenderer {
@@ -176,19 +227,51 @@
+ if (!selected && GetAttr().HasBackgroundColour()) {
+ dc->SetBrush(wxBrush(GetAttr().GetBackgroundColour()));
+ dc->SetPen(*wxTRANSPARENT_PEN);
+ dc->DrawRectangle(cell);
+ // The `cell` rect wx hands a custom renderer is shrunk to the content
+ // (text/shape) size by the alignment logic, so filling it alone left the
+ // zebra covering only the text and looking inconsistent with the full-cell
+ // native columns. Fill the whole column-wide cell instead; wxGTK clips the
+ // cell DC to the visible cell area, so the over-wide rect lands exactly on
+ // this cell without bleeding into the next column (round 11 #3).
+ wxRect bg = cell;
+ if (wxDataViewColumn* owner = const_cast<SegmentRenderer*>(this)->GetOwner()) {
+ int cw = owner->GetWidth();
+ if (cw > bg.width) bg.width = cw;
+ }
+ dc->DrawRectangle(bg);
+ }
+ wxColour highlight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
+ // For an uncoloured (default) segment, follow the DC's current text
+ // foreground rather than a hardcoded wxSYS_COLOUR_WINDOWTEXT, so these
+ // segments dim with the rest of the table when the window is backdropped.
+ wxColour plain = GetAttr().HasColour() ? GetAttr().GetColour()
+ : dc->GetTextForeground();
+ // An uncoloured (default) segment -- the "/" in a combined cell, a "Stock"
+ // firmware family, etc. -- must dim exactly like the native columns when the
+ // top-level window is backdropped. wxGTK dims a native cell's text via the
+ // widget's themed state colour, but a custom renderer's DC keeps the normal
+ // WINDOWTEXT, so ask the tree widget for its themed text colour AT ITS
+ // CURRENT STATE (which carries GTK_STATE_FLAG_BACKDROP while unfocused) and
+ // use that; off-GTK (or if the widget isn't reachable) fall back to the DC
+ // then the system colour (round 11 #1/#7).
+ wxColour plain;
+ if (GetAttr().HasColour()) {
+ plain = GetAttr().GetColour();
+ } else {
+ plain = ThemedTextColour();
+ }
+ if (!plain.IsOk()) {
+ plain = dc->GetTextForeground();
+ }
+ if (!plain.IsOk()) {
+ plain = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+ }
+ wxCoord x = cell.x;
+ for (const ColorSegment& seg : ParseColorSegments(m_value)) {
+ // Shape segments (status dots, access padlock) keep their own semantic
+ // colour even on a selected row, so the green/red reading survives the
+ // selection highlight (round 11 #10/#13).
+ wxUniChar shape;
+ if (IsShapeSentinel(seg.text, shape)) {
+ DrawShape(dc, shape, x, cell, seg.has_colour ? seg.colour : plain);
+ x += SHAPE_ADVANCE;
+ continue;
+ }
+ if (seg.text.IsEmpty()) continue;
+ dc->SetTextForeground(selected ? highlight : (seg.has_colour ? seg.colour : plain));
+ wxSize extent = dc->GetTextExtent(seg.text);
@@ -200,14 +283,49 @@
+ }
+
+ wxSize GetSize() const override {
+ wxString plain;
+ for (const ColorSegment& seg : ParseColorSegments(m_value)) plain += seg.text;
+ wxSize sz = GetTextExtent(plain);
+ if (sz.GetWidth() < 1) sz.SetWidth(1);
+ return sz;
+ int w = 0, h = 0;
+ for (const ColorSegment& seg : ParseColorSegments(m_value)) {
+ wxUniChar shape;
+ if (IsShapeSentinel(seg.text, shape)) {
+ w += SHAPE_ADVANCE;
+ if (h < 12) h = 12;
+ continue;
+ }
+ wxSize e = GetTextExtent(seg.text);
+ w += e.GetWidth();
+ if (e.GetHeight() > h) h = e.GetHeight();
+ }
+ if (w < 1) w = 1;
+ if (h < 1) h = 1;
+ return wxSize(w, h);
+ }
+
+ private:
+ // The owning tree widget's themed text colour at its current GTK state, so
+ // uncoloured segments dim on window-backdrop like the native columns
+ // (round 11 #1/#7). Returns an invalid colour off wxGTK or when the widget is
+ // unreachable, so the caller falls back to the DC / system colour.
+ wxColour ThemedTextColour() const {
+#ifdef __WXGTK__
+ wxDataViewColumn* col = const_cast<SegmentRenderer*>(this)->GetOwner();
+ if (col && col->GetOwner()) {
+ GtkWidget* tv = col->GetOwner()->GtkGetTreeView();
+ if (tv && GTK_IS_WIDGET(tv)) {
+ GtkStyleContext* ctx = gtk_widget_get_style_context(tv);
+ GtkStateFlags st = gtk_widget_get_state_flags(tv);
+ GdkRGBA c;
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+ gtk_style_context_get_color(ctx, st, &c);
+ G_GNUC_END_IGNORE_DEPRECATIONS
+ return wxColour((unsigned char)(c.red * 255.0 + 0.5),
+ (unsigned char)(c.green * 255.0 + 0.5),
+ (unsigned char)(c.blue * 255.0 + 0.5));
+ }
+ }
+#endif
+ return wxColour();
+ }
+
+ wxString m_value;
+};
+
@@ -146,6 +146,57 @@ std::vector<ColorSegment> ParseColorSegments(const wxString& value) {
return segs;
}
// Shape sentinels a segment's text may carry instead of glyphs (round 11
// #10/#13): a single control char selects a small vector icon drawn in the
// segment's colour. These are control characters (never emoji/pictographs) so
// they are safe in source and independent of the font's glyph coverage.
const wxUniChar SHAPE_DOT = 0x07; // filled status dot (hashboards, locate light)
const wxUniChar SHAPE_LOCK = 0x02; // closed padlock (locked / view-only)
const wxUniChar SHAPE_UNLOCK = 0x03; // open padlock (unlocked / writable)
const int SHAPE_ADVANCE = 15; // horizontal space one shape occupies
bool IsShapeSentinel(const wxString& s, wxUniChar& out) {
if (s.length() != 1) return false;
wxUniChar c = s[0];
if (c == SHAPE_DOT || c == SHAPE_LOCK || c == SHAPE_UNLOCK) {
out = c;
return true;
}
return false;
}
// Draw one shape sentinel, centred in the SHAPE_ADVANCE-wide slot at x.
void DrawShape(wxDC* dc, wxUniChar shape, wxCoord x, const wxRect& cell, const wxColour& colour) {
int cy = cell.y + cell.height / 2;
int cx = x + SHAPE_ADVANCE / 2;
if (shape == SHAPE_DOT) {
dc->SetPen(*wxTRANSPARENT_PEN);
dc->SetBrush(wxBrush(colour));
dc->DrawCircle(cx, cy, 4);
return;
}
// Padlock: a filled body with a staple shackle above. The colour carries the
// state (green = unlocked, red = locked); the shackle is drawn ajar when open.
bool open = (shape == SHAPE_UNLOCK);
int bw = 9, bh = 7;
int bx = cx - bw / 2;
int by = cy - bh / 2 + 1;
dc->SetPen(*wxTRANSPARENT_PEN);
dc->SetBrush(wxBrush(colour));
dc->DrawRoundedRectangle(bx, by, bw, bh, 1.5);
dc->SetBrush(*wxTRANSPARENT_BRUSH);
dc->SetPen(wxPen(colour, 2));
int sr = 3;
int legTop = by - sr - 1;
int lx = cx - sr, rx = cx + sr;
dc->DrawLine(lx, by, lx, legTop); // left leg
dc->DrawLine(lx, legTop, rx, legTop); // top bar
if (open)
dc->DrawLine(rx, legTop, rx, legTop + sr); // ajar: right leg lifted
else
dc->DrawLine(rx, legTop, rx, by); // closed: right leg to body
}
} // namespace
class SegmentRenderer : public wxDataViewCustomRenderer {
@@ -173,19 +224,51 @@ class SegmentRenderer : public wxDataViewCustomRenderer {
if (!selected && GetAttr().HasBackgroundColour()) {
dc->SetBrush(wxBrush(GetAttr().GetBackgroundColour()));
dc->SetPen(*wxTRANSPARENT_PEN);
dc->DrawRectangle(cell);
// The `cell` rect wx hands a custom renderer is shrunk to the content
// (text/shape) size by the alignment logic, so filling it alone left the
// zebra covering only the text and looking inconsistent with the full-cell
// native columns. Fill the whole column-wide cell instead; wxGTK clips the
// cell DC to the visible cell area, so the over-wide rect lands exactly on
// this cell without bleeding into the next column (round 11 #3).
wxRect bg = cell;
if (wxDataViewColumn* owner = const_cast<SegmentRenderer*>(this)->GetOwner()) {
int cw = owner->GetWidth();
if (cw > bg.width) bg.width = cw;
}
dc->DrawRectangle(bg);
}
wxColour highlight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
// For an uncoloured (default) segment, follow the DC's current text
// foreground rather than a hardcoded wxSYS_COLOUR_WINDOWTEXT, so these
// segments dim with the rest of the table when the window is backdropped.
wxColour plain = GetAttr().HasColour() ? GetAttr().GetColour()
: dc->GetTextForeground();
// An uncoloured (default) segment -- the "/" in a combined cell, a "Stock"
// firmware family, etc. -- must dim exactly like the native columns when the
// top-level window is backdropped. wxGTK dims a native cell's text via the
// widget's themed state colour, but a custom renderer's DC keeps the normal
// WINDOWTEXT, so ask the tree widget for its themed text colour AT ITS
// CURRENT STATE (which carries GTK_STATE_FLAG_BACKDROP while unfocused) and
// use that; off-GTK (or if the widget isn't reachable) fall back to the DC
// then the system colour (round 11 #1/#7).
wxColour plain;
if (GetAttr().HasColour()) {
plain = GetAttr().GetColour();
} else {
plain = ThemedTextColour();
}
if (!plain.IsOk()) {
plain = dc->GetTextForeground();
}
if (!plain.IsOk()) {
plain = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
}
wxCoord x = cell.x;
for (const ColorSegment& seg : ParseColorSegments(m_value)) {
// Shape segments (status dots, access padlock) keep their own semantic
// colour even on a selected row, so the green/red reading survives the
// selection highlight (round 11 #10/#13).
wxUniChar shape;
if (IsShapeSentinel(seg.text, shape)) {
DrawShape(dc, shape, x, cell, seg.has_colour ? seg.colour : plain);
x += SHAPE_ADVANCE;
continue;
}
if (seg.text.IsEmpty()) continue;
dc->SetTextForeground(selected ? highlight : (seg.has_colour ? seg.colour : plain));
wxSize extent = dc->GetTextExtent(seg.text);
@@ -197,14 +280,49 @@ class SegmentRenderer : public wxDataViewCustomRenderer {
}
wxSize GetSize() const override {
wxString plain;
for (const ColorSegment& seg : ParseColorSegments(m_value)) plain += seg.text;
wxSize sz = GetTextExtent(plain);
if (sz.GetWidth() < 1) sz.SetWidth(1);
return sz;
int w = 0, h = 0;
for (const ColorSegment& seg : ParseColorSegments(m_value)) {
wxUniChar shape;
if (IsShapeSentinel(seg.text, shape)) {
w += SHAPE_ADVANCE;
if (h < 12) h = 12;
continue;
}
wxSize e = GetTextExtent(seg.text);
w += e.GetWidth();
if (e.GetHeight() > h) h = e.GetHeight();
}
if (w < 1) w = 1;
if (h < 1) h = 1;
return wxSize(w, h);
}
private:
// The owning tree widget's themed text colour at its current GTK state, so
// uncoloured segments dim on window-backdrop like the native columns
// (round 11 #1/#7). Returns an invalid colour off wxGTK or when the widget is
// unreachable, so the caller falls back to the DC / system colour.
wxColour ThemedTextColour() const {
#ifdef __WXGTK__
wxDataViewColumn* col = const_cast<SegmentRenderer*>(this)->GetOwner();
if (col && col->GetOwner()) {
GtkWidget* tv = col->GetOwner()->GtkGetTreeView();
if (tv && GTK_IS_WIDGET(tv)) {
GtkStyleContext* ctx = gtk_widget_get_style_context(tv);
GtkStateFlags st = gtk_widget_get_state_flags(tv);
GdkRGBA c;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_style_context_get_color(ctx, st, &c);
G_GNUC_END_IGNORE_DEPRECATIONS
return wxColour((unsigned char)(c.red * 255.0 + 0.5),
(unsigned char)(c.green * 255.0 + 0.5),
(unsigned char)(c.blue * 255.0 + 0.5));
}
}
#endif
return wxColour();
}
wxString m_value;
};