GUI round 11 follow-ups: equal-height zebra, backdrop dimming, SVG KPI icons, boards sort
build-test-release / release (push) Successful in 7m24s

- Zebra stripe heights: the cell rect wx hands a custom renderer is shrunk to the
  content size in BOTH dimensions, so shape cells (dots) and text cells filled
  different-height bands -> unequal stripes across columns. SegmentRenderer now
  fills an over-sized rect (full column width + well beyond the row vertically);
  the cell DC clips it to the real cell, giving uniform full-row stripes. Verified
  in a screenshot.
- Focus dimming: the treeview's own state flags don't carry GTK_STATE_FLAG_BACKDROP
  (that lives on the toplevel), so uncoloured segments (combined-cell slashes,
  target hashrate, "Stock") never dimmed. ThemedTextColour now reads the toplevel
  window's active state (gtk_window_is_active) and forces BACKDROP onto the
  style-context state when inactive, so those segments take the same dimmed themed
  colour the native columns do.
- KPI icons: replaced the hand-drawn vectors with operator-supplied Font Awesome
  Pro SVGs (rabbit=hashing, turtle=slow, cracked wine glass=not hashing,
  otter=paused) plus matching in-repo bolt (power) and hive (hashrate) SVGs. New
  wxbr_svg_icon renders an SVG via wxBitmapBundle::FromSVG; the GUI recolours
  each icon's currentColor to the card's colour and sizes it to the SVG aspect
  ratio. Removed the old wxbr_kpi_icon path.
- Boards column sort: it sorted by total board count (all ~3, so no visible
  order). It now sorts by the number of ONLINE (green) boards, total count as a
  tiebreaker, so units with dead/missing boards surface.

