gpui: Use local coordinates & add scale
property
#24699
Draft
+684
−257
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Redo of #24352 (I wanted to get all the bugs with local coordinates rendering before adding scaling).
This PR changes the coordinate space of elements in GPUI to use local coordinates instead of window coordinates, meaning that the origin is always zero and the size of the bounds are not effected by the scale of the element when placed in the window. Events are also put into this coordinate space by default, but elements which need to access the absolute coordinates can still do so via the
absolute_position
property of mouse events.There is still some work to do (see below), but the core is complete and Zed can be scaled at the root within rendering issues. This PR will not aim to make Zed fully scalable without issues (through if I find any, I will fix them), but it does aim to not break Zed in the transition to local coordinates.
Screenshot of Zed scaled at root
Screenshot of scaled terminal panel
Video of gpui `scale` example
Screencast.from.2025-02-12.22-42-48.webm
TODO:
request_layout
for each child. Scale is applied automatically to all other elements, but it cannot be propagated to children automatically.position
,window.mouse_position()
or has mouse interaction)bounds
parameter to element functions to beSize
instead ofBounds
, since the origin is always zero (should this be a separate PR? It touches a lot of files but also lets me check for bugs at each one)Release Notes: