Inline buttons

This commit is contained in:
Marshall Bowers
2023-12-20 17:31:36 -05:00
parent 8a8b498ee1
commit 2ac472e0e0
2 changed files with 20 additions and 31 deletions
+20 -12
View File
@@ -289,18 +289,26 @@ impl Render for BufferSearchBar {
.child(self.render_text_input(&self.replacement_editor, cx)),
)
.when(should_show_replace_input, |this| {
this.child(super::render_replace_button(
ReplaceNext,
ui::Icon::ReplaceNext,
"Replace next",
cx.listener(|this, _, cx| this.replace_next(&ReplaceNext, cx)),
))
.child(super::render_replace_button(
ReplaceAll,
ui::Icon::ReplaceAll,
"Replace all",
cx.listener(|this, _, cx| this.replace_all(&ReplaceAll, cx)),
))
this.child(
IconButton::new("search-replace-next", ui::Icon::ReplaceNext)
.tooltip(move |cx| {
Tooltip::for_action("Replace next", &ReplaceNext, cx)
})
.on_click(cx.listener(|this, _, cx| {
this.replace_next(&ReplaceNext, cx)
})),
)
.child(
IconButton::new("search-replace-all", ui::Icon::ReplaceAll)
.tooltip(move |cx| {
Tooltip::for_action("Replace all", &ReplaceAll, cx)
})
.on_click(
cx.listener(|this, _, cx| {
this.replace_all(&ReplaceAll, cx)
}),
),
)
})
}),
)
-19
View File
@@ -5,10 +5,6 @@ pub use mode::SearchMode;
use project::search::SearchQuery;
use ui::{prelude::*, Tooltip};
use ui::{ButtonStyle, Icon, IconButton};
//pub use project_search::{ProjectSearchBar, ProjectSearchView};
// use theme::components::{
// action_button::Button, svg::Svg, ComponentExt, IconButtonStyle, ToggleIconButtonStyle,
// };
pub mod buffer_search;
mod history;
@@ -121,18 +117,3 @@ fn toggle_replace_button(
.when(active, |button| button.style(ButtonStyle::Filled))
.tooltip(|cx| Tooltip::for_action("Toggle replace", &ToggleReplace, cx))
}
fn render_replace_button(
action: impl Action + 'static + Send + Sync,
icon: Icon,
tooltip: &'static str,
on_click: impl Fn(&gpui::ClickEvent, &mut WindowContext) + 'static,
) -> impl IntoElement {
let id: SharedString = format!("search-replace-{}", action.name()).into();
IconButton::new(id, icon)
.tooltip({
let action = action.boxed_clone();
move |cx| Tooltip::for_action(tooltip, &*action, cx)
})
.on_click(on_click)
}