layout editor: column drag measures plot widths, not cell rects

This commit is contained in:
Martino Ferrari committed 2026-11-04 01:01:42 +01:00
1 parent 5f0bc75c27
commit b8177cc25a
3 files changed
+31 -7

No files matched your search

+13 -2
View File
@@ -4203,7 +4203,16 @@ gboolean split_probe_step(gpointer user) {
const double scale2 = (a->area != nullptr && a->area->device_scale() > 0.0f)
? static_cast<double>(a->area->device_scale()) : 1.0;
const int plot1 = rs.first_plot_of_row(0) + 1;
// The cells compared are *plot* widths (`axes.w` plus the right gutter, i.e. the cell rect without
// the y gutter that only the first cell has): the weights apply to those, so the divider follows the
// pointer only when the drag is measured the same way. The rect widths carry the gutter and are
// reported separately (`rect=`), they are not what is checked.
const auto width = [&](int cell) {
(void)rs.figure().layout(); // non-const: re-lays the figure and every plot out on the weights
const plot::PlotLayout& pl = rs.row(cell).plot->layout();
return static_cast<double>(pl.axes.w + pl.right_gutter) / scale2;
};
const auto rect_width = [&](int cell) {
return static_cast<double>(rs.figure().layout().cells[static_cast<std::size_t>(cell)].w) / scale2;
};
// One drag of `dx` logical px from the arrangement the figure is in now, then the widths read
@@ -4253,16 +4262,18 @@ gboolean split_probe_step(gpointer user) {
w0_max >= kMinCellPx - 1.0 && w1_max >= kMinCellPx - 1.0) ? 1 : 0;
const int ok = left_gt && left_grew && follows_80 && sum_80 && relative && right_floor &&
left_floor && sum_ext && both_above_min ? 1 : 0;
// What the rect carries over the plot: the first cell's y gutter (the second has none).
const double gutter0 = rect_width(0) - width(0);
// Leave the drag ended, as the gesture's end does.
a->layout_col_drag_plot = -1;
a->layout_col_drag_start.clear();
std::fprintf(stderr,
"[split-probe] col-drag ok=%d left_gt_right=%d follows_80=%d relative=%d "
"sum_80=%d right_floor=%d left_floor=%d sum_ext=%d both_above_min=%d "
"tile=%d d80=[%.1f,%.1f]->[%.1f,%.1f] ext=[%.1f,%.1f|%.1f,%.1f]\n",
"tile=%d d80=[%.1f,%.1f]->[%.1f,%.1f] ext=[%.1f,%.1f|%.1f,%.1f] gutter0=%.1f\n",
ok, left_gt, follows_80, relative, sum_80, right_floor, left_floor, sum_ext,
both_above_min, split_probe_tile(*a), d80.l0, d80.r0, d80.l, d80.r, w0_max,
w1_min, w0_min, w1_max);
w1_min, w0_min, w1_max, gutter0);
}
split_probe_next(*a);
break;