Compare commits

...
2 Commits
Author SHA1 Message Date
noahandClaude Opus 4.8 b7a77cbed8 GUI round 12 (#7): batch multi-select in the Columns and Filter menus
Both list widgets now support Excel-style batch selection so several rows can be
toggled at once.

- Filter menu value list (wxCheckListBox): was wxLB_SINGLE, so only one value
  could ever be selected. Switched to wxLB_EXTENDED -- ctrl-click, shift-click
  and rubber-band drag now select a range of values. Clicking any selected
  row's checkbox applies that new checked state to every selected row.
- Columns menu list (wxListCtrl): already multi-select for the drag-reorder, but
  a checkbox toggle only affected the clicked row. A toggle on a row that is part
  of a multi-row selection now applies to every selected row, so several columns
  can be shown/hidden together. Re-entrancy guarded (CheckItem re-fires the
  event).

Verified under Xvfb by driving the real dialogs: ctrl-click selects several
columns and one checkbox click toggles them together; shift-click selects a
range of filter values and one checkbox click toggles them together. Headless
self-test still passes. wx-rs patch 0003 regenerated to match the edited bridge.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-19 23:38:57 -06:00
noahandClaude Opus 4.8 606ae85781 GUI round 12 (#2): keep KPI units visible when the window shrinks
The two wide KPI cards (SHA-256 Hashrate, Est. power) carry a units-bearing
value like "685 TH" / "21.3 kW". When the window was narrowed the row squeezed
these cards below the width their value needs, clipping the trailing unit so it
read as "21.3" with no "kW". Two fixes:

- A nested wxPanel does not re-run its own sizer when its parent resizes it, so
  each card's value/label centring kept whatever slot width it had at the
  previous window size. on_resize now re-lays-out every card on each size event,
  so the value stays centred and gets its full best-size width allocation.
- Raise the wide-card minimum width (150 -> 176) to fit a ~20px icon + a value
  up to "118.0 PH" + the card's side inset, and derive the collapse threshold
  from the real per-card minimums. The wide cards now either show their full
  units or drop out of the row cleanly -- they never render a clipped value.

Verified under Xvfb: at 1050px all seven cards show "685 TH" / "21.3 kW" in
full; at 960px the two wide cards collapse and the five count cards fill the
row. Headless self-test still passes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-19 23:29:36 -06:00
3 changed files with 141 additions and 22 deletions
+42 -17
View File
@@ -295,6 +295,17 @@ 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");
/// KPI card minimum widths. The count cards (Total/Hashing/...) are narrow; the
/// two wide cards (SHA-256 Hashrate, Est. power) need more room so their
/// icon + units-bearing value never clips (round 12 #2). The wide floor fits the
/// widest realistic value the card can show -- a ~20px icon + 5px gap + a value
/// text up to "118.0 PH" (~127px at 19pt bold) + the card's 16px side inset --
/// so the units ("kW"/"PH"/...) stay visible instead of being squeezed off; the
/// row collapses the wide cards entirely (see `on_resize`) rather than shrink
/// them below this and clip.
const KPI_MIN: i32 = 116;
const KPI_WIDE_MIN: i32 = 176;
/// Recolour an SVG to the KPI card's colour (round 11 #15). Some Font Awesome
/// exports use fill="currentColor" (replaced here); others omit fill entirely and
/// default to black, so a root `fill` is also injected for shapes to inherit.
@@ -560,7 +571,7 @@ pub fn build(frame: Widget) -> App {
card.set_bg(pal.card_bg.0, pal.card_bg.1, pal.card_bg.2);
// Min-content floor (the widest label/value); cards grow equally past
// this to fill the window (proportion 1 + EXPAND on add).
card.set_min_size(116, 62);
card.set_min_size(KPI_MIN, 62);
let cs = Widget::box_sizer(true);
let value = Widget::static_text(card, "0");
value.set_font_size(19);
@@ -622,8 +633,13 @@ pub fn build(frame: Widget) -> App {
// Total-hashrate value renders in the default (black) text colour, not accent
// (round 12 #1); it still dims with focus like the other neutral cards.
let (card_hashrate, kpi_hashrate) = mk_card("SHA-256 Hashrate", ColorKind::Neutral, Some(SVG_HIVE));
let (_card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral, Some(SVG_BOLT));
let (card_power, kpi_power) = mk_card("Est. power", ColorKind::Neutral, Some(SVG_BOLT));
drop(mk_card);
// The two wide cards carry a units-bearing value (icon + e.g. "685 TH" /
// "21.3 kW"); give them a larger min width so the value never clips, and
// collapse them before the row would squeeze them below it (round 12 #2).
card_hashrate.set_min_size(KPI_WIDE_MIN, 62);
card_power.set_min_size(KPI_WIDE_MIN, 62);
let _ = (card_hashing, card_slow, card_not, card_paused);
// The hashrate card is kpi_cards[5] in build order (Total, Hashing, Slow,
// Not, Paused, Hashrate, Power); its caption is retitled per algorithm.
@@ -832,23 +848,32 @@ impl App {
/// seven cards at their minimum width, the two wide cards are hidden so the
/// five miner-count cards fill the row; they return when there is room again.
fn on_resize(&mut self, width: i32) {
// Each card is a ~116px min + BORDER_ALL*2 (8px); the row itself is
// inset by the root border. Below the width needed for all seven, drop
// the two wide cards.
const CARD_SLOT: i32 = 116 + 8;
let need_all = CARD_SLOT * 7 + 12;
// Each card occupies its min width + BORDER_ALL*2 (8px); the row itself is
// inset by the root border (~12px). Collapse the two wide cards below the
// width where all seven fit at their mins, so the wide cards' units-bearing
// value never gets squeezed/clipped (round 12 #2) -- they drop out cleanly
// instead.
let need_all = 5 * (KPI_MIN + 8) + 2 * (KPI_WIDE_MIN + 8) + 12;
let want_collapsed = width < need_all;
if want_collapsed == self.kpi_collapsed {
return;
if want_collapsed != self.kpi_collapsed {
self.kpi_collapsed = want_collapsed;
let show = !want_collapsed;
// kpi_cards[5] = Hashrate card, [6] = Est. power card (build order).
let hashrate_card = self.kpi_cards[5].0;
let power_card = self.kpi_cards[6].0;
self.kpi_row.sizer_show(hashrate_card, show);
self.kpi_row.sizer_show(power_card, show);
self.panel.layout();
}
// A nested wxPanel does not re-run its own sizer when the parent resizes
// it, so the value/label centring spacers keep the slot sizes they were
// given at the previous width. Re-layout each card here so the value
// (which may carry a units suffix like "kW"/"PH") stays centred and its
// full text is allocated -- otherwise the suffix reads as clipped when
// the row is squeezed (round 12 #2).
for (card, _, _, _) in &self.kpi_cards {
card.layout();
}
self.kpi_collapsed = want_collapsed;
let show = !want_collapsed;
// kpi_cards[5] = Hashrate card, [6] = Est. power card (build order).
let hashrate_card = self.kpi_cards[5].0;
let power_card = self.kpi_cards[6].0;
self.kpi_row.sizer_show(hashrate_card, show);
self.kpi_row.sizer_show(power_card, show);
self.panel.layout();
}
pub fn rebuild_table(&mut self) {
+50 -3
View File
@@ -1,6 +1,6 @@
--- a/cpp_src/widgets_bridge.cpp
+++ b/cpp_src/widgets_bridge.cpp
@@ -0,0 +1,1413 @@
@@ -0,0 +1,1460 @@
+// 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).
@@ -552,12 +552,31 @@
+// ---- check list box ---------------------------------------------------------
+
+void* wxbr_check_list_box(void* parent) {
+ // wxLB_EXTENDED so several rows can be selected at once (ctrl/shift-click and
+ // rubber-band drag, native to wxListBox); a checkbox toggle on any selected
+ // row then applies to every selected row (see the handler below). This is the
+ // Excel-style batch-check the filter menu needs (round 12 #7).
+ wxCheckListBox* clb = new wxCheckListBox((wxWindow*)parent, wxID_ANY,
+ wxDefaultPosition, wxSize(-1, -1),
+ 0, NULL, wxLB_SINGLE | wxLB_NEEDED_SB);
+ 0, NULL, wxLB_EXTENDED | wxLB_NEEDED_SB);
+ clb->Bind(wxEVT_CHECKLISTBOX, [clb](wxCommandEvent& e) {
+ int idx = e.GetInt();
+ // Batch toggle: if the clicked row is part of a multi-row selection, give
+ // every selected row the clicked row's new state. Check() does not itself
+ // fire wxEVT_CHECKLISTBOX, so there is no recursion.
+ wxArrayInt sel;
+ clb->GetSelections(sel);
+ if (sel.GetCount() > 1) {
+ bool inSel = false;
+ for (size_t i = 0; i < sel.GetCount(); i++)
+ if (sel[i] == idx) { inSel = true; break; }
+ if (inSel) {
+ bool state = clb->IsChecked(idx);
+ for (size_t i = 0; i < sel.GetCount(); i++) clb->Check(sel[i], state);
+ }
+ }
+ if (g_widget_event)
+ g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, e.GetInt());
+ g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, idx);
+ });
+ return (void*)clb;
+}
@@ -1155,6 +1174,34 @@
+ lc->SetItemData(row, (long)idx);
+ lc->CheckItem(row, enc >= 0);
+ }
+ // Batch checkbox toggle: checking/unchecking a row that is part of a
+ // multi-row selection applies the same state to every selected row, so the
+ // user can ctrl/shift-click several columns and show/hide them together
+ // (round 12 #7). CheckItem() re-enters this handler, so guard against it.
+ auto batchCheck = [lc](long item, bool state) {
+ static bool busy = false;
+ if (busy) return;
+ if (!(lc->GetItemState(item, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED))
+ return;
+ wxVector<long> sel;
+ long it = -1;
+ for (;;) {
+ it = lc->GetNextItem(it, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ if (it == -1) break;
+ sel.push_back(it);
+ }
+ if (sel.size() <= 1) return;
+ busy = true;
+ for (size_t i = 0; i < sel.size(); i++)
+ if (sel[i] != item) lc->CheckItem(sel[i], state);
+ busy = false;
+ };
+ lc->Bind(wxEVT_LIST_ITEM_CHECKED, [batchCheck](wxListEvent& e) {
+ batchCheck(e.GetIndex(), true);
+ });
+ lc->Bind(wxEVT_LIST_ITEM_UNCHECKED, [batchCheck](wxListEvent& e) {
+ batchCheck(e.GetIndex(), false);
+ });
+ lc->Bind(wxEVT_LIST_BEGIN_DRAG, [lc](wxListEvent&) {
+ g_reorder_drag.clear();
+ g_reorder_list = lc;
@@ -549,12 +549,31 @@ void wxbr_check_box_set(void* win, int v) {
// ---- check list box ---------------------------------------------------------
void* wxbr_check_list_box(void* parent) {
// wxLB_EXTENDED so several rows can be selected at once (ctrl/shift-click and
// rubber-band drag, native to wxListBox); a checkbox toggle on any selected
// row then applies to every selected row (see the handler below). This is the
// Excel-style batch-check the filter menu needs (round 12 #7).
wxCheckListBox* clb = new wxCheckListBox((wxWindow*)parent, wxID_ANY,
wxDefaultPosition, wxSize(-1, -1),
0, NULL, wxLB_SINGLE | wxLB_NEEDED_SB);
0, NULL, wxLB_EXTENDED | wxLB_NEEDED_SB);
clb->Bind(wxEVT_CHECKLISTBOX, [clb](wxCommandEvent& e) {
int idx = e.GetInt();
// Batch toggle: if the clicked row is part of a multi-row selection, give
// every selected row the clicked row's new state. Check() does not itself
// fire wxEVT_CHECKLISTBOX, so there is no recursion.
wxArrayInt sel;
clb->GetSelections(sel);
if (sel.GetCount() > 1) {
bool inSel = false;
for (size_t i = 0; i < sel.GetCount(); i++)
if (sel[i] == idx) { inSel = true; break; }
if (inSel) {
bool state = clb->IsChecked(idx);
for (size_t i = 0; i < sel.GetCount(); i++) clb->Check(sel[i], state);
}
}
if (g_widget_event)
g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, e.GetInt());
g_widget_event(WxEV_CLB_TOGGLED, (long)(intptr_t)clb, idx);
});
return (void*)clb;
}
@@ -1152,6 +1171,34 @@ void* wxbr_reorder_list(void* parent, int n, const int* order, const char** item
lc->SetItemData(row, (long)idx);
lc->CheckItem(row, enc >= 0);
}
// Batch checkbox toggle: checking/unchecking a row that is part of a
// multi-row selection applies the same state to every selected row, so the
// user can ctrl/shift-click several columns and show/hide them together
// (round 12 #7). CheckItem() re-enters this handler, so guard against it.
auto batchCheck = [lc](long item, bool state) {
static bool busy = false;
if (busy) return;
if (!(lc->GetItemState(item, wxLIST_STATE_SELECTED) & wxLIST_STATE_SELECTED))
return;
wxVector<long> sel;
long it = -1;
for (;;) {
it = lc->GetNextItem(it, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (it == -1) break;
sel.push_back(it);
}
if (sel.size() <= 1) return;
busy = true;
for (size_t i = 0; i < sel.size(); i++)
if (sel[i] != item) lc->CheckItem(sel[i], state);
busy = false;
};
lc->Bind(wxEVT_LIST_ITEM_CHECKED, [batchCheck](wxListEvent& e) {
batchCheck(e.GetIndex(), true);
});
lc->Bind(wxEVT_LIST_ITEM_UNCHECKED, [batchCheck](wxListEvent& e) {
batchCheck(e.GetIndex(), false);
});
lc->Bind(wxEVT_LIST_BEGIN_DRAG, [lc](wxListEvent&) {
g_reorder_drag.clear();
g_reorder_list = lc;