v0.6.3
This commit is contained in:
parent
89c1c8f396
commit
54012ab960
9 changed files with 1337 additions and 336 deletions
|
|
@ -122,12 +122,9 @@ fn create_monitor(app: &Application, params: SharedParams,
|
|||
let p = params.borrow();
|
||||
render::monitor_hit_test(x, y, canvas.width(), canvas.height(), &p)
|
||||
};
|
||||
match touched {
|
||||
Some(render::TouchChannel::Ecg) => open_ecg_menu(&app, &window,
|
||||
params.clone(), admin_changed.clone(), monitor_menu.clone()),
|
||||
Some(channel) => open_module_menu(&app, &window, params.clone(),
|
||||
admin_changed.clone(), monitor_menu.clone(), channel),
|
||||
None => (),
|
||||
if let Some(channel) = touched {
|
||||
open_module_menu(&app, &window, params.clone(),
|
||||
admin_changed.clone(), monitor_menu.clone(), channel);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -608,7 +605,16 @@ fn install_ecg_menu_style() {
|
|||
window.ecg-settings button.ecg-apply {
|
||||
color: #000000; background-color: #e5e9eb; font-weight: bold;
|
||||
}
|
||||
window.ecg-settings button.ecg-close { background-color: #171717; }"
|
||||
window.ecg-settings button.ecg-close { background-color: #171717; }
|
||||
window.ecg-settings box.alarm-limit-frame {
|
||||
border: 0.8px solid #6b757d; padding: 12px;
|
||||
}
|
||||
window.ecg-settings label.alarm-limit-heading {
|
||||
font-weight: bold; font-size: 17px;
|
||||
}
|
||||
window.ecg-settings label.alarm-limit-column-heading {
|
||||
font-size: 15px; font-weight: bold;
|
||||
}"
|
||||
);
|
||||
gtk::style_context_add_provider_for_display(
|
||||
&display, &provider, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
|
@ -632,14 +638,12 @@ fn ecg_menu_divider() -> gtk::DrawingArea {
|
|||
separator
|
||||
}
|
||||
|
||||
const TOUCH_HR_STEP: i32 = 5;
|
||||
const MAX_HR_ALARM: i32 = 240;
|
||||
|
||||
/// When a limit is OFF, either +/- first restores its previous value (or
|
||||
/// a sensible initial value). Subsequent presses adjust it by 5 bpm.
|
||||
fn stepped_hr_limit(current: Option<i32>, last_enabled: i32, direction: i32) -> i32 {
|
||||
current.map_or(last_enabled, |value| {
|
||||
(value + TOUCH_HR_STEP * direction).clamp(0, MAX_HR_ALARM)
|
||||
/// Apply a touchscreen step to an alarm value. When the alarm is disabled,
|
||||
/// either +/- first restores its last enabled value (unchanged behavior).
|
||||
fn stepped_alarm_limit(current: Option<i32>, previous: i32,
|
||||
direction: i32, step: i32, maximum: i32) -> i32 {
|
||||
current.map_or(previous, |value| {
|
||||
(value + step * direction).clamp(0, maximum)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -649,200 +653,23 @@ fn show_touch_hr_limit(value: Option<i32>, number: >k::Label,
|
|||
toggle.set_label(if value.is_some() { "OFF" } else { "ON" });
|
||||
}
|
||||
|
||||
/// Large, keyboard-free +/- and ON/OFF controls. Returning a Cell permits
|
||||
/// Apply to read the draft value without changing the shared configuration.
|
||||
fn ecg_touch_limit(parent: >k::Box, caption: &str,
|
||||
initial: Option<i32>, default: i32) -> Rc<Cell<Option<i32>>> {
|
||||
let state = Rc::new(Cell::new(initial));
|
||||
let previous = Rc::new(Cell::new(initial.unwrap_or(default)));
|
||||
let row = gtk::Box::new(Orientation::Horizontal, 10);
|
||||
|
||||
let heading = gtk::Label::new(Some(caption));
|
||||
heading.set_xalign(0.0);
|
||||
heading.set_width_chars(10);
|
||||
row.append(&heading);
|
||||
|
||||
let minus = gtk::Button::with_label("−");
|
||||
minus.set_tooltip_text(Some("Decrease alarm limit by 5 bpm"));
|
||||
minus.set_size_request(54, 50);
|
||||
row.append(&minus);
|
||||
|
||||
let display = gtk::Label::new(None);
|
||||
display.add_css_class("ecg-limit-value");
|
||||
display.set_width_chars(5);
|
||||
display.set_xalign(0.5);
|
||||
row.append(&display);
|
||||
|
||||
let plus = gtk::Button::with_label("+");
|
||||
plus.set_tooltip_text(Some("Increase alarm limit by 5 bpm"));
|
||||
plus.set_size_request(54, 50);
|
||||
row.append(&plus);
|
||||
|
||||
let enable_toggle = gtk::Button::new();
|
||||
enable_toggle.set_tooltip_text(Some("Enable or disable this alarm limit"));
|
||||
enable_toggle.set_size_request(78, 50);
|
||||
row.append(&enable_toggle);
|
||||
show_touch_hr_limit(initial, &display, &enable_toggle);
|
||||
|
||||
for (button, direction) in [(minus, -1), (plus, 1)] {
|
||||
let state = state.clone();
|
||||
let previous = previous.clone();
|
||||
let display = display.clone();
|
||||
let enable_toggle = enable_toggle.clone();
|
||||
button.connect_clicked(move |_| {
|
||||
let next = stepped_hr_limit(state.get(), previous.get(), direction);
|
||||
state.set(Some(next));
|
||||
previous.set(next);
|
||||
show_touch_hr_limit(Some(next), &display, &enable_toggle);
|
||||
});
|
||||
}
|
||||
enable_toggle.connect_clicked({
|
||||
let state = state.clone();
|
||||
let previous = previous.clone();
|
||||
let display = display.clone();
|
||||
move |button| {
|
||||
let new_value = match state.get() {
|
||||
Some(value) => {
|
||||
previous.set(value);
|
||||
None
|
||||
}
|
||||
None => Some(previous.get()),
|
||||
};
|
||||
state.set(new_value);
|
||||
show_touch_hr_limit(new_value, &display, button);
|
||||
}
|
||||
});
|
||||
parent.append(&row);
|
||||
state
|
||||
}
|
||||
|
||||
/// Displayed only for touches in the ECG row. The monitor window can remain
|
||||
/// fullscreen. The dialog is modal to that monitor, including on Wayland.
|
||||
fn open_ecg_menu(app: &Application, monitor: &ApplicationWindow,
|
||||
params: SharedParams, on_change: AdminChanged,
|
||||
open_menu: MonitorMenuHandle) {
|
||||
if let Some(existing) = open_menu.borrow().as_ref().and_then(|weak| weak.upgrade()) {
|
||||
existing.present();
|
||||
return;
|
||||
}
|
||||
let limits = params.borrow().alarms.hr;
|
||||
let dialog = gtk::Window::builder()
|
||||
.application(app)
|
||||
.title("ECG settings")
|
||||
.transient_for(monitor)
|
||||
.modal(true)
|
||||
.resizable(false)
|
||||
.default_width(550)
|
||||
.default_height(345)
|
||||
.build();
|
||||
dialog.add_css_class("ecg-settings");
|
||||
dialog.set_decorated(false);
|
||||
*open_menu.borrow_mut() = Some(dialog.downgrade());
|
||||
|
||||
let content = gtk::Box::new(Orientation::Vertical, 12);
|
||||
content.add_css_class("ecg-panel");
|
||||
content.set_margin_top(1);
|
||||
content.set_margin_bottom(1);
|
||||
content.set_margin_start(1);
|
||||
content.set_margin_end(1);
|
||||
// Inner padding keeps controls away from the thin panel border.
|
||||
let inner = gtk::Box::new(Orientation::Vertical, 12);
|
||||
inner.set_margin_top(20);
|
||||
inner.set_margin_bottom(20);
|
||||
inner.set_margin_start(20);
|
||||
inner.set_margin_end(20);
|
||||
content.append(&inner);
|
||||
|
||||
let title = gtk::Label::new(Some("ECG / SETTINGS"));
|
||||
title.set_xalign(0.0);
|
||||
title.add_css_class("title-2");
|
||||
inner.append(&title);
|
||||
inner.append(&ecg_menu_divider());
|
||||
|
||||
let limits_header = gtk::Label::new(Some("HR alarm limits · bpm"));
|
||||
limits_header.set_xalign(0.0);
|
||||
inner.append(&limits_header);
|
||||
let lower = ecg_touch_limit(&inner, "↓ Lower", limits.lower, 60);
|
||||
let upper = ecg_touch_limit(&inner, "↑ Upper", limits.upper, 100);
|
||||
let hint = gtk::Label::new(Some(
|
||||
"+/− adjusts by 5 bpm. OFF disables the limit; ON restores it."
|
||||
));
|
||||
hint.set_wrap(true);
|
||||
hint.set_xalign(0.0);
|
||||
inner.append(&hint);
|
||||
inner.append(&ecg_menu_divider());
|
||||
|
||||
let error = gtk::Label::new(None);
|
||||
error.add_css_class("menu-error");
|
||||
error.set_xalign(0.0);
|
||||
error.set_wrap(true);
|
||||
inner.append(&error);
|
||||
|
||||
let buttons = gtk::Box::new(Orientation::Horizontal, 12);
|
||||
buttons.set_halign(gtk::Align::End);
|
||||
let cancel = gtk::Button::with_label("Cancel");
|
||||
cancel.add_css_class("ecg-close");
|
||||
cancel.connect_clicked({
|
||||
let weak = dialog.downgrade();
|
||||
move |_| { if let Some(window) = weak.upgrade() { window.close(); } }
|
||||
});
|
||||
let apply = gtk::Button::with_label("Apply");
|
||||
apply.add_css_class("ecg-apply");
|
||||
apply.connect_clicked({
|
||||
let weak = dialog.downgrade();
|
||||
move |_| {
|
||||
let new_limits = AlarmLimits { lower: lower.get(), upper: upper.get() };
|
||||
if !new_limits.valid() {
|
||||
error.set_text("The lower limit must not exceed the upper limit.");
|
||||
return;
|
||||
}
|
||||
let alarm_changed = {
|
||||
let mut p = params.borrow_mut();
|
||||
let changed = p.alarms.hr != new_limits;
|
||||
p.alarms.hr = new_limits;
|
||||
changed
|
||||
};
|
||||
if let Some(callback) = on_change.borrow().as_ref() {
|
||||
callback(alarm_changed);
|
||||
}
|
||||
if let Some(window) = weak.upgrade() { window.close(); }
|
||||
}
|
||||
});
|
||||
buttons.append(&cancel);
|
||||
buttons.append(&apply);
|
||||
inner.append(&buttons);
|
||||
dialog.set_child(Some(&content));
|
||||
|
||||
let escape = gtk::EventControllerKey::new();
|
||||
escape.connect_key_pressed({
|
||||
let weak = dialog.downgrade();
|
||||
move |_, key, _, _| {
|
||||
if key == gdk::Key::Escape {
|
||||
if let Some(window) = weak.upgrade() { window.close(); }
|
||||
glib::Propagation::Stop
|
||||
} else { glib::Propagation::Proceed }
|
||||
}
|
||||
});
|
||||
dialog.add_controller(escape);
|
||||
dialog.present();
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod ecg_touch_menu_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn touch_step_uses_five_bpm_and_respects_bounds() {
|
||||
assert_eq!(stepped_hr_limit(Some(60), 60, 1), 65);
|
||||
assert_eq!(stepped_hr_limit(Some(60), 60, -1), 55);
|
||||
assert_eq!(stepped_hr_limit(Some(240), 240, 1), 240);
|
||||
assert_eq!(stepped_hr_limit(Some(0), 0, -1), 0);
|
||||
fn touch_step_preserves_per_parameter_increment_and_bounds() {
|
||||
assert_eq!(stepped_alarm_limit(Some(60), 60, 1, 5, 240), 65);
|
||||
assert_eq!(stepped_alarm_limit(Some(60), 60, -1, 5, 240), 55);
|
||||
assert_eq!(stepped_alarm_limit(Some(240), 240, 1, 5, 240), 240);
|
||||
assert_eq!(stepped_alarm_limit(Some(0), 0, -1, 5, 240), 0);
|
||||
assert_eq!(stepped_alarm_limit(Some(90), 90, 1, 1, 100), 91);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disabled_alarm_reenables_at_last_saved_value() {
|
||||
assert_eq!(stepped_hr_limit(None, 60, 1), 60);
|
||||
assert_eq!(stepped_hr_limit(None, 100, -1), 100);
|
||||
assert_eq!(stepped_alarm_limit(None, 60, 1, 5, 240), 60);
|
||||
assert_eq!(stepped_alarm_limit(None, 100, -1, 5, 240), 100);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -887,6 +714,9 @@ fn module_alarm_specs(channel: render::TouchChannel, p: &Parameters) -> Vec<Touc
|
|||
};
|
||||
}
|
||||
match channel {
|
||||
render::TouchChannel::Ecg => {
|
||||
limits!("HR", "bpm", hr, 240, 5, 60, 100);
|
||||
}
|
||||
render::TouchChannel::Spo2 => {
|
||||
limits!("SpO₂", "%", spo2, 100, 1, 90, 100);
|
||||
limits!("Pulse rate", "bpm", pr, 240, 5, 50, 120);
|
||||
|
|
@ -906,50 +736,53 @@ fn module_alarm_specs(channel: render::TouchChannel, p: &Parameters) -> Vec<Touc
|
|||
limits!("NIBP MAP", "mmHg", nibp_map, 260, 5, 60, 100);
|
||||
limits!("NIBP diastolic", "mmHg", nibp_dia, 260, 5, 40, 100);
|
||||
}
|
||||
render::TouchChannel::Ecg => {}
|
||||
}
|
||||
specs
|
||||
}
|
||||
|
||||
/// Generic unit-aware limit control with large +/- and ON/OFF touch buttons.
|
||||
/// Unlike the ECG-only helper, the increment and permitted range are per value.
|
||||
/// A compact alarm-limit cell: [+] value [−] [OFF/ON]. Its buttons retain
|
||||
/// the old size/style, step size, last-value restoration and draft semantics.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn module_touch_limit(parent: >k::Box, caption: &str, initial: Option<i32>,
|
||||
fallback: i32, step: i32, maximum: i32) -> Rc<Cell<Option<i32>>> {
|
||||
fn alarm_matrix_cell(initial: Option<i32>, fallback: i32, step: i32,
|
||||
maximum: i32) -> (gtk::Box, Rc<Cell<Option<i32>>>) {
|
||||
let state = Rc::new(Cell::new(initial));
|
||||
let previous = Rc::new(Cell::new(initial.unwrap_or(fallback)));
|
||||
let row = gtk::Box::new(Orientation::Horizontal, 10);
|
||||
let caption_label = gtk::Label::new(Some(caption));
|
||||
caption_label.set_width_chars(10);
|
||||
caption_label.set_xalign(0.0);
|
||||
row.append(&caption_label);
|
||||
let minus = gtk::Button::with_label("−");
|
||||
minus.set_size_request(54, 50);
|
||||
let display = gtk::Label::new(None);
|
||||
display.add_css_class("ecg-limit-value");
|
||||
display.set_xalign(0.5);
|
||||
display.set_width_chars(5);
|
||||
let controls = gtk::Box::new(Orientation::Horizontal, 5);
|
||||
controls.set_hexpand(true);
|
||||
controls.set_halign(gtk::Align::Center);
|
||||
|
||||
let plus = gtk::Button::with_label("+");
|
||||
plus.set_size_request(54, 50);
|
||||
plus.set_tooltip_text(Some("Increase alarm limit"));
|
||||
let display = gtk::Label::new(None);
|
||||
display.add_css_class("ecg-limit-value");
|
||||
display.set_width_chars(5);
|
||||
display.set_xalign(0.5);
|
||||
let minus = gtk::Button::with_label("−");
|
||||
minus.set_size_request(54, 50);
|
||||
minus.set_tooltip_text(Some("Decrease alarm limit"));
|
||||
let toggle = gtk::Button::new();
|
||||
toggle.set_size_request(78, 50);
|
||||
toggle.set_tooltip_text(Some("Enable or disable this alarm limit"));
|
||||
show_touch_hr_limit(initial, &display, &toggle);
|
||||
row.append(&minus);
|
||||
row.append(&display);
|
||||
row.append(&plus);
|
||||
row.append(&toggle);
|
||||
for (button, direction) in [(minus, -1), (plus, 1)] {
|
||||
|
||||
// Requested left-to-right order: plus, value, minus, OFF.
|
||||
controls.append(&plus);
|
||||
controls.append(&display);
|
||||
controls.append(&minus);
|
||||
controls.append(&toggle);
|
||||
|
||||
for (button, direction) in [(plus, 1), (minus, -1)] {
|
||||
let state = state.clone();
|
||||
let previous = previous.clone();
|
||||
let display = display.clone();
|
||||
let toggle = toggle.clone();
|
||||
button.connect_clicked(move |_| {
|
||||
let new_value = state.get().map_or(previous.get(), |current| {
|
||||
(current + direction * step).clamp(0, maximum)
|
||||
});
|
||||
state.set(Some(new_value));
|
||||
previous.set(new_value);
|
||||
show_touch_hr_limit(Some(new_value), &display, &toggle);
|
||||
let next = stepped_alarm_limit(state.get(), previous.get(),
|
||||
direction, step, maximum);
|
||||
state.set(Some(next));
|
||||
previous.set(next);
|
||||
show_touch_hr_limit(Some(next), &display, &toggle);
|
||||
});
|
||||
}
|
||||
toggle.connect_clicked({
|
||||
|
|
@ -957,16 +790,80 @@ fn module_touch_limit(parent: >k::Box, caption: &str, initial: Option<i32>,
|
|||
let previous = previous.clone();
|
||||
let display = display.clone();
|
||||
move |button| {
|
||||
let new_value = match state.get() {
|
||||
let next = match state.get() {
|
||||
Some(value) => { previous.set(value); None }
|
||||
None => Some(previous.get()),
|
||||
};
|
||||
state.set(new_value);
|
||||
show_touch_hr_limit(new_value, &display, button);
|
||||
state.set(next);
|
||||
show_touch_hr_limit(next, &display, button);
|
||||
}
|
||||
});
|
||||
parent.append(&row);
|
||||
state
|
||||
(controls, state)
|
||||
}
|
||||
|
||||
/// Short names in the alarm matrix; full labels remain available as tooltips.
|
||||
fn alarm_matrix_label(name: &str) -> &str {
|
||||
match name {
|
||||
"ART systolic" | "NIBP systolic" => "SYS",
|
||||
"ART MAP" | "NIBP MAP" => "MAP",
|
||||
"ART diastolic" | "NIBP diastolic" => "DIA",
|
||||
"Pulse rate" => "PR",
|
||||
"Respiratory rate" => "RR",
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
/// Common touchscreen matrix for ECG, SpO2, ART, CO2 and NIBP.
|
||||
/// Each parameter occupies one horizontal row; lower and upper limits have
|
||||
/// identical columns and the action order [+] value [−] [OFF/ON].
|
||||
fn alarm_limit_matrix(specs: Vec<TouchAlarmSpec>,
|
||||
drafts: &mut Vec<TouchAlarmDraft>) -> gtk::Box {
|
||||
let frame = gtk::Box::new(Orientation::Vertical, 8);
|
||||
frame.add_css_class("alarm-limit-frame");
|
||||
frame.set_hexpand(true);
|
||||
|
||||
let heading = gtk::Label::new(Some("Alarm Limits"));
|
||||
heading.add_css_class("alarm-limit-heading");
|
||||
heading.set_xalign(0.0);
|
||||
frame.append(&heading);
|
||||
|
||||
let grid = gtk::Grid::new();
|
||||
grid.set_hexpand(true);
|
||||
grid.set_column_spacing(8);
|
||||
grid.set_row_spacing(8);
|
||||
|
||||
for (column, text) in [(1, "↓ Lower"), (2, "↑ Upper")] {
|
||||
let label = gtk::Label::new(Some(text));
|
||||
label.add_css_class("alarm-limit-column-heading");
|
||||
label.set_halign(gtk::Align::Center);
|
||||
grid.attach(&label, column, 0, 1, 1);
|
||||
}
|
||||
|
||||
for (index, spec) in specs.into_iter().enumerate() {
|
||||
// An empty narrow divider row keeps each parameter visually distinct.
|
||||
let base = 1 + (index as i32) * 2;
|
||||
if index > 0 {
|
||||
grid.attach(&ecg_menu_divider(), 0, base - 1, 3, 1);
|
||||
}
|
||||
let label = gtk::Label::new(Some(alarm_matrix_label(spec.name)));
|
||||
label.set_xalign(0.0);
|
||||
label.set_tooltip_text(Some(&format!("{} ({})", spec.name, spec.unit)));
|
||||
label.add_css_class("alarm-limit-heading");
|
||||
label.set_width_chars(5);
|
||||
grid.attach(&label, 0, base, 1, 1);
|
||||
|
||||
let (lower_controls, lower) = alarm_matrix_cell(spec.limits.lower,
|
||||
spec.restore_lower, spec.step, spec.maximum);
|
||||
let (upper_controls, upper) = alarm_matrix_cell(spec.limits.upper,
|
||||
spec.restore_upper, spec.step, spec.maximum);
|
||||
grid.attach(&lower_controls, 1, base, 1, 1);
|
||||
grid.attach(&upper_controls, 2, base, 1, 1);
|
||||
drafts.push(TouchAlarmDraft {
|
||||
name: spec.name, lower, upper, apply: spec.apply,
|
||||
});
|
||||
}
|
||||
frame.append(&grid);
|
||||
frame
|
||||
}
|
||||
|
||||
/// A monitor-side menu may change only alarm limits. All patient and
|
||||
|
|
@ -998,7 +895,7 @@ fn open_module_menu(app: &Application, monitor: &ApplicationWindow,
|
|||
render::TouchChannel::Art => "ART / SETTINGS",
|
||||
render::TouchChannel::Capno => "CO₂ / SETTINGS",
|
||||
render::TouchChannel::Nibp => "NIBP / SETTINGS",
|
||||
render::TouchChannel::Ecg => return,
|
||||
render::TouchChannel::Ecg => "ECG / SETTINGS",
|
||||
};
|
||||
let dialog = gtk::Window::builder()
|
||||
.application(app)
|
||||
|
|
@ -1006,8 +903,13 @@ fn open_module_menu(app: &Application, monitor: &ApplicationWindow,
|
|||
.transient_for(monitor)
|
||||
.modal(true)
|
||||
.resizable(true)
|
||||
.default_width(560)
|
||||
.default_height(if channel == render::TouchChannel::Art { 720 } else { 610 })
|
||||
.default_width(800)
|
||||
.default_height(match channel {
|
||||
render::TouchChannel::Art => 560,
|
||||
render::TouchChannel::Nibp => 490,
|
||||
render::TouchChannel::Ecg => 310,
|
||||
_ => 420,
|
||||
})
|
||||
.build();
|
||||
dialog.add_css_class("ecg-settings");
|
||||
dialog.set_decorated(false);
|
||||
|
|
@ -1036,28 +938,22 @@ fn open_module_menu(app: &Application, monitor: &ApplicationWindow,
|
|||
inner.append(&heading);
|
||||
inner.append(&ecg_menu_divider());
|
||||
|
||||
// Every numeric alarm has two optional bounds, editable without a keyboard.
|
||||
// A shared horizontal matrix is used in every monitor-side touch menu.
|
||||
let specs = module_alarm_specs(channel, ¤t);
|
||||
let mut alarm_drafts = Vec::new();
|
||||
for spec in specs {
|
||||
let label = gtk::Label::new(Some(&format!("{} alarm limits · {}", spec.name, spec.unit)));
|
||||
label.set_xalign(0.0);
|
||||
inner.append(&label);
|
||||
let lower = module_touch_limit(&inner, "↓ Lower", spec.limits.lower,
|
||||
spec.restore_lower, spec.step, spec.maximum);
|
||||
let upper = module_touch_limit(&inner, "↑ Upper", spec.limits.upper,
|
||||
spec.restore_upper, spec.step, spec.maximum);
|
||||
alarm_drafts.push(TouchAlarmDraft {
|
||||
name: spec.name, lower, upper, apply: spec.apply,
|
||||
});
|
||||
inner.append(&ecg_menu_divider());
|
||||
}
|
||||
inner.append(&alarm_limit_matrix(specs, &mut alarm_drafts));
|
||||
|
||||
let error = gtk::Label::new(None);
|
||||
error.set_xalign(0.0);
|
||||
error.add_css_class("menu-error");
|
||||
error.set_wrap(true);
|
||||
inner.append(&error);
|
||||
// Validation and Apply/Cancel stay fixed when the matrix scrolls.
|
||||
let footer = gtk::Box::new(Orientation::Vertical, 8);
|
||||
footer.set_margin_start(20);
|
||||
footer.set_margin_end(20);
|
||||
footer.set_margin_top(8);
|
||||
footer.set_margin_bottom(12);
|
||||
footer.append(&error);
|
||||
let buttons = gtk::Box::new(Orientation::Horizontal, 12);
|
||||
buttons.set_halign(gtk::Align::End);
|
||||
let cancel = gtk::Button::with_label("Cancel");
|
||||
|
|
@ -1097,7 +993,8 @@ fn open_module_menu(app: &Application, monitor: &ApplicationWindow,
|
|||
});
|
||||
buttons.append(&cancel);
|
||||
buttons.append(&apply);
|
||||
inner.append(&buttons);
|
||||
footer.append(&buttons);
|
||||
content.append(&footer);
|
||||
dialog.set_child(Some(&content));
|
||||
|
||||
let escape = gtk::EventControllerKey::new();
|
||||
|
|
@ -1133,6 +1030,39 @@ mod module_touch_menu_tests {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alarm_matrix_order_and_labels() {
|
||||
let p = Parameters::default();
|
||||
for (channel, names) in [
|
||||
(render::TouchChannel::Ecg, vec!["HR"]),
|
||||
(render::TouchChannel::Spo2, vec!["SpO₂", "PR"]),
|
||||
(render::TouchChannel::Art, vec!["SYS", "MAP", "DIA", "PPV"]),
|
||||
(render::TouchChannel::Capno, vec!["EtCO₂", "RR"]),
|
||||
(render::TouchChannel::Nibp, vec!["SYS", "MAP", "DIA"]),
|
||||
] {
|
||||
let specs = module_alarm_specs(channel, &p);
|
||||
let actual: Vec<_> = specs.iter()
|
||||
.map(|spec| alarm_matrix_label(spec.name)).collect();
|
||||
assert_eq!(actual, names);
|
||||
}
|
||||
// Same underlying ART alarm setters are retained after rearrangement.
|
||||
let specs = module_alarm_specs(render::TouchChannel::Art, &p);
|
||||
let limits = [
|
||||
AlarmLimits { lower: Some(80), upper: Some(180) },
|
||||
AlarmLimits { lower: Some(60), upper: Some(100) },
|
||||
AlarmLimits { lower: None, upper: None },
|
||||
AlarmLimits { lower: None, upper: Some(10) },
|
||||
];
|
||||
let mut alarms = AlarmSettings::default();
|
||||
for (spec, value) in specs.into_iter().zip(limits.iter().copied()) {
|
||||
(spec.apply)(&mut alarms, value);
|
||||
}
|
||||
assert_eq!(alarms.art_sys, limits[0]);
|
||||
assert_eq!(alarms.art_map, limits[1]);
|
||||
assert_eq!(alarms.art_dia, limits[2]);
|
||||
assert_eq!(alarms.ppv, limits[3]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn touchscreen_applies_only_alarm_limits_and_preserves_other_controls() {
|
||||
let mut p = Parameters::default();
|
||||
|
|
|
|||
Loading…
Reference in a new issue