Compiling checkpoint
This commit is contained in:
parent
76993f6b57
commit
0747131bd4
11 changed files with 262 additions and 48 deletions
|
@ -3392,7 +3392,8 @@ pub trait RenderContext<'a, 'b, V> {
|
|||
}
|
||||
|
||||
pub struct LayoutContext<'a, 'b, 'c, V> {
|
||||
view_context: &'c mut ViewContext<'a, 'b, V>,
|
||||
// Nathan: Making this is public while I work on playground.
|
||||
pub view_context: &'c mut ViewContext<'a, 'b, V>,
|
||||
new_parents: &'c mut HashMap<usize, usize>,
|
||||
views_to_notify_if_ancestors_change: &'c mut HashMap<usize, SmallVec<[usize; 2]>>,
|
||||
text_style_stack: Vec<TextStyle>,
|
||||
|
@ -3643,6 +3644,9 @@ impl<V> BorrowWindowContext for PaintContext<'_, '_, '_, V> {
|
|||
pub struct EventContext<'a, 'b, 'c, V> {
|
||||
view_context: &'c mut ViewContext<'a, 'b, V>,
|
||||
pub(crate) handled: bool,
|
||||
// I would like to replace handled with this.
|
||||
// Being additive for now.
|
||||
pub bubble: bool,
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'c, V: 'static> EventContext<'a, 'b, 'c, V> {
|
||||
|
@ -3650,12 +3654,21 @@ impl<'a, 'b, 'c, V: 'static> EventContext<'a, 'b, 'c, V> {
|
|||
EventContext {
|
||||
view_context,
|
||||
handled: true,
|
||||
bubble: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn propagate_event(&mut self) {
|
||||
self.handled = false;
|
||||
}
|
||||
|
||||
pub fn bubble_event(&mut self) {
|
||||
self.bubble = true;
|
||||
}
|
||||
|
||||
pub fn event_bubbled(&self) -> bool {
|
||||
self.bubble
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b, 'c, V> Deref for EventContext<'a, 'b, 'c, V> {
|
||||
|
|
|
@ -1293,16 +1293,16 @@ impl LayoutEngine {
|
|||
Default::default()
|
||||
}
|
||||
|
||||
pub fn add_node<C>(&mut self, style: LayoutStyle, children: C) -> Result<LayoutNodeId>
|
||||
pub fn add_node<C>(&mut self, style: LayoutStyle, children: C) -> Result<LayoutId>
|
||||
where
|
||||
C: IntoIterator<Item = LayoutNodeId>,
|
||||
C: IntoIterator<Item = LayoutId>,
|
||||
{
|
||||
Ok(self
|
||||
.0
|
||||
.new_with_children(style, &children.into_iter().collect::<Vec<_>>())?)
|
||||
}
|
||||
|
||||
pub fn add_measured_node<F>(&mut self, style: LayoutStyle, measure: F) -> Result<LayoutNodeId>
|
||||
pub fn add_measured_node<F>(&mut self, style: LayoutStyle, measure: F) -> Result<LayoutId>
|
||||
where
|
||||
F: Fn(MeasureParams) -> Size<f32> + Sync + Send + 'static,
|
||||
{
|
||||
|
@ -1311,7 +1311,7 @@ impl LayoutEngine {
|
|||
.new_leaf_with_measure(style, MeasureFunc::Boxed(Box::new(MeasureFn(measure))))?)
|
||||
}
|
||||
|
||||
pub fn compute_layout(&mut self, root: LayoutNodeId, available_space: Vector2F) -> Result<()> {
|
||||
pub fn compute_layout(&mut self, root: LayoutId, available_space: Vector2F) -> Result<()> {
|
||||
self.0.compute_layout(
|
||||
root,
|
||||
taffy::geometry::Size {
|
||||
|
@ -1322,7 +1322,7 @@ impl LayoutEngine {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn computed_layout(&mut self, node: LayoutNodeId) -> Result<EngineLayout> {
|
||||
pub fn computed_layout(&mut self, node: LayoutId) -> Result<EngineLayout> {
|
||||
Ok(self.0.layout(node)?.into())
|
||||
}
|
||||
}
|
||||
|
@ -1346,7 +1346,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct EngineLayout {
|
||||
pub bounds: RectF,
|
||||
pub order: u32,
|
||||
|
@ -1367,6 +1367,12 @@ pub enum AvailableSpace {
|
|||
MaxContent,
|
||||
}
|
||||
|
||||
impl Default for AvailableSpace {
|
||||
fn default() -> Self {
|
||||
Self::Pixels(0.)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<taffy::prelude::AvailableSpace> for AvailableSpace {
|
||||
fn from(value: taffy::prelude::AvailableSpace) -> Self {
|
||||
match value {
|
||||
|
@ -1389,7 +1395,7 @@ impl From<&taffy::tree::Layout> for EngineLayout {
|
|||
}
|
||||
}
|
||||
|
||||
pub type LayoutNodeId = taffy::prelude::NodeId;
|
||||
pub type LayoutId = taffy::prelude::NodeId;
|
||||
|
||||
pub struct RenderParams {
|
||||
pub view_id: usize,
|
||||
|
|
|
@ -134,12 +134,12 @@ impl ToJson for RectF {
|
|||
}
|
||||
|
||||
#[derive(Refineable)]
|
||||
pub struct Point<T: Clone> {
|
||||
pub struct Point<T: Clone + Default> {
|
||||
pub x: T,
|
||||
pub y: T,
|
||||
}
|
||||
|
||||
impl<T: Clone> Clone for Point<T> {
|
||||
impl<T: Clone + Default> Clone for Point<T> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
x: self.x.clone(),
|
||||
|
@ -148,7 +148,7 @@ impl<T: Clone> Clone for Point<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Clone> Into<taffy::geometry::Point<T>> for Point<T> {
|
||||
impl<T: Clone + Default> Into<taffy::geometry::Point<T>> for Point<T> {
|
||||
fn into(self) -> taffy::geometry::Point<T> {
|
||||
taffy::geometry::Point {
|
||||
x: self.x,
|
||||
|
@ -158,12 +158,12 @@ impl<T: Clone> Into<taffy::geometry::Point<T>> for Point<T> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Refineable)]
|
||||
pub struct Size<T: Clone> {
|
||||
pub struct Size<T: Clone + Default> {
|
||||
pub width: T,
|
||||
pub height: T,
|
||||
}
|
||||
|
||||
impl<S, T: Clone> From<taffy::geometry::Size<S>> for Size<T>
|
||||
impl<S, T: Clone + Default> From<taffy::geometry::Size<S>> for Size<T>
|
||||
where
|
||||
S: Into<T>,
|
||||
{
|
||||
|
@ -175,7 +175,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<S, T: Clone> Into<taffy::geometry::Size<S>> for Size<T>
|
||||
impl<S, T: Clone + Default> Into<taffy::geometry::Size<S>> for Size<T>
|
||||
where
|
||||
T: Into<S>,
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ impl Size<Length> {
|
|||
}
|
||||
|
||||
#[derive(Clone, Default, Refineable)]
|
||||
pub struct Edges<T: Clone> {
|
||||
pub struct Edges<T: Clone + Default> {
|
||||
pub top: T,
|
||||
pub right: T,
|
||||
pub bottom: T,
|
||||
|
|
|
@ -28,7 +28,7 @@ pub mod keymap_matcher;
|
|||
pub mod platform;
|
||||
pub use gpui_macros::{test, Element};
|
||||
pub use window::{
|
||||
Axis, EngineLayout, LayoutEngine, LayoutNodeId, RectFExt, SizeConstraint, Vector2FExt,
|
||||
Axis, EngineLayout, LayoutEngine, LayoutId, RectFExt, SizeConstraint, Vector2FExt,
|
||||
WindowContext,
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue