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: Add support for slash pattern fills (///) #23576

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

Conversation

iamnbutler
Copy link
Member

@iamnbutler iamnbutler commented Jan 23, 2025

TODO:

  • Add BackgroundTag::PatternSlash
  • Support metal slash pattern fills
  • Support blade slash pattern fills

Adds support for a new background type in gpui, pattern_slash.

Usage:

div().size(px(56.0)).bg(pattern_slash(gpui::red()))

This will create a 56px square with a red slash pattern fill.

You can run the pattern example with cargo run -p gpui --example pattern:

CleanShot 2025-01-23 at 16 22 09@2x


After talking with @as-cii at length about how we want to support patterns in gpui, we decided for now we'll simply add a new BackgroundTag specific to this pattern.

It isn't the best long term plan however – we'll likely want to introduce the concept of a Fill at some point so we can have Fill::Solid, Fill::Gradient(LinearGradient), etc in the future.

The pattern is designed to seamlessly tile vertically for elements of the same height. For example, for use in editor line backgrounds:

CleanShot 2025-01-23 at 16 27 41@2x


Release Notes:

(do we do gpui release notes?)

  • Adds support for slash pattern fills in gpui.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 23, 2025
@zed-industries-bot
Copy link

zed-industries-bot commented Jan 23, 2025

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against 8598bda

@iamnbutler
Copy link
Member Author

@jansol Mind taking a peek at this one? Any thoughts?

@iamnbutler
Copy link
Member Author

iamnbutler commented Jan 23, 2025

Took a stab at the blade version. While I was doing that I noticed at larger scales there is a bit of mismatch at larger scales:
CleanShot 2025-01-23 at 18 28 40@2x

@jansol
Copy link
Contributor

jansol commented Jan 24, 2025

Looks like the base pattern size does not take display scaling into account? Other than that nothing immediately caught my eye on a quick peek. This was a problem for squiggly underlines too and I can't remember rn if those were ever fixed?

Also it would be neat if it was possible to specify the on and off size of the pattern from app code in em or pt units.

@iamnbutler
Copy link
Member Author

@jansol Thanks for taking a look! Hmm... let me take a look at the display scaling thing.

Agreed. I want to expand patterns quite a bit more than this – at the very least I'd like to use them for dashes. I'll see what I can do then about adding some more control!

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.

3 participants