Unified · Split
| @@ -1,4 +1,6 @@ | ||
| 1 | −use super::{Layout, LayoutId, Pixels, Point, Result, ViewContext}; | |
| 1 | +use crate::Bounds; | |
| 2 | + | |
| 3 | +use super::{LayoutId, Pixels, Point, Result, ViewContext}; | |
| 2 | 4 | pub(crate) use smallvec::SmallVec; |
| 3 | 5 | |
| 4 | 6 | pub trait Element: 'static { |
| @@ -13,7 +15,7 @@ pub trait Element: 'static { · 8 unmodified lines | ||
| 13 | 15 | |
| 14 | 16 | fn paint( |
| 15 | 17 | &mut self, |
| 16 | − layout: Layout, | |
| 18 | + bounds: Bounds<Pixels>, | |
| 17 | 19 | state: &mut Self::State, |
| 18 | 20 | frame_state: &mut Self::FrameState, |
| 19 | 21 | cx: &mut ViewContext<Self::State>, |
| @@ -65,7 +67,7 @@ enum ElementRenderPhase<S> { · 45 unmodified lines | ||
| 65 | 67 | frame_state: S, |
| 66 | 68 | }, |
| 67 | 69 | Painted { |
| 68 | − layout: Layout, | |
| 70 | + bounds: Bounds<Pixels>, | |
| 69 | 71 | frame_state: S, |
| 70 | 72 | }, |
| 71 | 73 | } |
| @@ -105,24 +107,23 @@ impl<E: Element> ElementObject<E::State> for RenderedElement<E> { · 33 unmodified lines | ||
| 105 | 107 | layout_id, |
| 106 | 108 | mut frame_state, |
| 107 | 109 | } => { |
| 108 | − let mut layout = cx.layout(layout_id)?.clone(); | |
| 109 | − offset.map(|offset| layout.bounds.origin += offset); | |
| 110 | − self.element | |
| 111 | − .paint(layout.clone(), state, &mut frame_state, cx)?; | |
| 110 | + let mut bounds = cx.layout_bounds(layout_id)?.clone(); | |
| 111 | + offset.map(|offset| bounds.origin += offset); | |
| 112 | + self.element.paint(bounds, state, &mut frame_state, cx)?; | |
| 112 | 113 | ElementRenderPhase::Painted { |
| 113 | − layout, | |
| 114 | + bounds, | |
| 114 | 115 | frame_state, |
| 115 | 116 | } |
| 116 | 117 | } |
| 117 | 118 | |
| 118 | 119 | ElementRenderPhase::Painted { |
| 119 | − layout, | |
| 120 | + bounds, | |
| 120 | 121 | mut frame_state, |
| 121 | 122 | } => { |
| 122 | 123 | self.element |
| 123 | − .paint(layout.clone(), state, &mut frame_state, cx)?; | |
| 124 | + .paint(bounds.clone(), state, &mut frame_state, cx)?; | |
| 124 | 125 | ElementRenderPhase::Painted { |
| 125 | − layout, | |
| 126 | + bounds, | |
| 126 | 127 | frame_state, |
| 127 | 128 | } |
| 128 | 129 | } |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | − AnyElement, Bounds, Element, Layout, LayoutId, Overflow, ParentElement, Pixels, Point, | |
| 3 | − Refineable, RefinementCascade, Result, Style, StyleHelpers, Styled, ViewContext, | |
| 2 | + AnyElement, Bounds, Element, LayoutId, Overflow, ParentElement, Pixels, Point, Refineable, | |
| 3 | + RefinementCascade, Result, Style, StyleHelpers, Styled, ViewContext, | |
| 4 | 4 | }; |
| 5 | 5 | use parking_lot::Mutex; |
| 6 | 6 | use smallvec::SmallVec; |
| @@ -40,31 +40,28 @@ impl<S: 'static + Send + Sync> Element for Div<S> { · 33 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | fn paint( |
| 42 | 42 | &mut self, |
| 43 | − layout: Layout, | |
| 43 | + bounds: Bounds<Pixels>, | |
| 44 | 44 | state: &mut S, |
| 45 | 45 | child_layouts: &mut Self::FrameState, |
| 46 | 46 | cx: &mut ViewContext<S>, |
| 47 | 47 | ) -> Result<()> { |
| 48 | − let Layout { order, bounds } = layout; | |
| 49 | − | |
| 50 | 48 | let style = self.computed_style(); |
| 51 | − cx.stack(0, |cx| style.paint(order, bounds, cx)); | |
| 49 | + cx.stack(0, |cx| style.paint(bounds, cx)); | |
| 52 | 50 | |
| 53 | 51 | let overflow = &style.overflow; |
| 54 | 52 | style.apply_text_style(cx, |cx| { |
| 55 | 53 | cx.stack(1, |cx| { |
| 56 | − style.apply_overflow(layout.bounds, cx, |cx| { | |
| 57 | − self.paint_children(overflow, state, cx) | |
| 58 | − }) | |
| 54 | + style.apply_overflow(bounds, cx, |cx| self.paint_children(overflow, state, cx)) | |
| 59 | 55 | }) |
| 60 | 56 | })?; |
| 61 | − self.handle_scroll(order, bounds, style.overflow.clone(), child_layouts, cx); | |
| 57 | + self.handle_scroll(bounds, style.overflow.clone(), child_layouts, cx); | |
| 62 | 58 | |
| 63 | 59 | // todo!("enable inspector") |
| 64 | 60 | // if cx.is_inspector_enabled() { |
| 65 | 61 | // self.paint_inspector(parent_origin, layout, cx); |
| 66 | 62 | // } |
| 67 | 63 | // |
| 64 | + | |
| 68 | 65 | Ok(()) |
| 69 | 66 | } |
| 70 | 67 | } |
| @@ -139,7 +136,6 @@ impl<S: 'static> Div<S> { · 68 unmodified lines | ||
| 139 | 136 | |
| 140 | 137 | fn handle_scroll( |
| 141 | 138 | &mut self, |
| 142 | − _order: u32, | |
| 143 | 139 | bounds: Bounds<Pixels>, |
| 144 | 140 | overflow: Point<Overflow>, |
| 145 | 141 | child_layout_ids: &[LayoutId], |
| @@ -148,8 +144,8 @@ impl<S: 'static> Div<S> { · 2 unmodified lines | ||
| 148 | 144 | if overflow.y == Overflow::Scroll || overflow.x == Overflow::Scroll { |
| 149 | 145 | let mut scroll_max = Point::default(); |
| 150 | 146 | for child_layout_id in child_layout_ids { |
| 151 | − if let Some(child_layout) = cx.layout(*child_layout_id).log_err() { | |
| 152 | − scroll_max = scroll_max.max(&child_layout.bounds.lower_right()); | |
| 147 | + if let Some(child_bounds) = cx.layout_bounds(*child_layout_id).log_err() { | |
| 148 | + scroll_max = scroll_max.max(&child_bounds.lower_right()); | |
| 153 | 149 | } |
| 154 | 150 | } |
| 155 | 151 | scroll_max -= bounds.size; |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | − BorrowWindow, Element, Layout, LayoutId, Result, SharedString, Style, StyleHelpers, Styled, | |
| 3 | − ViewContext, | |
| 2 | + BorrowWindow, Bounds, Element, LayoutId, Pixels, Result, SharedString, Style, StyleHelpers, | |
| 3 | + Styled, ViewContext, | |
| 4 | 4 | }; |
| 5 | 5 | use futures::FutureExt; |
| 6 | 6 | use refineable::RefinementCascade; |
| @@ -54,16 +54,14 @@ impl<S: Send + Sync + 'static> Element for Img<S> { · 47 unmodified lines | ||
| 54 | 54 | |
| 55 | 55 | fn paint( |
| 56 | 56 | &mut self, |
| 57 | − layout: Layout, | |
| 57 | + bounds: Bounds<Pixels>, | |
| 58 | 58 | _: &mut Self::State, |
| 59 | 59 | _: &mut Self::FrameState, |
| 60 | 60 | cx: &mut ViewContext<Self::State>, |
| 61 | 61 | ) -> Result<()> { |
| 62 | 62 | let style = self.computed_style(); |
| 63 | − let order = layout.order; | |
| 64 | − let bounds = layout.bounds; | |
| 65 | 63 | |
| 66 | − style.paint(order, bounds, cx); | |
| 64 | + style.paint(bounds, cx); | |
| 67 | 65 | |
| 68 | 66 | if let Some(uri) = self.uri.clone() { |
| 69 | 67 | let image_future = cx.image_cache.get(uri); |
| @@ -74,7 +72,7 @@ impl<S: Send + Sync + 'static> Element for Img<S> { · 4 unmodified lines | ||
| 74 | 72 | { |
| 75 | 73 | let corner_radii = style.corner_radii.to_pixels(bounds.size, cx.rem_size()); |
| 76 | 74 | cx.stack(1, |cx| { |
| 77 | − cx.paint_image(bounds, corner_radii, order, data, self.grayscale) | |
| 75 | + cx.paint_image(bounds, corner_radii, data, self.grayscale) | |
| 78 | 76 | })?; |
| 79 | 77 | } else { |
| 80 | 78 | cx.spawn(|_, mut cx| async move { |
| @@ -1,4 +1,4 @@ | ||
| 1 | −use crate::Element; | |
| 1 | +use crate::{Bounds, Element, Pixels}; | |
| 2 | 2 | use std::marker::PhantomData; |
| 3 | 3 | |
| 4 | 4 | pub struct Stateless<E: Element<State = ()>, S> { |
| @@ -20,11 +20,11 @@ impl<E: Element<State = ()>, S: Send + Sync + 'static> Element for Stateless<E, · 15 unmodified lines | ||
| 20 | 20 | |
| 21 | 21 | fn paint( |
| 22 | 22 | &mut self, |
| 23 | − layout: crate::Layout, | |
| 23 | + bounds: Bounds<Pixels>, | |
| 24 | 24 | _: &mut Self::State, |
| 25 | 25 | frame_state: &mut Self::FrameState, |
| 26 | 26 | cx: &mut crate::ViewContext<Self::State>, |
| 27 | 27 | ) -> anyhow::Result<()> { |
| 28 | − cx.erase_state(|cx| self.element.paint(layout, &mut (), frame_state, cx)) | |
| 28 | + cx.erase_state(|cx| self.element.paint(bounds, &mut (), frame_state, cx)) | |
| 29 | 29 | } |
| 30 | 30 | } |
| @@ -1,4 +1,4 @@ | ||
| 1 | −use crate::{Element, Layout, LayoutId, Result, SharedString, Style, StyleHelpers, Styled}; | |
| 1 | +use crate::{Bounds, Element, LayoutId, Pixels, Result, SharedString, Style, StyleHelpers, Styled}; | |
| 2 | 2 | use refineable::RefinementCascade; |
| 3 | 3 | use std::marker::PhantomData; |
| 4 | 4 | |
| @@ -41,7 +41,7 @@ impl<S: 'static> Element for Svg<S> { · 36 unmodified lines | ||
| 41 | 41 | |
| 42 | 42 | fn paint( |
| 43 | 43 | &mut self, |
| 44 | − layout: Layout, | |
| 44 | + bounds: Bounds<Pixels>, | |
| 45 | 45 | _: &mut Self::State, |
| 46 | 46 | _: &mut Self::FrameState, |
| 47 | 47 | cx: &mut crate::ViewContext<S>, |
| @@ -51,7 +51,7 @@ impl<S: 'static> Element for Svg<S> { · 3 unmodified lines | ||
| 51 | 51 | { |
| 52 | 52 | let fill_color = self.computed_style().fill.and_then(|fill| fill.color()); |
| 53 | 53 | if let Some((path, fill_color)) = self.path.as_ref().zip(fill_color) { |
| 54 | − cx.paint_svg(layout.bounds, layout.order, path.clone(), fill_color)?; | |
| 54 | + cx.paint_svg(bounds, path.clone(), fill_color)?; | |
| 55 | 55 | } |
| 56 | 56 | Ok(()) |
| 57 | 57 | } |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | − AnyElement, Element, IntoAnyElement, Layout, LayoutId, Line, Pixels, Result, Size, ViewContext, | |
| 2 | + AnyElement, Bounds, Element, IntoAnyElement, LayoutId, Line, Pixels, Result, Size, ViewContext, | |
| 3 | 3 | }; |
| 4 | 4 | use parking_lot::Mutex; |
| 5 | 5 | use std::{marker::PhantomData, sync::Arc}; |
| @@ -82,7 +82,7 @@ impl<S: 'static> Element for Text<S> { · 76 unmodified lines | ||
| 82 | 82 | |
| 83 | 83 | fn paint<'a>( |
| 84 | 84 | &mut self, |
| 85 | − layout: Layout, | |
| 85 | + bounds: Bounds<Pixels>, | |
| 86 | 86 | _: &mut Self::State, |
| 87 | 87 | frame_state: &mut Self::FrameState, |
| 88 | 88 | cx: &mut ViewContext<S>, |
| @@ -99,8 +99,7 @@ impl<S: 'static> Element for Text<S> { · 10 unmodified lines | ||
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | // todo!("We haven't added visible bounds to the new element system yet, so this is a placeholder."); |
| 102 | − let visible_bounds = layout.bounds; | |
| 103 | − line.paint(&layout, visible_bounds, line_height, cx)?; | |
| 102 | + line.paint(bounds, bounds, line_height, cx)?; | |
| 104 | 103 | |
| 105 | 104 | Ok(()) |
| 106 | 105 | } |
| @@ -241,7 +241,7 @@ impl Style { · 240 unmodified lines | ||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /// Paints the background of an element styled with this style. |
| 244 | − pub fn paint<V: 'static>(&self, order: u32, bounds: Bounds<Pixels>, cx: &mut ViewContext<V>) { | |
| 244 | + pub fn paint<V: 'static>(&self, bounds: Bounds<Pixels>, cx: &mut ViewContext<V>) { | |
| 245 | 245 | let rem_size = cx.rem_size(); |
| 246 | 246 | let scale = cx.scale_factor(); |
| 247 | 247 | |
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | use super::{ |
| 2 | − AbsoluteLength, Bounds, DefiniteLength, Edges, Layout, Length, Pixels, Point, Result, Size, | |
| 3 | − Style, | |
| 2 | + AbsoluteLength, Bounds, DefiniteLength, Edges, Length, Pixels, Point, Result, Size, Style, | |
| 4 | 3 | }; |
| 5 | 4 | use collections::HashMap; |
| 6 | 5 | use std::fmt::Debug; |
| @@ -14,7 +13,7 @@ use taffy::{ · 7 unmodified lines | ||
| 14 | 13 | pub struct TaffyLayoutEngine { |
| 15 | 14 | taffy: Taffy, |
| 16 | 15 | children_to_parents: HashMap<LayoutId, LayoutId>, |
| 17 | − absolute_layouts: HashMap<LayoutId, Layout>, | |
| 16 | + absolute_layout_bounds: HashMap<LayoutId, Bounds<Pixels>>, | |
| 18 | 17 | } |
| 19 | 18 | |
| 20 | 19 | impl TaffyLayoutEngine { |
| @@ -22,7 +21,7 @@ impl TaffyLayoutEngine { · 1 unmodified line | ||
| 22 | 21 | TaffyLayoutEngine { |
| 23 | 22 | taffy: Taffy::new(), |
| 24 | 23 | children_to_parents: HashMap::default(), |
| 25 | − absolute_layouts: HashMap::default(), | |
| 24 | + absolute_layout_bounds: HashMap::default(), | |
| 26 | 25 | } |
| 27 | 26 | } |
| 28 | 27 | |
| @@ -76,19 +75,24 @@ impl TaffyLayoutEngine { · 47 unmodified lines | ||
| 76 | 75 | Ok(()) |
| 77 | 76 | } |
| 78 | 77 | |
| 79 | − pub fn layout(&mut self, id: LayoutId) -> Result<Layout> { | |
| 80 | − if let Some(layout) = self.absolute_layouts.get(&id).cloned() { | |
| 78 | + pub fn layout_bounds(&mut self, id: LayoutId) -> Result<Bounds<Pixels>> { | |
| 79 | + if let Some(layout) = self.absolute_layout_bounds.get(&id).cloned() { | |
| 81 | 80 | return Ok(layout); |
| 82 | 81 | } |
| 83 | 82 | |
| 84 | − let mut relative_layout: Layout = self.taffy.layout(id.into()).map(Into::into)?; | |
| 83 | + let layout = self.taffy.layout(id.into())?; | |
| 84 | + let mut bounds = Bounds { | |
| 85 | + origin: layout.location.into(), | |
| 86 | + size: layout.size.into(), | |
| 87 | + }; | |
| 88 | + | |
| 85 | 89 | if let Some(parent_id) = self.children_to_parents.get(&id).copied() { |
| 86 | − let parent_layout = self.layout(parent_id)?; | |
| 87 | − relative_layout.bounds.origin += parent_layout.bounds.origin; | |
| 90 | + let parent_bounds = self.layout_bounds(parent_id)?; | |
| 91 | + bounds.origin += parent_bounds.origin; | |
| 88 | 92 | } |
| 89 | − self.absolute_layouts.insert(id, relative_layout.clone()); | |
| 93 | + self.absolute_layout_bounds.insert(id, bounds); | |
| 90 | 94 | |
| 91 | − Ok(relative_layout) | |
| 95 | + Ok(bounds) | |
| 92 | 96 | } |
| 93 | 97 | } |
| 94 | 98 | |
| @@ -369,15 +373,3 @@ impl From<Pixels> for AvailableSpace { · 274 unmodified lines | ||
| 369 | 373 | AvailableSpace::Definite(pixels) |
| 370 | 374 | } |
| 371 | 375 | } |
| 372 | − | |
| 373 | −impl From<&taffy::tree::Layout> for Layout { | |
| 374 | − fn from(layout: &taffy::tree::Layout) -> Self { | |
| 375 | − Layout { | |
| 376 | − order: layout.order, | |
| 377 | − bounds: Bounds { | |
| 378 | − origin: layout.location.into(), | |
| 379 | − size: layout.size.into(), | |
| 380 | − }, | |
| 381 | − } | |
| 382 | − } | |
| 383 | −} | |
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | use crate::{ |
| 2 | − black, point, px, Bounds, FontId, Hsla, Layout, Pixels, Point, RunStyle, ShapedBoundary, | |
| 3 | − ShapedLine, ShapedRun, UnderlineStyle, WindowContext, | |
| 2 | + black, point, px, Bounds, FontId, Hsla, Pixels, Point, RunStyle, ShapedBoundary, ShapedLine, | |
| 3 | + ShapedRun, UnderlineStyle, WindowContext, | |
| 4 | 4 | }; |
| 5 | 5 | use anyhow::Result; |
| 6 | 6 | use smallvec::SmallVec; |
| @@ -90,15 +90,14 @@ impl Line { · 83 unmodified lines | ||
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | − // todo! | |
| 94 | 93 | pub fn paint( |
| 95 | 94 | &self, |
| 96 | − layout: &Layout, | |
| 97 | − visible_bounds: Bounds<Pixels>, | |
| 95 | + bounds: Bounds<Pixels>, | |
| 96 | + visible_bounds: Bounds<Pixels>, // todo!("use clipping") | |
| 98 | 97 | line_height: Pixels, |
| 99 | 98 | cx: &mut WindowContext, |
| 100 | 99 | ) -> Result<()> { |
| 101 | − let origin = layout.bounds.origin; | |
| 100 | + let origin = bounds.origin; | |
| 102 | 101 | let padding_top = (line_height - self.layout.ascent - self.layout.descent) / 2.; |
| 103 | 102 | let baseline_offset = point(px(0.), padding_top + self.layout.ascent); |
| 104 | 103 | |
| @@ -159,17 +158,10 @@ impl Line { · 54 unmodified lines | ||
| 159 | 158 | } |
| 160 | 159 | |
| 161 | 160 | if glyph.is_emoji { |
| 162 | − cx.paint_emoji( | |
| 163 | − glyph_origin, | |
| 164 | − layout.order, | |
| 165 | − run.font_id, | |
| 166 | − glyph.id, | |
| 167 | − self.layout.font_size, | |
| 168 | − )?; | |
| 161 | + cx.paint_emoji(glyph_origin, run.font_id, glyph.id, self.layout.font_size)?; | |
| 169 | 162 | } else { |
| 170 | 163 | cx.paint_glyph( |
| 171 | 164 | glyph_origin, |
| 172 | − layout.order, | |
| 173 | 165 | run.font_id, |
| 174 | 166 | glyph.id, |
| 175 | 167 | self.layout.font_size, |
| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | use parking_lot::Mutex; |
| 2 | 2 | |
| 3 | 3 | use crate::{ |
| 4 | − AnyElement, Element, Handle, IntoAnyElement, Layout, LayoutId, Result, ViewContext, | |
| 4 | + AnyElement, Bounds, Element, Handle, IntoAnyElement, LayoutId, Pixels, Result, ViewContext, | |
| 5 | 5 | WindowContext, |
| 6 | 6 | }; |
| 7 | 7 | use std::{any::Any, marker::PhantomData, sync::Arc}; |
| @@ -67,7 +67,7 @@ impl<S: Send + Sync + 'static, P: Send + 'static> Element for View<S, P> { · 59 unmodified lines | ||
| 67 | 67 | |
| 68 | 68 | fn paint( |
| 69 | 69 | &mut self, |
| 70 | − _: Layout, | |
| 70 | + _: Bounds<Pixels>, | |
| 71 | 71 | _: &mut Self::State, |
| 72 | 72 | element: &mut Self::FrameState, |
| 73 | 73 | cx: &mut ViewContext<Self::State>, |
| @@ -81,7 +81,7 @@ trait ViewObject: Send + 'static { · 7 unmodified lines | ||
| 81 | 81 | fn layout(&mut self, cx: &mut WindowContext) -> Result<(LayoutId, Box<dyn Any>)>; |
| 82 | 82 | fn paint( |
| 83 | 83 | &mut self, |
| 84 | − layout: Layout, | |
| 84 | + bounds: Bounds<Pixels>, | |
| 85 | 85 | element: &mut dyn Any, |
| 86 | 86 | cx: &mut WindowContext, |
| 87 | 87 | ) -> Result<()>; |
| @@ -97,7 +97,12 @@ impl<S: Send + Sync + 'static, P: Send + 'static> ViewObject for View<S, P> { · 9 unmodified lines | ||
| 97 | 97 | }) |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | − fn paint(&mut self, _: Layout, element: &mut dyn Any, cx: &mut WindowContext) -> Result<()> { | |
| 100 | + fn paint( | |
| 101 | + &mut self, | |
| 102 | + _: Bounds<Pixels>, | |
| 103 | + element: &mut dyn Any, | |
| 104 | + cx: &mut WindowContext, | |
| 105 | + ) -> Result<()> { | |
| 101 | 106 | self.state.update(cx, |state, cx| { |
| 102 | 107 | let element = element.downcast_mut::<AnyElement<S>>().unwrap(); |
| 103 | 108 | element.paint(state, None, cx) |
| @@ -124,12 +129,12 @@ impl<S: 'static> Element for AnyView<S> { · 20 unmodified lines | ||
| 124 | 129 | |
| 125 | 130 | fn paint( |
| 126 | 131 | &mut self, |
| 127 | − layout: Layout, | |
| 132 | + bounds: Bounds<Pixels>, | |
| 128 | 133 | _: &mut (), |
| 129 | 134 | element: &mut Box<dyn Any>, |
| 130 | 135 | cx: &mut ViewContext<Self::State>, |
| 131 | 136 | ) -> Result<()> { |
| 132 | − self.view.lock().paint(layout, element.as_mut(), cx) | |
| 137 | + self.view.lock().paint(bounds, element.as_mut(), cx) | |
| 133 | 138 | } |
| 134 | 139 | } |
| 135 | 140 | |
| @@ -224,11 +224,11 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 223 unmodified lines | ||
| 224 | 224 | .request_measured_layout(style, rem_size, measure) |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | − pub fn layout(&mut self, layout_id: LayoutId) -> Result<Layout> { | |
| 227 | + pub fn layout_bounds(&mut self, layout_id: LayoutId) -> Result<Bounds<Pixels>> { | |
| 228 | 228 | Ok(self |
| 229 | 229 | .window |
| 230 | 230 | .layout_engine |
| 231 | − .layout(layout_id) | |
| 231 | + .layout_bounds(layout_id) | |
| 232 | 232 | .map(Into::into)?) |
| 233 | 233 | } |
| 234 | 234 | |
| @@ -262,7 +262,6 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 27 unmodified lines | ||
| 262 | 262 | pub fn paint_glyph( |
| 263 | 263 | &mut self, |
| 264 | 264 | origin: Point<Pixels>, |
| 265 | − order: u32, | |
| 266 | 265 | font_id: FontId, |
| 267 | 266 | glyph_id: GlyphId, |
| 268 | 267 | font_size: Pixels, |
| @@ -302,7 +301,7 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 33 unmodified lines | ||
| 302 | 301 | self.window.scene.insert( |
| 303 | 302 | layer_id, |
| 304 | 303 | MonochromeSprite { |
| 305 | − order, | |
| 304 | + order: 0, | |
| 306 | 305 | bounds, |
| 307 | 306 | content_mask, |
| 308 | 307 | color, |
| @@ -316,7 +315,6 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 7 unmodified lines | ||
| 316 | 315 | pub fn paint_emoji( |
| 317 | 316 | &mut self, |
| 318 | 317 | origin: Point<Pixels>, |
| 319 | − order: u32, | |
| 320 | 318 | font_id: FontId, |
| 321 | 319 | glyph_id: GlyphId, |
| 322 | 320 | font_size: Pixels, |
| @@ -352,7 +350,7 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 29 unmodified lines | ||
| 352 | 350 | self.window.scene.insert( |
| 353 | 351 | layer_id, |
| 354 | 352 | PolychromeSprite { |
| 355 | − order, | |
| 353 | + order: 0, | |
| 356 | 354 | bounds, |
| 357 | 355 | corner_radii: Default::default(), |
| 358 | 356 | content_mask, |
| @@ -367,7 +365,6 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 8 unmodified lines | ||
| 367 | 365 | pub fn paint_svg( |
| 368 | 366 | &mut self, |
| 369 | 367 | bounds: Bounds<Pixels>, |
| 370 | − order: u32, | |
| 371 | 368 | path: SharedString, |
| 372 | 369 | color: Hsla, |
| 373 | 370 | ) -> Result<()> { |
| @@ -394,7 +391,7 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 20 unmodified lines | ||
| 394 | 391 | self.window.scene.insert( |
| 395 | 392 | layer_id, |
| 396 | 393 | MonochromeSprite { |
| 397 | − order, | |
| 394 | + order: 0, | |
| 398 | 395 | bounds, |
| 399 | 396 | content_mask, |
| 400 | 397 | color, |
| @@ -409,7 +406,6 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 8 unmodified lines | ||
| 409 | 406 | &mut self, |
| 410 | 407 | bounds: Bounds<Pixels>, |
| 411 | 408 | corner_radii: Corners<Pixels>, |
| 412 | − order: u32, | |
| 413 | 409 | data: Arc<ImageData>, |
| 414 | 410 | grayscale: bool, |
| 415 | 411 | ) -> Result<()> { |
| @@ -430,7 +426,7 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 14 unmodified lines | ||
| 430 | 426 | self.window.scene.insert( |
| 431 | 427 | order, |
| 432 | 428 | PolychromeSprite { |
| 433 | − order: 0, // Used in in Scene::batches. 0 has no meaning. | |
| 429 | + order: 0, | |
| 434 | 430 | bounds, |
| 435 | 431 | content_mask, |
| 436 | 432 | corner_radii, |
| @@ -452,7 +448,7 @@ impl<'a, 'w> WindowContext<'a, 'w> { · 15 unmodified lines | ||
| 452 | 448 | cx.window |
| 453 | 449 | .layout_engine |
| 454 | 450 | .compute_layout(root_layout_id, available_space)?; |
| 455 | − let layout = cx.window.layout_engine.layout(root_layout_id)?; | |
| 451 | + let layout = cx.window.layout_engine.layout_bounds(root_layout_id)?; | |
| 456 | 452 | |
| 457 | 453 | root_view.paint(layout, &mut (), &mut frame_state, cx)?; |
| 458 | 454 | cx.window.root_view = Some(root_view); |
| @@ -786,9 +782,3 @@ pub struct AnyWindowHandle { · 327 unmodified lines | ||
| 786 | 782 | pub(crate) id: WindowId, |
| 787 | 783 | state_type: TypeId, |
| 788 | 784 | } |
| 789 | − | |
| 790 | −#[derive(Clone)] | |
| 791 | −pub struct Layout { | |
| 792 | − pub order: u32, | |
| 793 | − pub bounds: Bounds<Pixels>, | |
| 794 | −} | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | use gpui3::{ |
| 2 | − BorrowAppContext, Element, Hsla, Layout, LayoutId, Result, ViewContext, WindowContext, | |
| 2 | + BorrowAppContext, Bounds, Element, Hsla, LayoutId, Pixels, Result, ViewContext, WindowContext, | |
| 3 | 3 | }; |
| 4 | 4 | use serde::{de::Visitor, Deserialize, Deserializer}; |
| 5 | 5 | use std::{collections::HashMap, fmt}; |
| @@ -160,7 +160,7 @@ impl<E: Element> Element for Themed<E> { · 154 unmodified lines | ||
| 160 | 160 | |
| 161 | 161 | fn paint( |
| 162 | 162 | &mut self, |
| 163 | − layout: Layout, | |
| 163 | + bounds: Bounds<Pixels>, | |
| 164 | 164 | state: &mut Self::State, |
| 165 | 165 | frame_state: &mut Self::FrameState, |
| 166 | 166 | cx: &mut ViewContext<Self::State>, |
| @@ -169,7 +169,7 @@ impl<E: Element> Element for Themed<E> { · 2 unmodified lines | ||
| 169 | 169 | Self: Sized, |
| 170 | 170 | { |
| 171 | 171 | cx.with_state(self.theme.clone(), |cx| { |
| 172 | − self.child.paint(layout, state, frame_state, cx) | |
| 172 | + self.child.paint(bounds, state, frame_state, cx) | |
| 173 | 173 | }) |
| 174 | 174 | } |
| 175 | 175 | } |