1use gpui::{IntoElement, Render};
2use ui::{Divider, prelude::*, tooltip_container};
3
4pub struct TerminalTooltip {
5 title: SharedString,
6 pid: Option<u32>,
7}
8
9impl TerminalTooltip {
10 pub fn new(title: impl Into<SharedString>, pid: Option<u32>) -> Self {
11 Self {
12 title: title.into(),
13 pid,
14 }
15 }
16}
17
18impl Render for TerminalTooltip {
19 fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
20 tooltip_container(window, cx, move |this, _window, _cx| {
21 this.occlude()
22 .on_mouse_move(|_, _window, cx| cx.stop_propagation())
23 .child(
24 v_flex()
25 .gap_1()
26 .child(Label::new(self.title.clone()))
27 .child(Divider::horizontal())
28 .when_some(self.pid, |this, pid| {
29 this.child(
30 Label::new(format!("Process ID (PID): {}", pid))
31 .color(Color::Muted)
32 .size(LabelSize::Small),
33 )
34 }),
35 )
36 })
37 }
38}