root: Improve new method argument to use into <AnyView>. (#1594)
This commit is contained in:
parent
cf6d6b71a3
commit
69b21142dc
5 changed files with 7 additions and 6 deletions
|
|
@ -404,7 +404,7 @@ impl StoryWorkspace {
|
||||||
|
|
||||||
let window = cx.open_window(options, |window, cx| {
|
let window = cx.open_window(options, |window, cx| {
|
||||||
let story_view = cx.new(|cx| StoryWorkspace::new(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
|
window
|
||||||
|
|
|
||||||
|
|
@ -379,7 +379,7 @@ impl StoryTiles {
|
||||||
|
|
||||||
let window = cx.open_window(options, |window, cx| {
|
let window = cx.open_window(options, |window, cx| {
|
||||||
let tiles_view = cx.new(|cx| Self::new(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
|
window
|
||||||
|
|
|
||||||
|
|
@ -224,7 +224,7 @@ pub fn create_new_window_with_size<F, E>(
|
||||||
let view = crate_view_fn(window, cx);
|
let view = crate_view_fn(window, cx);
|
||||||
let root = cx.new(|cx| StoryRoot::new(title.clone(), view, 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");
|
.expect("failed to open window");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -235,7 +235,8 @@ pub(crate) struct ActiveDialog {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Root {
|
impl Root {
|
||||||
pub fn new(view: AnyView, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
/// Create a new Root view.
|
||||||
|
pub fn new(view: impl Into<AnyView>, window: &mut Window, cx: &mut Context<Self>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
previous_focus_handle: None,
|
previous_focus_handle: None,
|
||||||
active_sheet: None,
|
active_sheet: None,
|
||||||
|
|
@ -243,7 +244,7 @@ impl Root {
|
||||||
focused_input: None,
|
focused_input: None,
|
||||||
notification: cx.new(|cx| NotificationList::new(window, cx)),
|
notification: cx.new(|cx| NotificationList::new(window, cx)),
|
||||||
sheet_size: None,
|
sheet_size: None,
|
||||||
view,
|
view: view.into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ fn main() {
|
||||||
cx.open_window(WindowOptions::default(), |window, cx| {
|
cx.open_window(WindowOptions::default(), |window, cx| {
|
||||||
let view = cx.new(|_| Example);
|
let view = cx.new(|_| Example);
|
||||||
// The first level on the window must be Root.
|
// 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>(())
|
Ok::<_, anyhow::Error>(())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue