Change summary
crates/gpui/playground/ui/src/node.rs | 5 +++++
crates/gpui/src/app/window.rs | 9 +++++++--
2 files changed, 12 insertions(+), 2 deletions(-)
Detailed changes
@@ -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 (),
@@ -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