From 3e5efce7c388758bf38384695f9d347268ee658e Mon Sep 17 00:00:00 2001 From: noah Date: Sat, 19 Sep 2026 23:38:57 -0600 Subject: [PATCH] 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 Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh --- .../patches/0003-widget-bridge-cpp.patch | 53 +++++++++++++++++-- .../cpp_src/widgets_bridge.cpp | 51 +++++++++++++++++- 2 files changed, 99 insertions(+), 5 deletions(-) diff --git a/thirdparty/wx-rs/patches/0003-widget-bridge-cpp.patch b/thirdparty/wx-rs/patches/0003-widget-bridge-cpp.patch index 6cb2ddee..a58a6183 100644 --- a/thirdparty/wx-rs/patches/0003-widget-bridge-cpp.patch +++ b/thirdparty/wx-rs/patches/0003-widget-bridge-cpp.patch @@ -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 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; diff --git a/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp b/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp index 5a652d75..2a9ce17f 100644 --- a/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp +++ b/thirdparty/wx-rs/wx-rs-0.2.0-patched/cpp_src/widgets_bridge.cpp @@ -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 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;