Removed icons
This commit is contained in:
parent
96cc6d5ce5
commit
314c26e4ec
8 changed files with 55 additions and 89 deletions
|
@ -300,7 +300,7 @@
|
||||||
8
|
8
|
||||||
],
|
],
|
||||||
"cmd-b": "workspace::ToggleLeftSidebar",
|
"cmd-b": "workspace::ToggleLeftSidebar",
|
||||||
"cmd-shift-f": "project_search::Deploy",
|
"cmd-shift-f": "workspace::NewSearch",
|
||||||
"cmd-k cmd-t": "theme_selector::Toggle",
|
"cmd-k cmd-t": "theme_selector::Toggle",
|
||||||
"cmd-k cmd-s": "zed::OpenKeymap",
|
"cmd-k cmd-s": "zed::OpenKeymap",
|
||||||
"cmd-t": "project_symbols::Toggle",
|
"cmd-t": "project_symbols::Toggle",
|
||||||
|
|
|
@ -22,21 +22,20 @@ pub fn init(cx: &mut MutableAppContext) {
|
||||||
cx.add_action(ContextMenu::cancel);
|
cx.add_action(ContextMenu::cancel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
pub enum ContextMenuItem {
|
pub enum ContextMenuItem {
|
||||||
Item {
|
Item {
|
||||||
label: String,
|
label: String,
|
||||||
action: Box<dyn Action>,
|
action: Box<dyn Action>,
|
||||||
icon: Option<String>,
|
|
||||||
},
|
},
|
||||||
Separator,
|
Separator,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ContextMenuItem {
|
impl ContextMenuItem {
|
||||||
pub fn item(label: impl ToString, icon: Option<&str>, action: impl 'static + Action) -> Self {
|
pub fn item(label: impl ToString, action: impl 'static + Action) -> Self {
|
||||||
Self::Item {
|
Self::Item {
|
||||||
label: label.to_string(),
|
label: label.to_string(),
|
||||||
action: Box::new(action),
|
action: Box::new(action),
|
||||||
icon: icon.map(|item| item.to_string()),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -256,31 +255,15 @@ impl ContextMenu {
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_children(self.items.iter().enumerate().map(|(ix, item)| {
|
.with_children(self.items.iter().enumerate().map(|(ix, item)| {
|
||||||
match item {
|
match item {
|
||||||
ContextMenuItem::Item { label, icon, .. } => {
|
ContextMenuItem::Item { label, .. } => {
|
||||||
let style = style
|
let style = style
|
||||||
.item
|
.item
|
||||||
.style_for(Default::default(), Some(ix) == self.selected_index);
|
.style_for(Default::default(), Some(ix) == self.selected_index);
|
||||||
let mut line = Flex::row();
|
|
||||||
if let Some(_) = icon {
|
Label::new(label.to_string(), style.label.clone())
|
||||||
line.add_child(
|
.contained()
|
||||||
Empty::new()
|
.with_style(style.container)
|
||||||
.constrained()
|
.boxed()
|
||||||
.with_width(style.icon_width)
|
|
||||||
.boxed(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
line.add_child(
|
|
||||||
Label::new(label.to_string(), style.label.clone())
|
|
||||||
.contained()
|
|
||||||
.with_style(style.container)
|
|
||||||
.with_margin_left(if icon.is_some() {
|
|
||||||
style.icon_spacing
|
|
||||||
} else {
|
|
||||||
0.
|
|
||||||
})
|
|
||||||
.boxed(),
|
|
||||||
);
|
|
||||||
line.boxed()
|
|
||||||
}
|
}
|
||||||
ContextMenuItem::Separator => Empty::new()
|
ContextMenuItem::Separator => Empty::new()
|
||||||
.collapsed()
|
.collapsed()
|
||||||
|
@ -333,50 +316,30 @@ impl ContextMenu {
|
||||||
Flex::column()
|
Flex::column()
|
||||||
.with_children(self.items.iter().enumerate().map(|(ix, item)| {
|
.with_children(self.items.iter().enumerate().map(|(ix, item)| {
|
||||||
match item {
|
match item {
|
||||||
ContextMenuItem::Item {
|
ContextMenuItem::Item { label, action } => {
|
||||||
label,
|
|
||||||
action,
|
|
||||||
icon,
|
|
||||||
} => {
|
|
||||||
let action = action.boxed_clone();
|
let action = action.boxed_clone();
|
||||||
MouseEventHandler::new::<MenuItem, _, _>(ix, cx, |state, _| {
|
MouseEventHandler::new::<MenuItem, _, _>(ix, cx, |state, _| {
|
||||||
let style =
|
let style =
|
||||||
style.item.style_for(state, Some(ix) == self.selected_index);
|
style.item.style_for(state, Some(ix) == self.selected_index);
|
||||||
|
|
||||||
let mut line = Flex::row();
|
Flex::row()
|
||||||
if let Some(icon_file) = icon {
|
.with_child(
|
||||||
line.add_child(
|
Label::new(label.to_string(), style.label.clone())
|
||||||
Svg::new(format!("icons/{}", icon_file))
|
.contained()
|
||||||
.with_color(style.label.color)
|
|
||||||
.constrained()
|
|
||||||
.with_width(style.icon_width)
|
|
||||||
.aligned()
|
|
||||||
.boxed(),
|
.boxed(),
|
||||||
)
|
)
|
||||||
}
|
.with_child({
|
||||||
|
KeystrokeLabel::new(
|
||||||
line.with_child(
|
action.boxed_clone(),
|
||||||
Label::new(label.to_string(), style.label.clone())
|
style.keystroke.container,
|
||||||
.contained()
|
style.keystroke.text.clone(),
|
||||||
.with_margin_left(if icon.is_some() {
|
)
|
||||||
style.icon_spacing
|
.flex_float()
|
||||||
} else {
|
.boxed()
|
||||||
0.
|
})
|
||||||
})
|
.contained()
|
||||||
.boxed(),
|
.with_style(style.container)
|
||||||
)
|
|
||||||
.with_child({
|
|
||||||
KeystrokeLabel::new(
|
|
||||||
action.boxed_clone(),
|
|
||||||
style.keystroke.container,
|
|
||||||
style.keystroke.text.clone(),
|
|
||||||
)
|
|
||||||
.flex_float()
|
|
||||||
.boxed()
|
.boxed()
|
||||||
})
|
|
||||||
.contained()
|
|
||||||
.with_style(style.container)
|
|
||||||
.boxed()
|
|
||||||
})
|
})
|
||||||
.with_cursor_style(CursorStyle::PointingHand)
|
.with_cursor_style(CursorStyle::PointingHand)
|
||||||
.on_click(MouseButton::Left, move |_, cx| {
|
.on_click(MouseButton::Left, move |_, cx| {
|
||||||
|
|
|
@ -48,13 +48,12 @@ pub fn deploy_context_menu(
|
||||||
menu.show(
|
menu.show(
|
||||||
position,
|
position,
|
||||||
vec![
|
vec![
|
||||||
ContextMenuItem::item("Rename Symbol", None, Rename),
|
ContextMenuItem::item("Rename Symbol", Rename),
|
||||||
ContextMenuItem::item("Go To Definition", None, GoToDefinition),
|
ContextMenuItem::item("Go To Definition", GoToDefinition),
|
||||||
ContextMenuItem::item("Go To Type Definition", None, GoToTypeDefinition),
|
ContextMenuItem::item("Go To Type Definition", GoToTypeDefinition),
|
||||||
ContextMenuItem::item("Find All References", None, FindAllReferences),
|
ContextMenuItem::item("Find All References", FindAllReferences),
|
||||||
ContextMenuItem::item(
|
ContextMenuItem::item(
|
||||||
"Code Actions",
|
"Code Actions",
|
||||||
None,
|
|
||||||
ToggleCodeActions {
|
ToggleCodeActions {
|
||||||
deployed_from_indicator: false,
|
deployed_from_indicator: false,
|
||||||
},
|
},
|
||||||
|
|
|
@ -269,32 +269,30 @@ impl ProjectPanel {
|
||||||
if !project.is_remote() {
|
if !project.is_remote() {
|
||||||
menu_entries.push(ContextMenuItem::item(
|
menu_entries.push(ContextMenuItem::item(
|
||||||
"Add Folder to Project",
|
"Add Folder to Project",
|
||||||
None,
|
|
||||||
workspace::AddFolderToProject,
|
workspace::AddFolderToProject,
|
||||||
));
|
));
|
||||||
if is_root {
|
if is_root {
|
||||||
menu_entries.push(ContextMenuItem::item(
|
menu_entries.push(ContextMenuItem::item(
|
||||||
"Remove from Project",
|
"Remove from Project",
|
||||||
None,
|
|
||||||
workspace::RemoveWorktreeFromProject(worktree_id),
|
workspace::RemoveWorktreeFromProject(worktree_id),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
menu_entries.push(ContextMenuItem::item("New File", None, AddFile));
|
menu_entries.push(ContextMenuItem::item("New File", AddFile));
|
||||||
menu_entries.push(ContextMenuItem::item("New Folder", None, AddDirectory));
|
menu_entries.push(ContextMenuItem::item("New Folder", AddDirectory));
|
||||||
menu_entries.push(ContextMenuItem::Separator);
|
menu_entries.push(ContextMenuItem::Separator);
|
||||||
menu_entries.push(ContextMenuItem::item("Copy", None, Copy));
|
menu_entries.push(ContextMenuItem::item("Copy", Copy));
|
||||||
menu_entries.push(ContextMenuItem::item("Copy Path", None, CopyPath));
|
menu_entries.push(ContextMenuItem::item("Copy Path", CopyPath));
|
||||||
menu_entries.push(ContextMenuItem::item("Cut", None, Cut));
|
menu_entries.push(ContextMenuItem::item("Cut", Cut));
|
||||||
if let Some(clipboard_entry) = self.clipboard_entry {
|
if let Some(clipboard_entry) = self.clipboard_entry {
|
||||||
if clipboard_entry.worktree_id() == worktree.id() {
|
if clipboard_entry.worktree_id() == worktree.id() {
|
||||||
menu_entries.push(ContextMenuItem::item("Paste", None, Paste));
|
menu_entries.push(ContextMenuItem::item("Paste", Paste));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
menu_entries.push(ContextMenuItem::Separator);
|
menu_entries.push(ContextMenuItem::Separator);
|
||||||
menu_entries.push(ContextMenuItem::item("Rename", None, Rename));
|
menu_entries.push(ContextMenuItem::item("Rename", Rename));
|
||||||
if !is_root {
|
if !is_root {
|
||||||
menu_entries.push(ContextMenuItem::item("Delete", None, Delete));
|
menu_entries.push(ContextMenuItem::item("Delete", Delete));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ use workspace::{
|
||||||
Item, ItemHandle, ItemNavHistory, Pane, ToolbarItemLocation, ToolbarItemView, Workspace,
|
Item, ItemHandle, ItemNavHistory, Pane, ToolbarItemLocation, ToolbarItemView, Workspace,
|
||||||
};
|
};
|
||||||
|
|
||||||
actions!(project_search, [Deploy, SearchInNew, ToggleFocus]);
|
actions!(project_search, [SearchInNew, ToggleFocus]);
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ActiveSearches(HashMap<WeakModelHandle<Project>, WeakViewHandle<ProjectSearchView>>);
|
struct ActiveSearches(HashMap<WeakModelHandle<Project>, WeakViewHandle<ProjectSearchView>>);
|
||||||
|
@ -431,7 +431,11 @@ impl ProjectSearchView {
|
||||||
|
|
||||||
// Re-activate the most recently activated search or the most recent if it has been closed.
|
// Re-activate the most recently activated search or the most recent if it has been closed.
|
||||||
// If no search exists in the workspace, create a new one.
|
// If no search exists in the workspace, create a new one.
|
||||||
fn deploy(workspace: &mut Workspace, _: &Deploy, cx: &mut ViewContext<Workspace>) {
|
fn deploy(
|
||||||
|
workspace: &mut Workspace,
|
||||||
|
_: &workspace::NewSearch,
|
||||||
|
cx: &mut ViewContext<Workspace>,
|
||||||
|
) {
|
||||||
// Clean up entries for dropped projects
|
// Clean up entries for dropped projects
|
||||||
cx.update_global(|state: &mut ActiveSearches, cx| {
|
cx.update_global(|state: &mut ActiveSearches, cx| {
|
||||||
state.0.retain(|project, _| project.is_upgradable(cx))
|
state.0.retain(|project, _| project.is_upgradable(cx))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use super::{ItemHandle, SplitDirection};
|
use super::{ItemHandle, SplitDirection};
|
||||||
use crate::{toolbar::Toolbar, Item, NewFile, NewTerminal, WeakItemHandle, Workspace};
|
use crate::{toolbar::Toolbar, Item, NewFile, NewSearch, NewTerminal, WeakItemHandle, Workspace};
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use collections::{HashMap, HashSet, VecDeque};
|
use collections::{HashMap, HashSet, VecDeque};
|
||||||
use context_menu::{ContextMenu, ContextMenuItem};
|
use context_menu::{ContextMenu, ContextMenuItem};
|
||||||
|
@ -188,7 +188,7 @@ pub struct NavigationEntry {
|
||||||
impl Pane {
|
impl Pane {
|
||||||
pub fn new(cx: &mut ViewContext<Self>) -> Self {
|
pub fn new(cx: &mut ViewContext<Self>) -> Self {
|
||||||
let handle = cx.weak_handle();
|
let handle = cx.weak_handle();
|
||||||
let split_menu = cx.add_view(|cx| ContextMenu::new(cx));
|
let context_menu = cx.add_view(|cx| ContextMenu::new(cx));
|
||||||
Self {
|
Self {
|
||||||
items: Vec::new(),
|
items: Vec::new(),
|
||||||
is_active: true,
|
is_active: true,
|
||||||
|
@ -203,7 +203,7 @@ impl Pane {
|
||||||
pane: handle.clone(),
|
pane: handle.clone(),
|
||||||
})),
|
})),
|
||||||
toolbar: cx.add_view(|_| Toolbar::new(handle)),
|
toolbar: cx.add_view(|_| Toolbar::new(handle)),
|
||||||
context_menu: split_menu,
|
context_menu,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -841,10 +841,10 @@ impl Pane {
|
||||||
menu.show(
|
menu.show(
|
||||||
action.position,
|
action.position,
|
||||||
vec![
|
vec![
|
||||||
ContextMenuItem::item("Split Right", None, SplitRight),
|
ContextMenuItem::item("Split Right", SplitRight),
|
||||||
ContextMenuItem::item("Split Left", None, SplitLeft),
|
ContextMenuItem::item("Split Left", SplitLeft),
|
||||||
ContextMenuItem::item("Split Up", None, SplitUp),
|
ContextMenuItem::item("Split Up", SplitUp),
|
||||||
ContextMenuItem::item("Split Down", None, SplitDown),
|
ContextMenuItem::item("Split Down", SplitDown),
|
||||||
],
|
],
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
@ -856,8 +856,9 @@ impl Pane {
|
||||||
menu.show(
|
menu.show(
|
||||||
action.position,
|
action.position,
|
||||||
vec![
|
vec![
|
||||||
ContextMenuItem::item("New File", Some("circle_info_12.svg"), NewFile),
|
ContextMenuItem::item("New File", NewFile),
|
||||||
ContextMenuItem::item("New Terminal", Some("terminal_12.svg"), NewTerminal),
|
ContextMenuItem::item("New Terminal", NewTerminal),
|
||||||
|
ContextMenuItem::item("New Search", NewSearch),
|
||||||
],
|
],
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
|
|
|
@ -97,6 +97,7 @@ actions!(
|
||||||
ToggleLeftSidebar,
|
ToggleLeftSidebar,
|
||||||
ToggleRightSidebar,
|
ToggleRightSidebar,
|
||||||
NewTerminal,
|
NewTerminal,
|
||||||
|
NewSearch
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ pub fn menus() -> Vec<Menu<'static>> {
|
||||||
},
|
},
|
||||||
MenuItem::Action {
|
MenuItem::Action {
|
||||||
name: "Find In Project",
|
name: "Find In Project",
|
||||||
action: Box::new(search::project_search::Deploy),
|
action: Box::new(workspace::NewSearch),
|
||||||
},
|
},
|
||||||
MenuItem::Separator,
|
MenuItem::Separator,
|
||||||
MenuItem::Action {
|
MenuItem::Action {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue