remove the multi-theme system
This commit is contained in:
@@ -3,10 +3,9 @@ use std::panic::Location;
|
||||
use gpui::prelude::FluentBuilder;
|
||||
use gpui::{
|
||||
App, Div, Element, ElementId, InteractiveElement, IntoElement, ParentElement, RenderOnce,
|
||||
ScrollHandle, StatefulInteractiveElement, StyleRefinement, Styled, Window, div, px,
|
||||
ScrollHandle, StatefulInteractiveElement, StyleRefinement, Styled, Window, div,
|
||||
};
|
||||
use gpui_base::{Scrollbar, ScrollbarAxis, ScrollbarHandle};
|
||||
use theme::ActiveTheme as _;
|
||||
use gpui_base::{Scrollbar, ScrollbarAxis};
|
||||
|
||||
use crate::StyledExt as _;
|
||||
|
||||
@@ -19,53 +18,6 @@ pub trait ScrollableElement: InteractiveElement + Styled + ParentElement + Eleme
|
||||
}
|
||||
}
|
||||
|
||||
/// The scrollbar the application's theme describes: a 10px rail holding a 6px rounded thumb that grows to 8px under the pointer.
|
||||
fn scrollbar<H: ScrollbarHandle + Clone>(
|
||||
scroll_handle: &H,
|
||||
axis: ScrollbarAxis,
|
||||
cx: &App,
|
||||
) -> Scrollbar {
|
||||
let theme = cx.theme();
|
||||
let (thumb_width, thumb_radius) = if theme.scrollbar_mode.is_scrolling() {
|
||||
(px(6.), px(3.))
|
||||
} else {
|
||||
(px(8.), px(4.))
|
||||
};
|
||||
|
||||
Scrollbar::new(scroll_handle).axis(axis).styles(|styles| {
|
||||
styles
|
||||
.track(|track| {
|
||||
track
|
||||
.bg(theme.scrollbar_track_background)
|
||||
.border_color(theme.scrollbar_thumb_border)
|
||||
.width(px(10.))
|
||||
})
|
||||
.track_hover(|track| track.bg(theme.scrollbar_thumb_background).width(px(10.)))
|
||||
.thumb(|thumb| {
|
||||
thumb
|
||||
.bg(theme.scrollbar_thumb_background)
|
||||
.width(thumb_width)
|
||||
.inset(px(1.))
|
||||
.radius(thumb_radius)
|
||||
.min_length(px(48.))
|
||||
})
|
||||
.thumb_hover(|thumb| {
|
||||
thumb
|
||||
.bg(theme.scrollbar_thumb_hover_background)
|
||||
.width(px(8.))
|
||||
.inset(px(1.))
|
||||
.radius(px(4.))
|
||||
})
|
||||
.thumb_active(|thumb| {
|
||||
thumb
|
||||
.bg(theme.scrollbar_thumb_hover_background)
|
||||
.width(px(8.))
|
||||
.inset(px(1.))
|
||||
.radius(px(4.))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// A scrollable element wrapper that adds scrollbars to an interactive element.
|
||||
#[derive(IntoElement)]
|
||||
pub struct Scrollable<E: InteractiveElement + Styled + ParentElement + Element> {
|
||||
@@ -130,7 +82,11 @@ where
|
||||
})
|
||||
.child(self.element.size_auto().flex_1()),
|
||||
)
|
||||
.child(scrollbar(&scroll_handle, self.axis, cx).id("scrollbar"))
|
||||
.child(
|
||||
Scrollbar::new(&scroll_handle)
|
||||
.axis(self.axis)
|
||||
.id("scrollbar"),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user