Fix scroll area size clipping to screen rect
This commit is contained in:
parent
e547b149ca
commit
fc45b6fdf2
1 changed files with 12 additions and 8 deletions
|
@ -464,14 +464,18 @@ impl Prepared {
|
||||||
let mut inner_rect = Rect::from_min_size(inner_rect.min, inner_size);
|
let mut inner_rect = Rect::from_min_size(inner_rect.min, inner_size);
|
||||||
|
|
||||||
// The window that egui sits in can't be expanded by egui, so we need to respect it:
|
// The window that egui sits in can't be expanded by egui, so we need to respect it:
|
||||||
let max_x =
|
for d in 0..2 {
|
||||||
ui.input().screen_rect().right() - current_bar_use.x - ui.spacing().item_spacing.x;
|
if !has_bar[d] {
|
||||||
inner_rect.max.x = inner_rect.max.x.at_most(max_x);
|
// HACK for when we have a vertical-only scroll area in a top level panel,
|
||||||
|
// and that panel is not wide enough for the contents.
|
||||||
let max_y =
|
// This code ensures we still see the scroll bar!
|
||||||
ui.input().screen_rect().bottom() - current_bar_use.y - ui.spacing().item_spacing.y;
|
let max = ui.input().screen_rect().max[d]
|
||||||
inner_rect.max.y = inner_rect.max.y.at_most(max_y);
|
- current_bar_use[d]
|
||||||
// TODO: maybe auto-enable horizontal/vertical scrolling if this limit is reached
|
- ui.spacing().item_spacing[d];
|
||||||
|
inner_rect.max[d] = inner_rect.max[d].at_most(max);
|
||||||
|
// TODO: maybe auto-enable horizontal/vertical scrolling if this limit is reached
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inner_rect
|
inner_rect
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue