Compare commits

...
2 Commits
Author SHA1 Message Date
noahandClaude Opus 4.8 a81fef3c7d GUI round 8: Errors column hover tooltip (full message list)
Item 12 (tooltip half): hovering an Errors cell now shows the full list of the
miner's error/event messages ("[Severity] text (component)", most severe first)
as a tooltip; the cell itself keeps the compact red summary.

wxDataViewCtrl has no per-cell tooltip API, and wx mouse-motion events are not
delivered to wx handlers on the native GTK control, so this uses GtkTreeView's
native "query-tooltip" signal directly (guarded by __WXGTK__): a per-cell
tooltip map (row, model column) -> text on the AttrListStore, populated from
Rust via a new dvlc_set_cell_tooltip bridge fn, and looked up by the signal
handler using dv->GTKColumnToWX(gcol)->GetModelColumn(). The map is populated on
every platform (a no-op where nothing reads it) so the non-GTK platform round
can wire its own tooltip surface later.

Local wx-rs bridge compile + full cargo check clean; patches 0002/0003
regenerated + validated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-17 17:37:18 -06:00
noahandClaude Opus 4.8 365732b5d4 GUI round 8b.2 fix: rubber-band drag-select uses native GtkTreeView on GTK
The wx-mouse-event rubber-band approach (LEFT_DOWN/MOTION/LEFT_UP) does not work
on the native GTK wxDataViewCtrl: the underlying GtkTreeView grabs the pointer
during a button drag, so wx never delivers the MOTION events, and only the
initial click row was selected (verified against the shipped binary).

Fix: on GTK, enable the GtkTreeView's own native rubber-band selection via
dv->GtkGetTreeView() + gtk_tree_view_set_rubber_banding(TRUE), guarded by
__WXGTK__ (gtk/gtk.h included only there). The wx-mouse-event approach is kept
as the non-GTK fallback for the future Windows/macOS builds, where it will be
verified in the platform round. The column-header right-click menu (native wx
dataview event) already worked and is unchanged.

