diff --git a/crates/story/examples/dock.rs b/crates/story/examples/dock.rs index 4e36d60c..56a17eef 100644 --- a/crates/story/examples/dock.rs +++ b/crates/story/examples/dock.rs @@ -404,7 +404,7 @@ impl StoryWorkspace { let window = cx.open_window(options, |window, cx| { let story_view = cx.new(|cx| StoryWorkspace::new(window, cx)); - cx.new(|cx| Root::new(story_view.into(), window, cx)) + cx.new(|cx| Root::new(story_view, window, cx)) })?; window diff --git a/crates/story/examples/tiles.rs b/crates/story/examples/tiles.rs index 414522a2..b6b6a32b 100644 --- a/crates/story/examples/tiles.rs +++ b/crates/story/examples/tiles.rs @@ -379,7 +379,7 @@ impl StoryTiles { let window = cx.open_window(options, |window, cx| { let tiles_view = cx.new(|cx| Self::new(window, cx)); - cx.new(|cx| Root::new(tiles_view.into(), window, cx)) + cx.new(|cx| Root::new(tiles_view, window, cx)) })?; window diff --git a/crates/story/src/lib.rs b/crates/story/src/lib.rs index a519237d..11452711 100644 --- a/crates/story/src/lib.rs +++ b/crates/story/src/lib.rs @@ -224,7 +224,7 @@ pub fn create_new_window_with_size( let view = crate_view_fn(window, cx); let root = cx.new(|cx| StoryRoot::new(title.clone(), view, window, cx)); - cx.new(|cx| Root::new(root.into(), window, cx)) + cx.new(|cx| Root::new(root, window, cx)) }) .expect("failed to open window"); diff --git a/crates/ui/src/root.rs b/crates/ui/src/root.rs index f17d7470..015eca2f 100644 --- a/crates/ui/src/root.rs +++ b/crates/ui/src/root.rs @@ -235,7 +235,8 @@ pub(crate) struct ActiveDialog { } impl Root { - pub fn new(view: AnyView, window: &mut Window, cx: &mut Context) -> Self { + /// Create a new Root view. + pub fn new(view: impl Into, window: &mut Window, cx: &mut Context) -> Self { Self { previous_focus_handle: None, active_sheet: None, @@ -243,7 +244,7 @@ impl Root { focused_input: None, notification: cx.new(|cx| NotificationList::new(window, cx)), sheet_size: None, - view, + view: view.into(), } } diff --git a/examples/app_assets/src/main.rs b/examples/app_assets/src/main.rs index aaabc151..9626c463 100644 --- a/examples/app_assets/src/main.rs +++ b/examples/app_assets/src/main.rs @@ -54,7 +54,7 @@ fn main() { cx.open_window(WindowOptions::default(), |window, cx| { let view = cx.new(|_| Example); // The first level on the window must be Root. - cx.new(|cx| Root::new(view.into(), window, cx)) + cx.new(|cx| Root::new(view, window, cx)) })?; Ok::<_, anyhow::Error>(())