Compare commits

...
6 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
noahandClaude Opus 4.8 ad9b0dc868 GUI round 12 (batch 1): black hashrate value, Control Board label, blank placeholder serials, sensible WhatsMiner temps
- #1: the total-hashrate KPI value renders in the default (black) text colour
  instead of accent blue (and now dims with focus like the other neutral cards).
- #4: the board-code column header is now "Control Board".
- #5 (serial): placeholder serials ("N/A", "none", "null", ...) render as an
  empty cell instead of the literal placeholder.
- #3: the Chip-temp cell now prefers each board's board/PCB temperature over the
  hottest-chip (outlet) reading. WhatsMiner's outlet_chip is the max chip temp
  (verified live: ~100C on the hottest board of a M30S+ VE40) which read
  alarmingly high and didn't match the ~60-79C the miner itself reports; the
  board temperature is the figure the miner's UI shows. Falls back to the chip
  temp when no board temp is reported. Applies to all makes for consistency.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-19 23:02:39 -06:00
noahandClaude Opus 4.8 aaf049bbfc GUI round 11: use the exact potraced beehive for the Hashrate KPI icon
Replaced the hand-traced beehive with an exact potrace of the operator-supplied
beehive.png (parent miner-firmware folder): potrace -s on the flattened bilevel
bitmap, then the black fill rewritten to currentColor so it recolours to the
Hashrate accent. Renders correctly via wxBitmapBundle::FromSVG (nanosvg).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-19 22:26:02 -06:00
noahandClaude Opus 4.8 8b7b0c70b4 GUI round 11: hand-traced beehive KPI icon (Hashrate)
Replaced the placeholder skep with a beehive matching the operator's reference
(branch + hook on top, stacked pill bands, centre entrance), as an outline SVG
using stroke="currentColor" so it recolours to the Hashrate accent. Hand-traced
because a chat-pasted raster can't be reached as a file for potrace; if the
source raster is saved to disk later, it can be image-traced for an exact match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-19 22:14:12 -06:00
noahandClaude Opus 4.8 3ae80efdde GUI round 11: KPI icons match their card text colour + recolour SVGs without a fill
- Each KPI icon now uses its card's value colour (dropped the amber special-case),
  so the otter matches the Paused text colour and the lightning bolt matches the
  Est-power text colour, etc.
- svg_recolored also injects a root fill: some Font Awesome exports (e.g. the Free
  otter) omit fill entirely and default to black, so replacing currentColor alone
  left them black. Now shapes without their own fill inherit the card colour.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-19 20:53:28 -06:00
6 changed files with 179 additions and 39 deletions
+1 -1
View File
@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><g fill="currentColor"><rect x="176" y="40" width="160" height="70" rx="35"/><rect x="128" y="130" width="256" height="70" rx="35"/><rect x="80" y="220" width="352" height="72" rx="36"/><rect x="48" y="312" width="416" height="80" rx="40"/></g></svg>
<svg version="1.0" xmlns="http://www.w3.org/2000/svg" width="511.104248pt" height="512.144915pt" viewBox="0 0 511.104248 512.144915" preserveAspectRatio="xMidYMid meet"><g transform="translate(-0.500000,511.997478) scale(0.100000,-0.100000)" fill="currentColor" stroke="none"><path d="M82 5103 c-52 -25 -77 -69 -77 -133 0 -41 6 -63 22 -86 49 -68 -31 -64 1237 -64 l1146 0 0 -150 0 -150 -323 0 c-292 0 -332 -2 -403 -20 -201 -52 -370 -228 -414 -432 -8 -34 -11 -94 -8 -155 5 -90 12 -119 52 -214 6 -14 -9 -17 -121 -22 -142 -7 -205 -22 -304 -73 -123 -65 -229 -192 -272 -329 -33 -106 -30 -264 7 -360 15 -38 30 -77 32 -85 4 -12 -9 -20 -49 -33 -76 -24 -163 -83 -228 -156 -160 -176 -193 -424 -86 -638 61 -123 195 -242 315 -280 40 -13 52 -21 48 -33 -2 -8 -17 -46 -32 -85 -38 -95 -41 -253 -7 -360 56 -178 206 -323 393 -380 32 -9 108 -19 182 -22 l126 -6 -25 -66 c-31 -81 -42 -233 -23 -319 45 -210 221 -387 433 -437 94 -22 1622 -22 1716 0 108 26 188 71 272 155 126 125 176 255 167 437 -5 90 -12 119 -52 214 -6 14 9 17 122 22 147 6 246 33 337 92 110 70 199 186 238 310 33 106 30 264 -7 360 -15 39 -30 77 -32 85 -4 12 9 20 49 33 211 67 377 303 377 537 0 233 -167 470 -378 537 -40 13 -52 21 -48 33 2 8 17 47 32 85 37 96 40 254 7 360 -39 122 -130 241 -240 311 -89 58 -188 85 -335 91 -113 5 -128 8 -122 22 40 95 47 124 52 214 6 119 -7 184 -55 287 -46 97 -157 210 -254 257 -117 58 -159 63 -516 63 l-323 0 0 150 0 150 618 0 617 0 210 -211 c116 -116 227 -219 247 -230 122 -63 256 59 207 187 -5 16 -60 79 -121 141 l-112 113 313 0 c346 0 360 2 404 64 31 43 31 129 0 172 -50 70 173 64 -2535 64 -2230 0 -2446 -2 -2476 -17z m3337 -918 c94 -52 141 -134 141 -244 -1 -102 -60 -192 -155 -237 l-50 -24 -795 0 -795 0 -50 24 c-61 28 -116 87 -140 149 -26 70 -17 172 21 235 31 49 104 105 158 121 18 6 363 9 821 8 l790 -2 54 -30z m649 -834 c95 -43 162 -147 162 -251 0 -66 -30 -131 -85 -187 -84 -83 -84 -83 -593 -83 l-434 0 -55 50 c-281 257 -719 257 -1005 0 l-57 -51 -453 3 c-452 3 -453 3 -500 26 -92 45 -158 151 -158 252 0 119 99 235 221 259 24 5 688 8 1474 8 l1430 -2 53 -24z m-1317 -623 c130 -64 224 -184 249 -317 5 -29 10 -98 10 -151 0 -53 -5 -122 -10 -151 -25 -133 -119 -253 -249 -317 -73 -36 -77 -37 -191 -37 -114 0 -118 1 -191 37 -125 62 -210 164 -244 293 -20 79 -20 271 0 350 39 149 147 263 300 318 38 13 74 17 151 15 93 -3 107 -6 175 -40z m-924 -235 c-16 -51 -16 -415 0 -465 l11 -38 -547 0 -548 0 -62 31 c-87 43 -138 117 -148 213 -11 110 44 211 145 263 l64 33 548 0 548 0 -11 -37z m2580 24 c60 -22 117 -72 148 -128 26 -46 30 -64 30 -129 0 -65 -4 -83 -30 -129 -31 -56 -88 -106 -148 -128 -23 -8 -187 -12 -578 -12 l-546 -1 13 68 c17 86 17 318 0 405 l-13 67 546 -1 c391 0 555 -4 578 -12z m-2349 -878 c286 -256 725 -255 1006 1 l55 51 453 -3 c452 -3 453 -3 500 -26 90 -44 158 -151 158 -247 0 -99 -69 -204 -162 -246 l-53 -24 -1455 0 -1455 0 -53 24 c-95 43 -162 147 -162 251 0 66 30 131 85 187 83 82 79 81 588 82 l439 1 56 -51z m1342 -820 c97 -43 160 -138 160 -240 0 -111 -47 -192 -141 -244 l-54 -30 -783 -3 c-518 -2 -796 1 -822 8 -59 16 -131 70 -164 122 -38 63 -47 165 -21 235 24 62 79 121 140 149 l50 24 795 0 c778 0 796 -1 840 -21z"/></g></svg>

