diff --git a/crates/workspace2/src/pane.rs b/crates/workspace2/src/pane.rs index 7f3658260c..6399fe2121 100644 --- a/crates/workspace2/src/pane.rs +++ b/crates/workspace2/src/pane.rs @@ -125,10 +125,6 @@ pub fn init(cx: &mut AppContext) { // cx.add_async_action(Pane::close_items_to_the_left); // cx.add_async_action(Pane::close_items_to_the_right); // cx.add_async_action(Pane::close_all_items); - // cx.add_action(|pane: &mut Pane, _: &SplitLeft, cx| pane.split(SplitDirection::Left, cx)); - // cx.add_action(|pane: &mut Pane, _: &SplitUp, cx| pane.split(SplitDirection::Up, cx)); - // cx.add_action(|pane: &mut Pane, _: &SplitRight, cx| pane.split(SplitDirection::Right, cx)); - // cx.add_action(|pane: &mut Pane, _: &SplitDown, cx| pane.split(SplitDirection::Down, cx)); } pub enum Event { @@ -1195,9 +1191,9 @@ impl Pane { } } - // pub fn split(&mut self, direction: SplitDirection, cx: &mut ViewContext) { - // cx.emit(Event::Split(direction)); - // } + pub fn split(&mut self, direction: SplitDirection, cx: &mut ViewContext) { + cx.emit(Event::Split(direction)); + } // fn deploy_split_menu(&mut self, cx: &mut ViewContext) { // self.tab_bar_context_menu.handle.update(cx, |menu, cx| { @@ -1903,10 +1899,6 @@ impl Pane { } } -// impl Entity for Pane { -// type Event = Event; -// } - impl Render for Pane { type Element = Focusable>; @@ -1914,6 +1906,10 @@ impl Render for Pane { v_stack() .key_context("Pane") .track_focus(&self.focus_handle) + .on_action(|pane: &mut Pane, _: &SplitLeft, cx| pane.split(SplitDirection::Left, cx)) + .on_action(|pane: &mut Pane, _: &SplitUp, cx| pane.split(SplitDirection::Up, cx)) + .on_action(|pane: &mut Pane, _: &SplitRight, cx| pane.split(SplitDirection::Right, cx)) + .on_action(|pane: &mut Pane, _: &SplitDown, cx| pane.split(SplitDirection::Down, cx)) .size_full() .on_action(|pane: &mut Self, action, cx| { pane.close_active_item(action, cx) diff --git a/crates/workspace2/src/pane_group.rs b/crates/workspace2/src/pane_group.rs index a9e95b8c29..682bde5b0a 100644 --- a/crates/workspace2/src/pane_group.rs +++ b/crates/workspace2/src/pane_group.rs @@ -551,7 +551,32 @@ impl PaneAxis { ) -> AnyElement { debug_assert!(self.members.len() == self.flexes.lock().len()); - todo!() + div() + .flex() + .flex_auto() + .map(|s| match self.axis { + Axis::Vertical => s.flex_col(), + Axis::Horizontal => s.flex_row(), + }) + .children(self.members.iter().enumerate().map(|(ix, member)| { + match member { + Member::Axis(axis) => axis + .render( + project, + basis, + follower_states, + active_call, + active_pane, + zoomed, + app_state, + cx, + ) + .render(), + Member::Pane(pane) => pane.clone().render(), + } + })) + .render() + // let mut pane_axis = PaneAxisElement::new( // self.axis, // basis, diff --git a/crates/workspace2/src/workspace2.rs b/crates/workspace2/src/workspace2.rs index 6a26fbdb5c..6c2d0c0ede 100644 --- a/crates/workspace2/src/workspace2.rs +++ b/crates/workspace2/src/workspace2.rs @@ -36,11 +36,11 @@ use futures::{ Future, FutureExt, StreamExt, }; use gpui::{ - actions, div, point, prelude::*, register_action, rems, size, Action, AnyModel, AnyView, - AnyWeakView, AppContext, AsyncAppContext, AsyncWindowContext, Bounds, Component, Div, Entity, - EntityId, EventEmitter, GlobalPixels, KeyContext, Model, ModelContext, ParentComponent, Point, - Render, Size, Styled, Subscription, Task, View, ViewContext, WeakView, WindowBounds, - WindowContext, WindowHandle, WindowOptions, + actions, div, point, prelude::*, rems, size, Action, AnyModel, AnyView, AnyWeakView, + AppContext, AsyncAppContext, AsyncWindowContext, Bounds, Component, Div, Entity, EntityId, + EventEmitter, GlobalPixels, KeyContext, Model, ModelContext, ParentComponent, Point, Render, + Size, Styled, Subscription, Task, View, ViewContext, WeakView, WindowBounds, WindowContext, + WindowHandle, WindowOptions, }; use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem}; use itertools::Itertools;