menu: Fix Menu scrollbar will always showing bug. (#328)
- Improved Scrollbar size.
This commit is contained in:
parent
5915618928
commit
efa044f417
2 changed files with 25 additions and 14 deletions
|
|
@ -463,6 +463,7 @@ impl Render for PopupMenu {
|
|||
.popover_style(cx)
|
||||
.text_color(cx.theme().popover_foreground)
|
||||
.relative()
|
||||
.p_1()
|
||||
.child(
|
||||
div()
|
||||
.id("popup-menu-items")
|
||||
|
|
@ -473,7 +474,6 @@ impl Render for PopupMenu {
|
|||
})
|
||||
.child(
|
||||
v_flex()
|
||||
.p_1()
|
||||
.gap_y_0p5()
|
||||
.min_w(self.min_width)
|
||||
.max_w(self.max_width)
|
||||
|
|
@ -645,10 +645,10 @@ impl Render for PopupMenu {
|
|||
this.child(
|
||||
div()
|
||||
.absolute()
|
||||
.top_1()
|
||||
.left_1()
|
||||
.right_1()
|
||||
.bottom_1()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.right_0p5()
|
||||
.bottom_0()
|
||||
.child(Scrollbar::vertical(
|
||||
cx.entity_id(),
|
||||
self.scroll_state.clone(),
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ use gpui::{
|
|||
};
|
||||
|
||||
const MIN_THUMB_SIZE: f32 = 80.;
|
||||
const THUMB_RADIUS: Pixels = Pixels(4.0);
|
||||
const THUMB_INSET: Pixels = Pixels(2.);
|
||||
const THUMB_RADIUS: Pixels = Pixels(3.0);
|
||||
const THUMB_INSET: Pixels = Pixels(4.);
|
||||
|
||||
pub trait ScrollHandleOffsetable {
|
||||
fn offset(&self) -> Point<Pixels>;
|
||||
|
|
@ -162,7 +162,7 @@ impl Scrollbar {
|
|||
state,
|
||||
axis,
|
||||
scroll_size,
|
||||
width: px(8.),
|
||||
width: px(12.),
|
||||
scroll_handle: Rc::new(Box::new(scroll_handle)),
|
||||
}
|
||||
}
|
||||
|
|
@ -367,17 +367,30 @@ impl Element for Scrollbar {
|
|||
|
||||
let thumb_bg = cx.theme().scrollbar_thumb;
|
||||
let state = self.state.clone();
|
||||
let (thumb_bg, bar_bg, bar_border, inset) =
|
||||
let (thumb_bg, bar_bg, bar_border, inset, radius) =
|
||||
if state.get().dragged_axis == Some(axis) {
|
||||
(thumb_bg, cx.theme().scrollbar, cx.theme().border, px(1.))
|
||||
(
|
||||
thumb_bg,
|
||||
cx.theme().scrollbar,
|
||||
cx.theme().border,
|
||||
THUMB_INSET - px(1.),
|
||||
THUMB_RADIUS,
|
||||
)
|
||||
} else if state.get().hovered_axis == Some(axis) {
|
||||
(thumb_bg, cx.theme().scrollbar, cx.theme().border, px(1.))
|
||||
(
|
||||
thumb_bg,
|
||||
cx.theme().scrollbar,
|
||||
cx.theme().border,
|
||||
THUMB_INSET - px(1.),
|
||||
THUMB_RADIUS,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
thumb_bg.opacity(0.3),
|
||||
cx.theme().transparent,
|
||||
gpui::transparent_black(),
|
||||
THUMB_INSET,
|
||||
THUMB_RADIUS - px(1.),
|
||||
)
|
||||
};
|
||||
|
||||
|
|
@ -431,9 +444,7 @@ impl Element for Scrollbar {
|
|||
border_color: bar_border,
|
||||
});
|
||||
|
||||
cx.paint_quad(
|
||||
fill(thumb_bounds, thumb_bg).corner_radii(THUMB_RADIUS - inset),
|
||||
);
|
||||
cx.paint_quad(fill(thumb_bounds, thumb_bg).corner_radii(radius));
|
||||
}
|
||||
|
||||
cx.on_mouse_event({
|
||||
|
|
|
|||
Loading…
Reference in a new issue