Bug fix: forced shrunked clip rect is now nicer
This commit is contained in:
parent
2d7131d713
commit
24ce7b4145
3 changed files with 15 additions and 13 deletions
|
@ -179,26 +179,22 @@ impl Resize {
|
||||||
|
|
||||||
let inner_rect = Rect::from_min_size(region.cursor(), state.size);
|
let inner_rect = Rect::from_min_size(region.cursor(), state.size);
|
||||||
let desired_size = {
|
let desired_size = {
|
||||||
let mut contents_region = region.child_region(inner_rect);
|
let mut content_clip_rect = region
|
||||||
contents_region.clip_rect = region
|
|
||||||
.clip_rect()
|
.clip_rect()
|
||||||
.intersect(&inner_rect.expand(region.style().clip_rect_margin));
|
.intersect(&inner_rect.expand(region.style().clip_rect_margin));
|
||||||
|
|
||||||
// region.debug_text_at(
|
|
||||||
// inner_rect.min + last_frame_size,
|
|
||||||
// &format!("last_frame_size: {:?}", last_frame_size),
|
|
||||||
// );
|
|
||||||
|
|
||||||
// If we pull the resize handle to shrink, we want to TRY to shink it.
|
// If we pull the resize handle to shrink, we want to TRY to shink it.
|
||||||
// After laying out the contents, we might be much bigger.
|
// After laying out the contents, we might be much bigger.
|
||||||
// In those cases we don't want the clip_rect to be smaller, because
|
// In those cases we don't want the clip_rect to be smaller, because
|
||||||
// then we will clip the contents of the region even thought the result gets larger. This is simply ugly!
|
// then we will clip the contents of the region even thought the result gets larger. This is simply ugly!
|
||||||
contents_region.clip_rect.max = contents_region
|
// So we use the memory of last_frame_size to make the clip rect large enough.
|
||||||
.clip_rect
|
content_clip_rect.max = content_clip_rect
|
||||||
.max
|
.max
|
||||||
.max(contents_region.clip_rect.min + last_frame_size)
|
.max(content_clip_rect.min + last_frame_size)
|
||||||
.min(region.clip_rect.max); // Respect parent region
|
.min(region.clip_rect().max); // Respect parent region
|
||||||
|
|
||||||
|
let mut contents_region = region.child_region(inner_rect);
|
||||||
|
contents_region.set_clip_rect(content_clip_rect);
|
||||||
add_contents(&mut contents_region);
|
add_contents(&mut contents_region);
|
||||||
contents_region.bounding_size()
|
contents_region.bounding_size()
|
||||||
};
|
};
|
||||||
|
|
|
@ -80,8 +80,10 @@ impl ScrollArea {
|
||||||
outer_region.cursor() - state.offset,
|
outer_region.cursor() - state.offset,
|
||||||
vec2(inner_size.x, f32::INFINITY),
|
vec2(inner_size.x, f32::INFINITY),
|
||||||
));
|
));
|
||||||
// content_region.clip_rect = outer_region.clip_rect().intersect(&inner_rect);
|
let mut content_clip_rect = outer_region.clip_rect().intersect(&inner_rect);
|
||||||
content_region.clip_rect = outer_region.clip_rect(); // Nice handling of forced resizing beyon the possible
|
content_clip_rect.max.x = outer_region.clip_rect().max.x - current_scroll_bar_width; // Nice handling of forced resizing beyond the possible
|
||||||
|
content_region.set_clip_rect(content_clip_rect);
|
||||||
|
|
||||||
add_contents(&mut content_region);
|
add_contents(&mut content_region);
|
||||||
let content_size = content_region.bounding_size();
|
let content_size = content_region.bounding_size();
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,10 @@ impl Region {
|
||||||
self.clip_rect
|
self.clip_rect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_clip_rect(&mut self, clip_rect: Rect) {
|
||||||
|
self.clip_rect = clip_rect;
|
||||||
|
}
|
||||||
|
|
||||||
pub fn bottom_right(&self) -> Pos2 {
|
pub fn bottom_right(&self) -> Pos2 {
|
||||||
// If a child doesn't fit in desired_rect, we have effectively expanded:
|
// If a child doesn't fit in desired_rect, we have effectively expanded:
|
||||||
self.desired_rect.max.max(self.child_bounds.max)
|
self.desired_rect.max.max(self.child_bounds.max)
|
||||||
|
|
Loading…
Reference in a new issue