Before

Width:  |  Height:  |  Size: 313 B

After

Width:  |  Height:  |  Size: 3.0 KiB

+1 -1
View File
@@ -546,7 +546,7 @@ impl Column {
Column::Serial => "Serial",
Column::ApiVersion => "API ver",
Column::Cpu => "CPU",
Column::BoardCode => "Board",
Column::BoardCode => "Control Board",
Column::Algorithm => "Algorithm",
Column::Pic => "PIC",
Column::Locked => "Access",
+24 -5
View File
@@ -449,15 +449,19 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
.as_ref()
.map(|t| t.as_celsius())
.unwrap_or(0.0);
// Per-hashboard chip temperature (hottest chip per board, falling back to
// the board/PCB temp), for the "77 / 64 / 74" Chip-temp cell.
// Per-hashboard temperature for the "77 / 64 / 74" Chip-temp cell. Prefer the
// board/PCB temperature over the hottest-chip (outlet) reading: WhatsMiner's
// outlet_chip is the max chip temp (~100C on the hottest board), which read
// alarmingly high and didn't match the temperature the miner itself reports;
// the board temperature (~60-79C) is the figure the miner's own UI shows
// (round 12 #3). Falls back to the chip temp when no board temp is reported.
let board_temps: Vec<f64> = data
.hashboards
.iter()
.filter_map(|b| {
b.outlet_chip_temperature
b.board_temperature
.as_ref()
.or(b.board_temperature.as_ref())
.or(b.outlet_chip_temperature.as_ref())
.map(|t| t.as_celsius())
})
.filter(|&t| t > 0.0)
@@ -606,7 +610,22 @@ async fn to_row(miner: &dyn Miner) -> MinerRow {
submodel,
mac: data.mac.map(|m| m.to_string()).unwrap_or_default(),
hostname: data.hostname.clone().unwrap_or_default(),
serial: data.serial_number.clone().unwrap_or_default(),
serial: {
// Some miners report a placeholder serial ("N/A", "none", ...); show
// those as an empty cell rather than the literal placeholder (round 12).
let s = data.serial_number.clone().unwrap_or_default();
let t = s.trim();
if t.is_empty()
|| t.eq_ignore_ascii_case("n/a")
|| t.eq_ignore_ascii_case("na")
|| t.eq_ignore_ascii_case("none")
|| t.eq_ignore_ascii_case("null")
{
String::new()
} else {
s
}
},
firmware,
fw_version,
api_version: data.api_version.clone().unwrap_or_default(),
+54 -27
View File
@@ -295,13 +295,24 @@ 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).
/// 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.
fn svg_recolored(svg: &str, color: (u8, u8, u8)) -> String {
svg.replace(
"currentColor",
&format!("#{:02X}{:02X}{:02X}", color.0, color.1, color.2),
)
let hex = format!("#{:02X}{:02X}{:02X}", color.0, color.1, color.2);
let s = svg.replace("currentColor", &hex);
s.replacen("<svg ", &format!("<svg fill=\"{hex}\" "), 1)
}
/// Width to render an SVG at, preserving its viewBox aspect ratio at height `h`.
@@ -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);
@@ -592,9 +603,9 @@ pub fn build(frame: Widget) -> App {
let row = Widget::box_sizer(false);
row.add_stretch(1);
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 };
// Icon takes the card's value colour, so each icon matches its KPI
// text (otter = paused colour, bolt = est-power colour, etc.).
let icol = vc;
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);
@@ -619,9 +630,16 @@ pub fn build(frame: Widget) -> App {
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));
// 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));
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.
@@ -830,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;