Checkpoint

This commit is contained in:
Nathan Sobo
2023-09-14 21:42:56 -06:00
parent 4fd4f44bb7
commit 0a2a5be71c
5 changed files with 100 additions and 18 deletions
+1
View File
@@ -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
+7 -5
View File
@@ -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>;
+24
View File
@@ -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
}
}
+45
View File
@@ -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 {}