This commit is contained in:
Aaron Ang 2026-05-31 13:06:10 +02:00 committed by GitHub
commit 3d56d48824
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 30 deletions

View file

@ -62,7 +62,7 @@ use theme_settings::ThemeSettings;
use ui::{
Color, ContextMenu, ContextMenuEntry, DecoratedIcon, Icon, IconDecoration, IconDecorationKind,
IndentGuideColors, IndentGuideLayout, Indicator, KeyBinding, Label, LabelSize, ListItem,
ListItemSpacing, ProjectEmptyState, ScrollAxes, ScrollableHandle, Scrollbars, StickyCandidate,
ListItemSpacing, ProjectEmptyState, ScrollableHandle, Scrollbars, StickyCandidate,
Tooltip, WithScrollbar, prelude::*, v_flex,
};
use util::{
@ -7087,16 +7087,9 @@ impl Render for ProjectPanel {
)
.custom_scrollbars(
{
let mut scrollbars =
Scrollbars::for_settings::<ProjectPanelScrollbarProxy>()
.tracked_scroll_handle(&self.scroll_handle);
if horizontal_scroll {
scrollbars = scrollbars.with_track_along(
ScrollAxes::Horizontal,
cx.theme().colors().panel_background,
);
}
scrollbars.notify_content()
Scrollbars::for_settings::<ProjectPanelScrollbarProxy>()
.tracked_scroll_handle(&self.scroll_handle)
.notify_content()
},
window,
cx,

View file

@ -330,7 +330,7 @@ impl ReservedSpace {
}
fn needs_scroll_track(&self) -> bool {
matches!(self, Self::Track | Self::StableTrack)
matches!(self, Self::Thumb | Self::Track | Self::StableTrack)
}
fn needs_space_reserved(&self, max_offset: Pixels) -> bool {
@ -779,21 +779,26 @@ impl<T: ScrollableHandle> ScrollbarState<T> {
window: &mut Window,
cx: &mut Context<Self>,
) {
self.set_thumb_state(
if let Some(&ScrollbarLayout { axis, .. }) =
self.last_prepaint_state.as_ref().and_then(|state| {
state
.thumb_for_position(position)
.filter(|thumb| thumb.cursor_hitbox.is_hovered(window))
})
{
ThumbState::Hover(axis)
} else {
ThumbState::Inactive
},
window,
cx,
);
let thumb_state = if let Some(&ScrollbarLayout { axis, .. }) =
self.last_prepaint_state.as_ref().and_then(|state| {
state
.thumb_for_position(position)
.filter(|thumb| thumb.cursor_hitbox.is_hovered(window))
}) {
ThumbState::Hover(axis)
} else if let Some(&ScrollbarLayout { axis, .. }) =
self.last_prepaint_state.as_ref().and_then(|state| {
state
.thumbs
.iter()
.find(|thumb| thumb.cursor_hitbox.is_hovered(window))
})
{
ThumbState::Hover(axis)
} else {
ThumbState::Inactive
};
self.set_thumb_state(thumb_state, window, cx);
}
fn set_thumb_state(&mut self, state: ThumbState, window: &mut Window, cx: &mut Context<Self>) {
@ -829,9 +834,13 @@ impl<T: ScrollableHandle> ScrollbarState<T> {
}
fn parent_hovered(&self, window: &Window) -> bool {
self.last_prepaint_state
.as_ref()
.is_some_and(|state| state.parent_bounds_hitbox.is_hovered(window))
self.last_prepaint_state.as_ref().is_some_and(|state| {
state.parent_bounds_hitbox.is_hovered(window)
|| state
.thumbs
.iter()
.any(|thumb| thumb.cursor_hitbox.is_hovered(window))
})
}
fn hit_for_position(&self, position: &Point<Pixels>) -> Option<&ScrollbarLayout> {