Define theme/ui text style settings in theme crate

This commit is contained in:
Max Brunsfeld 2023-05-17 14:44:55 -07:00
parent 5c729c0e56
commit 67a25126d4
86 changed files with 530 additions and 637 deletions

View file

@ -30,7 +30,6 @@ use gpui::{
};
use project::{Project, ProjectEntryId, ProjectPath};
use serde::Deserialize;
use settings::Settings;
use std::{any::Any, cell::RefCell, cmp, mem, path::Path, rc::Rc};
use theme::Theme;
use util::ResultExt;
@ -1297,7 +1296,7 @@ impl Pane {
}
fn render_tabs(&mut self, cx: &mut ViewContext<Self>) -> impl Element<Self> {
let theme = cx.global::<Settings>().theme.clone();
let theme = theme::current(cx).clone();
let pane = cx.handle().downgrade();
let autoscroll = if mem::take(&mut self.autoscroll) {
@ -1328,7 +1327,7 @@ impl Pane {
let pane = pane.clone();
let detail = detail.clone();
let theme = cx.global::<Settings>().theme.clone();
let theme = theme::current(cx).clone();
let mut tooltip_theme = theme.tooltip.clone();
tooltip_theme.max_text_width = None;
let tab_tooltip_text = item.tab_tooltip_text(cx).map(|a| a.to_string());
@ -1406,7 +1405,7 @@ impl Pane {
pane: pane.clone(),
},
{
let theme = cx.global::<Settings>().theme.clone();
let theme = theme::current(cx).clone();
let detail = detail.clone();
move |dragged_item: &DraggedItem, cx: &mut ViewContext<Workspace>| {
@ -1699,7 +1698,7 @@ impl View for Pane {
if let Some(active_item) = self.active_item() {
Flex::column()
.with_child({
let theme = cx.global::<Settings>().theme.clone();
let theme = theme::current(cx).clone();
let mut stack = Stack::new();
@ -1765,7 +1764,7 @@ impl View for Pane {
.into_any()
} else {
enum EmptyPane {}
let theme = cx.global::<Settings>().theme.clone();
let theme = theme::current(cx).clone();
dragged_item_receiver::<EmptyPane, _, _>(0, 0, false, None, cx, |_, cx| {
self.render_blank_pane(&theme, cx)
@ -1862,7 +1861,7 @@ fn render_tab_bar_button<F: 'static + Fn(&mut Pane, &mut EventContext<Pane>)>(
Stack::new()
.with_child(
MouseEventHandler::<TabBarButton, _>::new(index, cx, |mouse_state, cx| {
let theme = &cx.global::<Settings>().theme.workspace.tab_bar;
let theme = &theme::current(cx).workspace.tab_bar;
let style = theme.pane_button.style_for(mouse_state, false);
Svg::new(icon)
.with_color(style.color)
@ -2024,7 +2023,7 @@ impl<V: View> Element<V> for PaneBackdrop<V> {
view: &mut V,
cx: &mut ViewContext<V>,
) -> Self::PaintState {
let background = cx.global::<Settings>().theme.editor.background;
let background = theme::current(cx).editor.background;
let visible_bounds = bounds.intersection(visible_bounds).unwrap_or_default();
@ -2536,7 +2535,7 @@ mod tests {
fn init_test(cx: &mut TestAppContext) {
cx.update(|cx| {
cx.set_global(SettingsStore::test(cx));
cx.set_global(settings::Settings::test(cx));
theme::init((), cx);
crate::init_settings(cx);
});
}