layout editor: column drag measures plot widths, not cell rects
This commit is contained in:
1 parent
5f0bc75c27
commit
b8177cc25a
3 files changed
+31
-7
No files matched your search
+14
-2
@@ -753,6 +753,8 @@ void on_layout_drag_end(GtkGestureDrag*, double, double, gpointer user) {
|
||||
|
||||
// --- column (cell) resize drag -----------------------------------------------
|
||||
|
||||
// The two cells' widths here are *plot* widths (a cell's rect without the first cell's y gutter): the
|
||||
// 96 px floor and the plotter's 64 px floor both apply to them, and the weights share them out.
|
||||
void layout_col_apply(App& app, int plot, double offset_px) {
|
||||
RowSet& rs = *app.rows;
|
||||
const int fr = rs.figure_row_of(plot);
|
||||
@@ -792,8 +794,18 @@ bool layout_col_drag_begin(App& app, int plot) {
|
||||
const plot::FigureLayout& fl = app.rows->figure().layout();
|
||||
const double scale =
|
||||
app.area != nullptr && app.area->device_scale() > 0.0f ? app.area->device_scale() : 1.0;
|
||||
app.layout_col_drag_left0 = static_cast<double>(fl.cells[static_cast<std::size_t>(plot - 1)].w) / scale;
|
||||
app.layout_col_drag_right0 = static_cast<double>(fl.cells[static_cast<std::size_t>(plot)].w) / scale;
|
||||
// The weights share out *plot* widths, so the pair is measured as plots: a cell's rect minus the y
|
||||
// gutter (axis strip + title column) that only the first cell of a row has. The left cell of the pair
|
||||
// is the first one when `plot - 1` starts the row; the right cell never has a gutter, and neither does
|
||||
// a non-first left cell (its plot's strips read 0).
|
||||
const auto plot_width = [&](int cell) {
|
||||
const RowSet::Row& r = app.rows->row(cell);
|
||||
const double gutter =
|
||||
r.plot != nullptr ? double(r.plot->layout().y_axis_width + r.plot->layout().y_title_width) : 0.0;
|
||||
return std::max(0.0, double(fl.cells[static_cast<std::size_t>(cell)].w) - gutter);
|
||||
};
|
||||
app.layout_col_drag_left0 = plot_width(plot - 1) / scale;
|
||||
app.layout_col_drag_right0 = plot_width(plot) / scale;
|
||||
app.layout_col_drag_start = app.rows->cell_weights(fr);
|
||||
app.layout_col_drag_start.resize(static_cast<std::size_t>(app.rows->cells_in_row(fr)), 1.0f);
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user