Checkpoint
This commit is contained in:
@@ -3,7 +3,7 @@ use std::{any::Any, collections::HashMap, marker::PhantomData};
|
||||
|
||||
use super::{
|
||||
window::{Window, WindowHandle, WindowId},
|
||||
Context, EntityId, LayoutId, Reference, View, WindowContext,
|
||||
Context, LayoutId, Reference, View, WindowContext,
|
||||
};
|
||||
|
||||
pub struct AppContext {
|
||||
@@ -135,6 +135,17 @@ pub struct Handle<T> {
|
||||
pub(crate) entity_type: PhantomData<T>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
|
||||
pub struct EntityId(usize);
|
||||
|
||||
impl EntityId {
|
||||
pub fn new(entity_count: &mut usize) -> EntityId {
|
||||
let id = *entity_count;
|
||||
*entity_count += 1;
|
||||
Self(id)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> Handle<T> {
|
||||
fn new(id: EntityId) -> Self {
|
||||
Self {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use anyhow::Result;
|
||||
|
||||
use super::{Element, IntoAnyElement, Layout, LayoutId, ParentElement, ViewContext};
|
||||
|
||||
pub struct Div<S>(PhantomData<S>);
|
||||
|
||||
impl<S: 'static> Element for Div<S> {
|
||||
type State = S;
|
||||
type FrameState = ();
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
state: &mut Self::State,
|
||||
cx: &mut ViewContext<Self::State>,
|
||||
) -> Result<(LayoutId, Self::FrameState)> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
layout: Layout,
|
||||
state: &mut Self::State,
|
||||
frame_state: &mut Self::FrameState,
|
||||
cx: &mut ViewContext<Self::State>,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> ParentElement<S> for Div<S> {
|
||||
fn child(self, child: impl IntoAnyElement<S>) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn div<S>() -> Div<S> {
|
||||
todo!()
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
mod app;
|
||||
mod element;
|
||||
mod elements;
|
||||
mod geometry;
|
||||
mod style;
|
||||
mod taffy;
|
||||
@@ -12,22 +13,12 @@ use std::marker::PhantomData;
|
||||
|
||||
pub use app::*;
|
||||
pub use element::*;
|
||||
pub use elements::*;
|
||||
pub use geometry::*;
|
||||
pub use style::*;
|
||||
use taffy::TaffyLayoutEngine;
|
||||
pub use window::*;
|
||||
|
||||
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
|
||||
pub struct EntityId(usize);
|
||||
|
||||
impl EntityId {
|
||||
fn new(entity_count: &mut usize) -> EntityId {
|
||||
let id = *entity_count;
|
||||
*entity_count += 1;
|
||||
Self(id)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait Context {
|
||||
type EntityContext<'a, 'w, T: 'static>;
|
||||
|
||||
@@ -43,41 +34,6 @@ pub trait Context {
|
||||
) -> R;
|
||||
}
|
||||
|
||||
pub struct Div<S>(PhantomData<S>);
|
||||
|
||||
impl<S: 'static> Element for Div<S> {
|
||||
type State = S;
|
||||
type FrameState = ();
|
||||
|
||||
fn layout(
|
||||
&mut self,
|
||||
state: &mut Self::State,
|
||||
cx: &mut ViewContext<Self::State>,
|
||||
) -> Result<(LayoutId, Self::FrameState)> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn paint(
|
||||
&mut self,
|
||||
layout: Layout,
|
||||
state: &mut Self::State,
|
||||
frame_state: &mut Self::FrameState,
|
||||
cx: &mut ViewContext<Self::State>,
|
||||
) -> Result<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> ParentElement<S> for Div<S> {
|
||||
fn child(self, child: impl IntoAnyElement<S>) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn div<S>() -> Div<S> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
pub struct SharedString(ArcCow<'static, str>);
|
||||
|
||||
impl<T: Into<ArcCow<'static, str>>> From<T> for SharedString {
|
||||
|
||||
Reference in New Issue
Block a user