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