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 <emil.ernerfeldt@gmail.com>
This commit is contained in:
Steven Weiss 2023-08-09 08:06:33 -07:00 committed by GitHub
parent f2769f3010
commit b2b6558c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 0 deletions

View File

@ -556,6 +556,7 @@ impl Ui {
// Layout related measures: // Layout related measures:
/// The available space at the moment, given the current cursor. /// The available space at the moment, given the current cursor.
///
/// This how much more space we can take up without overflowing our parent. /// This how much more space we can take up without overflowing our parent.
/// Shrinks as widgets allocate space and the cursor moves. /// Shrinks as widgets allocate space and the cursor moves.
/// A small size should be interpreted as "as little as possible". /// A small size should be interpreted as "as little as possible".
@ -564,19 +565,30 @@ impl Ui {
self.placer.available_size() 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 { pub fn available_width(&self) -> f32 {
self.available_size().x 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 { pub fn available_height(&self) -> f32 {
self.available_size().y self.available_size().y
} }
/// In case of a wrapping layout, how much space is left on this row/column? /// 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 { pub fn available_size_before_wrap(&self) -> Vec2 {
self.placer.available_rect_before_wrap().size() 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 { pub fn available_rect_before_wrap(&self) -> Rect {
self.placer.available_rect_before_wrap() self.placer.available_rect_before_wrap()
} }