mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 12:50:04 -04:00
Fix links and text selection in horizontal_wrapped layout (#6905)
* Closes <https://github.com/emilk/egui/issues/6904> * [x] I have followed the instructions in the PR template This was broken in https://github.com/emilk/egui/pull/5411. Not sure if this is the best fix or if `PlacedRow::rect` should be updated, but I think it makes sense that PlacedRow::rect ignores leading space.
This commit is contained in:
@@ -576,10 +576,18 @@ pub struct PlacedRow {
|
||||
|
||||
impl PlacedRow {
|
||||
/// Logical bounding rectangle on font heights etc.
|
||||
/// Use this when drawing a selection or similar!
|
||||
///
|
||||
/// This ignores / includes the `LayoutSection::leading_space`.
|
||||
pub fn rect(&self) -> Rect {
|
||||
Rect::from_min_size(self.pos, self.row.size)
|
||||
}
|
||||
|
||||
/// Same as [`Self::rect`] but excluding the `LayoutSection::leading_space`.
|
||||
pub fn rect_without_leading_space(&self) -> Rect {
|
||||
let x = self.glyphs.first().map_or(self.pos.x, |g| g.pos.x);
|
||||
let size_x = self.size.x - x;
|
||||
Rect::from_min_size(Pos2::new(x, self.pos.y), Vec2::new(size_x, self.size.y))
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Deref for PlacedRow {
|
||||
|
||||
Reference in New Issue
Block a user