Checkpoint

This commit is contained in:
Nathan Sobo
2023-09-14 15:34:39 -06:00
parent c74c60a629
commit cee5ddee53
2 changed files with 21 additions and 5 deletions
+7 -4
View File
@@ -23,15 +23,18 @@ impl AppContext {
}
}
pub fn open_window<S>(
pub fn open_window<S: 'static>(
&mut self,
build_root_view: impl FnOnce(&mut WindowContext) -> View<S>,
) -> WindowHandle<S> {
// let window = self.windows.insert_with_key(|id| {
let id = self.windows.insert(None);
// });
let mut window = Window::new(id);
let root_view = build_root_view(&mut WindowContext::mutable(self, &mut window));
window.root_view.replace(Box::new(root_view));
unimplemented!()
self.windows.get_mut(id).unwrap().replace(window);
WindowHandle::new(id)
}
pub(crate) fn update_window<R>(
+14 -1
View File
@@ -2,12 +2,15 @@ use super::{px, AppContext, Bounds, Context, EntityId, Handle, Pixels, Style, Ta
use anyhow::Result;
use derive_more::{Deref, DerefMut};
use gpui2::Reference;
use std::marker::PhantomData;
use std::{any::Any, marker::PhantomData};
pub struct AnyWindow {}
pub struct Window {
id: WindowId,
rem_size: Pixels,
layout_engine: Box<dyn LayoutEngine>,
pub(crate) root_view: Option<Box<dyn Any>>,
}
impl Window {
@@ -16,6 +19,7 @@ impl Window {
id,
layout_engine: Box::new(TaffyLayoutEngine::new()),
rem_size: px(16.),
root_view: None,
}
}
}
@@ -198,6 +202,15 @@ pub struct WindowHandle<S> {
state_type: PhantomData<S>,
}
impl<S> WindowHandle<S> {
pub fn new(id: WindowId) -> Self {
WindowHandle {
id,
state_type: PhantomData,
}
}
}
#[derive(Clone)]
pub struct Layout {
pub order: u32,