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

Tracking Issue: UI Density #18078

Open
3 tasks
iamnbutler opened this issue Sep 19, 2024 · 7 comments
Open
3 tasks

Tracking Issue: UI Density #18078

iamnbutler opened this issue Sep 19, 2024 · 7 comments
Labels
help wanted Looking for help from the community ignore top-ranking issues [ignored label] tracking Issue that tracks a group of related issues

Comments

@iamnbutler
Copy link
Member

iamnbutler commented Sep 19, 2024

I've been hacking away on customizable UI density for Zed on the side for a while now – I wanted to open up a tracking issue to help get the feature over the line, and would love to hear from anyone that has discovered it so far!

It's considered an unstable feature as it is not complete (many UI elements do not support density yet), however it is still usable today via the "unstable.ui_density" setting.

TODO:

  • Title bar (height)
    • This one is a bit tricky because of the way the traffic lights are drawn on macOS.
  • Tab bar (height - comfortable)
  • Pickers
  • Add more below and I'll update here!

What to expect

For the moment, the development focus for density is to make the UI optionally more dense. However, there is a "comfortable" setting for folks that want to try a little less density.

Try it

If you would like to give it a try you can add the following to your settings:

High Density

// settings.json
{
  "unstable.ui_density": "compact",
}

Low Density

// settings.json
{
  "unstable.ui_density": "comfortable",
}

Useful feedback

  • What elements aren't responding to density yet?
  • Are there specific places the dynamic density feels off?
  • Do you prefer the denser UI?

Contributing

You can help bring dynamic density to places it is missing by opening a PR. Please link to this issue and mention me so we can keep track of all the contributions coming in.

There are two main ways to dynamically adjust spacing, both shown in this example:

impl RenderOnce for ListItem {
    fn render(self, cx: &mut WindowContext) -> impl IntoElement {
        //...
        h_flex()
            .id("inner_list_item")
            .w_full()
            .relative()
            // Static/hard-coded spacing
            .gap_1()
            // Dynamic spacing based on [Spacing]
            .px(Spacing::Medium.rems(cx)) 
            // Dynamic spacing using [ListItemSpacing]
            .map(|this| match self.spacing {
                ListItemSpacing::Dense => this,
                ListItemSpacing::Sparse => this.py_1(),
            })
        //...
    }
}

Typically converting a statically spaced element to one that responds to density means taking spacing that is static and converting it to dynamic.

However, not all spacing should be dynamic. Consider what the spacing controls, and test if it makes sense for it to change with density.

@iamnbutler iamnbutler added design [core label] help wanted Looking for help from the community tracking Issue that tracks a group of related issues ignore top-ranking issues [ignored label] labels Sep 19, 2024
iamnbutler added a commit that referenced this issue Sep 19, 2024
Tracking issue: #18078

Improve UI Density support for List.

UI density is an unstable feature. You can read more about it in the
above issue!

| Before Normal - Before Dense - After Normal - After Dense |
|--------------------------------------------------------|
| ![Group
8](https://github.com/user-attachments/assets/bb896fcf-e4a6-4776-9308-1405906d2dbe)
| | | |

| Before Normal - Before Dense - After Normal - After Dense |
|--------------------------------------------------------|
| ![Group
9](https://github.com/user-attachments/assets/00815a1b-071b-4d02-96bc-36bf37b5ae8b)
|

Release Notes:

- N/A
@versecafe
Copy link
Contributor

@iamnbutler I love how it works in nightly but I did notice that neither compact or comfortable match the current which sits between the two, would it make sense to have an in-between setting that matches the current UI spacing

Comfortable

image

Unset/Current Default

image

Compact

image

@iamnbutler
Copy link
Member Author

@versecafe Hey, thanks for trying this!

Help me understand your feedback – The default/unset setting is "default", which you can activate using "unstable.ui_density": "default":

CleanShot 2024-10-03 at 08 10 25@2x

@ruijdacd
Copy link

ruijdacd commented Oct 3, 2024

@iamnbutler just a quick round of personal feedback.

I've tried out all of the options and eventually went back to "default" as it's the one that gives the UI more room to breathe. I might try out "compact" as it was a really close second for me. "comfortable" to me felt the least Zed-like as it felt too spacious 🙃

Great work on Zed's design and build so far! My favorite product/app at the moment ❤️

@versecafe
Copy link
Contributor

@iamnbutler default actually works perfectly, when I was first testing this the only options that would register and pop up were compact and comfortable, but that was on the nightly build weeks ago, so no issue on my end anymore!

@iamnbutler
Copy link
Member Author

Great! Thanks. Appreciate the kind words :)

@Aaron-212
Copy link
Contributor

Good feature! But I suggest to increase the tab bar height if set to comfortable. The current tab bar height is still a little bit narrow.

image

@iamnbutler iamnbutler removed the design [core label] label Oct 15, 2024
noaccOS pushed a commit to noaccOS/zed that referenced this issue Oct 19, 2024
Tracking issue: zed-industries#18078

Improve UI Density support for List.

UI density is an unstable feature. You can read more about it in the
above issue!

| Before Normal - Before Dense - After Normal - After Dense |
|--------------------------------------------------------|
| ![Group
8](https://github.com/user-attachments/assets/bb896fcf-e4a6-4776-9308-1405906d2dbe)
| | | |

| Before Normal - Before Dense - After Normal - After Dense |
|--------------------------------------------------------|
| ![Group
9](https://github.com/user-attachments/assets/00815a1b-071b-4d02-96bc-36bf37b5ae8b)
|

Release Notes:

- N/A
iamnbutler added a commit that referenced this issue Nov 11, 2024
Density tracking issue: #18078 

This PR refactors our spacing system to use a more flexible and
maintainable approach. We've replaced the static `Spacing` enum with a
dynamically generated `DynamicSpacing` enum using a proc macro.

Enum variants now use a `BaseXX` format, where XX = the pixel value @
default rem size and the default UI density.

For example:

`CustomSpacing::Base16` would return 16px at the default UI scale &
density.

I'd love to find another name other than `Base` that is clear (to avoid
base_10, etc confusion), let me know if you have any ideas!

Changes:

- Introduced a new `derive_dynamic_spacing` proc macro to generate the
`DynamicSpacing` enum
- Updated all usages of `Spacing` to use the new `DynamicSpacing`
- Removed the `custom_spacing` function, mapping previous usages to
appropriate `DynamicSpacing` variants
- Improved documentation and type safety for spacing values

New usage example:

```rust
.child(
    div()
        .flex()
        .flex_none()
        .m(DynamicSpacing::Base04.px(cx))
        .size(DynamicSpacing::Base16.rems(cx))
        .children(icon),
)
```

vs old usage example:

```
.child(
    div()
        .flex()
        .flex_none()
        .m(Spacing::Small.px(cx))
        .size(custom_spacing(px(16.)))
        .children(icon),
)
```

Release Notes:

- N/A
SomeoneToIgnore pushed a commit that referenced this issue Nov 16, 2024
Tracking issue: #18078

Release Notes:

- Change tab bar height according to `ui-density`

---------

Signed-off-by: Aaron Ruan <[email protected]>
@SomeoneToIgnore
Copy link
Contributor

Note: #19076 is merged and made some improvements on this front.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Looking for help from the community ignore top-ranking issues [ignored label] tracking Issue that tracks a group of related issues
Projects
None yet
Development

No branches or pull requests

5 participants