Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

WIP

Nathan Sobob6110fed9e78
diff --git a/crates/gpui/playground/ui/src/node.rs b/crates/gpui/playground/ui/src/node.rs
index 979b2f84157..9cea0aa0439 100644
--- a/crates/gpui/playground/ui/src/node.rs
+++ b/crates/gpui/playground/ui/src/node.rs
@@ -1528,6 +1528,11 @@ mod tests {
});
});
+ window.update(cx, |cx| {
+ let root = cx.root_element();
+ dbg!(root.debug(cx).unwrap());
+ });
+
// tree.layout(
// SizeConstraint::strict(vec2f(100., 100.)),
// &mut (),
diff --git a/crates/gpui/src/app/window.rs b/crates/gpui/src/app/window.rs
index 14728ae1b41..4a00e529823 100644
--- a/crates/gpui/src/app/window.rs
+++ b/crates/gpui/src/app/window.rs
@@ -923,7 +923,7 @@ impl<'a> WindowContext<'a> {
Ok(element)
}
- pub(crate) fn layout(&mut self, refreshing: bool) -> Result<HashMap<usize, usize>> {
+ pub fn layout(&mut self, refreshing: bool) -> Result<HashMap<usize, usize>> {
let window_size = self.window.platform_window.content_size();
let root_view_id = self.window.root_view().id();
let mut rendered_root = self.window.rendered_views.remove(&root_view_id).unwrap();
@@ -963,7 +963,7 @@ impl<'a> WindowContext<'a> {
Ok(old_parents)
}
- pub(crate) fn paint(&mut self) -> Result<Scene> {
+ pub fn paint(&mut self) -> Result<Scene> {
let window_size = self.window.platform_window.content_size();
let scale_factor = self.window.platform_window.scale_factor();
@@ -995,6 +995,11 @@ impl<'a> WindowContext<'a> {
Ok(scene)
}
+ pub fn root_element(&self) -> &Box<dyn AnyRootElement> {
+ let view_id = self.window.root_view().id();
+ self.window.rendered_views.get(&view_id).unwrap()
+ }
+
pub fn rect_for_text_range(&self, range_utf16: Range<usize>) -> Option<RectF> {
let focused_view_id = self.window.focused_view_id?;
self.window