Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Rename on/off states to active/inactive
Piotr Osiewicz0256f89dd66c
diff --git a/crates/collab_ui/src/collab_titlebar_item.rs b/crates/collab_ui/src/collab_titlebar_item.rsindex aa643f4416d..cf699d19889 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<Self>) {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.rsindex c0839249f25..0c8b27a1511 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.rsindex e9ab24f06e0..e140177c5c1 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::<MenuItem, ContextMenu>::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.rsindex a4ac8a5743d..dc592b75888 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.rsindex dbfad48e87c..fc17b57c6db 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.rsindex 1a059f5df78..c6a86b2f6a2 100644--- a/crates/search/src/buffer_search.rs+++ b/crates/search/src/buffer_search.rs@@ -375,7 +375,7 @@ impl BufferSearchBar {enum NavButton {}MouseEventHandler::<NavButton, _>::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.rsindex a379fa80e13..135194df6a2 100644--- a/crates/search/src/project_search.rs+++ b/crates/search/src/project_search.rs@@ -896,7 +896,7 @@ impl ProjectSearchBar {enum NavButton {}MouseEventHandler::<NavButton, _>::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.rsindex 812659078f1..7c4c8c1ce27 100644--- a/crates/theme/src/theme.rs+++ b/crates/theme/src/theme.rs@@ -812,40 +812,41 @@ pub struct Interactive<T> {#[derive(Clone, Copy, Debug, Default, Deserialize)]pub struct Toggleable<T> {- 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<T: std::borrow::Borrow<bool>> From<T> for ToggleState {fn from(item: T) -> Self {match *item.borrow() {- true => Self::On,- false => Self::Off,+ true => Self::Active,+ false => Self::Inactive,}}}impl<T> Toggleable<T> {- 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<ToggleState>) -> &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.rsindex 376fb85b21f..ec00ddece8f 100644--- a/crates/workspace/src/dock.rs+++ b/crates/workspace/src/dock.rs@@ -499,9 +499,9 @@ impl View for PanelButtons {.with_child(MouseEventHandler::<Self, _>::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.rsindex 59f39f1d935..d74e7f046ab 100644--- a/crates/workspace/src/toolbar.rs+++ b/crates/workspace/src/toolbar.rs@@ -231,9 +231,9 @@ fn nav_button<A: Action, F: 'static + Fn(&mut Toolbar, &mut ViewContext<Toolbar>) -> AnyElement<Toolbar> {MouseEventHandler::<A, _>::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)