Expose ui.cursor and ui.next_widget_position (#1342)

This commit is contained in:
Anna Clemens 2022-03-25 18:34:03 +00:00 committed by GitHub
parent dd9699099f
commit bc0fdefceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -783,7 +783,17 @@ impl Ui {
&self.placer
}
pub(crate) fn cursor(&self) -> Rect {
/// Where the next widget will be put.
///
/// One side of this will always be infinite: the direction in which new widgets will be added.
/// The opposing side is what is incremented.
/// The crossing sides are initialized to `max_rect`.
///
/// So one can think of `cursor` as a constraint on the available region.
///
/// If something has already been added, this will point to `style.spacing.item_spacing` beyond the latest child.
/// The cursor can thus be `style.spacing.item_spacing` pixels outside of the min_rect.
pub fn cursor(&self) -> Rect {
self.placer.cursor()
}
@ -792,7 +802,7 @@ impl Ui {
}
/// Where do we expect a zero-sized widget to be placed?
pub(crate) fn next_widget_position(&self) -> Pos2 {
pub fn next_widget_position(&self) -> Pos2 {
self.placer.next_widget_position()
}