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
+15 -1
View File
@@ -682,7 +682,21 @@ impl Column {
Column::FanCount => SortKey::Num(r.fan_count.map(|v| v as f64).unwrap_or(none)),
Column::ExpectedFans => SortKey::Num(r.expected_fans.map(|v| v as f64).unwrap_or(none)),
Column::TotalChips => SortKey::Num(r.total_chips.map(|v| v as f64).unwrap_or(none)),
Column::Hashboards => SortKey::Num(r.hashboards.map(|v| v as f64).unwrap_or(none)),
// The Boards column shows per-hashboard health dots, so sort by the
// number of ONLINE (green) boards -- surfacing units with dead/missing
// boards -- with the total board count as a tiebreaker (so full-health
// units still order by how many boards they have). Falls back to the
// reported board count when no per-board health is available (round 11).
Column::Hashboards => {
if r.board_status.is_empty() {
SortKey::Num(r.hashboards.map(|v| v as f64).unwrap_or(none))
} else {
let online =
r.board_status.iter().filter(|h| matches!(h, BoardHealth::Ok)).count();
let total = r.board_status.len();
SortKey::Num((online * 100 + total) as f64)
}
}
Column::Uptime => SortKey::Num(if r.uptime_secs > 0 { r.uptime_secs as f64 } else { none }),
Column::BestShare => SortKey::Num(r.best_share.unwrap_or(none)),
Column::SessionBestShare => SortKey::Num(r.session_best_share.unwrap_or(none)),
+45 -10
View File
@@ -285,6 +285,38 @@ fn encode_light_dot(pal: &Palette, flashing: Option<bool>) -> String {
}
}
// KPI card icons (round 11 #15). The animal/wine-glass SVGs are Font Awesome Pro
// (operator-supplied); bolt/hive are matching in-repo SVGs. All use
// fill="currentColor", recoloured per card at render time.
const SVG_RABBIT: &str = include_str!("../assets/icons/rabbit.svg");
const SVG_TURTLE: &str = include_str!("../assets/icons/turtle.svg");
const SVG_WINE_CRACK: &str = include_str!("../assets/icons/wine-glass-crack.svg");
const SVG_OTTER: &str = include_str!("../assets/icons/otter.svg");
const SVG_HIVE: &str = include_str!("../assets/icons/hive.svg");
const SVG_BOLT: &str = include_str!("../assets/icons/bolt.svg");
/// Replace an SVG's `currentColor` fill with an explicit hex colour so it renders
/// in the KPI card's colour (round 11 #15).
fn svg_recolored(svg: &str, color: (u8, u8, u8)) -> String {
svg.replace(
"currentColor",
&format!("#{:02X}{:02X}{:02X}", color.0, color.1, color.2),
)
}
/// Width to render an SVG at, preserving its viewBox aspect ratio at height `h`.
fn svg_width_for_height(svg: &str, h: i32) -> i32 {
svg.split("viewBox=\"")
.nth(1)
.and_then(|s| s.split('"').next())
.and_then(|vb| {
let n: Vec<f64> = vb.split_whitespace().filter_map(|x| x.parse().ok()).collect();
(n.len() == 4 && n[3] > 0.0).then(|| ((h as f64) * n[2] / n[3]).round() as i32)
})
.unwrap_or(h)
.max(1)
}
/// Build the segment-encoded cell text for the Cooling column: each fan's RPM
/// gets its own grey-to-blue colour by speed, and the "/" separators between
/// them stay in the default text colour.
@@ -522,7 +554,7 @@ pub fn build(frame: Widget) -> App {
// min size floors them at their largest content's width.
let kpi_row = Widget::box_sizer(false);
let mut kpi_cards: Vec<(Widget, Widget, Widget, ColorKind)> = Vec::new();
let mut mk_card = |label: &str, kind: ColorKind, icon: Option<i32>| -> (Widget, Widget) {
let mut mk_card = |label: &str, kind: ColorKind, icon: Option<&'static str>| -> (Widget, Widget) {
let vc = kind_color(&pal, kind);
let card = Widget::panel(panel);
card.set_bg(pal.card_bg.0, pal.card_bg.1, pal.card_bg.2);
@@ -559,9 +591,12 @@ pub fn build(frame: Widget) -> App {
let value_row = {
let row = Widget::box_sizer(false);
row.add_stretch(1);
if let Some(ik) = icon {
if let Some(svg) = icon {
// Neutral cards (Est. power) colour the icon amber so the bolt
// reads; the rest take the card's value colour.
let icol = if matches!(kind, ColorKind::Neutral) { pal.amber } else { vc };
let ic = Widget::kpi_icon(card, ik, icol);
let h = 20;
let ic = Widget::svg_icon(card, &svg_recolored(svg, icol), svg_width_for_height(svg, h), h);
row.add(ic, 0, sf::ALIGN_CENTRE_VERTICAL | sf::BORDER_RIGHT, 5);
}
row.add(value, 0, sf::ALIGN_CENTRE_VERTICAL, 0);
@@ -577,15 +612,15 @@ pub fn build(frame: Widget) -> App {
kpi_cards.push((card, value, lbl, kind));
(card, value)
};
// Icons (round 11 #15): rabbit=hashing, turtle=slow, broken glass=not
// Icons (round 11 #15): rabbit=hashing, turtle=slow, cracked wine glass=not
// hashing, otter=paused, hive=hashrate, lightning=power; Total has none.
let (_card_total, kpi_total) = mk_card("Total", ColorKind::Neutral, None);
let (card_hashing, kpi_hashing) = mk_card("Hashing", ColorKind::Green, Some(0));
let (card_slow, kpi_slow) = mk_card("Slow", ColorKind::Amber, Some(1));
let (card_not, kpi_not) = mk_card("Not hashing", ColorKind::Red, Some(2));
let (card_paused, kpi_paused) = mk_card("Paused", ColorKind::Blue, Some(3));
let (card_hashrate, kpi_hashrate) = mk_card("SHA-256 Hashrate", ColorKind::Accent, Some(4));
let (_card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral, Some(5));
let (card_hashing, kpi_hashing) = mk_card("Hashing", ColorKind::Green, Some(SVG_RABBIT));
let (card_slow, kpi_slow) = mk_card("Slow", ColorKind::Amber, Some(SVG_TURTLE));
let (card_not, kpi_not) = mk_card("Not hashing", ColorKind::Red, Some(SVG_WINE_CRACK));
let (card_paused, kpi_paused) = mk_card("Paused", ColorKind::Blue, Some(SVG_OTTER));
let (card_hashrate, kpi_hashrate) = mk_card("SHA-256 Hashrate", ColorKind::Accent, Some(SVG_HIVE));
let (_card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral, Some(SVG_BOLT));
drop(mk_card);
let _ = (card_hashing, card_slow, card_not, card_paused);
// The hashrate card is kpi_cards[5] in build order (Total, Hashing, Slow,