use gpui::{App, Global, Hsla};
use theme::Theme;
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct CommentWashes {
pub color: Hsla,
pub open: Hsla,
pub active: Hsla,
pub resolved: Hsla,
}
impl CommentWashes {
pub fn of(color: Hsla) -> Self {
Self {
color,
open: color.opacity(0.20),
active: color.opacity(0.38),
resolved: color.opacity(0.08),
}
}
}
pub type CommentPaint = fn(theme: &Theme) -> CommentWashes;
struct Installed(CommentPaint);
impl Global for Installed {}
pub(crate) fn set_comment_paint(cx: &mut App, paint: CommentPaint) {
cx.set_global(Installed(paint));
}
pub fn default_comment(theme: &Theme) -> CommentWashes {
CommentWashes::of(theme.warning)
}
pub(crate) fn comment_paint_of(cx: &App) -> CommentPaint {
cx.try_global::<Installed>()
.map_or(default_comment, |installed| installed.0)
}