Remove initialize_workspace

This commit is contained in:
Mikayla
2023-11-15 23:11:31 -08:00
parent 78cea69172
commit c70c0f9ae9
6 changed files with 182 additions and 315 deletions
-112
View File
@@ -69,41 +69,6 @@ impl StatusBar {
}
}
// todo!()
// impl View for StatusBar {
// fn ui_name() -> &'static str {
// "StatusBar"
// }
// fn render(&mut self, cx: &mut ViewContext<Self>) -> AnyElement<Self> {
// let theme = &theme::current(cx).workspace.status_bar;
// StatusBarElement {
// left: Flex::row()
// .with_children(self.left_items.iter().map(|i| {
// ChildView::new(i.as_any(), cx)
// .aligned()
// .contained()
// .with_margin_right(theme.item_spacing)
// }))
// .into_any(),
// right: Flex::row()
// .with_children(self.right_items.iter().rev().map(|i| {
// ChildView::new(i.as_any(), cx)
// .aligned()
// .contained()
// .with_margin_left(theme.item_spacing)
// }))
// .into_any(),
// }
// .contained()
// .with_style(theme.container)
// .constrained()
// .with_height(theme.height)
// .into_any()
// }
// }
impl StatusBar {
pub fn new(active_pane: &View<Pane>, cx: &mut ViewContext<Self>) -> Self {
let mut this = Self {
@@ -223,80 +188,3 @@ impl From<&dyn StatusItemViewHandle> for AnyView {
val.to_any().clone()
}
}
// todo!()
// struct StatusBarElement {
// left: AnyElement<StatusBar>,
// right: AnyElement<StatusBar>,
// }
// todo!()
// impl Element<StatusBar> for StatusBarElement {
// type LayoutState = ();
// type PaintState = ();
// fn layout(
// &mut self,
// mut constraint: SizeConstraint,
// view: &mut StatusBar,
// cx: &mut ViewContext<StatusBar>,
// ) -> (Vector2F, Self::LayoutState) {
// let max_width = constraint.max.x();
// constraint.min = vec2f(0., constraint.min.y());
// let right_size = self.right.layout(constraint, view, cx);
// let constraint = SizeConstraint::new(
// vec2f(0., constraint.min.y()),
// vec2f(max_width - right_size.x(), constraint.max.y()),
// );
// self.left.layout(constraint, view, cx);
// (vec2f(max_width, right_size.y()), ())
// }
// fn paint(
// &mut self,
// bounds: RectF,
// visible_bounds: RectF,
// _: &mut Self::LayoutState,
// view: &mut StatusBar,
// cx: &mut ViewContext<StatusBar>,
// ) -> Self::PaintState {
// let origin_y = bounds.upper_right().y();
// let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default();
// let left_origin = vec2f(bounds.lower_left().x(), origin_y);
// self.left.paint(left_origin, visible_bounds, view, cx);
// let right_origin = vec2f(bounds.upper_right().x() - self.right.size().x(), origin_y);
// self.right.paint(right_origin, visible_bounds, view, cx);
// }
// fn rect_for_text_range(
// &self,
// _: Range<usize>,
// _: RectF,
// _: RectF,
// _: &Self::LayoutState,
// _: &Self::PaintState,
// _: &StatusBar,
// _: &ViewContext<StatusBar>,
// ) -> Option<RectF> {
// None
// }
// fn debug(
// &self,
// bounds: RectF,
// _: &Self::LayoutState,
// _: &Self::PaintState,
// _: &StatusBar,
// _: &ViewContext<StatusBar>,
// ) -> serde_json::Value {
// json!({
// "type": "StatusBarElement",
// "bounds": bounds.to_json()
// })
// }
// }
+10 -19
View File
@@ -322,12 +322,6 @@ pub struct AppState {
pub fs: Arc<dyn fs2::Fs>,
pub build_window_options:
fn(Option<WindowBounds>, Option<Uuid>, &mut AppContext) -> WindowOptions,
pub initialize_workspace: fn(
WeakView<Workspace>,
bool,
Arc<AppState>,
AsyncWindowContext,
) -> Task<anyhow::Result<()>>,
pub node_runtime: Arc<dyn NodeRuntime>,
}
@@ -373,7 +367,6 @@ impl AppState {
user_store,
workspace_store,
node_runtime: FakeNodeRuntime::new(),
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
build_window_options: |_, _, _| Default::default(),
})
}
@@ -789,17 +782,17 @@ impl Workspace {
};
// todo!() Ask how to do this
let weak_view = window.update(&mut cx, |_, cx| cx.view().downgrade())?;
let async_cx = window.update(&mut cx, |_, cx| cx.to_async())?;
// let weak_view = window.update(&mut cx, |_, cx| cx.view().downgrade())?;
// let async_cx = window.update(&mut cx, |_, cx| cx.to_async())?;
(app_state.initialize_workspace)(
weak_view,
serialized_workspace.is_some(),
app_state.clone(),
async_cx,
)
.await
.log_err();
// (app_state.initialize_workspace)(
// weak_view,
// serialized_workspace.is_some(),
// app_state.clone(),
// async_cx,
// )
// .await
// .log_err();
window
.update(&mut cx, |_, cx| cx.activate_window())
@@ -3341,7 +3334,6 @@ impl Workspace {
// },
// );
.on_action(|this, e: &ToggleLeftDock, cx| {
println!("TOGGLING DOCK");
this.toggle_dock(DockPosition::Left, cx);
})
// cx.add_action(|workspace: &mut Workspace, _: &ToggleRightDock, cx| {
@@ -3405,7 +3397,6 @@ impl Workspace {
user_store,
fs: project.read(cx).fs().clone(),
build_window_options: |_, _, _| Default::default(),
initialize_workspace: |_, _, _, _| Task::ready(Ok(())),
node_runtime: FakeNodeRuntime::new(),
});
let workspace = Self::new(0, project, app_state, cx);