Add View::update which provides a ViewContext

This commit is contained in:
Nathan Sobo 2023-10-26 19:41:42 +02:00
parent 8e3314e680
commit a1c3826858
17 changed files with 403 additions and 247 deletions

View file

@ -1,6 +1,6 @@
use std::path::PathBuf;
use gpui2::{view, Context, View};
use gpui2::{AppContext, Context, View};
use crate::prelude::*;
use crate::{
@ -20,7 +20,7 @@ pub struct EditorPane {
impl EditorPane {
pub fn new(
cx: &mut WindowContext,
cx: &mut AppContext,
tabs: Vec<Tab>,
path: PathBuf,
symbols: Vec<Symbol>,
@ -42,11 +42,12 @@ impl EditorPane {
cx.notify();
}
pub fn view(cx: &mut WindowContext) -> View<Self> {
view(
cx.entity(|cx| hello_world_rust_editor_with_status_example(cx)),
Self::render,
)
pub fn view(cx: &mut AppContext) -> View<Self> {
{
let state = cx.entity(|cx| hello_world_rust_editor_with_status_example(cx));
let render = Self::render;
View::for_handle(state, render)
}
}
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Component<Self> {