Local wx-rs bridge compile clean; patch 0003 regenerated + validated.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
2026-09-17 17:27:16 -06:00
5 changed files with 172 additions and 12 deletions
+4
View File
@@ -694,6 +694,10 @@ impl App {
_ => continue,
};
t.dvlc_set_cell(disp, ci, &encoded);
// The Errors cell gets the full message list as a hover tooltip.
if matches!(c, Column::Error) {
t.dvlc_set_cell_tooltip(disp, ci, &r.errors.join("\n"));
}
}
}
if let Some(row) = top {
+9 -1
View File
@@ -10,7 +10,7 @@
+pub use widgets::*;
--- a/src/widgets.rs
+++ b/src/widgets.rs
@@ -0,0 +1,720 @@
@@ -0,0 +1,728 @@
+// widgets.rs — alkane-toolkit extension: Rust bindings for the widget bridge
+// in cpp_src/widgets_bridge.cpp. Handles are opaque pointers owned by the
+// wxWidgets object tree (parents own children; nothing to free in Rust).
@@ -71,6 +71,7 @@
+ pub fn wxbr_dvlc_clear(win: *mut c_void);
+ pub fn wxbr_dvlc_row_count(win: *mut c_void) -> c_int;
+ pub fn wxbr_dvlc_set_cell(win: *mut c_void, row: usize, col: usize, value: *const c_char);
+ pub fn wxbr_dvlc_set_cell_tooltip(win: *mut c_void, row: usize, col: usize, text: *const c_char);
+ pub fn wxbr_dvlc_get_cell(win: *mut c_void, row: usize, col: usize, buf: *mut c_char, cap: c_int) -> c_int;
+ pub fn wxbr_dvlc_col_count(win: *mut c_void) -> c_int;
+ pub fn wxbr_dvlc_autosize_col(win: *mut c_void, pos: c_int);
@@ -495,6 +496,13 @@
+ unsafe { notsafe::wxbr_dvlc_set_cell(self.0, row, col, c.as_ptr()) }
+ }
+
+ /// Set the hover tooltip for one cell (empty clears it). GTK only; a no-op
+ /// on other platforms until they gain per-cell tooltip support.
+ pub fn dvlc_set_cell_tooltip(&self, row: usize, col: usize, text: &str) {
+ let c = CString::new(text).unwrap_or_default();
+ unsafe { notsafe::wxbr_dvlc_set_cell_tooltip(self.0, row, col, c.as_ptr()) }
+ }
+
+ pub fn dvlc_get_cell(&self, row: usize, col: usize) -> Option<String> {
+ let mut buf = vec![0i8; 4096];
+ let n = unsafe {
+76 -6
View File
@@ -1,6 +1,6 @@
--- a/cpp_src/widgets_bridge.cpp
+++ b/cpp_src/widgets_bridge.cpp
@@ -0,0 +1,989 @@
@@ -0,0 +1,1059 @@
+// 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).
@@ -36,12 +36,21 @@
+#include <cstdio>
+#include <map>
+#include <vector>
+#ifdef __WXGTK__
+// For native GtkTreeView rubber-band (click-drag) selection, which wx does not
+// enable and which cannot be done via wx mouse events on GTK (the native widget
+// grabs the pointer during a drag). Guarded so non-GTK builds are unaffected.
+#include <gtk/gtk.h>
+#endif
+
+typedef void (*WxWidgetEventFn)(int kind, long p1, long p2);
+static WxWidgetEventFn g_widget_event = nullptr;
+
+// Anchor row per data-view control for rubber-band (click-drag) range select.
+#ifndef __WXGTK__
+// Anchor row per data-view control for the wx-mouse-event rubber-band fallback
+// (non-GTK platforms; GTK uses native GtkTreeView rubber-banding instead).
+static std::map<wxDataViewCtrl*, int> g_drag_anchor;
+#endif
+
+// Event kinds (must match Rust WxEventKind in src/widgets.rs)
+enum WxWidgetEventKind {
@@ -71,6 +80,9 @@
+ public:
+ std::vector<wxColour> row_fg;
+ wxColour zebra; // odd-row background; unset (=off) unless the app sets it
+ // Per-cell hover tooltip text, keyed by (row, model column). Used for the
+ // Errors column's full-message tooltip (see the GTK query-tooltip handler).
+ std::map<std::pair<unsigned, unsigned>, wxString> cell_tip;
+ bool GetAttrByRow(unsigned int row, unsigned int col,
+ wxDataViewItemAttr& attr) const override {
+ (void)col;
@@ -453,6 +465,36 @@
+ return static_cast<AttrListStore*>(((wxDataViewCtrl*)win)->GetModel());
+}
+
+#ifdef __WXGTK__
+// GtkTreeView "query-tooltip" handler: show the per-cell tooltip stored for the
+// (row, model column) under the pointer (used by the Errors column). wx does
+// not surface per-cell tooltips on wxDataViewCtrl, and mouse-motion events are
+// not delivered to wx handlers on the native GTK control, so this hooks the
+// native signal directly.
+static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keyboard,
+ GtkTooltip* tooltip, gpointer user_data) {
+ (void)keyboard;
+ wxDataViewCtrl* dv = static_cast<wxDataViewCtrl*>(user_data);
+ gint bx = 0, by = 0;
+ gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(tv), x, y, &bx, &by);
+ GtkTreePath* path = nullptr;
+ GtkTreeViewColumn* gcol = nullptr;
+ if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), bx, by, &path, &gcol, nullptr, nullptr))
+ return FALSE;
+ gint* idx = gtk_tree_path_get_indices(path);
+ int row = idx ? idx[0] : -1;
+ gtk_tree_path_free(path);
+ if (row < 0 || !gcol) return FALSE;
+ wxDataViewColumn* wxcol = dv->GTKColumnToWX(gcol);
+ if (!wxcol) return FALSE;
+ AttrListStore* store = static_cast<AttrListStore*>(dv->GetModel());
+ auto it = store->cell_tip.find({(unsigned)row, wxcol->GetModelColumn()});
+ if (it == store->cell_tip.end() || it->second.IsEmpty()) return FALSE;
+ gtk_tooltip_set_text(tooltip, it->second.utf8_str());
+ return TRUE;
+}
+#endif
+
+void* wxbr_dvlc(void* parent) {
+ // Multi-select (ctrl/shift-click) + row lines. Selection replaces the old
+ // checkbox column. A custom AttrListStore backs it so rows can be coloured by
@@ -490,10 +532,25 @@
+ dv->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) {
+ if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0);
+ });
+ // Rubber-band (click-drag) range selection: wxDataViewCtrl has none natively
+ // (only ctrl/shift-click), so track it here. LEFT_DOWN records the anchor row
+ // (and lets the native handler select it); dragging with the button down
+ // extends the selection to the row under the cursor.
+ // Rubber-band (click-drag) range selection. wxDataViewCtrl has none natively.
+#ifdef __WXGTK__
+ // On GTK the control wraps a GtkTreeView, which supports native rubber-band
+ // selection -- just not enabled by wx. Enable it directly. (wx delivers no
+ // MOTION events during the native drag, so the mouse-event fallback below is
+ // inapplicable on GTK.)
+ {
+ GtkWidget* tv = dv->GtkGetTreeView();
+ if (tv) {
+ gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tv), TRUE);
+ // Per-cell hover tooltips (Errors column) via the native signal.
+ gtk_widget_set_has_tooltip(tv, TRUE);
+ g_signal_connect(tv, "query-tooltip", G_CALLBACK(dvlc_query_tooltip), dv);
+ }
+ }
+#else
+ // Non-GTK fallback: track a drag anchor and extend the selection to the row
+ // under the cursor. LEFT_DOWN records the anchor (and lets the native handler
+ // select it); dragging with the button down selects the inclusive range.
+ dv->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& e) {
+ wxDataViewCtrl* dv = (wxDataViewCtrl*)e.GetEventObject();
+ if (!dv) { e.Skip(); return; }
@@ -534,6 +591,7 @@
+ if (dv) g_drag_anchor.erase(dv);
+ e.Skip();
+ });
+#endif
+ // Row activation (double-click / Enter): report the row + column so the app
+ // can, e.g., open the miner's IP in a browser.
+ dv->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) {
@@ -605,6 +663,18 @@
+ AttrListStore* store = dvlc_store(win);
+ store->DeleteAllItems();
+ store->row_fg.clear();
+ store->cell_tip.clear();
+}
+
+// Set (or clear, with an empty string) the hover tooltip for one cell,
+// addressed by (row, model column). Used for the Errors column's full text.
+void wxbr_dvlc_set_cell_tooltip(void* win, unsigned row, unsigned col, const char* text) {
+ AttrListStore* store = dvlc_store(win);
+ if (text && text[0]) {
+ store->cell_tip[{row, col}] = wxString::FromUTF8(text);
+ } else {
+ store->cell_tip.erase({row, col});
+ }
+}
+
+// Set (or clear, when r<0) a row's text colour; used to paint rows by status.
@@ -33,12 +33,21 @@
#include <cstdio>
#include <map>
#include <vector>
#ifdef __WXGTK__
// For native GtkTreeView rubber-band (click-drag) selection, which wx does not
// enable and which cannot be done via wx mouse events on GTK (the native widget
// grabs the pointer during a drag). Guarded so non-GTK builds are unaffected.
#include <gtk/gtk.h>
#endif
typedef void (*WxWidgetEventFn)(int kind, long p1, long p2);
static WxWidgetEventFn g_widget_event = nullptr;
// Anchor row per data-view control for rubber-band (click-drag) range select.
#ifndef __WXGTK__
// Anchor row per data-view control for the wx-mouse-event rubber-band fallback
// (non-GTK platforms; GTK uses native GtkTreeView rubber-banding instead).
static std::map<wxDataViewCtrl*, int> g_drag_anchor;
#endif
// Event kinds (must match Rust WxEventKind in src/widgets.rs)
enum WxWidgetEventKind {
@@ -68,6 +77,9 @@ class AttrListStore : public wxDataViewListStore {
public:
std::vector<wxColour> row_fg;
wxColour zebra; // odd-row background; unset (=off) unless the app sets it
// Per-cell hover tooltip text, keyed by (row, model column). Used for the
// Errors column's full-message tooltip (see the GTK query-tooltip handler).
std::map<std::pair<unsigned, unsigned>, wxString> cell_tip;
bool GetAttrByRow(unsigned int row, unsigned int col,
wxDataViewItemAttr& attr) const override {
(void)col;
@@ -450,6 +462,36 @@ static AttrListStore* dvlc_store(void* win) {
return static_cast<AttrListStore*>(((wxDataViewCtrl*)win)->GetModel());
}
#ifdef __WXGTK__
// GtkTreeView "query-tooltip" handler: show the per-cell tooltip stored for the
// (row, model column) under the pointer (used by the Errors column). wx does
// not surface per-cell tooltips on wxDataViewCtrl, and mouse-motion events are
// not delivered to wx handlers on the native GTK control, so this hooks the
// native signal directly.
static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keyboard,
GtkTooltip* tooltip, gpointer user_data) {
(void)keyboard;
wxDataViewCtrl* dv = static_cast<wxDataViewCtrl*>(user_data);
gint bx = 0, by = 0;
gtk_tree_view_convert_widget_to_bin_window_coords(GTK_TREE_VIEW(tv), x, y, &bx, &by);
GtkTreePath* path = nullptr;
GtkTreeViewColumn* gcol = nullptr;
if (!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tv), bx, by, &path, &gcol, nullptr, nullptr))
return FALSE;
gint* idx = gtk_tree_path_get_indices(path);
int row = idx ? idx[0] : -1;
gtk_tree_path_free(path);
if (row < 0 || !gcol) return FALSE;
wxDataViewColumn* wxcol = dv->GTKColumnToWX(gcol);
if (!wxcol) return FALSE;
AttrListStore* store = static_cast<AttrListStore*>(dv->GetModel());
auto it = store->cell_tip.find({(unsigned)row, wxcol->GetModelColumn()});
if (it == store->cell_tip.end() || it->second.IsEmpty()) return FALSE;
gtk_tooltip_set_text(tooltip, it->second.utf8_str());
return TRUE;
}
#endif
void* wxbr_dvlc(void* parent) {
// Multi-select (ctrl/shift-click) + row lines. Selection replaces the old
// checkbox column. A custom AttrListStore backs it so rows can be coloured by
@@ -487,10 +529,25 @@ void* wxbr_dvlc(void* parent) {
dv->Bind(wxEVT_DATAVIEW_COLUMN_REORDERED, [](wxDataViewEvent&) {
if (g_widget_event) g_widget_event(WxEV_DVLC_REORDERED, 0, 0);
});
// Rubber-band (click-drag) range selection: wxDataViewCtrl has none natively
// (only ctrl/shift-click), so track it here. LEFT_DOWN records the anchor row
// (and lets the native handler select it); dragging with the button down
// extends the selection to the row under the cursor.
// Rubber-band (click-drag) range selection. wxDataViewCtrl has none natively.
#ifdef __WXGTK__
// On GTK the control wraps a GtkTreeView, which supports native rubber-band
// selection -- just not enabled by wx. Enable it directly. (wx delivers no
// MOTION events during the native drag, so the mouse-event fallback below is
// inapplicable on GTK.)
{
GtkWidget* tv = dv->GtkGetTreeView();
if (tv) {
gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tv), TRUE);
// Per-cell hover tooltips (Errors column) via the native signal.
gtk_widget_set_has_tooltip(tv, TRUE);
g_signal_connect(tv, "query-tooltip", G_CALLBACK(dvlc_query_tooltip), dv);
}
}
#else
// Non-GTK fallback: track a drag anchor and extend the selection to the row
// under the cursor. LEFT_DOWN records the anchor (and lets the native handler
// select it); dragging with the button down selects the inclusive range.
dv->Bind(wxEVT_LEFT_DOWN, [](wxMouseEvent& e) {
wxDataViewCtrl* dv = (wxDataViewCtrl*)e.GetEventObject();
if (!dv) { e.Skip(); return; }
@@ -531,6 +588,7 @@ void* wxbr_dvlc(void* parent) {
if (dv) g_drag_anchor.erase(dv);
e.Skip();
});
#endif
// Row activation (double-click / Enter): report the row + column so the app
// can, e.g., open the miner's IP in a browser.
dv->Bind(wxEVT_DATAVIEW_ITEM_ACTIVATED, [](wxDataViewEvent& e) {
@@ -602,6 +660,18 @@ void wxbr_dvlc_clear(void* win) {
AttrListStore* store = dvlc_store(win);
store->DeleteAllItems();
store->row_fg.clear();
store->cell_tip.clear();
}
// Set (or clear, with an empty string) the hover tooltip for one cell,
// addressed by (row, model column). Used for the Errors column's full text.
void wxbr_dvlc_set_cell_tooltip(void* win, unsigned row, unsigned col, const char* text) {
AttrListStore* store = dvlc_store(win);
if (text && text[0]) {
store->cell_tip[{row, col}] = wxString::FromUTF8(text);
} else {
store->cell_tip.erase({row, col});
}
}
// Set (or clear, when r<0) a row's text colour; used to paint rows by status.
+8
View File
@@ -58,6 +58,7 @@ mod notsafe {
pub fn wxbr_dvlc_clear(win: *mut c_void);
pub fn wxbr_dvlc_row_count(win: *mut c_void) -> c_int;
pub fn wxbr_dvlc_set_cell(win: *mut c_void, row: usize, col: usize, value: *const c_char);
pub fn wxbr_dvlc_set_cell_tooltip(win: *mut c_void, row: usize, col: usize, text: *const c_char);
pub fn wxbr_dvlc_get_cell(win: *mut c_void, row: usize, col: usize, buf: *mut c_char, cap: c_int) -> c_int;
pub fn wxbr_dvlc_col_count(win: *mut c_void) -> c_int;
pub fn wxbr_dvlc_autosize_col(win: *mut c_void, pos: c_int);
@@ -482,6 +483,13 @@ impl Widget {
unsafe { notsafe::wxbr_dvlc_set_cell(self.0, row, col, c.as_ptr()) }
}
/// Set the hover tooltip for one cell (empty clears it). GTK only; a no-op
/// on other platforms until they gain per-cell tooltip support.
pub fn dvlc_set_cell_tooltip(&self, row: usize, col: usize, text: &str) {
let c = CString::new(text).unwrap_or_default();
unsafe { notsafe::wxbr_dvlc_set_cell_tooltip(self.0, row, col, c.as_ptr()) }
}
pub fn dvlc_get_cell(&self, row: usize, col: usize) -> Option<String> {
let mut buf = vec![0i8; 4096];
let n = unsafe {