gpui: Unify track_scroll method to receive a reference type (#43518)
Release Notes: - N/A This PR to change the `track_scroll` method to receive a reference type like the [Div#track_scroll](https://docs.rs/gpui/latest/gpui/trait.StatefulInteractiveElement.html#method.track_scroll), [Div#track_focus](https://docs.rs/gpui/latest/gpui/trait.InteractiveElement.html#method.track_focus). ```diff - .track_scroll(self.scroll_handle.clone()) + .track_scroll(&self.scroll_handle) - .vertical_scrollbar_for(self.scroll_handle.clone(), window, cx) + .vertical_scrollbar_for(&self.scroll_handle, window, cx) ``` https://github.com/zed-industries/zed/blob/56a2f9cfcf0c6a3c38f596b58002953763cd890f/crates/gpui/src/elements/div.rs#L1088-L1093 https://github.com/zed-industries/zed/blob/56a2f9cfcf0c6a3c38f596b58002953763cd890f/crates/gpui/src/elements/div.rs#L613-L620
This commit is contained in:
@@ -575,7 +575,7 @@ impl BreakpointList {
|
||||
)
|
||||
.with_horizontal_sizing_behavior(gpui::ListHorizontalSizingBehavior::Unconstrained)
|
||||
.with_width_from_item(self.max_width_index)
|
||||
.track_scroll(self.scroll_handle.clone())
|
||||
.track_scroll(&self.scroll_handle)
|
||||
.flex_1()
|
||||
}
|
||||
|
||||
@@ -776,7 +776,7 @@ impl Render for BreakpointList {
|
||||
.child(self.render_list(cx))
|
||||
.custom_scrollbars(
|
||||
ui::Scrollbars::new(ScrollAxes::Both)
|
||||
.tracked_scroll_handle(self.scroll_handle.clone())
|
||||
.tracked_scroll_handle(&self.scroll_handle)
|
||||
.with_track_along(ScrollAxes::Both, cx.theme().colors().panel_background)
|
||||
.tracked_entity(cx.entity_id()),
|
||||
window,
|
||||
|
||||
@@ -229,7 +229,7 @@ impl MemoryView {
|
||||
rows
|
||||
},
|
||||
)
|
||||
.track_scroll(view_state.scroll_handle)
|
||||
.track_scroll(&view_state.scroll_handle)
|
||||
.with_horizontal_sizing_behavior(ListHorizontalSizingBehavior::Unconstrained)
|
||||
.on_scroll_wheel(cx.listener(|this, evt: &ScrollWheelEvent, window, _| {
|
||||
let mut view_state = this.view_state();
|
||||
@@ -921,7 +921,7 @@ impl Render for MemoryView {
|
||||
}))
|
||||
.custom_scrollbars(
|
||||
ui::Scrollbars::new(ui::ScrollAxes::Both)
|
||||
.tracked_scroll_handle(self.view_state_handle.clone())
|
||||
.tracked_scroll_handle(&self.view_state_handle)
|
||||
.with_track_along(
|
||||
ui::ScrollAxes::Both,
|
||||
cx.theme().colors().panel_background,
|
||||
|
||||
@@ -253,7 +253,7 @@ impl ModuleList {
|
||||
range.map(|ix| this.render_entry(ix, cx)).collect()
|
||||
}),
|
||||
)
|
||||
.track_scroll(self.scroll_handle.clone())
|
||||
.track_scroll(&self.scroll_handle)
|
||||
.size_full()
|
||||
}
|
||||
}
|
||||
@@ -279,6 +279,6 @@ impl Render for ModuleList {
|
||||
.size_full()
|
||||
.p_1()
|
||||
.child(self.render_list(window, cx))
|
||||
.vertical_scrollbar_for(self.scroll_handle.clone(), window, cx)
|
||||
.vertical_scrollbar_for(&self.scroll_handle, window, cx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -913,7 +913,7 @@ impl Render for StackFrameList {
|
||||
)
|
||||
})
|
||||
.child(self.render_list(window, cx))
|
||||
.vertical_scrollbar_for(self.list_state.clone(), window, cx)
|
||||
.vertical_scrollbar_for(&self.list_state, window, cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1557,7 +1557,7 @@ impl Render for VariableList {
|
||||
this.render_entries(range, window, cx)
|
||||
}),
|
||||
)
|
||||
.track_scroll(self.list_handle.clone())
|
||||
.track_scroll(&self.list_handle)
|
||||
.with_width_from_item(self.max_width_index)
|
||||
.with_sizing_behavior(gpui::ListSizingBehavior::Auto)
|
||||
.with_horizontal_sizing_behavior(gpui::ListHorizontalSizingBehavior::Unconstrained)
|
||||
@@ -1574,10 +1574,10 @@ impl Render for VariableList {
|
||||
)
|
||||
.with_priority(1)
|
||||
}))
|
||||
// .vertical_scrollbar_for(self.list_handle.clone(), window, cx)
|
||||
// .vertical_scrollbar_for(&self.list_handle, window, cx)
|
||||
.custom_scrollbars(
|
||||
ui::Scrollbars::new(ScrollAxes::Both)
|
||||
.tracked_scroll_handle(self.list_handle.clone())
|
||||
.tracked_scroll_handle(&self.list_handle)
|
||||
.with_track_along(ScrollAxes::Both, cx.theme().colors().panel_background)
|
||||
.tracked_entity(cx.entity_id()),
|
||||
window,
|
||||
|
||||
Reference in New Issue
Block a user