Checkpoint
This commit is contained in:
@@ -12,6 +12,7 @@ path = "src/storybook.rs"
|
||||
anyhow.workspace = true
|
||||
derive_more.workspace = true
|
||||
gpui2 = { path = "../gpui2" }
|
||||
itertools = "0.11.0"
|
||||
log.workspace = true
|
||||
refineable = { path = "../refineable" }
|
||||
rust-embed.workspace = true
|
||||
|
||||
@@ -3,26 +3,28 @@ mod color;
|
||||
mod element;
|
||||
mod elements;
|
||||
mod geometry;
|
||||
mod ordered;
|
||||
mod scene;
|
||||
mod style;
|
||||
mod taffy;
|
||||
mod window;
|
||||
|
||||
use self::editor::Editor;
|
||||
use anyhow::Result;
|
||||
pub use gpui2::ArcCow;
|
||||
use gpui2::Reference;
|
||||
|
||||
pub use app::*;
|
||||
pub use color::*;
|
||||
pub use element::*;
|
||||
pub use elements::*;
|
||||
pub use geometry::*;
|
||||
pub use gpui2::ArcCow;
|
||||
use gpui2::Reference;
|
||||
use ordered::*;
|
||||
pub use scene::*;
|
||||
pub use style::*;
|
||||
pub use taffy::LayoutId;
|
||||
use taffy::TaffyLayoutEngine;
|
||||
pub use window::*;
|
||||
|
||||
use self::editor::Editor;
|
||||
|
||||
pub trait Context {
|
||||
type EntityContext<'a, 'w, T: 'static>;
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
pub struct Ordered<P> {
|
||||
pub order: u32,
|
||||
pub primitive: P,
|
||||
}
|
||||
|
||||
impl<P> Ord for Ordered<P> {
|
||||
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
|
||||
self.order.cmp(&other.order)
|
||||
}
|
||||
}
|
||||
|
||||
impl<P> PartialOrd for Ordered<P> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
impl<P> Eq for Ordered<P> {}
|
||||
|
||||
impl<P> PartialEq for Ordered<P> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.order == other.order
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
use super::Ordered;
|
||||
|
||||
/// A platform neutral representation of all geometry to be drawn for the current frame.
|
||||
pub struct Scene {
|
||||
quads: Vec<Ordered<Quad>>,
|
||||
glyphs: Vec<Ordered<Glyph>>,
|
||||
}
|
||||
|
||||
impl Scene {
|
||||
pub fn new() -> Self {
|
||||
Scene {
|
||||
quads: Vec::new(),
|
||||
glyphs: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add(&mut self, order: u32, primitive: impl Into<Primitive>) {
|
||||
match primitive.into() {
|
||||
Primitive::Quad(primitive) => self.quads.push(Ordered { order, primitive }),
|
||||
Primitive::Glyph(primitive) => self.glyphs.push(Ordered { order, primitive }),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw(&mut self) {
|
||||
self.quads.sort_unstable();
|
||||
self.glyphs.sort_unstable();
|
||||
}
|
||||
}
|
||||
|
||||
pub enum Primitive {
|
||||
Quad(Quad),
|
||||
Glyph(Glyph),
|
||||
// Icon(Icon),
|
||||
// Image(Image),
|
||||
// Shadow(Shadow),
|
||||
// Curve(Curve),
|
||||
}
|
||||
|
||||
#[derive(Eq, Ord, PartialEq, PartialOrd)]
|
||||
pub struct Quad {}
|
||||
pub struct Glyph {}
|
||||
// pub struct Icon {}
|
||||
// pub struct Image {}
|
||||
// pub struct Shadow {}
|
||||
// pub struct Curve {}
|
||||
Reference in New Issue
Block a user