From 110a9c39e3c0a5b9bf7f7838c6288a0c05a9c0ae Mon Sep 17 00:00:00 2001 From: Fishhh Date: Sat, 30 Nov 2024 18:25:02 +0100 Subject: [PATCH] Move some `PlacedRow` methods back to `Row` --- crates/epaint/src/text/text_layout_types.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/epaint/src/text/text_layout_types.rs b/crates/epaint/src/text/text_layout_types.rs index 3ebf07b8f5e..f90210ca136 100644 --- a/crates/epaint/src/text/text_layout_types.rs +++ b/crates/epaint/src/text/text_layout_types.rs @@ -693,6 +693,12 @@ impl Row { self.glyphs.len() } + /// Includes the implicit `\n` after the [`Row`], if any. + #[inline] + pub fn char_count_including_newline(&self) -> usize { + self.glyphs.len() + (self.ends_with_newline as usize) + } + /// Closest char at the desired x coordinate in row-relative coordinates. /// Returns something in the range `[0, char_count_excluding_newline()]`. pub fn char_at(&self, desired_x: f32) -> usize { @@ -711,15 +717,14 @@ impl Row { self.size.x } } -} -impl PlacedRow { - /// Includes the implicit `\n` after the [`Row`], if any. #[inline] - pub fn char_count_including_newline(&self) -> usize { - self.glyphs.len() + (self.ends_with_newline as usize) + pub fn height(&self) -> f32 { + self.size.y } +} +impl PlacedRow { #[inline] pub fn min_y(&self) -> f32 { self.rect().top() @@ -729,11 +734,6 @@ impl PlacedRow { pub fn max_y(&self) -> f32 { self.rect().bottom() } - - #[inline] - pub fn height(&self) -> f32 { - self.row.size.y - } } impl Galley {