mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 13:24:19 +00:00
WIP
This commit is contained in:
parent
c3dda14490
commit
d0a5bc694c
1 changed files with 67 additions and 2 deletions
|
@ -1,4 +1,8 @@
|
||||||
use crate::sum_tree::{self, SumTree};
|
use crate::{
|
||||||
|
geometry::{rect::RectF, vector::Vector2F},
|
||||||
|
sum_tree::{self, SumTree},
|
||||||
|
Element,
|
||||||
|
};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
|
@ -12,7 +16,7 @@ pub struct ListState(Arc<Mutex<StateInner>>);
|
||||||
|
|
||||||
struct StateInner {
|
struct StateInner {
|
||||||
elements: Vec<ElementBox>,
|
elements: Vec<ElementBox>,
|
||||||
element_heights: SumTree<ElementHeight>,
|
heights: SumTree<ElementHeight>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
@ -27,6 +31,67 @@ struct ElementHeightSummary {
|
||||||
height: f32,
|
height: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Element for List {
|
||||||
|
type LayoutState = ();
|
||||||
|
|
||||||
|
type PaintState = ();
|
||||||
|
|
||||||
|
fn layout(
|
||||||
|
&mut self,
|
||||||
|
constraint: crate::SizeConstraint,
|
||||||
|
cx: &mut crate::LayoutContext,
|
||||||
|
) -> (Vector2F, Self::LayoutState) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn after_layout(
|
||||||
|
&mut self,
|
||||||
|
size: Vector2F,
|
||||||
|
layout: &mut Self::LayoutState,
|
||||||
|
cx: &mut crate::AfterLayoutContext,
|
||||||
|
) {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn paint(
|
||||||
|
&mut self,
|
||||||
|
bounds: RectF,
|
||||||
|
layout: &mut Self::LayoutState,
|
||||||
|
cx: &mut crate::PaintContext,
|
||||||
|
) -> Self::PaintState {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn dispatch_event(
|
||||||
|
&mut self,
|
||||||
|
event: &crate::Event,
|
||||||
|
bounds: RectF,
|
||||||
|
layout: &mut Self::LayoutState,
|
||||||
|
paint: &mut Self::PaintState,
|
||||||
|
cx: &mut crate::EventContext,
|
||||||
|
) -> bool {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn debug(
|
||||||
|
&self,
|
||||||
|
bounds: RectF,
|
||||||
|
layout: &Self::LayoutState,
|
||||||
|
paint: &Self::PaintState,
|
||||||
|
cx: &crate::DebugContext,
|
||||||
|
) -> serde_json::Value {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ListState {
|
||||||
|
pub fn new(elements: Vec<ElementBox>) -> Self {
|
||||||
|
let mut heights = SumTree::new();
|
||||||
|
heights.extend(elements.iter().map(|_| ElementHeight::Pending), &());
|
||||||
|
Self(Arc::new(Mutex::new(StateInner { elements, heights })))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl sum_tree::Item for ElementHeight {
|
impl sum_tree::Item for ElementHeight {
|
||||||
type Summary = ElementHeightSummary;
|
type Summary = ElementHeightSummary;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue