Paint editor background

This commit is contained in:
Antonio Scandurra 2023-11-06 15:54:09 +01:00
parent 86d1defda2
commit 769526a76a
6 changed files with 948 additions and 809 deletions

View file

@ -36,7 +36,7 @@ pub use element::{
use futures::FutureExt;
use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{
div, AnyElement, AppContext, BackgroundExecutor, Context, Div, Element, EventEmitter,
div, px, AnyElement, AppContext, BackgroundExecutor, Context, Div, Element, EventEmitter,
FocusHandle, Hsla, Model, Pixels, Render, Styled, Subscription, Task, TextStyle, View,
ViewContext, VisualContext, WeakView, WindowContext,
};
@ -597,12 +597,11 @@ pub enum SoftWrap {
#[derive(Clone)]
pub struct EditorStyle {
pub background: Hsla,
pub local_player: PlayerColor,
pub text: TextStyle,
pub line_height_scalar: f32,
// pub placeholder_text: Option<TextStyle>,
// pub theme: theme::Editor,
pub theme_id: usize,
pub scrollbar_width: Pixels,
}
type CompletionId = usize;
@ -9327,10 +9326,11 @@ impl Render for Editor {
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
EditorElement::new(EditorStyle {
background: cx.theme().colors().editor,
local_player: cx.theme().players().local(),
text: cx.text_style(),
line_height_scalar: 1.,
theme_id: 0,
scrollbar_width: px(12.),
})
}
}

File diff suppressed because it is too large Load diff

View file

@ -176,6 +176,15 @@ pub fn black() -> Hsla {
}
}
pub fn transparent_black() -> Hsla {
Hsla {
h: 0.,
s: 0.,
l: 0.,
a: 0.,
}
}
pub fn white() -> Hsla {
Hsla {
h: 0.,

View file

@ -492,6 +492,15 @@ where
impl<T: Clone + Default + Debug + Copy> Copy for Edges<T> {}
impl<T: Clone + Default + Debug> Edges<T> {
pub fn all(value: T) -> Self {
Self {
top: value.clone(),
right: value.clone(),
bottom: value.clone(),
left: value,
}
}
pub fn map<U>(&self, f: impl Fn(&T) -> U) -> Edges<U>
where
U: Clone + Default + Debug,

View file

@ -103,10 +103,15 @@ pub struct ThemeColors {
pub tab_inactive: Hsla,
pub tab_active: Hsla,
pub editor: Hsla,
pub editor_gutter: Hsla,
pub editor_subheader: Hsla,
pub editor_active_line: Hsla,
pub editor_highlighted_line: Hsla,
pub editor_line_number: Hsla,
pub editor_active_line_number: Hsla,
pub editor_invisible: Hsla,
pub editor_wrap_guide: Hsla,
pub editor_active_wrap_guide: Hsla,
}
#[derive(Refineable, Clone)]

View file

@ -238,10 +238,15 @@ impl ThemeColors {
tab_active: neutral().light().step_1(),
tab_inactive: neutral().light().step_2(),
editor: neutral().light().step_1(),
editor_gutter: neutral().light().step_1(), // todo!("pick the right colors")
editor_subheader: neutral().light().step_2(),
editor_active_line: neutral().light_alpha().step_3(),
editor_line_number: neutral().light_alpha().step_3(), // todo!("pick the right colors")
editor_active_line_number: neutral().light_alpha().step_3(), // todo!("pick the right colors")
editor_highlighted_line: neutral().light_alpha().step_4(), // todo!("pick the right colors")
editor_invisible: neutral().light_alpha().step_4(), // todo!("pick the right colors")
editor_wrap_guide: neutral().light_alpha().step_4(), // todo!("pick the right colors")
editor_active_wrap_guide: neutral().light_alpha().step_4(), // todo!("pick the right colors")
}
}
@ -285,10 +290,15 @@ impl ThemeColors {
tab_active: neutral().dark().step_1(),
tab_inactive: neutral().dark().step_2(),
editor: neutral().dark().step_1(),
editor_gutter: neutral().dark().step_1(), // todo!("pick the right colors")
editor_subheader: neutral().dark().step_2(),
editor_active_line: neutral().dark_alpha().step_3(),
editor_line_number: neutral().dark_alpha().step_3(), // todo!("pick the right colors")
editor_active_line_number: neutral().dark_alpha().step_3(), // todo!("pick the right colors")
editor_highlighted_line: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
editor_invisible: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
editor_wrap_guide: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
editor_active_wrap_guide: neutral().dark_alpha().step_4(), // todo!("pick the right colors")
}
}
}