zzz
This commit is contained in:
parent
5e3d0a6d03
commit
0fefe53773
4 changed files with 158 additions and 136 deletions
|
@ -214,13 +214,13 @@ impl TerminalPanel {
|
|||
event: &pane::Event,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) {
|
||||
match event {
|
||||
match dbg!(event) {
|
||||
pane::Event::ActivateItem { .. } => self.serialize(cx),
|
||||
pane::Event::RemoveItem { .. } => self.serialize(cx),
|
||||
pane::Event::Remove => cx.emit(PanelEvent::Close),
|
||||
pane::Event::ZoomIn => cx.emit(PanelEvent::ZoomIn),
|
||||
pane::Event::ZoomOut => cx.emit(PanelEvent::ZoomOut),
|
||||
pane::Event::Focus => cx.emit(PanelEvent::Focus),
|
||||
pane::Event::Focus => cx.emit(dbg!(PanelEvent::Focus)),
|
||||
|
||||
pane::Event::AddItem { item } => {
|
||||
if let Some(workspace) = self.workspace.upgrade() {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::{status_bar::StatusItemView, Axis, Workspace};
|
||||
use gpui::{
|
||||
div, px, Action, AnchorCorner, AnyView, AppContext, Div, Entity, EntityId, EventEmitter,
|
||||
FocusHandle, FocusableView, IntoElement, ParentElement, Render, SharedString, Styled,
|
||||
Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||
FocusHandle, Focusable, FocusableView, IntoElement, ParentElement, Render, SharedString,
|
||||
Styled, Subscription, View, ViewContext, VisualContext, WeakView, WindowContext,
|
||||
};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
@ -10,6 +10,7 @@ use std::sync::Arc;
|
|||
use ui::{h_stack, ContextMenu, IconButton, Tooltip};
|
||||
use ui::{prelude::*, right_click_menu};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum PanelEvent {
|
||||
ChangePosition,
|
||||
ZoomIn,
|
||||
|
|
|
@ -1493,7 +1493,7 @@ impl Pane {
|
|||
.child(label);
|
||||
|
||||
right_click_menu(ix).trigger(tab).menu(|cx| {
|
||||
ContextMenu::build(cx, |menu, cx| {
|
||||
ContextMenu::build(cx, |menu, _| {
|
||||
menu.action("Close", CloseActiveItem { save_intent: None }.boxed_clone())
|
||||
.action("Close Others", CloseInactiveItems.boxed_clone())
|
||||
.separator()
|
||||
|
@ -2057,13 +2057,13 @@ impl Render for Pane {
|
|||
.overflow_hidden()
|
||||
.on_focus_in({
|
||||
let this = this.clone();
|
||||
move |event, cx| {
|
||||
move |_, cx| {
|
||||
this.update(cx, |this, cx| this.focus_in(cx)).ok();
|
||||
}
|
||||
})
|
||||
.on_focus_out({
|
||||
let this = this.clone();
|
||||
move |event, cx| {
|
||||
move |_, cx| {
|
||||
this.update(cx, |this, cx| this.focus_out(cx)).ok();
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1558,6 +1558,7 @@ impl Workspace {
|
|||
self.dismiss_zoomed_items_to_reveal(Some(dock_side), cx);
|
||||
}
|
||||
|
||||
dbg!("~~~~~~~~~~~~ ???????", focus_center);
|
||||
if focus_center {
|
||||
self.active_pane.update(cx, |pane, cx| pane.focus(cx))
|
||||
}
|
||||
|
@ -1738,8 +1739,10 @@ impl Workspace {
|
|||
}
|
||||
|
||||
pub fn add_item(&mut self, item: Box<dyn ItemHandle>, cx: &mut ViewContext<Self>) {
|
||||
self.active_pane
|
||||
.update(cx, |pane, cx| pane.add_item(item, true, true, None, cx));
|
||||
self.active_pane.update(cx, |pane, cx| {
|
||||
dbg!(pane.items_len());
|
||||
pane.add_item(item, true, true, None, cx)
|
||||
});
|
||||
}
|
||||
|
||||
pub fn split_item(
|
||||
|
@ -2039,7 +2042,14 @@ impl Workspace {
|
|||
}
|
||||
|
||||
fn handle_pane_focused(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
||||
// TODO kb remove
|
||||
eprintln!(
|
||||
"########## handle_pane_focused acrive: {}, new: {}",
|
||||
self.active_pane.read(cx).items_len(),
|
||||
pane.read(cx).items_len()
|
||||
);
|
||||
if self.active_pane != pane {
|
||||
dbg!("########## got new pane to activate",);
|
||||
self.active_pane = pane.clone();
|
||||
self.status_bar.update(cx, |status_bar, cx| {
|
||||
status_bar.set_active_pane(&self.active_pane, cx);
|
||||
|
@ -2233,6 +2243,7 @@ impl Workspace {
|
|||
}
|
||||
|
||||
fn remove_pane(&mut self, pane: View<Pane>, cx: &mut ViewContext<Self>) {
|
||||
dbg!("?????@@@@@@@@@@ remove pane");
|
||||
if self.center.remove(&pane).unwrap() {
|
||||
self.force_remove_pane(&pane, cx);
|
||||
self.unfollow(&pane, cx);
|
||||
|
@ -2241,8 +2252,14 @@ impl Workspace {
|
|||
self.panes_by_item.remove(&removed_item.item_id());
|
||||
}
|
||||
|
||||
dbg!("######### removed the pane", self.panes.len());
|
||||
// cx.focus_self();
|
||||
|
||||
cx.notify();
|
||||
} else {
|
||||
dbg!(
|
||||
"??????????? during pane removal, we decided to spare the pane and not removed it (main pane)"
|
||||
);
|
||||
self.active_item_path_changed(cx);
|
||||
}
|
||||
}
|
||||
|
@ -4400,9 +4417,12 @@ fn parse_pixel_size_env_var(value: &str) -> Option<Size<GlobalPixels>> {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::item::{
|
||||
test::{TestItem, TestProjectItem},
|
||||
ItemEvent,
|
||||
use crate::{
|
||||
dock::test::TestPanel,
|
||||
item::{
|
||||
test::{TestItem, TestProjectItem},
|
||||
ItemEvent,
|
||||
},
|
||||
};
|
||||
use fs::FakeFs;
|
||||
use gpui::TestAppContext;
|
||||
|
@ -4975,153 +4995,154 @@ mod tests {
|
|||
});
|
||||
}
|
||||
|
||||
// #[gpui::test]
|
||||
// async fn test_toggle_docks_and_panels(cx: &mut gpui::TestAppContext) {
|
||||
// init_test(cx);
|
||||
// let fs = FakeFs::new(cx.executor());
|
||||
#[gpui::test]
|
||||
async fn test_toggle_docks_and_panels(cx: &mut gpui::TestAppContext) {
|
||||
init_test(cx);
|
||||
let fs = FakeFs::new(cx.background_executor.clone());
|
||||
|
||||
// let project = Project::test(fs, [], cx).await;
|
||||
// let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||
// let workspace = window.root(cx);
|
||||
let project = Project::test(fs, [], cx).await;
|
||||
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||
let workspace = window.root(cx).unwrap();
|
||||
|
||||
// let panel = workspace.update(cx, |workspace, cx| {
|
||||
// let panel = cx.build_view(|_| TestPanel::new(DockPosition::Right));
|
||||
// workspace.add_panel(panel.clone(), cx);
|
||||
cx.update_window(window.into(), |_, cx| {
|
||||
let panel = workspace.update(cx, |workspace, cx| {
|
||||
let panel = cx.build_view(|cx| TestPanel::new(DockPosition::Right, cx));
|
||||
workspace.add_panel(panel.clone(), cx);
|
||||
|
||||
// workspace
|
||||
// .right_dock()
|
||||
// .update(cx, |right_dock, cx| right_dock.set_open(true, cx));
|
||||
workspace
|
||||
.right_dock()
|
||||
.update(cx, |right_dock, cx| right_dock.set_open(true, cx));
|
||||
panel
|
||||
});
|
||||
let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
||||
pane.update(cx, |pane, cx| {
|
||||
let item = cx.build_view(|cx| TestItem::new(cx));
|
||||
pane.add_item(Box::new(item), true, true, None, cx);
|
||||
});
|
||||
|
||||
// panel
|
||||
// });
|
||||
// Transfer focus from center to panel
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
});
|
||||
|
||||
// let pane = workspace.update(cx, |workspace, _| workspace.active_pane().clone());
|
||||
// pane.update(cx, |pane, cx| {
|
||||
// let item = cx.build_view(|_| TestItem::new(cx));
|
||||
// pane.add_item(Box::new(item), true, true, None, cx);
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Transfer focus from center to panel
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
// });
|
||||
// Transfer focus from panel to center
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Transfer focus from panel to center
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
// });
|
||||
// Close the dock
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx);
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
// assert!(!panel.has_focus(cx));
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(!workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Close the dock
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx);
|
||||
// });
|
||||
// Open the dock
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx);
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
// assert!(!panel.has_focus(cx));
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Open the dock
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx);
|
||||
// });
|
||||
// Focus and zoom panel
|
||||
panel.update(cx, |panel, cx| {
|
||||
cx.focus_self();
|
||||
panel.set_zoomed(true, cx)
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(!panel.is_zoomed(cx));
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Focus and zoom panel
|
||||
// panel.update(cx, |panel, cx| {
|
||||
// cx.focus_self();
|
||||
// panel.set_zoomed(true, cx)
|
||||
// });
|
||||
// Transfer focus to the center closes the dock
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(!workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Transfer focus to the center closes the dock
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
// });
|
||||
// Transferring focus back to the panel keeps it zoomed
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(!panel.has_focus(cx));
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Transferring focus back to the panel keeps it zoomed
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_panel_focus::<TestPanel>(cx);
|
||||
// });
|
||||
// Close the dock while it is zoomed
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx)
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(!workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(workspace.zoomed.is_none());
|
||||
assert!(!panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Close the dock while it is zoomed
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
||||
// });
|
||||
// Opening the dock, when it's zoomed, retains focus
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx)
|
||||
});
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(!workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(workspace.zoomed.is_none());
|
||||
// assert!(!panel.has_focus(cx));
|
||||
// });
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
assert!(panel.is_zoomed(cx));
|
||||
assert!(workspace.zoomed.is_some());
|
||||
assert!(panel.focus_handle(cx).is_focused(cx));
|
||||
});
|
||||
|
||||
// // Opening the dock, when it's zoomed, retains focus
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
||||
// });
|
||||
// Unzoom and close the panel, zoom the active pane.
|
||||
panel.update(cx, |panel, cx| panel.set_zoomed(false, cx));
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx)
|
||||
});
|
||||
pane.update(cx, |pane, cx| pane.toggle_zoom(&Default::default(), cx));
|
||||
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(panel.is_zoomed(cx));
|
||||
// assert!(workspace.zoomed.is_some());
|
||||
// assert!(panel.has_focus(cx));
|
||||
// });
|
||||
|
||||
// // Unzoom and close the panel, zoom the active pane.
|
||||
// panel.update(cx, |panel, cx| panel.set_zoomed(false, cx));
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
||||
// });
|
||||
// pane.update(cx, |pane, cx| pane.toggle_zoom(&Default::default(), cx));
|
||||
|
||||
// // Opening a dock unzooms the pane.
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// workspace.toggle_dock(DockPosition::Right, cx)
|
||||
// });
|
||||
// workspace.update(cx, |workspace, cx| {
|
||||
// let pane = pane.read(cx);
|
||||
// assert!(!pane.is_zoomed());
|
||||
// assert!(!pane.has_focus());
|
||||
// assert!(workspace.right_dock().read(cx).is_open());
|
||||
// assert!(workspace.zoomed.is_none());
|
||||
// });
|
||||
// }
|
||||
// Opening a dock unzooms the pane.
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
workspace.toggle_dock(DockPosition::Right, cx)
|
||||
});
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
let pane = pane.read(cx);
|
||||
// assert!(!pane.is_zoomed());
|
||||
assert!(!pane.focus_handle(cx).is_focused(cx));
|
||||
assert!(workspace.right_dock().read(cx).is_open());
|
||||
assert!(workspace.zoomed.is_none());
|
||||
});
|
||||
})
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// #[gpui::test]
|
||||
// async fn test_panels(cx: &mut gpui::TestAppContext) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue