use egui::Color32;
pub(crate) const WIDTH_SMALL: f32 = 360.0;
pub(crate) const WIDTH_MEDIUM: f32 = 520.0;
pub(crate) const WIDTH_LARGE: f32 = 640.0;
pub(crate) const PANEL_FILL: Color32 = Color32::from_rgb(30, 30, 30);
pub(crate) const PANEL_BORDER: Color32 = Color32::from_gray(80);
pub(crate) const TOAST_FILL: Color32 = Color32::from_rgba_unmultiplied_const(30, 30, 30, 240);
pub(crate) const BANNER_FILL: Color32 = Color32::from_rgba_unmultiplied_const(20, 40, 70, 240);
pub(crate) const DETAIL_FILL: Color32 = Color32::from_rgba_unmultiplied_const(60, 60, 60, 200);
pub(crate) const TEXT: Color32 = Color32::from_rgb(235, 235, 235);
pub(crate) const TEXT_MUTED: Color32 = Color32::GRAY;
pub(crate) const TEXT_ON_FILL: Color32 = Color32::WHITE;
pub(crate) const DETAIL_TEXT: Color32 = Color32::LIGHT_GREEN;
pub(crate) const ACCENT: Color32 = Color32::from_rgb(90, 150, 230);
pub(crate) const SUCCESS: Color32 = Color32::from_rgb(80, 180, 110);
pub(crate) const WARNING: Color32 = Color32::from_rgb(230, 180, 60);
pub(crate) const DANGER: Color32 = Color32::from_rgb(230, 90, 90);
pub(crate) const SAFE_FILL: Color32 = Color32::from_rgb(60, 120, 180);
pub(crate) const DESTRUCTIVE_FILL: Color32 = Color32::from_rgb(180, 50, 50);
pub(crate) fn solid_panel(ui: &mut egui::Ui) {
let visuals = ui.visuals_mut();
visuals.window_fill = PANEL_FILL;
visuals.panel_fill = PANEL_FILL;
visuals.widgets.noninteractive.bg_fill = PANEL_FILL;
}
#[cfg(test)]
mod tests {
#[test]
fn overlay_surfaces_take_colours_from_the_theme() {
let needles = [
["Color32::from", "_rgb("].join(""),
["Color32::from", "_rgba_unmultiplied("].join(""),
["Color32::from", "_gray("].join(""),
];
for (path, source) in [
("overlay/confirm.rs", include_str!("confirm.rs")),
("overlay/toast.rs", include_str!("toast.rs")),
(
"session_picker_mux.rs",
include_str!("../../session_picker_mux.rs"),
),
(
"tmux_session_picker_ui.rs",
include_str!("../../tmux_session_picker_ui.rs"),
),
("help_ui.rs", include_str!("../../help_ui.rs")),
("search/mod.rs", include_str!("../../search/mod.rs")),
(
"shader_install_ui.rs",
include_str!("../../shader_install_ui.rs"),
),
(
"integrations_ui.rs",
include_str!("../../integrations_ui.rs"),
),
] {
for needle in &needles {
assert!(
!source.contains(needle.as_str()),
"{path} spells a colour literal ({needle}); use an overlay::theme token"
);
}
}
}
}