From bc0fdefceb2082fa0ef8c16796d38a46a873275e Mon Sep 17 00:00:00 2001 From: Anna Clemens Date: Fri, 25 Mar 2022 18:34:03 +0000 Subject: [PATCH] Expose ui.cursor and ui.next_widget_position (#1342) --- egui/src/ui.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/egui/src/ui.rs b/egui/src/ui.rs index ae4a9601..b958855c 100644 --- a/egui/src/ui.rs +++ b/egui/src/ui.rs @@ -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() }