pane: Add ability to use custom tooltip content (#22879)
This PR is an alternate version of https://github.com/zed-industries/zed/pull/22850, but now using a similar approach to the existing `tab_content` and `tab_content_text`, where `tab_tooltip_content` refers to the existing `tab_tooltip_text` if there's no custom tooltip content/trait defined, meaning it will simplify render the text/string content in this case. This is all motivated by https://github.com/zed-industries/zed/pull/21955, as we want to pull off the ability to add custom content to a terminal tab tooltip. Release Notes: - N/A
This commit is contained in:
parent
e64a56ffad
commit
5c239be757
2 changed files with 40 additions and 14 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::{
|
||||
item::{
|
||||
ActivateOnClose, ClosePosition, Item, ItemHandle, ItemSettings, PreviewTabsSettings,
|
||||
ShowDiagnostics, TabContentParams, WeakItemHandle,
|
||||
ShowDiagnostics, TabContentParams, TabTooltipContent, WeakItemHandle,
|
||||
},
|
||||
move_item,
|
||||
notifications::NotifyResultExt,
|
||||
|
@ -2149,8 +2149,11 @@ impl Pane {
|
|||
this.drag_split_direction = None;
|
||||
this.handle_external_paths_drop(paths, cx)
|
||||
}))
|
||||
.when_some(item.tab_tooltip_text(cx), |tab, text| {
|
||||
tab.tooltip(move |cx| Tooltip::text(text.clone(), cx))
|
||||
.when_some(item.tab_tooltip_content(cx), |tab, content| match content {
|
||||
TabTooltipContent::Text(text) => {
|
||||
tab.tooltip(move |cx| Tooltip::text(text.clone(), cx))
|
||||
}
|
||||
TabTooltipContent::Custom(element_fn) => tab.tooltip(move |cx| element_fn(cx)),
|
||||
})
|
||||
.start_slot::<Indicator>(indicator)
|
||||
.map(|this| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue