Rename IconElement
to just Icon
(#3974)
This PR renames the `IconElement` component to just `Icon`. This better matches the rest of our components, as `IconElement` was the only one using this naming convention. The `Icon` enum has been renamed to `IconName` to free up the name. I was trying to come up with a way that would allow rendering an `Icon::Zed` directly (and thus make the `IconElement` a hidden part of the API), but I couldn't come up with a way to do this cleanly. Release Notes: - N/A
This commit is contained in:
parent
29ed067b26
commit
fa53353c57
45 changed files with 364 additions and 360 deletions
|
@ -21,7 +21,7 @@ use settings::Settings;
|
|||
use std::{any::Any, sync::Arc};
|
||||
use theme::ThemeSettings;
|
||||
|
||||
use ui::{h_stack, prelude::*, Icon, IconButton, IconElement, ToggleButton, Tooltip};
|
||||
use ui::{h_stack, prelude::*, Icon, IconButton, IconName, ToggleButton, Tooltip};
|
||||
use util::ResultExt;
|
||||
use workspace::{
|
||||
item::ItemHandle,
|
||||
|
@ -225,7 +225,7 @@ impl Render for BufferSearchBar {
|
|||
.border_color(editor_border)
|
||||
.min_w(rems(384. / 16.))
|
||||
.rounded_lg()
|
||||
.child(IconElement::new(Icon::MagnifyingGlass))
|
||||
.child(Icon::new(IconName::MagnifyingGlass))
|
||||
.child(self.render_text_input(&self.query_editor, cx))
|
||||
.children(supported_options.case.then(|| {
|
||||
self.render_search_option_button(
|
||||
|
@ -287,7 +287,7 @@ impl Render for BufferSearchBar {
|
|||
this.child(
|
||||
IconButton::new(
|
||||
"buffer-search-bar-toggle-replace-button",
|
||||
Icon::Replace,
|
||||
IconName::Replace,
|
||||
)
|
||||
.style(ButtonStyle::Subtle)
|
||||
.when(self.replace_enabled, |button| {
|
||||
|
@ -323,7 +323,7 @@ impl Render for BufferSearchBar {
|
|||
)
|
||||
.when(should_show_replace_input, |this| {
|
||||
this.child(
|
||||
IconButton::new("search-replace-next", ui::Icon::ReplaceNext)
|
||||
IconButton::new("search-replace-next", ui::IconName::ReplaceNext)
|
||||
.tooltip(move |cx| {
|
||||
Tooltip::for_action("Replace next", &ReplaceNext, cx)
|
||||
})
|
||||
|
@ -332,7 +332,7 @@ impl Render for BufferSearchBar {
|
|||
})),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("search-replace-all", ui::Icon::ReplaceAll)
|
||||
IconButton::new("search-replace-all", ui::IconName::ReplaceAll)
|
||||
.tooltip(move |cx| {
|
||||
Tooltip::for_action("Replace all", &ReplaceAll, cx)
|
||||
})
|
||||
|
@ -350,7 +350,7 @@ impl Render for BufferSearchBar {
|
|||
.gap_0p5()
|
||||
.flex_none()
|
||||
.child(
|
||||
IconButton::new("select-all", ui::Icon::SelectAll)
|
||||
IconButton::new("select-all", ui::IconName::SelectAll)
|
||||
.on_click(|_, cx| cx.dispatch_action(SelectAllMatches.boxed_clone()))
|
||||
.tooltip(|cx| {
|
||||
Tooltip::for_action("Select all matches", &SelectAllMatches, cx)
|
||||
|
@ -358,13 +358,13 @@ impl Render for BufferSearchBar {
|
|||
)
|
||||
.children(match_count)
|
||||
.child(render_nav_button(
|
||||
ui::Icon::ChevronLeft,
|
||||
ui::IconName::ChevronLeft,
|
||||
self.active_match_index.is_some(),
|
||||
"Select previous match",
|
||||
&SelectPrevMatch,
|
||||
))
|
||||
.child(render_nav_button(
|
||||
ui::Icon::ChevronRight,
|
||||
ui::IconName::ChevronRight,
|
||||
self.active_match_index.is_some(),
|
||||
"Select next match",
|
||||
&SelectNextMatch,
|
||||
|
|
|
@ -38,7 +38,7 @@ use std::{
|
|||
use theme::ThemeSettings;
|
||||
|
||||
use ui::{
|
||||
h_stack, prelude::*, v_stack, Icon, IconButton, IconElement, Label, LabelCommon, LabelSize,
|
||||
h_stack, prelude::*, v_stack, Icon, IconButton, IconName, Label, LabelCommon, LabelSize,
|
||||
Selectable, ToggleButton, Tooltip,
|
||||
};
|
||||
use util::{paths::PathMatcher, ResultExt as _};
|
||||
|
@ -432,7 +432,7 @@ impl Item for ProjectSearchView {
|
|||
.unwrap_or_else(|| "Project search".into());
|
||||
h_stack()
|
||||
.gap_2()
|
||||
.child(IconElement::new(Icon::MagnifyingGlass).color(if selected {
|
||||
.child(Icon::new(IconName::MagnifyingGlass).color(if selected {
|
||||
Color::Default
|
||||
} else {
|
||||
Color::Muted
|
||||
|
@ -1616,12 +1616,12 @@ impl Render for ProjectSearchBar {
|
|||
.on_action(cx.listener(|this, action, cx| this.confirm(action, cx)))
|
||||
.on_action(cx.listener(|this, action, cx| this.previous_history_query(action, cx)))
|
||||
.on_action(cx.listener(|this, action, cx| this.next_history_query(action, cx)))
|
||||
.child(IconElement::new(Icon::MagnifyingGlass))
|
||||
.child(Icon::new(IconName::MagnifyingGlass))
|
||||
.child(self.render_text_input(&search.query_editor, cx))
|
||||
.child(
|
||||
h_stack()
|
||||
.child(
|
||||
IconButton::new("project-search-filter-button", Icon::Filter)
|
||||
IconButton::new("project-search-filter-button", IconName::Filter)
|
||||
.tooltip(|cx| {
|
||||
Tooltip::for_action("Toggle filters", &ToggleFilters, cx)
|
||||
})
|
||||
|
@ -1639,7 +1639,7 @@ impl Render for ProjectSearchBar {
|
|||
this.child(
|
||||
IconButton::new(
|
||||
"project-search-case-sensitive",
|
||||
Icon::CaseSensitive,
|
||||
IconName::CaseSensitive,
|
||||
)
|
||||
.tooltip(|cx| {
|
||||
Tooltip::for_action(
|
||||
|
@ -1659,7 +1659,7 @@ impl Render for ProjectSearchBar {
|
|||
)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("project-search-whole-word", Icon::WholeWord)
|
||||
IconButton::new("project-search-whole-word", IconName::WholeWord)
|
||||
.tooltip(|cx| {
|
||||
Tooltip::for_action(
|
||||
"Toggle whole word",
|
||||
|
@ -1738,7 +1738,7 @@ impl Render for ProjectSearchBar {
|
|||
}),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("project-search-toggle-replace", Icon::Replace)
|
||||
IconButton::new("project-search-toggle-replace", IconName::Replace)
|
||||
.on_click(cx.listener(|this, _, cx| {
|
||||
this.toggle_replace(&ToggleReplace, cx);
|
||||
}))
|
||||
|
@ -1755,7 +1755,7 @@ impl Render for ProjectSearchBar {
|
|||
.border_1()
|
||||
.border_color(cx.theme().colors().border)
|
||||
.rounded_lg()
|
||||
.child(IconElement::new(Icon::Replace).size(ui::IconSize::Small))
|
||||
.child(Icon::new(IconName::Replace).size(ui::IconSize::Small))
|
||||
.child(self.render_text_input(&search.replacement_editor, cx))
|
||||
} else {
|
||||
// Fill out the space if we don't have a replacement editor.
|
||||
|
@ -1764,7 +1764,7 @@ impl Render for ProjectSearchBar {
|
|||
let actions_column = h_stack()
|
||||
.when(search.replace_enabled, |this| {
|
||||
this.child(
|
||||
IconButton::new("project-search-replace-next", Icon::ReplaceNext)
|
||||
IconButton::new("project-search-replace-next", IconName::ReplaceNext)
|
||||
.on_click(cx.listener(|this, _, cx| {
|
||||
if let Some(search) = this.active_project_search.as_ref() {
|
||||
search.update(cx, |this, cx| {
|
||||
|
@ -1775,7 +1775,7 @@ impl Render for ProjectSearchBar {
|
|||
.tooltip(|cx| Tooltip::for_action("Replace next match", &ReplaceNext, cx)),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("project-search-replace-all", Icon::ReplaceAll)
|
||||
IconButton::new("project-search-replace-all", IconName::ReplaceAll)
|
||||
.on_click(cx.listener(|this, _, cx| {
|
||||
if let Some(search) = this.active_project_search.as_ref() {
|
||||
search.update(cx, |this, cx| {
|
||||
|
@ -1796,7 +1796,7 @@ impl Render for ProjectSearchBar {
|
|||
this
|
||||
})
|
||||
.child(
|
||||
IconButton::new("project-search-prev-match", Icon::ChevronLeft)
|
||||
IconButton::new("project-search-prev-match", IconName::ChevronLeft)
|
||||
.disabled(search.active_match_index.is_none())
|
||||
.on_click(cx.listener(|this, _, cx| {
|
||||
if let Some(search) = this.active_project_search.as_ref() {
|
||||
|
@ -1810,7 +1810,7 @@ impl Render for ProjectSearchBar {
|
|||
}),
|
||||
)
|
||||
.child(
|
||||
IconButton::new("project-search-next-match", Icon::ChevronRight)
|
||||
IconButton::new("project-search-next-match", IconName::ChevronRight)
|
||||
.disabled(search.active_match_index.is_none())
|
||||
.on_click(cx.listener(|this, _, cx| {
|
||||
if let Some(search) = this.active_project_search.as_ref() {
|
||||
|
|
|
@ -60,11 +60,11 @@ impl SearchOptions {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn icon(&self) -> ui::Icon {
|
||||
pub fn icon(&self) -> ui::IconName {
|
||||
match *self {
|
||||
SearchOptions::WHOLE_WORD => ui::Icon::WholeWord,
|
||||
SearchOptions::CASE_SENSITIVE => ui::Icon::CaseSensitive,
|
||||
SearchOptions::INCLUDE_IGNORED => ui::Icon::FileGit,
|
||||
SearchOptions::WHOLE_WORD => ui::IconName::WholeWord,
|
||||
SearchOptions::CASE_SENSITIVE => ui::IconName::CaseSensitive,
|
||||
SearchOptions::INCLUDE_IGNORED => ui::IconName::FileGit,
|
||||
_ => panic!("{:?} is not a named SearchOption", self),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use ui::IconButton;
|
|||
use ui::{prelude::*, Tooltip};
|
||||
|
||||
pub(super) fn render_nav_button(
|
||||
icon: ui::Icon,
|
||||
icon: ui::IconName,
|
||||
active: bool,
|
||||
tooltip: &'static str,
|
||||
action: &'static dyn Action,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue