admin interface: design tweaks

This commit is contained in:
GABRIEL Sebastian 2026-11-12 12:47:47 +01:00
commit e831364e43
5 changed files with 182 additions and 11 deletions

View file

@ -14,6 +14,14 @@ use crate::simulation::Simulator;
type SharedParams = Rc<RefCell<Parameters>>;
// Match the RGB colors of the monitor traces (see render.rs).
// NIBP uses the same light grey as the NIBP footer and capnography.
type AccentColor = (f64, f64, f64);
const ECG_GREEN: AccentColor = (0.26, 1.0, 0.39);
const SPO2_YELLOW: AccentColor = (1.0, 0.85, 0.17);
const ART_RED: AccentColor = (1.0, 0.30, 0.31);
const MONITOR_GREY: AccentColor = (0.80, 0.84, 0.87);
pub fn create_windows(app: &Application) {
let parameters = Rc::new(RefCell::new(Parameters::default()));
let simulator = Rc::new(RefCell::new(Simulator::new(&parameters.borrow())));
@ -125,7 +133,7 @@ fn create_admin(app: &Application, params: SharedParams,
let updating_preset = Rc::new(Cell::new(false));
let mut alarm_editors: Vec<(AlarmEditor, fn(&AlarmSettings) -> AlarmLimits)> = Vec::new();
let patient = group(&controls, "Patient");
let patient = group(&controls, "Patient", None);
let patient_row = gtk::Box::new(Orientation::Horizontal, 8);
let patient_label = gtk::Label::new(Some("Patient name"));
patient_label.set_xalign(0.0);
@ -143,7 +151,7 @@ fn create_admin(app: &Application, params: SharedParams,
patient_row.append(&name_entry);
patient.append(&patient_row);
let ecg = group(&controls, "ECG");
let ecg = group(&controls, "ECG", Some(ECG_GREEN));
add_visibility(&ecg, params.borrow().show_ecg, params.clone(), |p, show| p.show_ecg = show);
let rhythm_dropdown = add_dropdown_at(&ecg, "ECG rhythm", &[
"Sinus rhythm", "Atrial fibrillation", "Ventricular tachycardia (VT)",
@ -173,7 +181,7 @@ fn create_admin(app: &Application, params: SharedParams,
params.borrow().alarms.hr, params.clone(), |p, v| p.alarms.hr = v,
&preset_dropdown, &updating_preset), |s| s.hr));
let spo2 = group(&controls, "Pulse oximetry");
let spo2 = group(&controls, "Pulse oximetry", Some(SPO2_YELLOW));
add_visibility(&spo2, params.borrow().show_spo2, params.clone(), |p, show| p.show_spo2 = show);
let (spo2_row, _, _) = add_numeric(&spo2, "SpO₂", "%", 0, 100, params.borrow().spo2,
params.clone(), |p, v| p.spo2 = v);
@ -238,7 +246,7 @@ ART and pleth are delayed. VT can be perfusing; PVT, VF and asystole are pulsele
conduction_hint.set_wrap(true);
spo2.append(&conduction_hint);
let art = group(&controls, "Invasive arterial blood pressure");
let art = group(&controls, "Invasive arterial blood pressure", Some(ART_RED));
add_visibility(&art, params.borrow().show_art, params.clone(), |p, show| p.show_art = show);
let (art_sys_row, _, _) = add_numeric(&art, "Systolic", "mmHg", 0, 200, params.borrow().art_systolic,
params.clone(), |p, v| p.art_systolic = v);
@ -275,7 +283,7 @@ ART and pleth are delayed. VT can be perfusing; PVT, VF and asystole are pulsele
};
});
let nibp = group(&controls, "Non-invasive blood pressure (NIBP)");
let nibp = group(&controls, "Non-invasive blood pressure (NIBP)", Some(MONITOR_GREY));
add_visibility(&nibp, params.borrow().show_nibp, params.clone(), |p, show| p.show_nibp = show);
let (nibp_sys_row, _, _) = add_numeric(&nibp, "Systolic", "mmHg", 0, 260, params.borrow().nibp_systolic,
params.clone(), |p, v| p.nibp_systolic = v);
@ -291,7 +299,7 @@ ART and pleth are delayed. VT can be perfusing; PVT, VF and asystole are pulsele
params.borrow().alarms.nibp_dia, params.clone(), |p, v| p.alarms.nibp_dia = v,
&preset_dropdown, &updating_preset), |s| s.nibp_dia));
let capno = group(&controls, "Capnography");
let capno = group(&controls, "Capnography", Some(MONITOR_GREY));
add_visibility(&capno, params.borrow().show_capno, params.clone(), |p, show| p.show_capno = show);
add_dropdown(&capno, "Capnogram", &["Normal", "Obstructive / shark fin"],
params.clone(), |p, selected| {
@ -352,14 +360,30 @@ ART and pleth are delayed. VT can be perfusing; PVT, VF and asystole are pulsele
window
}
fn group(parent: &gtk::Box, title: &str) -> gtk::Box {
/// Frame a parameter section with an optional monitor-colored left sidebar.
/// A DrawingArea keeps the color independent of the user's GTK theme/CSS.
fn group(parent: &gtk::Box, title: &str, accent: Option<AccentColor>) -> gtk::Box {
let frame = gtk::Frame::new(Some(title));
let body = gtk::Box::new(Orientation::Horizontal, 0);
if let Some((red, green, blue)) = accent {
let stripe = gtk::DrawingArea::new();
stripe.set_content_width(7);
stripe.set_vexpand(true);
stripe.set_draw_func(move |_area, cr, width, height| {
cr.set_source_rgb(red, green, blue);
cr.rectangle(0.0, 0.0, f64::from(width), f64::from(height));
let _ = cr.fill();
});
body.append(&stripe);
}
let content = gtk::Box::new(Orientation::Vertical, 8);
content.set_hexpand(true);
content.set_margin_top(10);
content.set_margin_bottom(10);
content.set_margin_start(10);
content.set_margin_end(10);
frame.set_child(Some(&content));
body.append(&content);
frame.set_child(Some(&body));
parent.append(&frame);
content
}