Skip to content

Commit 4a48609

Browse files
committed
impl Deref for Layout
1 parent a6e0cd1 commit 4a48609

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

internal/core/textlayout/sharedparley.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ pub fn layout(text: &str, scale_factor: f32, options: LayoutOptions) -> Layout {
133133
}
134134

135135
pub struct Layout {
136-
pub inner: parley::Layout<Brush>,
136+
inner: parley::Layout<Brush>,
137137
pub y_offset: f32,
138138
}
139+
140+
impl std::ops::Deref for Layout {
141+
type Target = parley::Layout<Brush>;
142+
143+
fn deref(&self) -> &Self::Target {
144+
&self.inner
145+
}
146+
}

internal/renderers/femtovg/itemrenderer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ fn draw_glyphs<R: femtovg::Renderer + TextureImporter>(
202202
selection_foreground_color: Color,
203203
selection_background_color: Color,
204204
) {
205-
for line in layout.inner.lines() {
205+
for line in layout.lines() {
206206
for item in line.items() {
207207
match item {
208208
parley::PositionedLayoutItem::GlyphRun(glyph_run) => {
@@ -532,11 +532,11 @@ impl<'a, R: femtovg::Renderer + TextureImporter> ItemRenderer for GLItemRenderer
532532

533533
if cursor_visible {
534534
let cursor = parley::layout::cursor::Cursor::from_byte_index(
535-
&layout.inner,
535+
&layout,
536536
cursor_pos,
537537
Default::default(),
538538
);
539-
let rect = cursor.geometry(&layout.inner, (text_input.text_cursor_width()).get());
539+
let rect = cursor.geometry(&layout, (text_input.text_cursor_width()).get());
540540

541541
let mut cursor_rect = femtovg::Path::new();
542542
cursor_rect.rect(

internal/renderers/femtovg/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ impl<B: GraphicsBackend> RendererSealed for FemtoVGRenderer<B> {
298298
..Default::default()
299299
},
300300
);
301-
LogicalSize::new(layout.inner.width(), layout.inner.height())
301+
LogicalSize::new(layout.width(), layout.height())
302302
}
303303

304304
fn font_metrics(
@@ -346,7 +346,7 @@ impl<B: GraphicsBackend> RendererSealed for FemtoVGRenderer<B> {
346346
},
347347
);
348348
let cursor = parley::layout::cursor::Cursor::from_point(
349-
&layout.inner,
349+
&layout,
350350
pos.x,
351351
pos.y - layout.y_offset,
352352
);
@@ -385,11 +385,11 @@ impl<B: GraphicsBackend> RendererSealed for FemtoVGRenderer<B> {
385385
},
386386
);
387387
let cursor = parley::layout::cursor::Cursor::from_byte_index(
388-
&layout.inner,
388+
&layout,
389389
byte_offset,
390390
Default::default(),
391391
);
392-
let rect = cursor.geometry(&layout.inner, (text_input.text_cursor_width()).get());
392+
let rect = cursor.geometry(&layout, (text_input.text_cursor_width()).get());
393393
LogicalRect::new(
394394
LogicalPoint::new(rect.min_x() as _, rect.min_y() as f32 + layout.y_offset),
395395
LogicalSize::new(rect.width() as _, rect.height() as _),

0 commit comments

Comments
 (0)