From 199e896d9625c8f5da46c0ff3e45dce04ea23f05 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Sat, 21 Nov 2026 18:26:52 -0700 Subject: there's a concept of module visibility so that, for example, the battery module can self-hide and self-show when batteries are added or removed. also, said module now displays a list of battery names Force-Push: yes Change-Id: I8696f1b7e914aad3b1a663af12d6a00d9861b28c --- src/main.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 76e7fbb..d7710c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -345,7 +345,22 @@ impl Dock { let mut facilities = self.facilities.lock()?; for (module, framing) in &self.modules { - let text = module.lock()?.format(facilities.borrow_mut())?; + let text = { + let mut module = module.lock()?; + + let text = module.format(facilities.borrow_mut())?; + + /* We do this after calling format(), rather than before, to give + * the module a chance to decide whether it's shy. Thus, for example, + * hot-plugging the only battery will make the Battery module appear + * or disappear on the very next redraw, which will likely exceed the + * user's expectation of slickness. + */ + if !module.is_visible() { continue; } + + text + }; + self.draw_text(&mut open_parcel, &text, framing.alignment)?; } } -- cgit 1.4.1