terminal view: Use tooltip element for the tab tooltip (#44169)
Just recently realized we don't need this custom component for it given we now have `Tooltip::element`. UI result is exactly the same; nothing changes. Release Notes: - N/A
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
use gpui::{IntoElement, Render};
|
||||
use ui::{Divider, prelude::*, tooltip_container};
|
||||
|
||||
pub struct TerminalTooltip {
|
||||
title: SharedString,
|
||||
pid: u32,
|
||||
}
|
||||
|
||||
impl TerminalTooltip {
|
||||
pub fn new(title: impl Into<SharedString>, pid: u32) -> Self {
|
||||
Self {
|
||||
title: title.into(),
|
||||
pid,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Render for TerminalTooltip {
|
||||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
tooltip_container(cx, move |this, _cx| {
|
||||
this.occlude()
|
||||
.on_mouse_move(|_, _window, cx| cx.stop_propagation())
|
||||
.child(
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.child(Label::new(self.title.clone()))
|
||||
.child(Divider::horizontal())
|
||||
.child(
|
||||
Label::new(format!("Process ID (PID): {}", self.pid))
|
||||
.color(Color::Muted)
|
||||
.size(LabelSize::Small),
|
||||
),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ pub mod terminal_panel;
|
||||
mod terminal_path_like_target;
|
||||
pub mod terminal_scrollbar;
|
||||
mod terminal_slash_command;
|
||||
pub mod terminal_tab_tooltip;
|
||||
|
||||
use assistant_slash_command::SlashCommandRegistry;
|
||||
use editor::{EditorSettings, actions::SelectAll, blink_manager::BlinkManager};
|
||||
@@ -32,9 +31,8 @@ use terminal_panel::TerminalPanel;
|
||||
use terminal_path_like_target::{hover_path_like_target, open_path_like_target};
|
||||
use terminal_scrollbar::TerminalScrollHandle;
|
||||
use terminal_slash_command::TerminalSlashCommand;
|
||||
use terminal_tab_tooltip::TerminalTooltip;
|
||||
use ui::{
|
||||
ContextMenu, Icon, IconName, Label, ScrollAxes, Scrollbars, Tooltip, WithScrollbar, h_flex,
|
||||
ContextMenu, Divider, ScrollAxes, Scrollbars, Tooltip, WithScrollbar,
|
||||
prelude::*,
|
||||
scrollbars::{self, GlobalSetting, ScrollbarVisibility},
|
||||
};
|
||||
@@ -1140,14 +1138,24 @@ impl Item for TerminalView {
|
||||
type Event = ItemEvent;
|
||||
|
||||
fn tab_tooltip_content(&self, cx: &App) -> Option<TabTooltipContent> {
|
||||
let terminal = self.terminal().read(cx);
|
||||
let title = terminal.title(false);
|
||||
let pid = terminal.pid_getter()?.fallback_pid();
|
||||
Some(TabTooltipContent::Custom(Box::new(Tooltip::element({
|
||||
let terminal = self.terminal().read(cx);
|
||||
let title = terminal.title(false);
|
||||
let pid = terminal.pid_getter()?.fallback_pid();
|
||||
|
||||
Some(TabTooltipContent::Custom(Box::new(move |_window, cx| {
|
||||
cx.new(|_| TerminalTooltip::new(title.clone(), pid.as_u32()))
|
||||
.into()
|
||||
})))
|
||||
move |_, _| {
|
||||
v_flex()
|
||||
.gap_1()
|
||||
.child(Label::new(title.clone()))
|
||||
.child(h_flex().flex_grow().child(Divider::horizontal()))
|
||||
.child(
|
||||
Label::new(format!("Process ID (PID): {}", pid))
|
||||
.color(Color::Muted)
|
||||
.size(LabelSize::Small),
|
||||
)
|
||||
.into_any_element()
|
||||
}
|
||||
}))))
|
||||
}
|
||||
|
||||
fn tab_content(&self, params: TabContentParams, _window: &Window, cx: &App) -> AnyElement {
|
||||
|
||||
Reference in New Issue
Block a user