layout/scrolling: Inline popup_target_rect up to ScrollingSpace

This commit is contained in:
Ivan Molodetskikh
2025-06-09 13:39:08 +03:00
parent f918eabe6a
commit 2066737024
+18 -22
View File
@@ -2437,9 +2437,24 @@ impl<W: LayoutElement> ScrollingSpace<W> {
}
pub fn popup_target_rect(&self, id: &W::Id) -> Option<Rectangle<f64, Logical>> {
self.columns
.iter()
.find_map(|col| col.popup_target_rect(id))
for col in &self.columns {
for (tile, pos) in col.tiles() {
if tile.window().id() == id {
// In the scrolling layout, we try to position popups horizontally within the
// window geometry (so they remain visible even if the window scrolls flush with
// the left/right edge of the screen), and vertically wihin the whole view size.
let width = tile.window_size().w;
let height = self.view_size.h;
let mut target = Rectangle::from_size(Size::from((width, height)));
target.loc.y -= pos.y;
target.loc.y -= tile.window_loc().y;
return Some(target);
}
}
}
None
}
pub fn toggle_width(&mut self) {
@@ -4756,25 +4771,6 @@ impl<W: LayoutElement> Column<W> {
self.update_tile_sizes(true);
}
fn popup_target_rect(&self, id: &W::Id) -> Option<Rectangle<f64, Logical>> {
for (tile, pos) in self.tiles() {
if tile.window().id() == id {
// In the scrolling layout, we try to position popups horizontally within the
// window geometry (so they remain visible even if the window scrolls flush with
// the left/right edge of the screen), and vertically wihin the whole view size.
let width = tile.window_size().w;
let height = self.view_size.h;
let mut target = Rectangle::from_size(Size::from((width, height)));
target.loc.y -= pos.y;
target.loc.y -= tile.window_loc().y;
return Some(target);
}
}
None
}
fn tiles_origin(&self) -> Point<f64, Logical> {
let mut origin = Point::from((0., 0.));