Add a new button for the action
This commit is contained in:
parent
ccc78000bd
commit
b14cd5f56d
2 changed files with 33 additions and 0 deletions
|
@ -148,6 +148,7 @@ impl View for BufferSearchBar {
|
||||||
Flex::row()
|
Flex::row()
|
||||||
.with_child(self.render_nav_button("<", Direction::Prev, cx))
|
.with_child(self.render_nav_button("<", Direction::Prev, cx))
|
||||||
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
.with_child(self.render_nav_button(">", Direction::Next, cx))
|
||||||
|
.with_child(self.render_action_button("Select All", cx))
|
||||||
.aligned(),
|
.aligned(),
|
||||||
)
|
)
|
||||||
.with_child(
|
.with_child(
|
||||||
|
@ -403,6 +404,37 @@ impl BufferSearchBar {
|
||||||
.into_any()
|
.into_any()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn render_action_button(
|
||||||
|
&self,
|
||||||
|
icon: &'static str,
|
||||||
|
cx: &mut ViewContext<Self>,
|
||||||
|
) -> AnyElement<Self> {
|
||||||
|
let tooltip = "Select All Matches";
|
||||||
|
let tooltip_style = theme::current(cx).tooltip.clone();
|
||||||
|
let action_type_id = 0_usize;
|
||||||
|
|
||||||
|
enum ActionButton {}
|
||||||
|
MouseEventHandler::<ActionButton, _>::new(action_type_id, cx, |state, cx| {
|
||||||
|
let theme = theme::current(cx);
|
||||||
|
let style = theme.search.action_button.style_for(state);
|
||||||
|
Label::new(icon, style.text.clone())
|
||||||
|
.contained()
|
||||||
|
.with_style(style.container)
|
||||||
|
})
|
||||||
|
.on_click(MouseButton::Left, move |_, this, cx| {
|
||||||
|
this.select_all_matches(&SelectAllMatches, cx)
|
||||||
|
})
|
||||||
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
|
.with_tooltip::<ActionButton>(
|
||||||
|
action_type_id,
|
||||||
|
tooltip.to_string(),
|
||||||
|
Some(Box::new(SelectAllMatches)),
|
||||||
|
tooltip_style,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
.into_any()
|
||||||
|
}
|
||||||
|
|
||||||
fn render_close_button(
|
fn render_close_button(
|
||||||
&self,
|
&self,
|
||||||
theme: &theme::Search,
|
theme: &theme::Search,
|
||||||
|
|
|
@ -379,6 +379,7 @@ pub struct Search {
|
||||||
pub invalid_include_exclude_editor: ContainerStyle,
|
pub invalid_include_exclude_editor: ContainerStyle,
|
||||||
pub include_exclude_inputs: ContainedText,
|
pub include_exclude_inputs: ContainedText,
|
||||||
pub option_button: Toggleable<Interactive<ContainedText>>,
|
pub option_button: Toggleable<Interactive<ContainedText>>,
|
||||||
|
pub action_button: Interactive<ContainedText>,
|
||||||
pub match_background: Color,
|
pub match_background: Color,
|
||||||
pub match_index: ContainedText,
|
pub match_index: ContainedText,
|
||||||
pub results_status: TextStyle,
|
pub results_status: TextStyle,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue