mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-01 03:14:56 +07:00
Merge 119ef17316 into 09165c15dc
This commit is contained in:
commit
3d56d48824
2 changed files with 32 additions and 30 deletions
|
|
@ -62,7 +62,7 @@ use theme_settings::ThemeSettings;
|
||||||
use ui::{
|
use ui::{
|
||||||
Color, ContextMenu, ContextMenuEntry, DecoratedIcon, Icon, IconDecoration, IconDecorationKind,
|
Color, ContextMenu, ContextMenuEntry, DecoratedIcon, Icon, IconDecoration, IconDecorationKind,
|
||||||
IndentGuideColors, IndentGuideLayout, Indicator, KeyBinding, Label, LabelSize, ListItem,
|
IndentGuideColors, IndentGuideLayout, Indicator, KeyBinding, Label, LabelSize, ListItem,
|
||||||
ListItemSpacing, ProjectEmptyState, ScrollAxes, ScrollableHandle, Scrollbars, StickyCandidate,
|
ListItemSpacing, ProjectEmptyState, ScrollableHandle, Scrollbars, StickyCandidate,
|
||||||
Tooltip, WithScrollbar, prelude::*, v_flex,
|
Tooltip, WithScrollbar, prelude::*, v_flex,
|
||||||
};
|
};
|
||||||
use util::{
|
use util::{
|
||||||
|
|
@ -7087,16 +7087,9 @@ impl Render for ProjectPanel {
|
||||||
)
|
)
|
||||||
.custom_scrollbars(
|
.custom_scrollbars(
|
||||||
{
|
{
|
||||||
let mut scrollbars =
|
|
||||||
Scrollbars::for_settings::<ProjectPanelScrollbarProxy>()
|
Scrollbars::for_settings::<ProjectPanelScrollbarProxy>()
|
||||||
.tracked_scroll_handle(&self.scroll_handle);
|
.tracked_scroll_handle(&self.scroll_handle)
|
||||||
if horizontal_scroll {
|
.notify_content()
|
||||||
scrollbars = scrollbars.with_track_along(
|
|
||||||
ScrollAxes::Horizontal,
|
|
||||||
cx.theme().colors().panel_background,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
scrollbars.notify_content()
|
|
||||||
},
|
},
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,7 @@ impl ReservedSpace {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn needs_scroll_track(&self) -> bool {
|
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 {
|
fn needs_space_reserved(&self, max_offset: Pixels) -> bool {
|
||||||
|
|
@ -779,21 +779,26 @@ impl<T: ScrollableHandle> ScrollbarState<T> {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) {
|
) {
|
||||||
self.set_thumb_state(
|
let thumb_state = if let Some(&ScrollbarLayout { axis, .. }) =
|
||||||
if let Some(&ScrollbarLayout { axis, .. }) =
|
|
||||||
self.last_prepaint_state.as_ref().and_then(|state| {
|
self.last_prepaint_state.as_ref().and_then(|state| {
|
||||||
state
|
state
|
||||||
.thumb_for_position(position)
|
.thumb_for_position(position)
|
||||||
.filter(|thumb| thumb.cursor_hitbox.is_hovered(window))
|
.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)
|
ThumbState::Hover(axis)
|
||||||
} else {
|
} else {
|
||||||
ThumbState::Inactive
|
ThumbState::Inactive
|
||||||
},
|
};
|
||||||
window,
|
self.set_thumb_state(thumb_state, window, cx);
|
||||||
cx,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_thumb_state(&mut self, state: ThumbState, window: &mut Window, cx: &mut Context<Self>) {
|
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 {
|
fn parent_hovered(&self, window: &Window) -> bool {
|
||||||
self.last_prepaint_state
|
self.last_prepaint_state.as_ref().is_some_and(|state| {
|
||||||
.as_ref()
|
state.parent_bounds_hitbox.is_hovered(window)
|
||||||
.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> {
|
fn hit_for_position(&self, position: &Point<Pixels>) -> Option<&ScrollbarLayout> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue