From b2b6558c78ee8a85d778f2c885639a45a7eab87f Mon Sep 17 00:00:00 2001 From: Steven Weiss Date: Wed, 9 Aug 2023 08:06:33 -0700 Subject: [PATCH] Tiny PR: Document available_width() and available_height() (#3130) * Update ui.rs docs to clarify available_size and co Added docs to the available_width() and available_height() methods. Added a quick note about the wrapping versions of the methods as well. * fix a couple of typos, and use code-style for doc-links * fix doclinks --------- Co-authored-by: Emil Ernerfeldt --- crates/egui/src/ui.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index 13b3e81f..4e4b4559 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -556,6 +556,7 @@ impl Ui { // Layout related measures: /// The available space at the moment, given the current cursor. + /// /// This how much more space we can take up without overflowing our parent. /// Shrinks as widgets allocate space and the cursor moves. /// A small size should be interpreted as "as little as possible". @@ -564,19 +565,30 @@ impl Ui { self.placer.available_size() } + /// The available width at the moment, given the current cursor. + /// + /// See [`Self::available_size`] for more information. pub fn available_width(&self) -> f32 { self.available_size().x } + /// The available height at the moment, given the current cursor. + /// + /// See [`Self::available_size`] for more information. pub fn available_height(&self) -> f32 { self.available_size().y } /// In case of a wrapping layout, how much space is left on this row/column? + /// + /// If the layout does not wrap, this will return the same value as [`Self::available_size`]. pub fn available_size_before_wrap(&self) -> Vec2 { self.placer.available_rect_before_wrap().size() } + /// In case of a wrapping layout, how much space is left on this row/column? + /// + /// If the layout does not wrap, this will return the same value as [`Self::available_size`]. pub fn available_rect_before_wrap(&self) -> Rect { self.placer.available_rect_before_wrap() }