diff --git a/crates/gpui3/src/app.rs b/crates/gpui3/src/app.rs index 5981754a28..a6f83a6fc7 100644 --- a/crates/gpui3/src/app.rs +++ b/crates/gpui3/src/app.rs @@ -230,19 +230,16 @@ impl AppContext { } fn update(&mut self, update: impl FnOnce(&mut Self) -> R) -> R { - dbg!("update"); self.pending_updates += 1; let result = update(self); - self.pending_updates -= 1; - if self.pending_updates == 0 { + if self.pending_updates == 1 { self.flush_effects(); } + self.pending_updates -= 1; result } fn flush_effects(&mut self) { - dbg!("Flush effects"); - while let Some(effect) = self.pending_effects.pop_front() { match effect { Effect::Notify(entity_id) => self.apply_notify_effect(entity_id), @@ -319,16 +316,16 @@ impl AppContext { options: crate::WindowOptions, build_root_view: impl FnOnce(&mut WindowContext) -> RootView + Send + 'static, ) -> WindowHandle { - let id = self.windows.insert(None); - let handle = WindowHandle::new(id); - let mut window = Window::new(handle.into(), options, self); - let root_view = build_root_view(&mut WindowContext::mutable( - self.downcast_mut(), - &mut window, - )); - window.root_view.replace(root_view.into_any()); - self.windows.get_mut(id).unwrap().replace(window); - handle + self.update(|cx| { + let id = cx.windows.insert(None); + let handle = WindowHandle::new(id); + let mut window = Window::new(handle.into(), options, cx); + let root_view = + build_root_view(&mut WindowContext::mutable(cx.downcast_mut(), &mut window)); + window.root_view.replace(root_view.into_any()); + cx.windows.get_mut(id).unwrap().replace(window); + handle + }) } } diff --git a/crates/gpui3/src/platform/mac/metal_renderer.rs b/crates/gpui3/src/platform/mac/metal_renderer.rs index cb76feae14..db7311a9e4 100644 --- a/crates/gpui3/src/platform/mac/metal_renderer.rs +++ b/crates/gpui3/src/platform/mac/metal_renderer.rs @@ -228,7 +228,6 @@ impl MetalRenderer { "instance buffer exhausted" ); - dbg!(quads.len()); command_encoder.draw_primitives_instanced( metal::MTLPrimitiveType::Triangle, 0, diff --git a/crates/gpui3/src/view.rs b/crates/gpui3/src/view.rs index 218ca1c4f4..7b510c6674 100644 --- a/crates/gpui3/src/view.rs +++ b/crates/gpui3/src/view.rs @@ -59,7 +59,6 @@ impl Element for View { _: &mut Self::State, cx: &mut ViewContext, ) -> Result<(LayoutId, Self::FrameState)> { - dbg!("Layout view"); self.state.update(cx, |state, cx| { let mut element = (self.render)(state, cx); let layout_id = element.layout(state, cx)?; @@ -74,7 +73,6 @@ impl Element for View { element: &mut Self::FrameState, cx: &mut ViewContext, ) -> Result<()> { - dbg!("Paint view"); self.state .update(cx, |state, cx| element.paint(state, None, cx)) } @@ -128,11 +126,10 @@ impl Element for AnyView { fn paint( &mut self, layout: Layout, - _: &mut Self::State, - element: &mut Self::FrameState, + _: &mut (), + element: &mut Box, cx: &mut ViewContext, ) -> Result<()> { - dbg!("Element.paint for AnyView"); self.view.lock().paint(layout, element.as_mut(), cx) } } diff --git a/crates/gpui3/src/window.rs b/crates/gpui3/src/window.rs index 129f0d0e3f..85cd5d3311 100644 --- a/crates/gpui3/src/window.rs +++ b/crates/gpui3/src/window.rs @@ -128,7 +128,6 @@ impl<'a, 'w> WindowContext<'a, 'w> { } pub(crate) fn draw(&mut self) -> Result<()> { - dbg!("Draw"); let unit_entity = self.unit_entity.clone(); self.update_entity(&unit_entity, |_, cx| { let mut root_view = cx.window.root_view.take().unwrap(); @@ -138,14 +137,13 @@ impl<'a, 'w> WindowContext<'a, 'w> { .layout_engine .compute_layout(root_layout_id, available_space)?; let layout = cx.window.layout_engine.layout(root_layout_id)?; - dbg!("Paint root view"); root_view.paint(layout, &mut (), &mut frame_state, cx)?; cx.window.root_view = Some(root_view); let scene = cx.window.scene.take(); dbg!(&scene); - // todo! + // // todo! // self.run_on_main(|cx| { // cx.window // .platform_window diff --git a/crates/storybook2/src/storybook2.rs b/crates/storybook2/src/storybook2.rs index b119c56a20..4e93b75ef4 100644 --- a/crates/storybook2/src/storybook2.rs +++ b/crates/storybook2/src/storybook2.rs @@ -20,26 +20,21 @@ fn main() { SimpleLogger::init(LevelFilter::Info, Default::default()).expect("could not initialize logger"); gpui3::App::production().run(|cx| { - cx.run_on_main(|cx| { - dbg!("Run on main"); - let window = cx.open_window( - WindowOptions { - bounds: WindowBounds::Fixed(Bounds { - size: gpui3::Size { - width: 800_f32.into(), - height: 600_f32.into(), - }, - ..Default::default() - }), + let window = cx.open_window( + WindowOptions { + bounds: WindowBounds::Fixed(Bounds { + size: gpui3::Size { + width: 800_f32.into(), + height: 600_f32.into(), + }, ..Default::default() - }, - |cx| { - dbg!("in build_root_view"); - workspace(cx) - }, - ); - cx.activate(true); - }); + }), + ..Default::default() + }, + |cx| workspace(cx), + ); + + cx.activate(true); }); } diff --git a/crates/storybook2/src/workspace.rs b/crates/storybook2/src/workspace.rs index 3385410e49..19b3711db5 100644 --- a/crates/storybook2/src/workspace.rs +++ b/crates/storybook2/src/workspace.rs @@ -19,7 +19,6 @@ pub fn workspace(cx: &mut WindowContext) -> RootView { impl Workspace { fn new(cx: &mut ViewContext) -> Self { - dbg!("Workspace::new"); Self { left_panel: collab_panel(cx), right_panel: collab_panel(cx), @@ -28,9 +27,7 @@ impl Workspace { fn render(&mut self, cx: &mut ViewContext) -> impl Element { let theme = rose_pine_dawn(); - - dbg!("Render workspace"); - div() + div().fill(theme.middle.positive.default.background) // TODO: Implement style. //.size_full().fill(gpui3::hsla(0.83, 1., 0.5, 1.))