Inset ContextMenu headers (#9197)

This PR insets the headers within `ContextMenu`s to give them some more
breathing room.

#### Before

<img width="347" alt="Screenshot 2024-03-11 at 4 13 31 PM"
src="https://github.com/zed-industries/zed/assets/1486634/73a56d68-d40e-4396-b584-f443197b69d6">

#### After

<img width="354" alt="Screenshot 2024-03-11 at 4 12 43 PM"
src="https://github.com/zed-industries/zed/assets/1486634/44c12a07-0784-4c94-b194-245f5cf94b2b">

Release Notes:

- Added padding to headers in context menus.
This commit is contained in:
Marshall Bowers 2024-03-11 16:28:16 -04:00 committed by GitHub
parent 02dcdd0228
commit c0b1f74794
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 80 additions and 71 deletions

View file

@ -272,11 +272,12 @@ impl Render for ContextMenu {
}) })
.flex_none() .flex_none()
.child(List::new().children(self.items.iter_mut().enumerate().map( .child(List::new().children(self.items.iter_mut().enumerate().map(
|(ix, item)| match item { |(ix, item)| {
match item {
ContextMenuItem::Separator => ListSeparator.into_any_element(), ContextMenuItem::Separator => ListSeparator.into_any_element(),
ContextMenuItem::Header(header) => { ContextMenuItem::Header(header) => ListSubHeader::new(header.clone())
ListSubHeader::new(header.clone()).into_any_element() .inset(true)
} .into_any_element(),
ContextMenuItem::Entry { ContextMenuItem::Entry {
label, label,
handler, handler,
@ -317,7 +318,9 @@ impl Render for ContextMenu {
self.action_context self.action_context
.as_ref() .as_ref()
.map(|focus| { .map(|focus| {
KeyBinding::for_action_in(&**action, focus, cx) KeyBinding::for_action_in(
&**action, focus, cx,
)
}) })
.unwrap_or_else(|| { .unwrap_or_else(|| {
KeyBinding::for_action(&**action, cx) KeyBinding::for_action(&**action, cx)
@ -347,6 +350,7 @@ impl Render for ContextMenu {
.child(entry_render(cx)) .child(entry_render(cx))
.into_any_element() .into_any_element()
} }
}
}, },
))), ))),
) )

View file

@ -21,6 +21,11 @@ impl ListSubHeader {
self.start_slot = left_icon; self.start_slot = left_icon;
self self
} }
pub fn inset(mut self, inset: bool) -> Self {
self.inset = inset;
self
}
} }
impl RenderOnce for ListSubHeader { impl RenderOnce for ListSubHeader {