Make the wx-rs patch queue reproducible and checkable
The queue had drifted from the patched tree it describes: 0003 predated rounds 12-19 of bridge work, 0005 no longer applied on top of it, and the Cargo.toml note and the case-duplicate readme.md were in no patch at all. Vendor the pristine crates.io crate (sha256 pinned in VERSION) and add scripts/wx_rs_patches.py: 'check' rebuilds the tree from upstream + patches and requires an exact match, 'capture' records an edit as the next patch. 0002/0003 are regenerated to the current bridge files (0005's GTK tooltip fix is folded into 0003); 0005 now carries the packaging leftovers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,151 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""Keep thirdparty/wx-rs/patches/ an exact recipe for the patched wx-rs tree.
|
||||
|
||||
The patched crate (thirdparty/wx-rs/wx-rs-0.2.0-patched) is what cargo builds;
|
||||
the numbered patches are how a reviewer or an upstream bump reproduces it from
|
||||
the pristine crates.io tarball (thirdparty/wx-rs/upstream/, digest pinned in
|
||||
thirdparty/wx-rs/VERSION). The two drift apart whenever someone edits the tree
|
||||
and forgets the patch, so:
|
||||
|
||||
wx_rs_patches.py check
|
||||
Unpack the upstream crate, apply every patch in order (no fuzz), and
|
||||
require the result to equal the patched tree byte for byte. Offline; CI
|
||||
runs it on every bridge change.
|
||||
|
||||
wx_rs_patches.py capture NNNN-short-name "Subject line" [PATH ...]
|
||||
Write the difference between (upstream + current queue) and the patched
|
||||
tree as the next patch, optionally limited to PATHs, then re-check.
|
||||
Workflow: edit the patched tree, build/test, capture, commit both.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
WXRS = ROOT / "thirdparty/wx-rs"
|
||||
PATCHED = WXRS / "wx-rs-0.2.0-patched"
|
||||
PATCHES = WXRS / "patches"
|
||||
CRATE = WXRS / "upstream/wx-rs-0.2.0.crate"
|
||||
# Build products and the wx source download cache are never part of the recipe.
|
||||
IGNORED = {"target", "dist"}
|
||||
|
||||
|
||||
def pinned_digest() -> str:
|
||||
for line in (WXRS / "VERSION").read_text().splitlines():
|
||||
if line.startswith("sha256:"):
|
||||
return line.split()[1]
|
||||
sys.exit("thirdparty/wx-rs/VERSION has no sha256 line")
|
||||
|
||||
|
||||
def unpack_upstream(dest: Path) -> Path:
|
||||
data = CRATE.read_bytes()
|
||||
if hashlib.sha256(data).hexdigest() != pinned_digest():
|
||||
sys.exit(f"{CRATE.relative_to(ROOT)} does not match the pinned sha256")
|
||||
with tarfile.open(CRATE) as tar:
|
||||
tar.extractall(dest, filter="data")
|
||||
tree = dest / "wx-rs-0.2.0"
|
||||
if not tree.is_dir():
|
||||
sys.exit("upstream crate did not unpack to wx-rs-0.2.0/")
|
||||
return tree
|
||||
|
||||
|
||||
def patch_files() -> list:
|
||||
return sorted(PATCHES.glob("[0-9][0-9][0-9][0-9]-*.patch"))
|
||||
|
||||
|
||||
def apply_queue(tree: Path) -> None:
|
||||
for patch in patch_files():
|
||||
result = subprocess.run(
|
||||
["patch", "-p1", "-s", "-F0", "--no-backup-if-mismatch", "-i", str(patch)],
|
||||
cwd=tree, capture_output=True, text=True)
|
||||
if result.returncode != 0:
|
||||
sys.exit(f"{patch.name} does not apply cleanly:\n{result.stdout}{result.stderr}")
|
||||
|
||||
|
||||
def copy_patched(dest: Path) -> Path:
|
||||
tree = dest / "b"
|
||||
shutil.copytree(PATCHED, tree, ignore=lambda d, names: [
|
||||
n for n in names if Path(d) == PATCHED and n in IGNORED])
|
||||
return tree
|
||||
|
||||
|
||||
def unified_diff(work: Path, paths: list) -> str:
|
||||
"""diff -ruN a b, run from `work` so headers read a/<path> and b/<path>."""
|
||||
targets = [(f"a/{p}", f"b/{p}") for p in paths] if paths else [("a", "b")]
|
||||
out = []
|
||||
for left, right in targets:
|
||||
result = subprocess.run(["diff", "-ruN", left, right], cwd=work,
|
||||
capture_output=True, text=True)
|
||||
if result.returncode > 1:
|
||||
sys.exit(result.stderr)
|
||||
out.append(result.stdout)
|
||||
# Drop the mtimes diff appends to ---/+++ headers so a regenerated patch
|
||||
# only changes when its content does.
|
||||
return "".join(
|
||||
line.split("\t", 1)[0] + "\n" if line.startswith(("--- ", "+++ ")) else line
|
||||
for line in "".join(out).splitlines(keepends=True))
|
||||
|
||||
|
||||
def prepare(work: Path) -> None:
|
||||
unpack_upstream(work).rename(work / "a")
|
||||
apply_queue(work / "a")
|
||||
copy_patched(work)
|
||||
|
||||
|
||||
def check() -> int:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
work = Path(tmp)
|
||||
prepare(work)
|
||||
drift = unified_diff(work, [])
|
||||
if drift:
|
||||
print("wx-rs patch queue does not reproduce the patched tree;", file=sys.stderr)
|
||||
print("capture the change with scripts/wx_rs_patches.py capture:", file=sys.stderr)
|
||||
print(drift[:4000], file=sys.stderr)
|
||||
return 1
|
||||
print(f"wx-rs patch queue OK ({len(patch_files())} patches reproduce the tree)")
|
||||
return 0
|
||||
|
||||
|
||||
def capture(name: str, subject: str, paths: list) -> int:
|
||||
existing = patch_files()
|
||||
number = int(existing[-1].name[:4]) + 1 if existing else 1
|
||||
if not name[:4].isdigit():
|
||||
name = f"{number:04d}-{name}"
|
||||
target = PATCHES / (name if name.endswith(".patch") else name + ".patch")
|
||||
if target.exists():
|
||||
sys.exit(f"{target.name} already exists")
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
work = Path(tmp)
|
||||
prepare(work)
|
||||
body = unified_diff(work, paths)
|
||||
if not body:
|
||||
sys.exit("nothing to capture: the queue already reproduces the tree")
|
||||
target.write_text(f"Subject: [PATCH {target.name[:4]}] {subject}\n\n{body}")
|
||||
print(f"wrote {target.relative_to(ROOT)}")
|
||||
return check()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__,
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||
sub = parser.add_subparsers(dest="cmd", required=True)
|
||||
sub.add_parser("check")
|
||||
cap = sub.add_parser("capture")
|
||||
cap.add_argument("name")
|
||||
cap.add_argument("subject")
|
||||
cap.add_argument("paths", nargs="*")
|
||||
args = parser.parse_args()
|
||||
if args.cmd == "check":
|
||||
return check()
|
||||
return capture(args.name, args.subject, args.paths)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
+33
-7
@@ -1,3 +1,5 @@
|
||||
Subject: [PATCH 0002] widget/event bridge, Rust side
|
||||
|
||||
--- a/src/lib.rs
|
||||
+++ b/src/lib.rs
|
||||
@@ -3,3 +3,7 @@
|
||||
@@ -10,7 +12,7 @@
|
||||
+pub use widgets::*;
|
||||
--- a/src/widgets.rs
|
||||
+++ b/src/widgets.rs
|
||||
@@ -0,0 +1,911 @@
|
||||
@@ -0,0 +1,935 @@
|
||||
+// 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).
|
||||
@@ -20,6 +22,11 @@
|
||||
+use std::ffi::CString;
|
||||
+use std::os::raw::{c_char, c_int, c_long, c_void};
|
||||
+
|
||||
+/// Column alignment for `dvlc_append_text_col` / `dvlc_append_colored_col`.
|
||||
+pub const ALIGN_LEFT: i32 = 0;
|
||||
+pub const ALIGN_RIGHT: i32 = 1;
|
||||
+pub const ALIGN_CENTER: i32 = 2;
|
||||
+
|
||||
+mod notsafe {
|
||||
+ use std::os::raw::{c_char, c_int, c_long, c_void};
|
||||
+
|
||||
@@ -49,6 +56,7 @@
|
||||
+ pub fn wxbr_button(parent: *mut c_void, label: *const c_char, id: c_int) -> *mut c_void;
|
||||
+ pub fn wxbr_bind_click(win: *mut c_void, id: c_int);
|
||||
+ pub fn wxbr_text_ctrl(parent: *mut c_void, multiline: c_int) -> *mut c_void;
|
||||
+ pub fn wxbr_text_ctrl_password(parent: *mut c_void) -> *mut c_void;
|
||||
+ pub fn wxbr_text_ctrl_get(win: *mut c_void, buf: *mut c_char, cap: c_int) -> c_int;
|
||||
+ pub fn wxbr_text_ctrl_set(win: *mut c_void, value: *const c_char);
|
||||
+ pub fn wxbr_text_ctrl_write(win: *mut c_void, value: *const c_char);
|
||||
@@ -68,8 +76,8 @@
|
||||
+ pub fn wxbr_file_dialog(parent: *mut c_void, title: *const c_char, buf: *mut c_char, cap: c_int) -> c_int;
|
||||
+ pub fn wxbr_save_file_dialog(parent: *mut c_void, title: *const c_char, default_name: *const c_char, wildcard: *const c_char, buf: *mut c_char, cap: c_int) -> c_int;
|
||||
+ pub fn wxbr_dvlc(parent: *mut c_void) -> *mut c_void;
|
||||
+ pub fn wxbr_dvlc_append_text_col(win: *mut c_void, title: *const c_char, width: c_int, reorderable: c_int);
|
||||
+ pub fn wxbr_dvlc_append_colored_col(win: *mut c_void, title: *const c_char, width: c_int, reorderable: c_int) -> *mut c_void;
|
||||
+ pub fn wxbr_dvlc_append_text_col(win: *mut c_void, title: *const c_char, width: c_int, reorderable: c_int, align: c_int);
|
||||
+ pub fn wxbr_dvlc_append_colored_col(win: *mut c_void, title: *const c_char, width: c_int, reorderable: c_int, align: c_int) -> *mut c_void;
|
||||
+ pub fn wxbr_dvlc_append_toggle_col(win: *mut c_void, width: c_int);
|
||||
+ pub fn wxbr_dvlc_append_row(win: *mut c_void, nvals: c_int, vals: *const *const c_char);
|
||||
+ pub fn wxbr_dvlc_delete_row(win: *mut c_void, row: usize);
|
||||
@@ -81,6 +89,7 @@
|
||||
+ 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);
|
||||
+ pub fn wxbr_dvlc_autosize_col_capped(win: *mut c_void, pos: c_int, cap_px: c_int);
|
||||
+ pub fn wxbr_dvlc_set_col_title(win: *mut c_void, col: c_int, title: *const c_char);
|
||||
+ pub fn wxbr_dvlc_set_sort_indicator(win: *mut c_void, col: c_int, active: c_int, ascending: c_int);
|
||||
+ pub fn wxbr_dvlc_col_at_pos(win: *mut c_void, pos: c_int) -> c_int;
|
||||
@@ -450,6 +459,11 @@
|
||||
+ Widget(unsafe { notsafe::wxbr_text_ctrl(parent.0, multiline as c_int) })
|
||||
+ }
|
||||
+
|
||||
+ /// A single-line text control that masks its content (for password entry).
|
||||
+ pub fn password_ctrl(parent: Widget) -> Widget {
|
||||
+ Widget(unsafe { notsafe::wxbr_text_ctrl_password(parent.0) })
|
||||
+ }
|
||||
+
|
||||
+ pub fn get_value(&self) -> String {
|
||||
+ let mut buf = vec![0i8; 65536];
|
||||
+ let n = unsafe { notsafe::wxbr_text_ctrl_get(self.0, buf.as_mut_ptr(), buf.len() as c_int) };
|
||||
@@ -583,17 +597,23 @@
|
||||
+ Widget(unsafe { notsafe::wxbr_dvlc(parent.0) })
|
||||
+ }
|
||||
+
|
||||
+ pub fn dvlc_append_text_col(&self, title: &str, width: i32, reorderable: bool) {
|
||||
+ /// Append a text column. `align` is the cell + header alignment:
|
||||
+ /// [`ALIGN_LEFT`] (0), [`ALIGN_RIGHT`] (1) or [`ALIGN_CENTER`] (2).
|
||||
+ pub fn dvlc_append_text_col(&self, title: &str, width: i32, reorderable: bool, align: i32) {
|
||||
+ let c = CString::new(title).unwrap_or_default();
|
||||
+ unsafe { notsafe::wxbr_dvlc_append_text_col(self.0, c.as_ptr(), width, reorderable as c_int) }
|
||||
+ unsafe {
|
||||
+ notsafe::wxbr_dvlc_append_text_col(self.0, c.as_ptr(), width, reorderable as c_int, align)
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /// Like `dvlc_append_text_col`, but the column renders cell values through
|
||||
+ /// the SegmentRenderer, so a value built with `model::encode_segments` is
|
||||
+ /// drawn as coloured text runs (a plain string still renders normally).
|
||||
+ pub fn dvlc_append_colored_col(&self, title: &str, width: i32, reorderable: bool) {
|
||||
+ pub fn dvlc_append_colored_col(&self, title: &str, width: i32, reorderable: bool, align: i32) {
|
||||
+ let c = CString::new(title).unwrap_or_default();
|
||||
+ unsafe { notsafe::wxbr_dvlc_append_colored_col(self.0, c.as_ptr(), width, reorderable as c_int) };
|
||||
+ unsafe {
|
||||
+ notsafe::wxbr_dvlc_append_colored_col(self.0, c.as_ptr(), width, reorderable as c_int, align)
|
||||
+ };
|
||||
+ }
|
||||
+
|
||||
+ pub fn dvlc_append_toggle_col(&self, width: i32) {
|
||||
@@ -660,6 +680,12 @@
|
||||
+ unsafe { notsafe::wxbr_dvlc_autosize_col(self.0, pos as c_int) }
|
||||
+ }
|
||||
+
|
||||
+ /// Size the column at display position `pos` to its content, then clamp to
|
||||
+ /// `cap_px`: the width becomes min(cap, content-fit) (round 18 #10).
|
||||
+ pub fn dvlc_autosize_col_capped(&self, pos: usize, cap_px: i32) {
|
||||
+ unsafe { notsafe::wxbr_dvlc_autosize_col_capped(self.0, pos as c_int, cap_px) }
|
||||
+ }
|
||||
+
|
||||
+ /// Model column index shown at display position `pos` (after drag reorder).
|
||||
+ pub fn dvlc_col_at_pos(&self, pos: usize) -> Option<usize> {
|
||||
+ let v = unsafe { notsafe::wxbr_dvlc_col_at_pos(self.0, pos as c_int) };
|
||||
|
||||
+115
-17
@@ -1,6 +1,8 @@
|
||||
Subject: [PATCH 0003] widget/event bridge, C++ side
|
||||
|
||||
--- a/cpp_src/widgets_bridge.cpp
|
||||
+++ b/cpp_src/widgets_bridge.cpp
|
||||
@@ -0,0 +1,2053 @@
|
||||
@@ -0,0 +1,2149 @@
|
||||
+// 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).
|
||||
@@ -338,15 +340,32 @@
|
||||
+ if (h < 8) h = 8;
|
||||
+ int w = (sv->vbh > 0) ? (int)((double)h * sv->vbw / sv->vbh + 0.5) : h;
|
||||
+ if (w < 1) w = 1;
|
||||
+ const wxBitmap& bmp = ShapeBitmap(shape, *sv, colour, w, h);
|
||||
+ // The Font Awesome fan and brain glyphs fill their square box more than the
|
||||
+ // other health icons (chip/bolt), so at the shared size they read as oversized.
|
||||
+ // Draw them a bit smaller, centred in their full-size slot, so the slot advance
|
||||
+ // and the per-icon tooltip hit-test (both keyed to the full width) are
|
||||
+ // unchanged (round 17 R1; round 18 #1 brain).
|
||||
+ int dw = w, dh = h;
|
||||
+ double glyph_scale = (shape == SHAPE_FAN) ? 0.80 : (shape == SHAPE_BRAIN) ? 0.82 : 1.0;
|
||||
+ if (glyph_scale < 1.0) {
|
||||
+ dh = (int)(h * glyph_scale + 0.5);
|
||||
+ if (dh < 8) dh = 8;
|
||||
+ dw = (sv->vbh > 0) ? (int)((double)dh * sv->vbw / sv->vbh + 0.5) : dh;
|
||||
+ if (dw < 1) dw = 1;
|
||||
+ }
|
||||
+ const wxBitmap& bmp = ShapeBitmap(shape, *sv, colour, dw, dh);
|
||||
+ if (bmp.IsOk()) {
|
||||
+ if (health) {
|
||||
+ // Left-align and advance by less than the icon width so adjacent health
|
||||
+ // icons sit close together (the Font Awesome glyphs carry inner margin,
|
||||
+ // so a small bounding-box overlap does not visually collide).
|
||||
+ dc->DrawBitmap(bmp, x, cy - h / 2, true);
|
||||
+ int adv = w - 3;
|
||||
+ return adv < 1 ? 1 : adv;
|
||||
+ // UNIFORM fixed-width slot (round 19): every health icon (and the
|
||||
+ // alignment gap) advances by the same amount -- the square (h - 3) -- so
|
||||
+ // power/control/fan/board icons line up in fixed columns across rows
|
||||
+ // regardless of each glyph's aspect ratio (a narrow bolt or a shrunk fan
|
||||
+ // no longer shifts the icons after it). Each glyph is centred in its slot.
|
||||
+ // This matches SHAPE_GAP's advance and the per-icon tooltip hit-test.
|
||||
+ int adv = h - 3;
|
||||
+ if (adv < 1) adv = 1;
|
||||
+ dc->DrawBitmap(bmp, x + (adv - dw) / 2, cy - dh / 2, true);
|
||||
+ return adv;
|
||||
+ }
|
||||
+ int slot = (w > SHAPE_ADVANCE) ? w : SHAPE_ADVANCE;
|
||||
+ dc->DrawBitmap(bmp, x + (slot - w) / 2, cy - h / 2, true);
|
||||
@@ -441,7 +460,13 @@
|
||||
+ wxRect bg = cell;
|
||||
+ if (wxDataViewColumn* owner = const_cast<SegmentRenderer*>(this)->GetOwner()) {
|
||||
+ int cw = owner->GetWidth();
|
||||
+ if (cw > bg.width) bg.width = cw;
|
||||
+ // Extend BOTH directions by the column width. For a right-aligned column
|
||||
+ // (round 19 #21) wx anchors `cell` at the content's left edge (near the
|
||||
+ // column's right side), so extending only rightward left the column's left
|
||||
+ // portion unstriped; over-spanning both sides and letting the cell-DC clip
|
||||
+ // trim it fills the whole cell regardless of alignment (round 19 review M1).
|
||||
+ bg.x -= cw;
|
||||
+ bg.width += 2 * cw;
|
||||
+ }
|
||||
+ bg.y -= 40;
|
||||
+ bg.height += 80;
|
||||
@@ -524,7 +549,10 @@
|
||||
+ } else if (const ShapeSvg* sv = LookupShapeSvg(shape)) {
|
||||
+ int ww = (sv->vbh > 0) ? (int)((double)hh * sv->vbw / sv->vbh + 0.5) : hh;
|
||||
+ if (health) {
|
||||
+ adv = ww - 3;
|
||||
+ // UNIFORM fixed-width slot (round 19), matching DrawShape + the gap, so
|
||||
+ // every health icon lines up in fixed columns across rows regardless of
|
||||
+ // its glyph aspect. Width is measured square (hh - 3), not per-glyph.
|
||||
+ adv = hh - 3;
|
||||
+ if (adv < 1) adv = 1;
|
||||
+ } else if (ww > adv) {
|
||||
+ adv = ww;
|
||||
@@ -765,6 +793,13 @@
|
||||
+ wxDefaultPosition, wxSize(-1, -1), style);
|
||||
+}
|
||||
+
|
||||
+// A single-line text control that masks its content (wxTE_PASSWORD), for secret
|
||||
+// entry so a saved password is never rendered in the clear (round 18 #12).
|
||||
+void* wxbr_text_ctrl_password(void* parent) {
|
||||
+ return (void*)new wxTextCtrl((wxWindow*)parent, wxID_ANY, wxT(""),
|
||||
+ wxDefaultPosition, wxSize(-1, -1), wxTE_PASSWORD);
|
||||
+}
|
||||
+
|
||||
+int wxbr_text_ctrl_get(void* win, char* buf, int cap) {
|
||||
+ wxTextCtrl* t = (wxTextCtrl*)win;
|
||||
+ wxString v = t->GetValue();
|
||||
@@ -957,7 +992,10 @@
|
||||
+ GdkRectangle crect;
|
||||
+ gtk_tree_view_get_cell_area(GTK_TREE_VIEW(tv), path, gcol, &crect);
|
||||
+ gtk_tree_path_free(path);
|
||||
+ // Icon advance matches DrawShape's health-icon width (square icons: h - 3).
|
||||
+ // Icon advance must match DrawShape's now-UNIFORM health-icon slot, which is
|
||||
+ // (row height - 1, capped at 28*zoom) - 3 for every glyph and gap alike. The
|
||||
+ // earlier per-glyph advance (w-3) shifted the hit slots so tooltips landed on
|
||||
+ // the wrong icon (round 19 #2); with the uniform slot the hit-test lines up.
|
||||
+ int h = crect.height - 1;
|
||||
+ int cap = (int)(28 * g_table_zoom + 0.5);
|
||||
+ if (cap < 8) cap = 8;
|
||||
@@ -965,13 +1003,45 @@
|
||||
+ if (h < 8) h = 8;
|
||||
+ int adv = h - 3;
|
||||
+ if (adv < 1) adv = 1;
|
||||
+ int off = bx - crect.x;
|
||||
+ int n = (int)iit->second.size();
|
||||
+ // A right-aligned column (round 19 #21) draws the icon block flush to the
|
||||
+ // cell's right edge, so measure the pointer from the block's left, not the
|
||||
+ // cell's left.
|
||||
+ int block_left = crect.x;
|
||||
+ if (wxcol->GetAlignment() == wxALIGN_RIGHT) {
|
||||
+ int content_w = n * adv;
|
||||
+ if (content_w < crect.width) block_left = crect.x + (crect.width - content_w);
|
||||
+ }
|
||||
+ int off = bx - block_left;
|
||||
+ if (off < 0) off = 0;
|
||||
+ int slot = off / adv;
|
||||
+ if (slot < 0) slot = 0;
|
||||
+ if (slot >= (int)iit->second.size()) slot = (int)iit->second.size() - 1;
|
||||
+ if (slot >= n) slot = n - 1;
|
||||
+ const wxString& tip = iit->second[(size_t)slot];
|
||||
+ if (tip.IsEmpty()) return FALSE;
|
||||
+ // Scope the tooltip's "tip area" to just this icon's slot (round 18 #4a).
|
||||
+ // Without a tip area GTK defaults it to the whole widget, so it never re-queries
|
||||
+ // or moves the tooltip as the pointer crosses from one icon to the next -- the
|
||||
+ // old tooltip just stays put with stale text. Setting a per-slot area makes GTK
|
||||
+ // hide + re-show + reposition the tooltip for each icon.
|
||||
+ //
|
||||
+ // CRITICAL (round 19 #2, the reason the health tooltips never showed): the slot
|
||||
+ // geometry above (block_left, crect) is in BIN-WINDOW coordinates (what
|
||||
+ // gtk_tree_view_get_cell_area and get_path_at_pos use), but
|
||||
+ // gtk_tooltip_set_tip_area expects WIDGET coordinates. Feeding it bin-window
|
||||
+ // coords offsets the area upward by the header height, so it does not contain
|
||||
+ // the pointer -- and GTK then suppresses the tooltip entirely (it only shows a
|
||||
+ // tooltip whose tip area contains the cursor). The Errors column worked because
|
||||
+ // it sets no tip area. Convert the slot rect back to widget coordinates.
|
||||
+ gint area_wx = 0, area_wy = 0;
|
||||
+ gtk_tree_view_convert_bin_window_to_widget_coords(
|
||||
+ GTK_TREE_VIEW(tv), block_left + slot * adv, crect.y, &area_wx, &area_wy);
|
||||
+ GdkRectangle area;
|
||||
+ area.x = area_wx;
|
||||
+ area.y = area_wy;
|
||||
+ area.width = adv;
|
||||
+ area.height = crect.height;
|
||||
+ gtk_tooltip_set_tip_area(tooltip, &area);
|
||||
+ gtk_tooltip_set_text(tooltip, tip.utf8_str());
|
||||
+ return TRUE;
|
||||
+ }
|
||||
@@ -1097,14 +1167,23 @@
|
||||
+ return (void*)dv;
|
||||
+}
|
||||
+
|
||||
+void wxbr_dvlc_append_text_col(void* win, const char* title, int width, int reorderable) {
|
||||
+// Map the bridge alignment code (0 left, 1 right, 2 centre) to a wxAlignment.
|
||||
+static wxAlignment dvlc_wx_align(int align) {
|
||||
+ switch (align) {
|
||||
+ case 1: return wxALIGN_RIGHT;
|
||||
+ case 2: return wxALIGN_CENTER;
|
||||
+ default: return wxALIGN_NOT;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void wxbr_dvlc_append_text_col(void* win, const char* title, int width, int reorderable, int align) {
|
||||
+ wxDataViewCtrl* dv = (wxDataViewCtrl*)win;
|
||||
+ int flags = wxDATAVIEW_COL_RESIZABLE;
|
||||
+ if (reorderable) flags |= wxDATAVIEW_COL_REORDERABLE;
|
||||
+ unsigned col = dv->GetColumnCount(); // next model column index
|
||||
+ dvlc_store(win)->AppendColumn("string");
|
||||
+ dv->AppendTextColumn(wxString::FromUTF8(title), col, wxDATAVIEW_CELL_INERT,
|
||||
+ width, wxALIGN_NOT, flags);
|
||||
+ width, dvlc_wx_align(align), flags);
|
||||
+ // Record the 100% column width for the zoom (round 14 #3); the first column of
|
||||
+ // a (re)built table resets the list.
|
||||
+ if (col == 0) g_zoom_base_w.clear();
|
||||
@@ -1115,15 +1194,17 @@
|
||||
+// SegmentRenderer so its cell values can carry the '\x1f'/'\x1e' colour-run
|
||||
+// encoding produced by alkane_gui::model::encode_segments. An ordinary string
|
||||
+// with no encoding in it still renders fine (single default-coloured run).
|
||||
+void* wxbr_dvlc_append_colored_col(void* win, const char* title, int width, int reorderable) {
|
||||
+void* wxbr_dvlc_append_colored_col(void* win, const char* title, int width, int reorderable, int align) {
|
||||
+ wxDataViewCtrl* dv = (wxDataViewCtrl*)win;
|
||||
+ int flags = wxDATAVIEW_COL_RESIZABLE;
|
||||
+ if (reorderable) flags |= wxDATAVIEW_COL_REORDERABLE;
|
||||
+ unsigned col = dv->GetColumnCount(); // next model column index
|
||||
+ dvlc_store(win)->AppendColumn("string");
|
||||
+ SegmentRenderer* renderer = new SegmentRenderer();
|
||||
+ wxAlignment al = dvlc_wx_align(align);
|
||||
+ renderer->SetAlignment(al);
|
||||
+ wxDataViewColumn* c = new wxDataViewColumn(wxString::FromUTF8(title), renderer, col,
|
||||
+ width, wxALIGN_NOT, flags);
|
||||
+ width, al, flags);
|
||||
+ dv->AppendColumn(c);
|
||||
+ // Record the 100% column width for the zoom (round 14 #3).
|
||||
+ if (col == 0) g_zoom_base_w.clear();
|
||||
@@ -1269,6 +1350,23 @@
|
||||
+ if (c) c->SetWidth(wxCOL_WIDTH_AUTOSIZE);
|
||||
+}
|
||||
+
|
||||
+// Size a column to fit its content + header, then clamp to cap_px so the default
|
||||
+// width is min(reasonable cap, content-fit) -- a short column shrinks to its
|
||||
+// content, a long one is capped at the caller's sensible default (round 18 #10).
|
||||
+// A small floor keeps a column from collapsing to nothing.
|
||||
+void wxbr_dvlc_autosize_col_capped(void* win, int pos, int cap_px) {
|
||||
+ wxDataViewCtrl* dv = (wxDataViewCtrl*)win;
|
||||
+ if (pos < 0 || (unsigned)pos >= dv->GetColumnCount()) return;
|
||||
+ wxDataViewColumn* c = dv->GetColumn((unsigned)pos);
|
||||
+ if (!c) return;
|
||||
+ c->SetWidth(wxCOL_WIDTH_AUTOSIZE);
|
||||
+ int w = c->GetWidth();
|
||||
+ const int floor_px = 24;
|
||||
+ if (w < floor_px) w = floor_px;
|
||||
+ if (cap_px > 0 && w > cap_px) w = cap_px;
|
||||
+ c->SetWidth(w);
|
||||
+}
|
||||
+
|
||||
+// Update a column's header text in place (creation index) without recreating
|
||||
+// the control -- used to refresh the ASCII sort marker on a sort click.
|
||||
+void wxbr_dvlc_set_col_title(void* win, int col, const char* title) {
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
Subject: [PATCH 0005] health tooltips: convert tip area to widget coordinates
|
||||
|
||||
Round 19 #2 (the real fix). The GtkTreeView "query-tooltip" handler for the Health
|
||||
column set a per-icon tip area from gtk_tree_view_get_cell_area, whose rectangle is
|
||||
in BIN-WINDOW coordinates, but gtk_tooltip_set_tip_area expects WIDGET coordinates.
|
||||
The area was therefore offset upward by the column-header height, so it did not
|
||||
contain the pointer -- and GTK suppresses a tooltip whose tip area excludes the
|
||||
cursor. That is why the health icon tooltips never appeared, while the Errors column
|
||||
(which sets no tip area) worked. Convert the slot rectangle back to widget
|
||||
coordinates with gtk_tree_view_convert_bin_window_to_widget_coords before setting it.
|
||||
|
||||
diff --git a/cpp_src/widgets_bridge.cpp b/cpp_src/widgets_bridge.cpp
|
||||
index ba9f1c04..6d09ccb7 100644
|
||||
--- a/cpp_src/widgets_bridge.cpp
|
||||
+++ b/cpp_src/widgets_bridge.cpp
|
||||
@@ -1019,9 +1019,21 @@ static gboolean dvlc_query_tooltip(GtkWidget* tv, gint x, gint y, gboolean keybo
|
||||
// or moves the tooltip as the pointer crosses from one icon to the next -- the
|
||||
// old tooltip just stays put with stale text. Setting a per-slot area makes GTK
|
||||
// hide + re-show + reposition the tooltip for each icon.
|
||||
+ //
|
||||
+ // CRITICAL (round 19 #2, the reason the health tooltips never showed): the slot
|
||||
+ // geometry above (block_left, crect) is in BIN-WINDOW coordinates (what
|
||||
+ // gtk_tree_view_get_cell_area and get_path_at_pos use), but
|
||||
+ // gtk_tooltip_set_tip_area expects WIDGET coordinates. Feeding it bin-window
|
||||
+ // coords offsets the area upward by the header height, so it does not contain
|
||||
+ // the pointer -- and GTK then suppresses the tooltip entirely (it only shows a
|
||||
+ // tooltip whose tip area contains the cursor). The Errors column worked because
|
||||
+ // it sets no tip area. Convert the slot rect back to widget coordinates.
|
||||
+ gint area_wx = 0, area_wy = 0;
|
||||
+ gtk_tree_view_convert_bin_window_to_widget_coords(
|
||||
+ GTK_TREE_VIEW(tv), block_left + slot * adv, crect.y, &area_wx, &area_wy);
|
||||
GdkRectangle area;
|
||||
- area.x = block_left + slot * adv;
|
||||
- area.y = crect.y;
|
||||
+ area.x = area_wx;
|
||||
+ area.y = area_wy;
|
||||
area.width = adv;
|
||||
area.height = crect.height;
|
||||
gtk_tooltip_set_tip_area(tooltip, &area);
|
||||
@@ -0,0 +1,85 @@
|
||||
Subject: [PATCH 0005] packaging: document the build-only reqwest; drop the case-duplicate readme.md
|
||||
|
||||
diff -ruN a/Cargo.toml b/Cargo.toml
|
||||
--- a/Cargo.toml
|
||||
+++ b/Cargo.toml
|
||||
@@ -39,6 +39,11 @@
|
||||
[build-dependencies.embed-resource]
|
||||
version = "1.3"
|
||||
|
||||
+# reqwest is only used by build.rs to download the wxWidgets source on
|
||||
+# Windows/macOS; on Linux download_dist() returns before touching it, and it is
|
||||
+# never linked into the runtime binary. Kept at the vendored 0.11 (the build tree
|
||||
+# is fully vendored / offline); the h2 0.3 advisory it pulls is build-time only
|
||||
+# and is documented as accepted in audit.toml (RUSTSEC-2026-0258).
|
||||
[build-dependencies.reqwest]
|
||||
version = "0.11"
|
||||
features = ["blocking"]
|
||||
diff -ruN a/readme.md b/readme.md
|
||||
--- a/readme.md
|
||||
+++ b/readme.md
|
||||
@@ -1,64 +0,0 @@
|
||||
-# wx-rs
|
||||
-
|
||||
-[](https://crates.io/crates/wx-rs)
|
||||
-[](https://docs.rs/wx-rs)
|
||||
-
|
||||
-*This is an alpha release. Don't expect much from me.*
|
||||
-
|
||||
-**Only builds on the MSVC toolchain right now**
|
||||
-
|
||||
-An extremely partial set of bindings to wxWidgets, for Rust. The intent is that you can import this and all the bits of wxWidgets provided are statically linked in. Implements [`HasRawWindowHandle`](https://crates.io/crates/raw-window-handle). Callbacks are used for rendering and event handling. Features:
|
||||
-- Window initialization
|
||||
-- Keyboard, mouse events
|
||||
-- Clipboard support
|
||||
-- Native menus
|
||||
-- Cursor selection
|
||||
-
|
||||
-Some things that'd be great to have:
|
||||
-- The build script has only been tested on MSVC. Previously I've gotten this to compile on OSX and Windows with the GNU toolchain. There's no reason why this can't work on Linux as well.
|
||||
-- Icon support for Windows/Linux
|
||||
-
|
||||
-
|
||||
-## Building
|
||||
-The approach this crate takes is to download wxWidgets into the `./dist` directory, then build it. This means that you need to have a toolchain capable of compiling wxWidgets.
|
||||
-
|
||||
-Why are we doing this instead of using submodules? Because with submodules cargo would naturally check out files, but this isn't desirable since we want cargo to ignore these files when packaging (because wxWidgets is huge: The package, when you trim out all non-source files is still around 100MB).
|
||||
-
|
||||
-Why do we save/compile to `dist` rather than cargo's preferred `OUT_DIR`? Because with the latter, we'd have to recompile wxWidgets more frequently. Since it takes quite a while to do so, it's much nicer to only have to compile once and then have the artifact around forever.
|
||||
-
|
||||
-If you want to do a fresh install, just `rm -R ./dist`.
|
||||
-
|
||||
-# Building wxWidgets
|
||||
-
|
||||
-## Windows
|
||||
-
|
||||
-### Using the MSVC toolchain
|
||||
-
|
||||
-Make sure you're using ""x64 Native Tools Command Prompt for VS 2019"", and that cargo is in your path when compiling for the first time. After it's built, msys works fine to continue building things from the Rust side.
|
||||
-- https://stackoverflow.com/questions/11065421/command-prompt-wont-change-directory-to-another-drive
|
||||
-
|
||||
-### Using the GNU toolchain on Windows
|
||||
-This depends on nightly rust to build correctly
|
||||
-
|
||||
-#### Getting MSYS2
|
||||
-https://www.msys2.org/
|
||||
-
|
||||
-```
|
||||
-$ pacman -Syu
|
||||
-$ pacman -S mingw-w64-x86_64-gcc mingw-w64-x86_64-make mingw-w64-x86_64-libexpat mingw-w64-x86_64-zlib msys2-w32api-runtime pacman -S mingw-w64-x86_64-lld
|
||||
-```
|
||||
-
|
||||
-#### Building
|
||||
-This is a note of what needs to be integrated into the build script.
|
||||
-
|
||||
-In a MSYS2 MinGW64 terminal:
|
||||
-
|
||||
-```
|
||||
-$ cd dist/wxWidgets
|
||||
-$ mkdir msw64-release-build
|
||||
-$ ../configure --with-opengl --disable-shared
|
||||
-$ make -j20
|
||||
-```
|
||||
-
|
||||
-### Using the OSX toolchain
|
||||
-... why aren't I documented? :(
|
||||
BIN
Binary file not shown.
Reference in New Issue
Block a user