diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-11-21 18:26:52 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-11-21 18:32:36 -0700 |
| commit | 199e896d9625c8f5da46c0ff3e45dce04ea23f05 (patch) | |
| tree | 5be8404893b52eee44d7b96f2219b8b218c9a56e /src/main.rs | |
| parent | 3f9e377d790da460919bd9f6ab82402424744c96 (diff) | |
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
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 17 |
1 files changed, 16 insertions, 1 deletions
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)?; } } |