gpui: Fix Interactivity prepaint to update scroll_handle bounds (#35013)
It took a long time to check this problem. Finally, I found that due to a detail missing when changing #34832, the bounds of `ScrollHandle` was not updated in the Interactivity `prepaint` phase. ```diff - scroll_handle_state.padded_content_size = padded_content_size; + scroll_handle_state.max_offset = scroll_max; ``` It was correct before the change, because the `padded_content_size` (including `bounds.size`) was saved before, and the bounds was missing after changing to `max_offset`, but the bounds were not updated anywhere. So when `scroll_handle.bounds()` is obtained outside, it is always 0px here. @MrSubidubi Release Notes: - N/A
This commit is contained in:
parent
ddd50aabba
commit
65759d4316
2 changed files with 3 additions and 9 deletions
|
@ -1334,7 +1334,6 @@ impl Element for Div {
|
||||||
} else if let Some(scroll_handle) = self.interactivity.tracked_scroll_handle.as_ref() {
|
} else if let Some(scroll_handle) = self.interactivity.tracked_scroll_handle.as_ref() {
|
||||||
let mut state = scroll_handle.0.borrow_mut();
|
let mut state = scroll_handle.0.borrow_mut();
|
||||||
state.child_bounds = Vec::with_capacity(request_layout.child_layout_ids.len());
|
state.child_bounds = Vec::with_capacity(request_layout.child_layout_ids.len());
|
||||||
state.bounds = bounds;
|
|
||||||
for child_layout_id in &request_layout.child_layout_ids {
|
for child_layout_id in &request_layout.child_layout_ids {
|
||||||
let child_bounds = window.layout_bounds(*child_layout_id);
|
let child_bounds = window.layout_bounds(*child_layout_id);
|
||||||
child_min = child_min.min(&child_bounds.origin);
|
child_min = child_min.min(&child_bounds.origin);
|
||||||
|
@ -1706,6 +1705,7 @@ impl Interactivity {
|
||||||
|
|
||||||
if let Some(mut scroll_handle_state) = tracked_scroll_handle {
|
if let Some(mut scroll_handle_state) = tracked_scroll_handle {
|
||||||
scroll_handle_state.max_offset = scroll_max;
|
scroll_handle_state.max_offset = scroll_max;
|
||||||
|
scroll_handle_state.bounds = bounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
*scroll_offset
|
*scroll_offset
|
||||||
|
@ -3007,11 +3007,6 @@ impl ScrollHandle {
|
||||||
self.0.borrow().bounds
|
self.0.borrow().bounds
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set the bounds into which this child is painted
|
|
||||||
pub(super) fn set_bounds(&self, bounds: Bounds<Pixels>) {
|
|
||||||
self.0.borrow_mut().bounds = bounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the bounds for a specific child.
|
/// Get the bounds for a specific child.
|
||||||
pub fn bounds_for_item(&self, ix: usize) -> Option<Bounds<Pixels>> {
|
pub fn bounds_for_item(&self, ix: usize) -> Option<Bounds<Pixels>> {
|
||||||
self.0.borrow().child_bounds.get(ix).cloned()
|
self.0.borrow().child_bounds.get(ix).cloned()
|
||||||
|
|
|
@ -295,9 +295,8 @@ impl Element for UniformList {
|
||||||
bounds.bottom_right() - point(border.right + padding.right, border.bottom),
|
bounds.bottom_right() - point(border.right + padding.right, border.bottom),
|
||||||
);
|
);
|
||||||
|
|
||||||
let y_flipped = if let Some(scroll_handle) = self.scroll_handle.as_mut() {
|
let y_flipped = if let Some(scroll_handle) = &self.scroll_handle {
|
||||||
let mut scroll_state = scroll_handle.0.borrow_mut();
|
let scroll_state = scroll_handle.0.borrow();
|
||||||
scroll_state.base_handle.set_bounds(bounds);
|
|
||||||
scroll_state.y_flipped
|
scroll_state.y_flipped
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue