I think the adapter is ready. Close to pixels.
This commit is contained in:
parent
625e4a1bd0
commit
7662210776
2 changed files with 15 additions and 16 deletions
|
@ -1,4 +1,5 @@
|
||||||
use crate::element::LayoutContext;
|
use crate::element::{LayoutContext, PaintContext};
|
||||||
|
use gpui::geometry::rect::RectF;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
use crate::element::AnyElement;
|
use crate::element::AnyElement;
|
||||||
|
@ -22,11 +23,8 @@ impl<V: 'static> gpui::Element<V> for Adapter<V> {
|
||||||
.log_err();
|
.log_err();
|
||||||
|
|
||||||
if let Some(node) = node {
|
if let Some(node) = node {
|
||||||
legacy_cx
|
let layout_engine = legacy_cx.layout_engine().unwrap();
|
||||||
.layout_engine()
|
layout_engine.compute_layout(node, constraint.max).log_err();
|
||||||
.unwrap()
|
|
||||||
.compute_layout(node, constraint.max)
|
|
||||||
.log_err();
|
|
||||||
}
|
}
|
||||||
legacy_cx.pop_layout_engine();
|
legacy_cx.pop_layout_engine();
|
||||||
|
|
||||||
|
@ -36,31 +34,32 @@ impl<V: 'static> gpui::Element<V> for Adapter<V> {
|
||||||
fn paint(
|
fn paint(
|
||||||
&mut self,
|
&mut self,
|
||||||
scene: &mut gpui::SceneBuilder,
|
scene: &mut gpui::SceneBuilder,
|
||||||
bounds: gpui::geometry::rect::RectF,
|
bounds: RectF,
|
||||||
visible_bounds: gpui::geometry::rect::RectF,
|
visible_bounds: RectF,
|
||||||
layout: &mut Self::LayoutState,
|
layout: &mut (),
|
||||||
view: &mut V,
|
view: &mut V,
|
||||||
cx: &mut gpui::PaintContext<V>,
|
legacy_cx: &mut gpui::PaintContext<V>,
|
||||||
) -> Self::PaintState {
|
) -> Self::PaintState {
|
||||||
todo!()
|
let mut cx = PaintContext { legacy_cx, scene };
|
||||||
|
self.0.paint(view, &mut cx).log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rect_for_text_range(
|
fn rect_for_text_range(
|
||||||
&self,
|
&self,
|
||||||
range_utf16: std::ops::Range<usize>,
|
range_utf16: std::ops::Range<usize>,
|
||||||
bounds: gpui::geometry::rect::RectF,
|
bounds: RectF,
|
||||||
visible_bounds: gpui::geometry::rect::RectF,
|
visible_bounds: RectF,
|
||||||
layout: &Self::LayoutState,
|
layout: &Self::LayoutState,
|
||||||
paint: &Self::PaintState,
|
paint: &Self::PaintState,
|
||||||
view: &V,
|
view: &V,
|
||||||
cx: &gpui::ViewContext<V>,
|
cx: &gpui::ViewContext<V>,
|
||||||
) -> Option<gpui::geometry::rect::RectF> {
|
) -> Option<RectF> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug(
|
fn debug(
|
||||||
&self,
|
&self,
|
||||||
bounds: gpui::geometry::rect::RectF,
|
bounds: RectF,
|
||||||
layout: &Self::LayoutState,
|
layout: &Self::LayoutState,
|
||||||
paint: &Self::PaintState,
|
paint: &Self::PaintState,
|
||||||
view: &V,
|
view: &V,
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub struct PaintContext<'a, 'b, 'c, 'd, V> {
|
||||||
#[deref]
|
#[deref]
|
||||||
#[deref_mut]
|
#[deref_mut]
|
||||||
pub(crate) legacy_cx: &'d mut LegacyPaintContext<'a, 'b, 'c, V>,
|
pub(crate) legacy_cx: &'d mut LegacyPaintContext<'a, 'b, 'c, V>,
|
||||||
scene: &'d mut gpui::SceneBuilder,
|
pub(crate) scene: &'d mut gpui::SceneBuilder,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait Element<V> {
|
pub trait Element<V> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue