Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gpui: Use local coordinates & add scale property #24699

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

someone13574
Copy link
Contributor

@someone13574 someone13574 commented Feb 11, 2025

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 from 2025-02-12 22-34-49

Screenshot of scaled terminal panel

Screenshot from 2025-02-12 22-40-37

Video of gpui `scale` example
Screencast.from.2025-02-12.22-42-48.webm

TODO:

  • Put file drop events into local coordinates
  • Make other Styled implementors react to the scale property
    • This only needs to be done for containers which call request_layout for each child. Scale is applied automatically to all other elements, but it cannot be propagated to children automatically.
  • Fix issue with window & pane resize edges
    • Window resize edges is an issue with the absolute child canvas having the incorrect element offset. Likely a cause of other issues too
  • Fix issue with file hover in project panel
  • Fix issue with markdown tooltip not showing
  • Fix failing tests (are test contexts broken with local coords?)
  • Go back through changes to main Zed code and account for scaling where local origin was accounted for
  • Bug-test Zed (particularly anything using position, window.mouse_position() or has mouse interaction)
  • Fix data-table example scroll bar
    • Horizontal editor scroll bar is broken as well.
  • Document changed and added functions
  • Check GPUI debugging tools for oversights
  • Change the bounds parameter to element functions to be Size instead of Bounds, 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:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant