Introduce autoscroll support for elements (#10889)

This pull request introduces the new
`ElementContext::request_autoscroll(bounds)` and
`ElementContext::take_autoscroll()` methods in GPUI. These new APIs
enable container elements such as `List` to change their scroll position
if one of their children requested an autoscroll. We plan to use this in
the revamped assistant.

As a drive-by, we also:

- Renamed `Element::before_layout` to `Element::request_layout`
- Renamed `Element::after_layout` to `Element::prepaint`
- Introduced a new `List::splice_focusable` method to splice focusable
elements into the list, which enables rendering offscreen elements that
are focused.

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra
2024-04-23 15:14:22 +02:00
committed by GitHub
co-authored by Nathan
parent efcd31c254
commit bcbf2f2fd3
31 changed files with 780 additions and 513 deletions
+13
View File
@@ -283,6 +283,19 @@ impl DispatchTree {
}
}
pub fn truncate(&mut self, index: usize) {
for node in &self.nodes[index..] {
if let Some(focus_id) = node.focus_id {
self.focusable_node_ids.remove(&focus_id);
}
if let Some(view_id) = node.view_id {
self.view_node_ids.remove(&view_id);
}
}
self.nodes.truncate(index);
}
pub fn clear_pending_keystrokes(&mut self) {
self.keystroke_matchers.clear();
}