feat: an open box zoom draws the frame the release will apply
The controller has always tracked its selection; nothing drew it, so a Ctrl or Shift drag framed a range with no feedback until the release. The preview is the area the release will change, not what the pointer swept: Ctrl frames the x range only, so a band across the plot is what it will zoom, where the sliver a straight horizontal drag sweeps is only the gesture. The plot carries the rect a host hands it -- it learns nothing about pointers -- and the renderer draws a low-alpha fill under a light border over everything else inside the axes.
This commit is contained in:
1 parent
1fc97d818f
commit
be1f31a04f
14 files changed
+276
-1
No files matched your search
@@ -751,6 +751,31 @@ void Controller::pan(const PointerEvent& e) {
|
||||
}
|
||||
}
|
||||
|
||||
Rect Controller::selection_preview() const noexcept {
|
||||
// Nothing to preview off a box zoom: the mask bits outlive the gesture -- `end_drag()` clears the
|
||||
// selection, not them -- so widening without this guard would hand out a full-band rect for a drag
|
||||
// that finished minutes ago.
|
||||
if (mode_ != DragMode::BoxZoom) return Rect{};
|
||||
// And nothing has been framed until the drag has swept every axis the release will apply: at the
|
||||
// press instant the selection is an empty rect at the pointer, and the *widened* form of that is a
|
||||
// band the width of the plot, which is a claim about a range that does not exist yet. Ctrl's other
|
||||
// axis is deliberately not required: a drag with no vertical movement at all is a band across the
|
||||
// plot, which is exactly what Ctrl is for.
|
||||
if ((box_zoom_x_ && !(selection_.w > 0.0f)) || (box_zoom_y_ && !(selection_.h > 0.0f))) return Rect{};
|
||||
Rect preview = selection_;
|
||||
if (box_zoom_x_ && box_zoom_y_) return preview;
|
||||
const Rect& axes = plot_->layout().axes;
|
||||
if (!box_zoom_x_) {
|
||||
preview.x = axes.x;
|
||||
preview.w = axes.w;
|
||||
}
|
||||
if (!box_zoom_y_) {
|
||||
preview.y = axes.y;
|
||||
preview.h = axes.h;
|
||||
}
|
||||
return preview;
|
||||
}
|
||||
|
||||
void Controller::box_zoom_update(const PointerEvent& e) {
|
||||
const f32 x = std::min(origin_x_, e.x);
|
||||
const f32 y = std::min(origin_y_, e.y);
|
||||
|
||||
Reference in new issue
Block a user