Forbid creating a panel from within another panel
This commit is contained in:
parent
16a984b71f
commit
07a32793d6
1 changed files with 9 additions and 1 deletions
|
@ -281,6 +281,10 @@ impl Context {
|
||||||
|
|
||||||
/// Shrink `available_rect()`.
|
/// Shrink `available_rect()`.
|
||||||
pub(crate) fn allocate_left_panel(&self, panel_rect: Rect) {
|
pub(crate) fn allocate_left_panel(&self, panel_rect: Rect) {
|
||||||
|
debug_assert!(
|
||||||
|
panel_rect.min == self.available_rect().min,
|
||||||
|
"Mismatching panels. You must not create a panel from within another panel."
|
||||||
|
);
|
||||||
let mut remainder = self.available_rect();
|
let mut remainder = self.available_rect();
|
||||||
remainder.min.x = panel_rect.max.x;
|
remainder.min.x = panel_rect.max.x;
|
||||||
*self.available_rect.lock() = Some(remainder);
|
*self.available_rect.lock() = Some(remainder);
|
||||||
|
@ -289,6 +293,10 @@ impl Context {
|
||||||
|
|
||||||
/// Shrink `available_rect()`.
|
/// Shrink `available_rect()`.
|
||||||
pub(crate) fn allocate_top_panel(&self, panel_rect: Rect) {
|
pub(crate) fn allocate_top_panel(&self, panel_rect: Rect) {
|
||||||
|
debug_assert!(
|
||||||
|
panel_rect.min == self.available_rect().min,
|
||||||
|
"Mismatching panels. You must not create a panel from within another panel."
|
||||||
|
);
|
||||||
let mut remainder = self.available_rect();
|
let mut remainder = self.available_rect();
|
||||||
remainder.min.y = panel_rect.max.y;
|
remainder.min.y = panel_rect.max.y;
|
||||||
*self.available_rect.lock() = Some(remainder);
|
*self.available_rect.lock() = Some(remainder);
|
||||||
|
@ -300,7 +308,7 @@ impl Context {
|
||||||
let mut available_rect = self.available_rect.lock();
|
let mut available_rect = self.available_rect.lock();
|
||||||
debug_assert!(
|
debug_assert!(
|
||||||
*available_rect != Some(Rect::nothing()),
|
*available_rect != Some(Rect::nothing()),
|
||||||
"You already created a `CentralPanel` this frame!"
|
"You already created a `CentralPanel` this frame!"
|
||||||
);
|
);
|
||||||
*available_rect = Some(Rect::nothing()); // Nothing left after this
|
*available_rect = Some(Rect::nothing()); // Nothing left after this
|
||||||
self.register_panel(panel_rect);
|
self.register_panel(panel_rect);
|
||||||
|
|
Loading…
Reference in a new issue