GUI round 8b.1: scroll-hold, zebra striping + vertical gridlines, default-colour text
Bridge + rendering rework (validated with a local wx-rs bridge compile + full cargo check; CI is the build oracle). - Scroll position hold (#2): the table no longer jumps to the top as new rows stream in during a scan. fill_rows captures the top visible row before the clear+refill and restores it after (new wx-rs bridge fns dvlc_get_top_row / dvlc_ensure_visible, wrapping wxDataViewCtrl::GetTopItem / EnsureVisible). - Default-colour text (#3b): rows are no longer tinted wholesale by status. Every cell is now the default text colour (black in light mode, white in dark -- the SegmentRenderer falls back to wxSYS_COLOUR_WINDOWTEXT for any run with no explicit colour), so IP addresses, slashes, expected/target values and all non-conditional cells read in the default colour. Only the conditionally- formatted columns carry colour: Hashrate/Boards/Chips actual (ratio scale), Chip temp (blue-red), fans (grey-blue), Access (red/green), Errors (red), and the Status column keeps its own status colour on its own cell. - Zebra striping (#8): odd rows get a subtle theme-aware background via the AttrListStore (a per-row BACKGROUND attr, so it does not disturb the default-foreground fallback and the native selection highlight still shows through). This replaces the status row-tint as the row separator. (The earlier abandoned attempt used SetAlternateRowColour / GTK CSS against the status foreground tint; removing that tint is what makes the background approach clean now.) - Vertical gridlines (#8): wxDV_VERT_RULES added to the table style (row lines were already on), so columns have borders. - KPI cards: wxWrapSizer now drops wxEXTEND_LAST_ON_EACH_LINE, so the last card on a line is no longer stretched -- the uniform-size KPI boxes stay uniform. wx-rs patches 0002/0003 regenerated and round-trip-validated against the source. cargo check --release --tests is clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y8h447BPyJR4fioYZvQ9bh
This commit is contained in:
+31
-17
@@ -82,6 +82,8 @@ struct Palette {
|
||||
amber: (u8, u8, u8),
|
||||
red: (u8, u8, u8),
|
||||
accent: (u8, u8, u8),
|
||||
/// Odd-row (zebra) background: a subtle tint of the window colour.
|
||||
zebra: (u8, u8, u8),
|
||||
}
|
||||
|
||||
fn luminance(c: (u8, u8, u8)) -> f32 {
|
||||
@@ -236,14 +238,6 @@ fn status_kind_color(pal: &Palette, status: &str) -> (u8, u8, u8) {
|
||||
}
|
||||
}
|
||||
|
||||
/// A miner row's text colour, by status: green = hashing, amber = slow, blue =
|
||||
/// paused, red = not hashing. This both conveys status and separates rows
|
||||
/// visually (GTK's native zebra/alt-row support is unreliable and fights
|
||||
/// selection).
|
||||
fn status_color(pal: &Palette, r: &MinerRow) -> (u8, u8, u8) {
|
||||
status_kind_color(pal, r.status())
|
||||
}
|
||||
|
||||
fn palette() -> Palette {
|
||||
let win = wx_rs::system_color(0); // window background
|
||||
let text = wx_rs::system_color(1); // window text
|
||||
@@ -258,6 +252,9 @@ fn palette() -> Palette {
|
||||
amber: if dark { (245, 190, 66) } else { (176, 120, 10) },
|
||||
red: if dark { (245, 110, 100) } else { (198, 55, 45) },
|
||||
accent: if dark { (108, 168, 250) } else { (40, 100, 170) },
|
||||
// Subtle zebra tint of the window: slightly lighter in dark mode, a
|
||||
// touch darker than the light window.
|
||||
zebra: if dark { nudge(win, 12) } else { nudge(win, -10) },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -550,6 +547,9 @@ impl App {
|
||||
t.destroy();
|
||||
}
|
||||
let t = Widget::dvlc(self.table_parent);
|
||||
// Zebra striping (theme-aware) for row separation now that rows are no
|
||||
// longer tinted by status.
|
||||
t.dvlc_set_zebra(Some(self.pal.zebra));
|
||||
// Creation order == display order. IP is the fixed first column (not
|
||||
// reorderable); the rest are reorderable. The active sort column carries
|
||||
// an ASCII direction marker in its header ("^" asc, "v" desc) -- wx's
|
||||
@@ -563,7 +563,7 @@ impl App {
|
||||
Some((sc, false)) if sc == c => title.push_str(" v"),
|
||||
_ => {}
|
||||
}
|
||||
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Error) {
|
||||
if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Error | Column::Status) {
|
||||
// These columns show two-tone / multi-tone text (actual vs.
|
||||
// expected, or one colour per fan) via a custom renderer that
|
||||
// parses the segment-encoded cell value fill_rows writes.
|
||||
@@ -583,6 +583,9 @@ impl App {
|
||||
|
||||
pub fn fill_rows(&mut self) {
|
||||
let Some(t) = self.table else { return };
|
||||
// Hold the scroll position across the full clear+refill so the table
|
||||
// doesn't jump back to the top as new rows stream in during a scan.
|
||||
let top = t.dvlc_get_top_row();
|
||||
t.dvlc_clear();
|
||||
self.view_idx = self.view.view(&self.rows);
|
||||
let cols = self.view.display_columns();
|
||||
@@ -592,13 +595,12 @@ impl App {
|
||||
let refs: Vec<&str> = cells.iter().map(|s| s.as_str()).collect();
|
||||
t.dvlc_append_row(&refs);
|
||||
}
|
||||
// Colour each row's text by status (also separates rows visually).
|
||||
for (disp, &ri) in self.view_idx.iter().enumerate() {
|
||||
t.dvlc_set_row_color(disp, Some(status_color(&self.pal, &self.rows[ri])));
|
||||
}
|
||||
// Overwrite the combined actual/expected + cooling-fan cells with
|
||||
// segment-encoded coloured text (the custom renderer these columns use
|
||||
// parses it back out; see encode_combined_cell/encode_cooling_cell).
|
||||
// Rows are NOT tinted by status any more: every cell is the default text
|
||||
// colour except the conditionally-formatted columns below (the Status
|
||||
// column carries the status colour itself). Zebra striping + gridlines
|
||||
// (set at table build) separate rows instead.
|
||||
// Overwrite the conditionally-coloured cells with segment-encoded text
|
||||
// (the custom renderer these columns use parses it back out).
|
||||
for (disp, &ri) in self.view_idx.iter().enumerate() {
|
||||
let r = &self.rows[ri];
|
||||
for (ci, c) in cols.iter().enumerate() {
|
||||
@@ -651,11 +653,19 @@ impl App {
|
||||
let color = (!r.errors.is_empty()).then_some(self.pal.red);
|
||||
encode_flag_cell(&c.cell(r), color)
|
||||
}
|
||||
Column::Status => {
|
||||
// Status keeps its status colour on its own cell (the
|
||||
// row is no longer tinted wholesale).
|
||||
encode_flag_cell(&c.cell(r), Some(status_kind_color(&self.pal, r.status())))
|
||||
}
|
||||
_ => continue,
|
||||
};
|
||||
t.dvlc_set_cell(disp, ci, &encoded);
|
||||
}
|
||||
}
|
||||
if let Some(row) = top {
|
||||
t.dvlc_ensure_visible(row.min(self.view_idx.len().saturating_sub(1)));
|
||||
}
|
||||
// Re-apply the selection (a refresh clears the control's selection).
|
||||
let sel: Vec<usize> = self
|
||||
.view_idx
|
||||
@@ -694,6 +704,9 @@ impl App {
|
||||
caption.set_fg(self.pal.label.0, self.pal.label.1, self.pal.label.2);
|
||||
}
|
||||
self.highlight_kpi_filter();
|
||||
if let Some(t) = self.table {
|
||||
t.dvlc_set_zebra(Some(self.pal.zebra));
|
||||
}
|
||||
self.fill_rows(); // re-colour rows with the new palette
|
||||
self.table_parent.layout();
|
||||
}
|
||||
@@ -2075,7 +2088,7 @@ impl App {
|
||||
for (j, c) in cols.iter().enumerate() {
|
||||
let want = c.cell(r);
|
||||
let raw = t.dvlc_get_cell(disp_row, j).unwrap_or_default();
|
||||
let got = if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Error) {
|
||||
let got = if matches!(c, Column::Hashrate | Column::Hashboards | Column::TotalChips | Column::ChipTemp | Column::Cooling | Column::Locked | Column::Error | Column::Status) {
|
||||
decode_segments_plain(&raw)
|
||||
} else {
|
||||
raw
|
||||
@@ -2212,6 +2225,7 @@ mod tests {
|
||||
amber: (255, 128, 0),
|
||||
red: (255, 0, 0),
|
||||
accent: (0, 0, 255),
|
||||
zebra: (245, 245, 245),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user