burn_mode_tooltip.rs

 1use gpui::{Context, FontWeight, IntoElement, Render, Window};
 2use ui::{prelude::*, tooltip_container};
 3
 4pub struct BurnModeTooltip {
 5    selected: bool,
 6}
 7
 8impl BurnModeTooltip {
 9    pub fn new() -> Self {
10        Self { selected: false }
11    }
12
13    pub fn selected(mut self, selected: bool) -> Self {
14        self.selected = selected;
15        self
16    }
17}
18
19impl Render for BurnModeTooltip {
20    fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
21        let (icon, color) = if self.selected {
22            (IconName::ZedBurnModeOn, Color::Error)
23        } else {
24            (IconName::ZedBurnMode, Color::Default)
25        };
26
27        let turned_on = h_flex()
28            .h_4()
29            .px_1()
30            .border_1()
31            .border_color(cx.theme().colors().border)
32            .bg(cx.theme().colors().text_accent.opacity(0.1))
33            .rounded_sm()
34            .child(
35                Label::new("ON")
36                    .size(LabelSize::XSmall)
37                    .weight(FontWeight::SEMIBOLD)
38                    .color(Color::Accent),
39            );
40
41        let title = h_flex()
42            .gap_1p5()
43            .child(Icon::new(icon).size(IconSize::Small).color(color))
44            .child(Label::new("Burn Mode"))
45            .when(self.selected, |title| title.child(turned_on));
46
47        tooltip_container(window, cx, |this, _, _| {
48            this
49                .child(title)
50                .child(
51                    div()
52                        .max_w_64()
53                        .child(
54                            Label::new("Enables models to use large context windows, unlimited tool calls, and other capabilities for expanded reasoning.")
55                                .size(LabelSize::Small)
56                                .color(Color::Muted)
57                        )
58                )
59        })
60    }
61}