wx-rs bridge/Rust changes mirrored into patches 0002 (widgets.rs) and 0003
(widgets_bridge.cpp) per ADR 0003.

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-19 11:55:39 -06:00
co-authored by Claude Opus 4.8
parent 2f914b9e8e
commit 67a7d832ee
12 changed files with 142 additions and 239 deletions
@@ -24,6 +24,7 @@
#include <wx/choice.h>
#include <wx/bmpbuttn.h>
#include <wx/bitmap.h>
#include <wx/bmpbndl.h>
#include <wx/image.h>
#include <wx/dcmemory.h>
#include <wx/dcgraph.h>
@@ -227,16 +228,20 @@ class SegmentRenderer : public wxDataViewCustomRenderer {
dc->SetBrush(wxBrush(GetAttr().GetBackgroundColour()));
dc->SetPen(*wxTRANSPARENT_PEN);
// 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).
// (text/shape) size in BOTH dimensions by the alignment logic, so filling
// it alone left the zebra covering only a content-sized band -- and since
// shape cells (dots) and text cells have different content heights, the
// stripes ended up unequal across columns. Fill an over-sized rect (full
// column width, and well beyond the row vertically); wxGTK clips the cell
// DC to the real cell background area, so this lands exactly on the full
// row height of this cell without bleeding into neighbours (round 11 #1/#3).
wxRect bg = cell;
if (wxDataViewColumn* owner = const_cast<SegmentRenderer*>(this)->GetOwner()) {
int cw = owner->GetWidth();
if (cw > bg.width) bg.width = cw;
}
bg.y -= 40;
bg.height += 80;
dc->DrawRectangle(bg);
}
wxColour highlight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
@@ -310,12 +315,23 @@ class SegmentRenderer : public wxDataViewCustomRenderer {
if (col && col->GetOwner()) {
GtkWidget* tv = col->GetOwner()->GtkGetTreeView();
if (tv && GTK_IS_WIDGET(tv)) {
// The treeview's own state flags do NOT reliably carry
// GTK_STATE_FLAG_BACKDROP (that lives on the toplevel), so query the
// toplevel window's active state directly and force BACKDROP onto the
// style-context state when it is inactive. Then the themed cell text
// colour matches what GTK paints on the native columns when the window
// loses focus (round 11 #1/#7).
GtkWidget* top = gtk_widget_get_toplevel(tv);
bool active = GTK_IS_WINDOW(top) && gtk_window_is_active(GTK_WINDOW(top));
GtkStyleContext* ctx = gtk_widget_get_style_context(tv);
GtkStateFlags st = gtk_widget_get_state_flags(tv);
st = active ? (GtkStateFlags)(st & ~GTK_STATE_FLAG_BACKDROP)
: (GtkStateFlags)(st | GTK_STATE_FLAG_BACKDROP);
GdkRGBA c;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_style_context_get_color(ctx, st, &c);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_style_context_save(ctx);
gtk_style_context_set_state(ctx, st);
gtk_style_context_get_color(ctx, gtk_style_context_get_state(ctx), &c);
gtk_style_context_restore(ctx);
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));
@@ -1306,98 +1322,12 @@ void* wxbr_media_button(void* parent, int id, int kind, int r, int g, int b) {
return (void*)btn;
}
// A small vector icon drawn into a transparent bitmap and wrapped in a
// wxStaticBitmap, for the KPI cards (round 11 #15). kind: 0 rabbit (hashing),
// 1 turtle (slow), 2 broken wine glass (not hashing), 3 otter (paused),
// 4 hive (hashrate), 5 lightning bolt (power). Drawn as simple silhouettes so
// they read at ~22px; the colour matches the card's value colour.
void* wxbr_kpi_icon(void* parent, int kind, int r, int g, int b) {
const int sz = 22;
wxImage img(sz, sz);
img.InitAlpha();
unsigned char* a = img.GetAlpha();
if (a) memset(a, 0, (size_t)sz * sz);
wxBitmap bmp(img);
{
wxMemoryDC mdc(bmp);
wxGraphicsContext* gc = wxGraphicsContext::Create(mdc);
if (gc) {
gc->SetAntialiasMode(wxANTIALIAS_DEFAULT);
wxColour col(r, g, b);
wxColour dark((unsigned char)(r * 0.5), (unsigned char)(g * 0.5), (unsigned char)(b * 0.5));
gc->SetBrush(wxBrush(col));
gc->SetPen(wxPen(col, 1.0));
switch (kind) {
case 0: { // rabbit: low haunch body + head + two long spread ears
gc->DrawEllipse(4, 12, 14, 8); // haunch (low, wide)
gc->DrawEllipse(6.5, 7, 8, 8); // head
gc->DrawEllipse(6, 0, 2.6, 9); // left ear (long)
gc->DrawEllipse(12, 0, 2.6, 9); // right ear (long, spread)
break;
}
case 1: { // turtle: wide shell + head + two visible legs
gc->DrawEllipse(4, 6, 13, 9);
gc->DrawEllipse(15.5, 8, 4.5, 4.5); // head
gc->DrawEllipse(4.5, 12.5, 4, 4); // front leg
gc->DrawEllipse(11, 12.5, 4, 4); // back leg
break;
}
case 2: { // broken wine glass: bowl + stem + base, with a crack
wxGraphicsPath bowl = gc->CreatePath();
bowl.MoveToPoint(5, 3);
bowl.AddLineToPoint(17, 3);
bowl.AddLineToPoint(11, 12);
bowl.CloseSubpath();
gc->FillPath(bowl);
gc->DrawRectangle(10.2, 12, 1.6, 6);
gc->DrawRoundedRectangle(7, 18, 8, 2, 1);
wxGraphicsPath crack = gc->CreatePath(); // jagged crack across the bowl
crack.MoveToPoint(11, 3);
crack.AddLineToPoint(9, 6);
crack.AddLineToPoint(12.5, 8);
crack.AddLineToPoint(10.5, 11.5);
gc->SetPen(wxPen(dark, 1.4));
gc->StrokePath(crack);
break;
}
case 3: { // otter: upright tapered body + head + small ears + thick tail
wxGraphicsPath tail = gc->CreatePath(); // thick tapering tail curving right
tail.MoveToPoint(13, 17);
tail.AddCurveToPoint(19, 16, 21, 20, 19, 21);
tail.AddCurveToPoint(17, 21, 15, 20, 12, 19);
tail.CloseSubpath();
gc->FillPath(tail);
gc->DrawEllipse(6, 8, 10, 13); // body (tapered upright)
gc->DrawEllipse(7, 3, 8, 8); // head (wide)
gc->DrawEllipse(7, 2.5, 2.6, 2.6); // ear L
gc->DrawEllipse(12.4, 2.5, 2.6, 2.6);// ear R
break;
}
case 4: { // hive (skep): three stacked bands narrowing upward + entrance
gc->DrawRoundedRectangle(6, 2.5, 10, 4, 2);
gc->DrawRoundedRectangle(4, 7, 14, 4, 2);
gc->DrawRoundedRectangle(2.5, 11.5, 17, 5, 2.5);
gc->SetBrush(wxBrush(dark));
gc->SetPen(wxPen(dark, 1.0));
gc->DrawEllipse(9.3, 13, 3.4, 3.6);
break;
}
default: { // 5 lightning bolt
wxGraphicsPath p = gc->CreatePath();
p.MoveToPoint(13, 2);
p.AddLineToPoint(5, 12);
p.AddLineToPoint(10, 12);
p.AddLineToPoint(8, 20);
p.AddLineToPoint(17, 9);
p.AddLineToPoint(11, 9);
p.CloseSubpath();
gc->FillPath(p);
break;
}
}
delete gc;
}
}
// Render an SVG (already recoloured on the Rust side -- its fill is an explicit
// #RRGGBB) into a wxStaticBitmap for the KPI cards (round 11 #15). The caller
// passes the target pixel size (w chosen from the SVG aspect ratio, h fixed).
void* wxbr_svg_icon(void* parent, const char* svg, int w, int h) {
wxBitmapBundle bundle = wxBitmapBundle::FromSVG(svg, wxSize(w, h));
wxBitmap bmp = bundle.GetBitmap(wxSize(w, h));
return (void*)new wxStaticBitmap((wxWindow*)parent, wxID_ANY, bmp);
}