Render other tab icons in the start slot (#14683)

This PR reworks the rendering for tab icons to allow us to render all of
the tab icons—not just file icons—in the tab's start slot.

The `Item` trait now has a separate `tab_icon` method that can be used
to indicate what icon should be shown for the tab.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-07-17 16:59:41 -04:00 committed by GitHub
parent 2edf224599
commit 00c3c02f7d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 80 additions and 80 deletions

View file

@ -452,27 +452,22 @@ impl EventEmitter<PreviewEvent> for MarkdownPreviewView {}
impl Item for MarkdownPreviewView {
type Event = PreviewEvent;
fn tab_icon(&self, _cx: &WindowContext) -> Option<Icon> {
Some(Icon::new(IconName::FileDoc))
}
fn tab_content(&self, params: TabContentParams, _cx: &WindowContext) -> AnyElement {
h_flex()
.gap_2()
.child(Icon::new(IconName::FileDoc).color(if params.selected {
Color::Default
} else {
Color::Muted
}))
.child(
Label::new(if let Some(description) = &self.tab_description {
description.clone().into()
} else {
self.fallback_tab_description.clone()
})
.color(if params.selected {
Color::Default
} else {
Color::Muted
}),
)
.into_any()
Label::new(if let Some(description) = &self.tab_description {
description.clone().into()
} else {
self.fallback_tab_description.clone()
})
.color(if params.selected {
Color::Default
} else {
Color::Muted
})
.into_any_element()
}
fn telemetry_event_text(&self) -> Option<&'static str> {