diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rs index aa643f4416..cf699d1988 100644 --- a/crates/collab_ui/src/collab_titlebar_item.rs +++ b/crates/collab_ui/src/collab_titlebar_item.rs @@ -299,7 +299,12 @@ impl CollabTitlebarItem { pub fn toggle_user_menu(&mut self, _: &ToggleUserMenu, cx: &mut ViewContext) { let theme = theme::current(cx).clone(); let avatar_style = theme.workspace.titlebar.leader_avatar.clone(); - let item_style = theme.context_menu.item.off_state().disabled_style().clone(); + let item_style = theme + .context_menu + .item + .inactive_state() + .disabled_style() + .clone(); self.user_menu.update(cx, |user_menu, cx| { let items = if let Some(user) = self.user_store.read(cx).current_user() { vec![ @@ -364,14 +369,14 @@ impl CollabTitlebarItem { .with_margin_left( titlebar .toggle_contacts_button - .off_state() + .inactive_state() .default .icon_width, ) .with_margin_top( titlebar .toggle_contacts_button - .off_state() + .inactive_state() .default .icon_width, ) diff --git a/crates/collab_ui/src/contact_list.rs b/crates/collab_ui/src/contact_list.rs index c0839249f2..0c8b27a151 100644 --- a/crates/collab_ui/src/contact_list.rs +++ b/crates/collab_ui/src/contact_list.rs @@ -798,7 +798,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.off_state().default; + let row = &theme.project_row.inactive_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); @@ -897,7 +897,7 @@ impl ContactList { .width .or(theme.contact_avatar.height) .unwrap_or(0.); - let row = &theme.project_row.off_state().default; + let row = &theme.project_row.inactive_state().default; let tree_branch = theme.tree_branch; let line_height = row.name.text.line_height(font_cache); let cap_height = row.name.text.cap_height(font_cache); diff --git a/crates/context_menu/src/context_menu.rs b/crates/context_menu/src/context_menu.rs index e9ab24f06e..e140177c5c 100644 --- a/crates/context_menu/src/context_menu.rs +++ b/crates/context_menu/src/context_menu.rs @@ -330,9 +330,9 @@ impl ContextMenu { match item { ContextMenuItem::Item { label, .. } => { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(&mut Default::default()); @@ -368,9 +368,9 @@ impl ContextMenu { match item { ContextMenuItem::Item { action, .. } => { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(&mut Default::default()); @@ -420,9 +420,9 @@ impl ContextMenu { let view_id = self.parent_view_id; MouseEventHandler::::new(ix, cx, |state, _| { let toggle_state = if Some(ix) == self.selected_index { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = style.item.in_state(toggle_state); let style = style.style_for(state); diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index a4ac8a5743..dc592b7588 100644 --- a/crates/project_panel/src/project_panel.rs +++ b/crates/project_panel/src/project_panel.rs @@ -1267,7 +1267,7 @@ impl ProjectPanel { .filter(|destination| details.path.starts_with(destination)) .is_some() { - style = entry_style.on_state().default.clone(); + style = entry_style.active_state().default.clone(); } let row_container_style = if show_editor { @@ -1409,8 +1409,10 @@ impl View for ProjectPanel { let context_menu_item_style = theme::current(cx).context_menu.item.clone(); move |state, cx| { let button_style = button_style.style_for(state).clone(); - let context_menu_item = - context_menu_item_style.on_state().style_for(state).clone(); + let context_menu_item = context_menu_item_style + .active_state() + .style_for(state) + .clone(); theme::ui::keystroke_label( "Open a project", diff --git a/crates/project_symbols/src/project_symbols.rs b/crates/project_symbols/src/project_symbols.rs index dbfad48e87..fc17b57c6d 100644 --- a/crates/project_symbols/src/project_symbols.rs +++ b/crates/project_symbols/src/project_symbols.rs @@ -229,7 +229,10 @@ impl PickerDelegate for ProjectSymbolsDelegate { .with_child( // Avoid styling the path differently when it is selected, since // the symbol's syntax highlighting doesn't change when selected. - Label::new(path.to_string(), style.off_state().default.label.clone()), + Label::new( + path.to_string(), + style.inactive_state().default.label.clone(), + ), ) .contained() .with_style(current_style.container) diff --git a/crates/search/src/buffer_search.rs b/crates/search/src/buffer_search.rs index 1a059f5df7..c6a86b2f6a 100644 --- a/crates/search/src/buffer_search.rs +++ b/crates/search/src/buffer_search.rs @@ -375,7 +375,7 @@ impl BufferSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.off_state().style_for(state); + let style = theme.search.option_button.inactive_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/search/src/project_search.rs b/crates/search/src/project_search.rs index a379fa80e1..135194df6a 100644 --- a/crates/search/src/project_search.rs +++ b/crates/search/src/project_search.rs @@ -896,7 +896,7 @@ impl ProjectSearchBar { enum NavButton {} MouseEventHandler::::new(direction as usize, cx, |state, cx| { let theme = theme::current(cx); - let style = theme.search.option_button.off_state().style_for(state); + let style = theme.search.option_button.inactive_state().style_for(state); Label::new(icon, style.text.clone()) .contained() .with_style(style.container) diff --git a/crates/theme/src/theme.rs b/crates/theme/src/theme.rs index 812659078f..7c4c8c1ce2 100644 --- a/crates/theme/src/theme.rs +++ b/crates/theme/src/theme.rs @@ -812,40 +812,41 @@ pub struct Interactive { #[derive(Clone, Copy, Debug, Default, Deserialize)] pub struct Toggleable { - on: T, - off: T, + active: T, + inactive: T, } -#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)] +#[derive(Copy, Clone, Debug, Default, Hash, PartialEq, Eq)] pub enum ToggleState { - Off, - On, + #[default] + Inactive, + Active, } impl> From for ToggleState { fn from(item: T) -> Self { match *item.borrow() { - true => Self::On, - false => Self::Off, + true => Self::Active, + false => Self::Inactive, } } } impl Toggleable { - pub fn new(on: T, off: T) -> Self { - Self { on, off } + pub fn new(active: T, inactive: T) -> Self { + Self { active, inactive } } pub fn in_state(&self, state: impl Into) -> &T { match state.into() { - ToggleState::Off => &self.off, - ToggleState::On => &self.on, + ToggleState::Inactive => &self.inactive, + ToggleState::Active => &self.active, } } - pub fn on_state(&self) -> &T { - self.in_state(ToggleState::On) + pub fn active_state(&self) -> &T { + self.in_state(ToggleState::Active) } - pub fn off_state(&self) -> &T { - self.in_state(ToggleState::Off) + pub fn inactive_state(&self) -> &T { + self.in_state(ToggleState::Inactive) } } diff --git a/crates/workspace/src/dock.rs b/crates/workspace/src/dock.rs index 376fb85b21..ec00ddece8 100644 --- a/crates/workspace/src/dock.rs +++ b/crates/workspace/src/dock.rs @@ -499,9 +499,9 @@ impl View for PanelButtons { .with_child( MouseEventHandler::::new(panel_ix, cx, |state, cx| { let toggle_state = if is_active { - ToggleState::On + ToggleState::Active } else { - ToggleState::Off + ToggleState::Inactive }; let style = button_style.in_state(toggle_state); diff --git a/crates/workspace/src/toolbar.rs b/crates/workspace/src/toolbar.rs index 59f39f1d93..d74e7f046a 100644 --- a/crates/workspace/src/toolbar.rs +++ b/crates/workspace/src/toolbar.rs @@ -231,9 +231,9 @@ fn nav_button ) -> AnyElement { MouseEventHandler::::new(0, cx, |state, _| { let style = if enabled { - style.off_state().style_for(state) + style.inactive_state().style_for(state) } else { - style.off_state().disabled_style() + style.inactive_state().disabled_style() }; Svg::new(svg_path) .with_color(style.color)