Improve `debug_assert` when calling `add_space()` in `Grid` layout (#7399)
Makes it clearer to understand than the lower-level `advance_cursor` assert for an user who accidentally does this.
This commit is contained in:
parent
8333615072
commit
a1e5501db8
|
|
@ -145,6 +145,8 @@ impl Placer {
|
||||||
|
|
||||||
/// Advance the cursor by this many points.
|
/// Advance the cursor by this many points.
|
||||||
/// [`Self::min_rect`] will expand to contain the cursor.
|
/// [`Self::min_rect`] will expand to contain the cursor.
|
||||||
|
///
|
||||||
|
/// Note that `advance_cursor` isn't supported when in a grid layout.
|
||||||
pub(crate) fn advance_cursor(&mut self, amount: f32) {
|
pub(crate) fn advance_cursor(&mut self, amount: f32) {
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
self.grid.is_none(),
|
self.grid.is_none(),
|
||||||
|
|
|
||||||
|
|
@ -1877,6 +1877,7 @@ impl Ui {
|
||||||
/// Add extra space before the next widget.
|
/// Add extra space before the next widget.
|
||||||
///
|
///
|
||||||
/// The direction is dependent on the layout.
|
/// The direction is dependent on the layout.
|
||||||
|
/// Note that `add_space` isn't supported when in a grid layout.
|
||||||
///
|
///
|
||||||
/// This will be in addition to the [`crate::style::Spacing::item_spacing`]
|
/// This will be in addition to the [`crate::style::Spacing::item_spacing`]
|
||||||
/// that is always added, but `item_spacing` won't be added _again_ by `add_space`.
|
/// that is always added, but `item_spacing` won't be added _again_ by `add_space`.
|
||||||
|
|
@ -1884,6 +1885,7 @@ impl Ui {
|
||||||
/// [`Self::min_rect`] will expand to contain the space.
|
/// [`Self::min_rect`] will expand to contain the space.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn add_space(&mut self, amount: f32) {
|
pub fn add_space(&mut self, amount: f32) {
|
||||||
|
debug_assert!(!self.is_grid(), "add_space makes no sense in a grid layout");
|
||||||
self.placer.advance_cursor(amount.round_ui());
|
self.placer.advance_cursor(amount.round_ui());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue