fix(examples): keep the glfw demo's region off the pan path, and print the multiplot's region geometry
Adding a grabbable region across the middle of the glfw demo turned the pan gesture PLOT_DEMO_FOLLOW makes -- and a user's own centre drag -- into a region drag, which that mode's self-check reported as 'distance behind only by the pan: NO' and exit 1. The region now rides the left sixth of the live window, so a press in the middle pans exactly as it always did, and the reason is written where the bounds are placed. The multiplot demo also prints its region's last-frame fill rect and bound columns, so the exit frame's region pixels can be read against the geometry Plot::layout() measured. Report: .superpowers/sdd/p2-task-7-report.md
This commit is contained in:
1 parent
942f88c568
commit
a70c381a1e
2 files changed
+17
-1
No files matched your search
@@ -580,7 +580,12 @@ int main() {
|
|||||||
} else {
|
} else {
|
||||||
graph.set_cursor_x(cursor_a, xr.min + 0.35 * xr.span());
|
graph.set_cursor_x(cursor_a, xr.min + 0.35 * xr.span());
|
||||||
graph.set_cursor_x(cursor_b, xr.min + 0.65 * xr.span());
|
graph.set_cursor_x(cursor_b, xr.min + 0.65 * xr.span());
|
||||||
graph.set_region(region, xr.min + 0.40 * xr.span(), xr.min + 0.60 * xr.span());
|
// The region sits on the left sixth of the window, not across its middle: it is a
|
||||||
|
// grabbable handle, so a region over the centre would turn the pan gesture the
|
||||||
|
// `PLOT_DEMO_FOLLOW` script makes (and the pan a user makes) into a region drag.
|
||||||
|
// The two cursors stay where they are -- neither is within a grab radius of the
|
||||||
|
// centre either, which is why the script's pan has always been a pan.
|
||||||
|
graph.set_region(region, xr.min + 0.06 * xr.span(), xr.min + 0.18 * xr.span());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -655,6 +655,17 @@ int main() {
|
|||||||
" %.4f, max %.4f, integral %.4f\n",
|
" %.4f, max %.4f, integral %.4f\n",
|
||||||
region, rs.x0, rs.x1, static_cast<unsigned long long>(rs.count), rs.mean, rs.rms,
|
region, rs.x0, rs.x1, static_cast<unsigned long long>(rs.count), rs.mean, rs.rms,
|
||||||
rs.min, rs.max, rs.integral);
|
rs.min, rs.max, rs.integral);
|
||||||
|
// The region's last-frame geometry on row 0, as the layout measured it: the rect the
|
||||||
|
// fill and the bound strokes are drawn in, which is also what the screenshot's region
|
||||||
|
// pixels are read against.
|
||||||
|
for (const plot::RegionLayout& rl : std::as_const(figure.plot(0)).layout().regions) {
|
||||||
|
if (rl.region != region) continue;
|
||||||
|
std::printf("[multiplot] region %u: fill x %.1f y %.1f w %.1f h %.1f, bounds at %.1f and"
|
||||||
|
" %.1f\n",
|
||||||
|
region, rl.fill.x, rl.fill.y, rl.fill.w, rl.fill.h,
|
||||||
|
static_cast<plot::f64>(plot::handle_column(rl.left_handle)),
|
||||||
|
static_cast<plot::f64>(plot::handle_column(rl.right_handle)));
|
||||||
|
}
|
||||||
std::printf("[multiplot] cursors a %.6f s, b %.6f s, dx %g s dy %g\n",
|
std::printf("[multiplot] cursors a %.6f s, b %.6f s, dx %g s dy %g\n",
|
||||||
figure.plot(0).cursor(cursor_a).x, figure.plot(0).cursor(cursor_b).x,
|
figure.plot(0).cursor(cursor_a).x, figure.plot(0).cursor(cursor_b).x,
|
||||||
figure.plot(0).measurement(measure).dx, figure.plot(0).measurement(measure).dy);
|
figure.plot(0).measurement(measure).dx, figure.plot(0).measurement(measure).dy);
|
||||||
|
|||||||
Reference in new issue
Block a user