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

@ -0,0 +1,141 @@
diff --git a/Cargo.toml b/Cargo.toml
index e273c5e..b9aa888 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "patient-monitor-simulation"
-version = "0.4.3"
+version = "0.4.4"
edition = "2021"
license = "MIT"
description = "Synthetic patient-monitor simulation for teaching (not for clinical use)"
diff --git a/README.md b/README.md
index cdc1f9b..21e1f99 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Patient Monitor Simulation (PaMSim) — v0.4.3
+# Patient Monitor Simulation (PaMSim) — v0.4.4
A two-window, Rust/GTK4 patient-monitor simulator for teaching on Fedora Linux.
@@ -20,6 +20,12 @@ session (e.g., Fedora KDE/Wayland).
## Windows
+**Admin sections** have a narrow colored stripe on their left edge to match the
+monitor: ECG **green**, SpO₂ **yellow**, invasive arterial pressure **red**,
+capnography **light grey**, NIBP **light grey**. The Patient section remains
+neutral. These accents are drawn by GTK and remain visible independently of
+light/dark themes. This is a visual-only change; control behavior is unchanged.
+
**Admin:** Controls patient name; ECG rhythm and rate; mechanical capture;
SpO₂, signal quality and sensor connection; invasive arterial pressure,
waveform shape and pulse-pressure variation; NIBP; and capnography. Numeric inputs have bidirectionally linked sliders and text fields.
diff --git a/src/ui.rs b/src/ui.rs
index 55d31cb..7000833 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -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
}

View file

@ -438,7 +438,7 @@ dependencies = [
[[package]] [[package]]
name = "patient-monitor-simulation" name = "patient-monitor-simulation"
version = "0.4.3" version = "0.4.4"
dependencies = [ dependencies = [
"gtk4", "gtk4",
] ]

View file

@ -1,6 +1,6 @@
[package] [package]
name = "patient-monitor-simulation" name = "patient-monitor-simulation"
version = "0.4.3" version = "0.4.4"
edition = "2021" edition = "2021"
license = "MIT" license = "MIT"
description = "Synthetic patient-monitor simulation for teaching (not for clinical use)" description = "Synthetic patient-monitor simulation for teaching (not for clinical use)"

View file

@ -1,4 +1,4 @@
# Patient Monitor Simulation (PaMSim) — v0.4.3 # Patient Monitor Simulation (PaMSim) — v0.4.4
A two-window, Rust/GTK4 patient-monitor simulator for teaching on Fedora Linux. A two-window, Rust/GTK4 patient-monitor simulator for teaching on Fedora Linux.
@ -20,6 +20,12 @@ session (e.g., Fedora KDE/Wayland).
## Windows ## Windows
**Admin sections** have a narrow colored stripe on their left edge to match the
monitor: ECG **green**, SpO₂ **yellow**, invasive arterial pressure **red**,
capnography **light grey**, NIBP **light grey**. The Patient section remains
neutral. These accents are drawn by GTK and remain visible independently of
light/dark themes. This is a visual-only change; control behavior is unchanged.
**Admin:** Controls patient name; ECG rhythm and rate; mechanical capture; **Admin:** Controls patient name; ECG rhythm and rate; mechanical capture;
SpO₂, signal quality and sensor connection; invasive arterial pressure, SpO₂, signal quality and sensor connection; invasive arterial pressure,
waveform shape and pulse-pressure variation; NIBP; and capnography. Numeric inputs have bidirectionally linked sliders and text fields. waveform shape and pulse-pressure variation; NIBP; and capnography. Numeric inputs have bidirectionally linked sliders and text fields.

View file

@ -14,6 +14,14 @@ use crate::simulation::Simulator;
type SharedParams = Rc<RefCell<Parameters>>; 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) { pub fn create_windows(app: &Application) {
let parameters = Rc::new(RefCell::new(Parameters::default())); let parameters = Rc::new(RefCell::new(Parameters::default()));
let simulator = Rc::new(RefCell::new(Simulator::new(&parameters.borrow()))); 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 updating_preset = Rc::new(Cell::new(false));
let mut alarm_editors: Vec<(AlarmEditor, fn(&AlarmSettings) -> AlarmLimits)> = Vec::new(); 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_row = gtk::Box::new(Orientation::Horizontal, 8);
let patient_label = gtk::Label::new(Some("Patient name")); let patient_label = gtk::Label::new(Some("Patient name"));
patient_label.set_xalign(0.0); patient_label.set_xalign(0.0);
@ -143,7 +151,7 @@ fn create_admin(app: &Application, params: SharedParams,
patient_row.append(&name_entry); patient_row.append(&name_entry);
patient.append(&patient_row); 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); add_visibility(&ecg, params.borrow().show_ecg, params.clone(), |p, show| p.show_ecg = show);
let rhythm_dropdown = add_dropdown_at(&ecg, "ECG rhythm", &[ let rhythm_dropdown = add_dropdown_at(&ecg, "ECG rhythm", &[
"Sinus rhythm", "Atrial fibrillation", "Ventricular tachycardia (VT)", "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, params.borrow().alarms.hr, params.clone(), |p, v| p.alarms.hr = v,
&preset_dropdown, &updating_preset), |s| s.hr)); &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); 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, let (spo2_row, _, _) = add_numeric(&spo2, "SpO₂", "%", 0, 100, params.borrow().spo2,
params.clone(), |p, v| p.spo2 = v); 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); conduction_hint.set_wrap(true);
spo2.append(&conduction_hint); 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); 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, let (art_sys_row, _, _) = add_numeric(&art, "Systolic", "mmHg", 0, 200, params.borrow().art_systolic,
params.clone(), |p, v| p.art_systolic = v); 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); 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, let (nibp_sys_row, _, _) = add_numeric(&nibp, "Systolic", "mmHg", 0, 260, params.borrow().nibp_systolic,
params.clone(), |p, v| p.nibp_systolic = v); 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, params.borrow().alarms.nibp_dia, params.clone(), |p, v| p.alarms.nibp_dia = v,
&preset_dropdown, &updating_preset), |s| s.nibp_dia)); &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_visibility(&capno, params.borrow().show_capno, params.clone(), |p, show| p.show_capno = show);
add_dropdown(&capno, "Capnogram", &["Normal", "Obstructive / shark fin"], add_dropdown(&capno, "Capnogram", &["Normal", "Obstructive / shark fin"],
params.clone(), |p, selected| { params.clone(), |p, selected| {
@ -352,14 +360,30 @@ ART and pleth are delayed. VT can be perfusing; PVT, VF and asystole are pulsele
window 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 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); let content = gtk::Box::new(Orientation::Vertical, 8);
content.set_hexpand(true);
content.set_margin_top(10); content.set_margin_top(10);
content.set_margin_bottom(10); content.set_margin_bottom(10);
content.set_margin_start(10); content.set_margin_start(10);
content.set_margin_end(10); content.set_margin_end(10);
frame.set_child(Some(&content)); body.append(&content);
frame.set_child(Some(&body));
parent.append(&frame); parent.append(&frame);
content content
} }