Port 1.00 following tests

Co-Authored-By: Max <max@zed.dev>
This commit is contained in:
Conrad Irwin 2024-01-05 14:23:07 -07:00
parent 5037cca7ec
commit 81d707adbc
5 changed files with 534 additions and 534 deletions

View file

@ -19,7 +19,6 @@ pub enum PanelEvent {
ZoomOut,
Activate,
Close,
Focus,
}
pub trait Panel: FocusableView + EventEmitter<PanelEvent> {
@ -216,6 +215,28 @@ impl Dock {
}
});
cx.on_focus_in(&focus_handle, {
let dock = dock.downgrade();
move |workspace, cx| {
let Some(dock) = dock.upgrade() else {
return;
};
let Some(panel) = dock.read(cx).active_panel() else {
return;
};
if panel.is_zoomed(cx) {
workspace.zoomed = Some(panel.to_any().downgrade().into());
workspace.zoomed_position = Some(position);
} else {
workspace.zoomed = None;
workspace.zoomed_position = None;
}
workspace.dismiss_zoomed_items_to_reveal(Some(position), cx);
workspace.update_active_view_for_followers(cx)
}
})
.detach();
cx.observe(&dock, move |workspace, dock, cx| {
if dock.read(cx).is_open() {
if let Some(panel) = dock.read(cx).active_panel() {
@ -394,7 +415,6 @@ impl Dock {
this.set_open(false, cx);
}
}
PanelEvent::Focus => {}
}),
];
@ -561,6 +581,7 @@ impl Render for Dock {
}
div()
.track_focus(&self.focus_handle)
.flex()
.bg(cx.theme().colors().panel_background)
.border_color(cx.theme().colors().border)
@ -584,7 +605,7 @@ impl Render for Dock {
)
.child(handle)
} else {
div()
div().track_focus(&self.focus_handle)
}
}
}
@ -720,7 +741,7 @@ pub mod test {
impl Render for TestPanel {
fn render(&mut self, _cx: &mut ViewContext<Self>) -> impl IntoElement {
div()
div().id("test").track_focus(&self.focus_handle)
}
}

View file

@ -442,7 +442,7 @@ impl<T: Item> ItemHandle for View<T> {
) && !pending_update_scheduled.load(Ordering::SeqCst)
{
pending_update_scheduled.store(true, Ordering::SeqCst);
cx.on_next_frame({
cx.defer({
let pending_update = pending_update.clone();
let pending_update_scheduled = pending_update_scheduled.clone();
move |this, cx| {