History

Checkpoint

Nathan Sobo committed 3 years ago

Commit 65c77651 parent e99f6c012 files · +78 −105Browse files

Unified · Split

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

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t