WIP
This commit is contained in:
parent
ca35573ad5
commit
2044ccdc0b
4 changed files with 27 additions and 17 deletions
|
@ -41,6 +41,14 @@ pub fn derive_element(input: TokenStream) -> TokenStream {
|
|||
let (impl_generics, ty_generics, where_clause) = ast.generics.split_for_impl();
|
||||
|
||||
let gen = quote! {
|
||||
impl #impl_generics gpui3::IntoAnyElement<#state_type> for #type_name #ty_generics
|
||||
#where_clause
|
||||
{
|
||||
fn into_any(self) -> gpui3::AnyElement<#state_type> {
|
||||
gpui3::AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl #impl_generics gpui3::Element for #type_name #ty_generics
|
||||
#where_clause
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::marker::PhantomData;
|
||||
|
||||
use gpui3::{div, Div, Hsla, WindowContext};
|
||||
use gpui3::{div, Div};
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::theme::theme;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
use std::marker::PhantomData;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use std::sync::{Arc, OnceLock};
|
||||
|
||||
|
@ -116,7 +115,7 @@ pub struct Workspace {
|
|||
bottom_panel_scroll_state: ScrollState,
|
||||
}
|
||||
|
||||
fn workspace<P: 'static>(cx: &mut WindowContext) -> View<Workspace> {
|
||||
fn workspace(cx: &mut WindowContext) -> View<Workspace> {
|
||||
view(cx.entity(|cx| Workspace::new()), Workspace::render)
|
||||
}
|
||||
|
||||
|
@ -372,23 +371,16 @@ pub use stories::*;
|
|||
mod stories {
|
||||
use super::*;
|
||||
|
||||
// #[derive(Element)]
|
||||
// pub struct WorkspaceStory<S: 'static + Send + Sync + Clone> {
|
||||
// state_type: PhantomData<S>,
|
||||
// }
|
||||
|
||||
pub struct WorkspaceStory {
|
||||
workspace: View<Workspace>,
|
||||
}
|
||||
|
||||
pub fn workspace_story(cx: &mut WindowContext) -> View<WorkspaceStory> {
|
||||
todo!()
|
||||
// let workspace = workspace::<P>(cx);
|
||||
// view(
|
||||
// cx.entity(|cx| WorkspaceStory {
|
||||
// workspace,
|
||||
// }),
|
||||
// |view, cx| view.workspace.clone(),
|
||||
// )
|
||||
view(
|
||||
cx.entity(|cx| WorkspaceStory {
|
||||
workspace: workspace(cx),
|
||||
}),
|
||||
|view, cx| view.workspace.clone(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@ use std::fmt;
|
|||
use std::sync::Arc;
|
||||
|
||||
use gpui3::{
|
||||
BorrowAppContext, Bounds, Element, Hsla, LayoutId, Pixels, Result, ViewContext, WindowContext,
|
||||
AnyElement, BorrowAppContext, Bounds, Element, Hsla, IntoAnyElement, LayoutId, Pixels, Result,
|
||||
ViewContext, WindowContext,
|
||||
};
|
||||
use serde::{de::Visitor, Deserialize, Deserializer};
|
||||
|
||||
|
@ -146,6 +147,15 @@ pub struct Themed<E> {
|
|||
pub(crate) child: E,
|
||||
}
|
||||
|
||||
impl<E> IntoAnyElement<E::ViewState> for Themed<E>
|
||||
where
|
||||
E: Element,
|
||||
{
|
||||
fn into_any(self) -> AnyElement<E::ViewState> {
|
||||
AnyElement::new(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Element> Element for Themed<E> {
|
||||
type ViewState = E::ViewState;
|
||||
type ElementState = E::ElementState;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue