search_status_button.rs

 1use editor::EditorSettings;
 2use settings::Settings as _;
 3use ui::{
 4    ButtonCommon, ButtonLike, Clickable, Color, Context, Icon, IconName, IconSize, ParentElement,
 5    Render, Styled, Tooltip, Window, h_flex,
 6};
 7use workspace::{ItemHandle, StatusItemView};
 8
 9pub struct SearchButton;
10
11impl SearchButton {
12    pub fn new() -> Self {
13        Self {}
14    }
15}
16
17impl Render for SearchButton {
18    fn render(&mut self, _window: &mut Window, cx: &mut Context<Self>) -> impl ui::IntoElement {
19        let button = h_flex().gap_2();
20        if !EditorSettings::get_global(cx).search.button {
21            return button;
22        }
23
24        button.child(
25            ButtonLike::new("project-search-indicator")
26                .child(
27                    Icon::new(IconName::MagnifyingGlass)
28                        .size(IconSize::Small)
29                        .color(Color::Default),
30                )
31                .tooltip(|window, cx| {
32                    Tooltip::for_action(
33                        "Project Search",
34                        &workspace::DeploySearch::default(),
35                        window,
36                        cx,
37                    )
38                })
39                .on_click(cx.listener(|_this, _, window, cx| {
40                    window.dispatch_action(Box::new(workspace::DeploySearch::default()), cx);
41                })),
42        )
43    }
44}
45
46impl StatusItemView for SearchButton {
47    fn set_active_pane_item(
48        &mut self,
49        _active_pane_item: Option<&dyn ItemHandle>,
50        _window: &mut Window,
51        _cx: &mut Context<Self>,
52    ) {
53    }
54}