Enable zoom (#3668)

* [x] zoom
* [x] pane tests
This commit is contained in:
Max Brunsfeld
2023-12-15 12:58:03 -08:00
committed by GitHub
3 changed files with 598 additions and 817 deletions

View File

@@ -317,7 +317,7 @@ impl Dock {
new_dock.add_panel(panel.clone(), workspace.clone(), cx);
if was_visible {
new_dock.set_open(true, cx);
new_dock.activate_panel(this.panels_len() - 1, cx);
new_dock.activate_panel(new_dock.panels_len() - 1, cx);
}
});
}

File diff suppressed because it is too large Load Diff

View File

@@ -3556,6 +3556,8 @@ impl Render for Workspace {
)
};
let theme = cx.theme().clone();
let colors = theme.colors();
cx.set_rem_size(ui_font_size);
self.actions(div(), cx)
@@ -3568,10 +3570,10 @@ impl Render for Workspace {
.gap_0()
.justify_start()
.items_start()
.text_color(cx.theme().colors().text)
.bg(cx.theme().colors().background)
.text_color(colors.text)
.bg(colors.background)
.border()
.border_color(cx.theme().colors().border)
.border_color(colors.border)
.children(self.titlebar_item.clone())
.child(
div()
@@ -3584,7 +3586,7 @@ impl Render for Workspace {
.overflow_hidden()
.border_t()
.border_b()
.border_color(cx.theme().colors().border)
.border_color(colors.border)
.child(
canvas(cx.listener(|workspace, bounds, _| {
workspace.bounds = *bounds;
@@ -3623,13 +3625,15 @@ impl Render for Workspace {
.flex_row()
.h_full()
// Left Dock
.child(
div()
.flex()
.flex_none()
.overflow_hidden()
.child(self.left_dock.clone()),
)
.children(self.zoomed_position.ne(&Some(DockPosition::Left)).then(
|| {
div()
.flex()
.flex_none()
.overflow_hidden()
.child(self.left_dock.clone())
},
))
// Panes
.child(
div()
@@ -3646,154 +3650,48 @@ impl Render for Workspace {
&self.app_state,
cx,
))
.child(self.bottom_dock.clone()),
.children(
self.zoomed_position
.ne(&Some(DockPosition::Bottom))
.then(|| self.bottom_dock.clone()),
),
)
// Right Dock
.child(
div()
.flex()
.flex_none()
.overflow_hidden()
.child(self.right_dock.clone()),
),
.children(self.zoomed_position.ne(&Some(DockPosition::Right)).then(
|| {
div()
.flex()
.flex_none()
.overflow_hidden()
.child(self.right_dock.clone())
},
)),
)
.children(self.render_notifications(cx)),
.children(self.render_notifications(cx))
.children(self.zoomed.as_ref().and_then(|view| {
let zoomed_view = view.upgrade()?;
let div = div()
.z_index(1)
.absolute()
.overflow_hidden()
.border_color(colors.border)
.bg(colors.background)
.child(zoomed_view)
.inset_0()
.shadow_lg();
Some(match self.zoomed_position {
Some(DockPosition::Left) => div.right_2().border_r(),
Some(DockPosition::Right) => div.left_2().border_l(),
Some(DockPosition::Bottom) => div.top_2().border_t(),
None => div.top_2().bottom_2().left_2().right_2().border(),
})
})),
)
.child(self.status_bar.clone())
}
}
// impl View for Workspace {
// fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
// let theme = theme::current(cx).clone();
// Stack::new()
// .with_child(
// Flex::column()
// .with_child(self.render_titlebar(&theme, cx))
// .with_child(
// Stack::new()
// .with_child({
// let project = self.project.clone();
// Flex::row()
// .with_children(self.render_dock(DockPosition::Left, cx))
// .with_child(
// Flex::column()
// .with_child(
// FlexItem::new(
// self.center.render(
// &project,
// &theme,
// &self.follower_states,
// self.active_call(),
// self.active_pane(),
// self.zoomed
// .as_ref()
// .and_then(|zoomed| zoomed.upgrade(cx))
// .as_ref(),
// &self.app_state,
// cx,
// ),
// )
// .flex(1., true),
// )
// .with_children(
// self.render_dock(DockPosition::Bottom, cx),
// )
// .flex(1., true),
// )
// .with_children(self.render_dock(DockPosition::Right, cx))
// })
// .with_child(Overlay::new(
// Stack::new()
// .with_children(self.zoomed.as_ref().and_then(|zoomed| {
// enum ZoomBackground {}
// let zoomed = zoomed.upgrade(cx)?;
// let mut foreground_style =
// theme.workspace.zoomed_pane_foreground;
// if let Some(zoomed_dock_position) = self.zoomed_position {
// foreground_style =
// theme.workspace.zoomed_panel_foreground;
// let margin = foreground_style.margin.top;
// let border = foreground_style.border.top;
// // Only include a margin and border on the opposite side.
// foreground_style.margin.top = 0.;
// foreground_style.margin.left = 0.;
// foreground_style.margin.bottom = 0.;
// foreground_style.margin.right = 0.;
// foreground_style.border.top = false;
// foreground_style.border.left = false;
// foreground_style.border.bottom = false;
// foreground_style.border.right = false;
// match zoomed_dock_position {
// DockPosition::Left => {
// foreground_style.margin.right = margin;
// foreground_style.border.right = border;
// }
// DockPosition::Right => {
// foreground_style.margin.left = margin;
// foreground_style.border.left = border;
// }
// DockPosition::Bottom => {
// foreground_style.margin.top = margin;
// foreground_style.border.top = border;
// }
// }
// }
// Some(
// ChildView::new(&zoomed, cx)
// .contained()
// .with_style(foreground_style)
// .aligned()
// .contained()
// .with_style(theme.workspace.zoomed_background)
// .mouse::<ZoomBackground>(0)
// .capture_all()
// .on_down(
// MouseButton::Left,
// |_, this: &mut Self, cx| {
// this.zoom_out(cx);
// },
// ),
// )
// }))
// .with_children(self.modal.as_ref().map(|modal| {
// // Prevent clicks within the modal from falling
// // through to the rest of the workspace.
// enum ModalBackground {}
// MouseEventHandler::new::<ModalBackground, _>(
// 0,
// cx,
// |_, cx| ChildView::new(modal.view.as_any(), cx),
// )
// .on_click(MouseButton::Left, |_, _, _| {})
// .contained()
// .with_style(theme.workspace.modal)
// .aligned()
// .top()
// }))
// .with_children(self.render_notifications(&theme.workspace, cx)),
// ))
// .provide_resize_bounds::<WorkspaceBounds>()
// .flex(1.0, true),
// )
// .with_child(ChildView::new(&self.status_bar, cx))
// .contained()
// .with_background_color(theme.workspace.background),
// )
// .with_children(DragAndDrop::render(cx))
// .with_children(self.render_disconnected_overlay(cx))
// .into_any_named("workspace")
// }
// fn modifiers_changed(&mut self, e: &ModifiersChangedEvent, cx: &mut ViewContext<Self>) -> bool {
// DragAndDrop::<Workspace>::update_modifiers(e.modifiers, cx)
// }
// }
impl WorkspaceStore {
pub fn new(client: Arc<Client>, cx: &mut ModelContext<Self>) -> Self {
Self {