Skip to content

Rewrite 2D panning/zooming #2531

@emilk

Description

@emilk

Currently the panning and zooming of the 2D space views is handled by egui::ScrollArea. This has several down-sides, such as not being able to zoom out further than "full view".

We should instead allow any pan and zoom, treating it more similar to the 3D "eye".

This is the first step towards fixing a bunch of 2D issues:

To start with, it's good enough to support just panning and uniform scaling.
In the future we may want to support non-uniform scaling (including mirroring), as well as rotation.

Parameterizations

  • How do we represent this as components?
  • How do we control this from code?

One important case to consider is for the user to be able to set some 'view bounds' for the 2D spatial view.
This should act as some minimum bounds, that can grow in order to keep the aspect ratio of the actual space view, adding letterboxing to maintain a uniform axis scaling.
Again, when the space view is resized we should always see everything in the set view rectangle, but at little as possible outside.

This is similar to how egui_plot works.

So that implies that perhaps the entire 2D Eye is parameterized as a bounding-box in the space of the space-view.
Panning translates this bounding box, and zooming scales it. When rendering, this bounding box is fit to the frame of the space view.
Double-clicking resets the bounding-box to the one set via code (if it exists) or a tight bounding box of the contents (if it doesn't).

So I propose we use a component SpaceView2DBounds { rect: datatypes.Rect }.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestuiconcerns graphical user interface📺 re_vieweraffects re_viewer itself

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions