use egui::{Color32, CornerRadius, FontId, Style, TextStyle, Vec2, Visuals};
pub mod qdark {
use super::*;
pub const BG1: Color32 = Color32::from_rgb(0x19, 0x23, 0x2D);
pub const BG2: Color32 = Color32::from_rgb(0x29, 0x35, 0x44);
pub const BG4: Color32 = Color32::from_rgb(0x45, 0x53, 0x64);
pub const BG5: Color32 = Color32::from_rgb(0x54, 0x68, 0x7A);
pub const BG6: Color32 = Color32::from_rgb(0x60, 0x79, 0x8B);
pub const TEXT1: Color32 = Color32::from_rgb(0xDF, 0xE1, 0xE2);
pub const TEXT3: Color32 = Color32::from_rgb(0xAC, 0xB1, 0xB6);
pub const ACCENT2: Color32 = Color32::from_rgb(0x34, 0x67, 0x92);
pub const ACCENT4: Color32 = Color32::from_rgb(0x25, 0x9A, 0xE9);
}
pub mod alert {
use egui::Color32;
pub const INFO: Color32 = Color32::from_rgb(0x18, 0x90, 0xFF);
pub const WARNING: Color32 = Color32::from_rgb(0xFA, 0xAD, 0x14);
pub const ERROR: Color32 = Color32::from_rgb(0xFF, 0x4D, 0x4F);
}
pub mod semantic {
use super::*;
pub const RISE: Color32 = Color32::from_rgb(0xE0, 0x50, 0x50);
pub const FALL: Color32 = Color32::from_rgb(0x2E, 0x9E, 0x2E);
pub const WARN: Color32 = Color32::from_rgb(0xE0, 0x88, 0x10);
pub const ERROR: Color32 = Color32::from_rgb(0xC0, 0x30, 0x30);
pub const OK: Color32 = Color32::from_rgb(0x2E, 0x7D, 0x32);
pub const INFO: Color32 = Color32::from_rgb(0x9A, 0xA8, 0xC0);
pub const MUTED: Color32 = Color32::from_rgb(0x88, 0x88, 0x88);
}
pub const FONT_HEADING: f32 = 22.0;
pub const FONT_BODY: f32 = 16.0;
pub const FONT_SMALL: f32 = 14.0;
pub const FONT_MONO: f32 = 15.0;
pub const CORNER: u8 = 4;
pub const STROKE_WIDTH: f32 = 1.0;
pub const SPACING_ITEM_X: f32 = 8.0;
pub const SPACING_ITEM_Y: f32 = 6.0;
pub const INTERACT_HEIGHT: f32 = 26.0;
pub const FRAME_INNER: f32 = 8.0;
pub const GROUP_GAP: f32 = 12.0;
pub const MARKET_BAND_HEIGHT: f32 = 240.0;
pub const ORDER_SIDE_WIDTH: f32 = 300.0;
pub fn apply(style: &mut Style) {
style
.text_styles
.insert(TextStyle::Body, FontId::proportional(FONT_BODY));
style
.text_styles
.insert(TextStyle::Button, FontId::proportional(FONT_BODY));
style
.text_styles
.insert(TextStyle::Small, FontId::proportional(FONT_SMALL));
style
.text_styles
.insert(TextStyle::Heading, FontId::proportional(FONT_HEADING));
style
.text_styles
.insert(TextStyle::Monospace, FontId::monospace(FONT_MONO));
style.spacing.item_spacing = Vec2::new(SPACING_ITEM_X, SPACING_ITEM_Y);
style.spacing.interact_size = Vec2::new(40.0, INTERACT_HEIGHT);
}
pub fn visuals() -> Visuals {
use qdark::*;
let r4 = CornerRadius::same(CORNER);
let mut v = Visuals::dark();
v.dark_mode = true;
v.window_fill = BG1;
v.panel_fill = BG1;
v.extreme_bg_color = BG1; v.faint_bg_color = BG2;
v.hyperlink_color = ACCENT4;
v.weak_text_color = Some(TEXT3);
v.window_stroke = egui::Stroke::new(STROKE_WIDTH, BG4);
v.window_corner_radius = r4;
v.menu_corner_radius = r4;
let stroke1 = egui::Stroke::new(STROKE_WIDTH, TEXT1);
v.widgets.noninteractive = egui::style::WidgetVisuals {
bg_fill: BG1,
weak_bg_fill: BG1,
bg_stroke: egui::Stroke::new(STROKE_WIDTH, BG4), corner_radius: r4,
fg_stroke: stroke1,
expansion: 0.0,
};
v.widgets.inactive = egui::style::WidgetVisuals {
bg_fill: BG4,
weak_bg_fill: BG4,
bg_stroke: egui::Stroke::new(STROKE_WIDTH, BG4), corner_radius: r4,
fg_stroke: stroke1,
expansion: 0.0,
};
v.widgets.hovered = egui::style::WidgetVisuals {
bg_fill: BG5,
weak_bg_fill: BG5,
bg_stroke: egui::Stroke::new(STROKE_WIDTH, BG5),
corner_radius: r4,
fg_stroke: stroke1,
expansion: 0.0,
};
v.widgets.active = egui::style::WidgetVisuals {
bg_fill: BG6,
weak_bg_fill: BG6,
bg_stroke: egui::Stroke::new(STROKE_WIDTH, BG6),
corner_radius: r4,
fg_stroke: stroke1,
expansion: 0.0,
};
v.widgets.open = egui::style::WidgetVisuals {
bg_fill: BG6,
weak_bg_fill: BG6,
bg_stroke: egui::Stroke::new(STROKE_WIDTH, BG4),
corner_radius: r4,
fg_stroke: stroke1,
expansion: 0.0,
};
v.selection = egui::style::Selection {
bg_fill: ACCENT2,
stroke: egui::Stroke::new(STROKE_WIDTH, TEXT1), };
v.interact_cursor = Some(egui::CursorIcon::PointingHand);
v
}
pub fn rise_fall(v: f64) -> Color32 {
if v > 0.0 {
semantic::RISE
} else if v < 0.0 {
semantic::FALL
} else {
qdark::TEXT1
}
}