mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-17 23:56:55 +00:00
Move project panel's dispatch_context() to render()
This commit is contained in:
parent
f922ad9f7f
commit
9849a0a6d8
1 changed files with 35 additions and 37 deletions
|
@ -1355,7 +1355,7 @@ impl ProjectPanel {
|
||||||
details: EntryDetails,
|
details: EntryDetails,
|
||||||
// dragged_entry_destination: &mut Option<Arc<Path>>,
|
// dragged_entry_destination: &mut Option<Arc<Path>>,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) -> Div {
|
) -> ListItem {
|
||||||
let kind = details.kind;
|
let kind = details.kind;
|
||||||
let settings = ProjectPanelSettings::get_global(cx);
|
let settings = ProjectPanelSettings::get_global(cx);
|
||||||
let show_editor = details.is_editing && !details.is_processing;
|
let show_editor = details.is_editing && !details.is_processing;
|
||||||
|
@ -1374,46 +1374,44 @@ impl ProjectPanel {
|
||||||
})
|
})
|
||||||
.unwrap_or(theme.status().info);
|
.unwrap_or(theme.status().info);
|
||||||
|
|
||||||
div().key_context(self.dispatch_context(cx)).child(
|
ListItem::new(entry_id.to_proto() as usize)
|
||||||
ListItem::new(entry_id.to_proto() as usize)
|
.indent_level(details.depth)
|
||||||
.indent_level(details.depth)
|
.indent_step_size(px(settings.indent_size))
|
||||||
.indent_step_size(px(settings.indent_size))
|
.selected(is_selected)
|
||||||
.selected(is_selected)
|
.child(if let Some(icon) = &details.icon {
|
||||||
.child(if let Some(icon) = &details.icon {
|
div().child(IconElement::from_path(icon.to_string()))
|
||||||
div().child(IconElement::from_path(icon.to_string()))
|
} else {
|
||||||
|
div()
|
||||||
|
})
|
||||||
|
.child(
|
||||||
|
if let (Some(editor), true) = (Some(&self.filename_editor), show_editor) {
|
||||||
|
div().h_full().w_full().child(editor.clone())
|
||||||
} else {
|
} else {
|
||||||
div()
|
div()
|
||||||
})
|
.text_color(filename_text_color)
|
||||||
.child(
|
.child(Label::new(details.filename.clone()))
|
||||||
if let (Some(editor), true) = (Some(&self.filename_editor), show_editor) {
|
}
|
||||||
div().h_full().w_full().child(editor.clone())
|
.ml_1(),
|
||||||
|
)
|
||||||
|
.on_click(cx.listener(move |this, event: &gpui::ClickEvent, cx| {
|
||||||
|
if event.down.button == MouseButton::Right {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if !show_editor {
|
||||||
|
if kind.is_dir() {
|
||||||
|
this.toggle_expanded(entry_id, cx);
|
||||||
} else {
|
} else {
|
||||||
div()
|
if event.down.modifiers.command {
|
||||||
.text_color(filename_text_color)
|
this.split_entry(entry_id, cx);
|
||||||
.child(Label::new(details.filename.clone()))
|
|
||||||
}
|
|
||||||
.ml_1(),
|
|
||||||
)
|
|
||||||
.on_click(cx.listener(move |this, event: &gpui::ClickEvent, cx| {
|
|
||||||
if event.down.button == MouseButton::Right {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if !show_editor {
|
|
||||||
if kind.is_dir() {
|
|
||||||
this.toggle_expanded(entry_id, cx);
|
|
||||||
} else {
|
} else {
|
||||||
if event.down.modifiers.command {
|
this.open_entry(entry_id, event.up.click_count > 1, cx);
|
||||||
this.split_entry(entry_id, cx);
|
|
||||||
} else {
|
|
||||||
this.open_entry(entry_id, event.up.click_count > 1, cx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}))
|
}
|
||||||
.on_secondary_mouse_down(cx.listener(move |this, event: &MouseDownEvent, cx| {
|
}))
|
||||||
this.deploy_context_menu(event.position, entry_id, cx);
|
.on_secondary_mouse_down(cx.listener(move |this, event: &MouseDownEvent, cx| {
|
||||||
})),
|
this.deploy_context_menu(event.position, entry_id, cx);
|
||||||
)
|
}))
|
||||||
// .on_drop::<ProjectEntryId>(|this, event, cx| {
|
// .on_drop::<ProjectEntryId>(|this, event, cx| {
|
||||||
// this.move_entry(
|
// this.move_entry(
|
||||||
// *dragged_entry,
|
// *dragged_entry,
|
||||||
|
@ -1426,8 +1424,8 @@ impl ProjectPanel {
|
||||||
|
|
||||||
fn dispatch_context(&self, cx: &ViewContext<Self>) -> KeyContext {
|
fn dispatch_context(&self, cx: &ViewContext<Self>) -> KeyContext {
|
||||||
let mut dispatch_context = KeyContext::default();
|
let mut dispatch_context = KeyContext::default();
|
||||||
|
dispatch_context.add("ProjectPanel");
|
||||||
dispatch_context.add("menu");
|
dispatch_context.add("menu");
|
||||||
dispatch_context.add("not_editing");
|
|
||||||
|
|
||||||
let identifier = if self.filename_editor.focus_handle(cx).is_focused(cx) {
|
let identifier = if self.filename_editor.focus_handle(cx).is_focused(cx) {
|
||||||
"editing"
|
"editing"
|
||||||
|
@ -1452,7 +1450,7 @@ impl Render for ProjectPanel {
|
||||||
.id("project-panel")
|
.id("project-panel")
|
||||||
.size_full()
|
.size_full()
|
||||||
.relative()
|
.relative()
|
||||||
.key_context("ProjectPanel")
|
.key_context(self.dispatch_context(cx))
|
||||||
.on_action(cx.listener(Self::select_next))
|
.on_action(cx.listener(Self::select_next))
|
||||||
.on_action(cx.listener(Self::select_prev))
|
.on_action(cx.listener(Self::select_prev))
|
||||||
.on_action(cx.listener(Self::expand_selected_entry))
|
.on_action(cx.listener(Self::expand_selected_entry))
|
||||||
|
|
Loading…
Reference in a new issue