Merge branch 'main' into project-panel2
This commit is contained in:
commit
1968becf94
47 changed files with 4485 additions and 3457 deletions
|
@ -36,11 +36,12 @@ use futures::{
|
|||
Future, FutureExt, StreamExt,
|
||||
};
|
||||
use gpui::{
|
||||
actions, div, point, rems, size, AnyModel, AnyView, AnyWeakView, AppContext, AsyncAppContext,
|
||||
AsyncWindowContext, Bounds, Component, Div, Entity, EntityId, EventEmitter, FocusHandle,
|
||||
GlobalPixels, Model, ModelContext, ParentElement, Point, Render, Size, StatefulInteractive,
|
||||
StatelessInteractive, Styled, Subscription, Task, View, ViewContext, VisualContext, WeakView,
|
||||
WindowBounds, WindowContext, WindowHandle, WindowOptions,
|
||||
actions, div, point, rems, size, Action, AnyModel, AnyView, AnyWeakView, AppContext,
|
||||
AsyncAppContext, AsyncWindowContext, Bounds, Component, DispatchContext, Div, Entity, EntityId,
|
||||
EventEmitter, FocusHandle, GlobalPixels, Model, ModelContext, ParentElement, Point, Render,
|
||||
Size, StatefulInteractive, StatefulInteractivity, StatelessInteractive, Styled, Subscription,
|
||||
Task, View, ViewContext, VisualContext, WeakView, WindowBounds, WindowContext, WindowHandle,
|
||||
WindowOptions,
|
||||
};
|
||||
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};
|
||||
use itertools::Itertools;
|
||||
|
@ -434,6 +435,13 @@ pub enum Event {
|
|||
pub struct Workspace {
|
||||
weak_self: WeakView<Self>,
|
||||
focus_handle: FocusHandle,
|
||||
workspace_actions: Vec<
|
||||
Box<
|
||||
dyn Fn(
|
||||
Div<Workspace, StatefulInteractivity<Workspace>>,
|
||||
) -> Div<Workspace, StatefulInteractivity<Workspace>>,
|
||||
>,
|
||||
>,
|
||||
zoomed: Option<AnyWeakView>,
|
||||
zoomed_position: Option<DockPosition>,
|
||||
center: PaneGroup,
|
||||
|
@ -446,7 +454,7 @@ pub struct Workspace {
|
|||
last_active_center_pane: Option<WeakView<Pane>>,
|
||||
last_active_view_id: Option<proto::ViewId>,
|
||||
status_bar: View<StatusBar>,
|
||||
modal_layer: ModalLayer,
|
||||
modal_layer: View<ModalLayer>,
|
||||
// titlebar_item: Option<AnyViewHandle>,
|
||||
notifications: Vec<(TypeId, usize, Box<dyn NotificationHandle>)>,
|
||||
project: Model<Project>,
|
||||
|
@ -598,7 +606,7 @@ impl Workspace {
|
|||
});
|
||||
|
||||
let workspace_handle = cx.view().downgrade();
|
||||
let modal_layer = ModalLayer::new();
|
||||
let modal_layer = cx.build_view(|cx| ModalLayer::new());
|
||||
|
||||
// todo!()
|
||||
// cx.update_default_global::<DragAndDrop<Workspace>, _, _>(|drag_and_drop, _| {
|
||||
|
@ -679,13 +687,10 @@ impl Workspace {
|
|||
leader_updates_tx,
|
||||
subscriptions,
|
||||
pane_history_timestamp,
|
||||
workspace_actions: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn modal_layer(&mut self) -> &mut ModalLayer {
|
||||
&mut self.modal_layer
|
||||
}
|
||||
|
||||
fn new_local(
|
||||
abs_paths: Vec<PathBuf>,
|
||||
app_state: Arc<AppState>,
|
||||
|
@ -3356,23 +3361,27 @@ impl Workspace {
|
|||
// #[cfg(any(test, feature = "test-support"))]
|
||||
// pub fn test_new(project: ModelHandle<Project>, cx: &mut ViewContext<Self>) -> Self {
|
||||
// use node_runtime::FakeNodeRuntime;
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn test_new(project: Model<Project>, cx: &mut ViewContext<Self>) -> Self {
|
||||
use gpui::Context;
|
||||
use node_runtime::FakeNodeRuntime;
|
||||
|
||||
// let client = project.read(cx).client();
|
||||
// let user_store = project.read(cx).user_store();
|
||||
let client = project.read(cx).client();
|
||||
let user_store = project.read(cx).user_store();
|
||||
|
||||
// let workspace_store = cx.add_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
// let app_state = Arc::new(AppState {
|
||||
// languages: project.read(cx).languages().clone(),
|
||||
// workspace_store,
|
||||
// client,
|
||||
// user_store,
|
||||
// fs: project.read(cx).fs().clone(),
|
||||
// build_window_options: |_, _, _| Default::default(),
|
||||
// initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
|
||||
// node_runtime: FakeNodeRuntime::new(),
|
||||
// });
|
||||
// Self::new(0, project, app_state, cx)
|
||||
// }
|
||||
let workspace_store = cx.build_model(|cx| WorkspaceStore::new(client.clone(), cx));
|
||||
let app_state = Arc::new(AppState {
|
||||
languages: project.read(cx).languages().clone(),
|
||||
workspace_store,
|
||||
client,
|
||||
user_store,
|
||||
fs: project.read(cx).fs().clone(),
|
||||
build_window_options: |_, _, _| Default::default(),
|
||||
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
|
||||
node_runtime: FakeNodeRuntime::new(),
|
||||
});
|
||||
Self::new(0, project, app_state, cx)
|
||||
}
|
||||
|
||||
// fn render_dock(&self, position: DockPosition, cx: &WindowContext) -> Option<AnyElement<Self>> {
|
||||
// let dock = match position {
|
||||
|
@ -3404,6 +3413,35 @@ impl Workspace {
|
|||
// )
|
||||
// }
|
||||
// }
|
||||
pub fn register_action<A: Action>(
|
||||
&mut self,
|
||||
callback: impl Fn(&mut Self, &A, &mut ViewContext<Self>) + 'static,
|
||||
) {
|
||||
let callback = Arc::new(callback);
|
||||
|
||||
self.workspace_actions.push(Box::new(move |div| {
|
||||
let callback = callback.clone();
|
||||
div.on_action(move |workspace, event, cx| (callback.clone())(workspace, event, cx))
|
||||
}));
|
||||
}
|
||||
|
||||
fn add_workspace_actions_listeners(
|
||||
&self,
|
||||
mut div: Div<Workspace, StatefulInteractivity<Workspace>>,
|
||||
) -> Div<Workspace, StatefulInteractivity<Workspace>> {
|
||||
for action in self.workspace_actions.iter() {
|
||||
div = (action)(div)
|
||||
}
|
||||
div
|
||||
}
|
||||
|
||||
pub fn toggle_modal<V: Modal, B>(&mut self, cx: &mut ViewContext<Self>, build: B)
|
||||
where
|
||||
B: FnOnce(&mut ViewContext<V>) -> V,
|
||||
{
|
||||
self.modal_layer
|
||||
.update(cx, |modal_layer, cx| modal_layer.toggle_modal(cx, build))
|
||||
}
|
||||
}
|
||||
|
||||
fn window_bounds_env_override(cx: &AsyncAppContext) -> Option<WindowBounds> {
|
||||
|
@ -3618,142 +3656,110 @@ impl Render for Workspace {
|
|||
type Element = Div<Self>;
|
||||
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
|
||||
div()
|
||||
.relative()
|
||||
.size_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.font("Zed Sans")
|
||||
.gap_0()
|
||||
.justify_start()
|
||||
.items_start()
|
||||
.text_color(cx.theme().colors().text)
|
||||
.bg(cx.theme().colors().background)
|
||||
.child(self.render_titlebar(cx))
|
||||
.child(Workspace::actions(
|
||||
// todo! should this be a component a view?
|
||||
self.modal_layer
|
||||
.wrapper_element(cx)
|
||||
.relative()
|
||||
.flex_1()
|
||||
.w_full()
|
||||
.flex()
|
||||
.overflow_hidden()
|
||||
.border_t()
|
||||
.border_b()
|
||||
.border_color(cx.theme().colors().border)
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.flex_1()
|
||||
.h_full()
|
||||
.child(div().flex().flex_1().child(self.left_dock.clone()))
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.flex_1()
|
||||
.child(self.center.render(
|
||||
&self.project,
|
||||
&self.follower_states,
|
||||
self.active_call(),
|
||||
&self.active_pane,
|
||||
self.zoomed.as_ref(),
|
||||
&self.app_state,
|
||||
cx,
|
||||
))
|
||||
.child(div().flex().flex_1().child(self.bottom_dock.clone())),
|
||||
)
|
||||
.child(div().flex().flex_1().child(self.right_dock.clone())),
|
||||
), // .children(
|
||||
// Some(
|
||||
// Panel::new("chat-panel-outer", cx)
|
||||
// .side(PanelSide::Right)
|
||||
// .child(ChatPanel::new("chat-panel-inner").messages(vec![
|
||||
// ChatMessage::new(
|
||||
// "osiewicz".to_string(),
|
||||
// "is this thing on?".to_string(),
|
||||
// DateTime::parse_from_rfc3339("2023-09-27T15:40:52.707Z")
|
||||
// .unwrap()
|
||||
// .naive_local(),
|
||||
// ),
|
||||
// ChatMessage::new(
|
||||
// "maxdeviant".to_string(),
|
||||
// "Reading you loud and clear!".to_string(),
|
||||
// DateTime::parse_from_rfc3339("2023-09-28T15:40:52.707Z")
|
||||
// .unwrap()
|
||||
// .naive_local(),
|
||||
// ),
|
||||
// ])),
|
||||
// )
|
||||
// .filter(|_| self.is_chat_panel_open()),
|
||||
// )
|
||||
// .children(
|
||||
// Some(
|
||||
// Panel::new("notifications-panel-outer", cx)
|
||||
// .side(PanelSide::Right)
|
||||
// .child(NotificationsPanel::new("notifications-panel-inner")),
|
||||
// )
|
||||
// .filter(|_| self.is_notifications_panel_open()),
|
||||
// )
|
||||
// .children(
|
||||
// Some(
|
||||
// Panel::new("assistant-panel-outer", cx)
|
||||
// .child(AssistantPanel::new("assistant-panel-inner")),
|
||||
// )
|
||||
// .filter(|_| self.is_assistant_panel_open()),
|
||||
// ),
|
||||
))
|
||||
.child(self.status_bar.clone())
|
||||
// .when(self.debug.show_toast, |this| {
|
||||
// this.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast")))
|
||||
// })
|
||||
// .children(
|
||||
// Some(
|
||||
// div()
|
||||
// .absolute()
|
||||
// .top(px(50.))
|
||||
// .left(px(640.))
|
||||
// .z_index(8)
|
||||
// .child(LanguageSelector::new("language-selector")),
|
||||
// )
|
||||
// .filter(|_| self.is_language_selector_open()),
|
||||
// )
|
||||
.z_index(8)
|
||||
// Debug
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.z_index(9)
|
||||
.absolute()
|
||||
.top_20()
|
||||
.left_1_4()
|
||||
.w_40()
|
||||
.gap_2(), // .when(self.show_debug, |this| {
|
||||
// this.child(Button::<Workspace>::new("Toggle User Settings").on_click(
|
||||
// Arc::new(|workspace, cx| workspace.debug_toggle_user_settings(cx)),
|
||||
// ))
|
||||
// .child(
|
||||
// Button::<Workspace>::new("Toggle Toasts").on_click(Arc::new(
|
||||
// |workspace, cx| workspace.debug_toggle_toast(cx),
|
||||
// )),
|
||||
// )
|
||||
// .child(
|
||||
// Button::<Workspace>::new("Toggle Livestream").on_click(Arc::new(
|
||||
// |workspace, cx| workspace.debug_toggle_livestream(cx),
|
||||
// )),
|
||||
// )
|
||||
// })
|
||||
// .child(
|
||||
// Button::<Workspace>::new("Toggle Debug")
|
||||
// .on_click(Arc::new(|workspace, cx| workspace.toggle_debug(cx))),
|
||||
// ),
|
||||
)
|
||||
let mut context = DispatchContext::default();
|
||||
context.insert("Workspace");
|
||||
cx.with_key_dispatch_context(context, |cx| {
|
||||
div()
|
||||
.relative()
|
||||
.size_full()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.font("Zed Sans")
|
||||
.gap_0()
|
||||
.justify_start()
|
||||
.items_start()
|
||||
.text_color(cx.theme().colors().text)
|
||||
.bg(cx.theme().colors().background)
|
||||
.child(self.render_titlebar(cx))
|
||||
.child(
|
||||
// todo! should this be a component a view?
|
||||
self.add_workspace_actions_listeners(div().id("workspace"))
|
||||
.relative()
|
||||
.flex_1()
|
||||
.w_full()
|
||||
.flex()
|
||||
.overflow_hidden()
|
||||
.border_t()
|
||||
.border_b()
|
||||
.border_color(cx.theme().colors().border)
|
||||
.child(self.modal_layer.clone())
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_row()
|
||||
.flex_1()
|
||||
.h_full()
|
||||
.child(div().flex().flex_1().child(self.left_dock.clone()))
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.flex_1()
|
||||
.child(self.center.render(
|
||||
&self.project,
|
||||
&self.follower_states,
|
||||
self.active_call(),
|
||||
&self.active_pane,
|
||||
self.zoomed.as_ref(),
|
||||
&self.app_state,
|
||||
cx,
|
||||
))
|
||||
.child(
|
||||
div().flex().flex_1().child(self.bottom_dock.clone()),
|
||||
),
|
||||
)
|
||||
.child(div().flex().flex_1().child(self.right_dock.clone())),
|
||||
),
|
||||
)
|
||||
.child(self.status_bar.clone())
|
||||
// .when(self.debug.show_toast, |this| {
|
||||
// this.child(Toast::new(ToastOrigin::Bottom).child(Label::new("A toast")))
|
||||
// })
|
||||
// .children(
|
||||
// Some(
|
||||
// div()
|
||||
// .absolute()
|
||||
// .top(px(50.))
|
||||
// .left(px(640.))
|
||||
// .z_index(8)
|
||||
// .child(LanguageSelector::new("language-selector")),
|
||||
// )
|
||||
// .filter(|_| self.is_language_selector_open()),
|
||||
// )
|
||||
.z_index(8)
|
||||
// Debug
|
||||
.child(
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.z_index(9)
|
||||
.absolute()
|
||||
.top_20()
|
||||
.left_1_4()
|
||||
.w_40()
|
||||
.gap_2(), // .when(self.show_debug, |this| {
|
||||
// this.child(Button::<Workspace>::new("Toggle User Settings").on_click(
|
||||
// Arc::new(|workspace, cx| workspace.debug_toggle_user_settings(cx)),
|
||||
// ))
|
||||
// .child(
|
||||
// Button::<Workspace>::new("Toggle Toasts").on_click(Arc::new(
|
||||
// |workspace, cx| workspace.debug_toggle_toast(cx),
|
||||
// )),
|
||||
// )
|
||||
// .child(
|
||||
// Button::<Workspace>::new("Toggle Livestream").on_click(Arc::new(
|
||||
// |workspace, cx| workspace.debug_toggle_livestream(cx),
|
||||
// )),
|
||||
// )
|
||||
// })
|
||||
// .child(
|
||||
// Button::<Workspace>::new("Toggle Debug")
|
||||
// .on_click(Arc::new(|workspace, cx| workspace.toggle_debug(cx))),
|
||||
// ),
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// todo!()
|
||||
// impl Entity for Workspace {
|
||||
// type Event = Event;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue