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

Add external span IDs #230

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nicoburns
Copy link
Contributor

@nicoburns nicoburns commented Dec 16, 2024

This associated a user-specified ID with each style span in a TreeBuilder, which can then be retrieved from a Cluster after layout (and notably from a Cluster created using Cluster::from_point).

This enables hit-testing of inline spans (for click and hover behaviour).

The current behaviour of Cluster::from_point isn't ideal for this application: it will try to find the "nearest" cluster even if the cursor isn't exactly above one (which makes sense for placing a caret but not for hover/click). But it's "good enough" for now, and I think we can add a new function for that in a followup.

Rendered using Parley + Blitz:

Screen.Recording.2024-12-17.at.07.51.41.mov

Signed-off-by: Nico Burns <[email protected]>
@nicoburns nicoburns requested review from dfrg and xorgy December 16, 2024 18:59
@DJMcNab
Copy link
Member

DJMcNab commented Dec 17, 2024

Hmm. The way I solved a very similar problem in Masonry, which worked quite well, was to just make the Brush parameter contain the style id. You would then do a look-up from the style id to your painting property, and whatever other metadata you need (so for hover in this case)

My understanding is that something like this would be a future plan, but likely as part of the much more significant refactor discussed here.

@nicoburns
Copy link
Contributor Author

Hmm. The way I solved a very similar problem in Masonry, which worked quite well, was to just make the Brush parameter contain the style id. You would then do a look-up from the style id to your painting property, and whatever other metadata you need (so for hover in this case)

My understanding is that something like this would be a future plan, but likely as part of the much more significant refactor discussed here.

Definitely looking forward to the refactor, but we I don't want to wait on it as my understanding is that it is likely to come as part of the switch to using harfruzz for shaping which is likely several months off at this point. In the meantime, we can improve the current API (and evolve it closer towards the new design in the process)

IMO it's a bit neater if it's separate as conceptually an ID is not a "style", but I suppose putting it in Brush would work (and then I guess you can use () for Brush until we remove it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants