A treemap for finding and removing what fills your disk, for Omarchy. Rust + GPUI.
Rust
fix: keep a check on the saved Power Efficiency preset
Harold Hunt464e476c9e57
diff --git a/crates/disktree-app/src/tests.rs b/crates/disktree-app/src/tests.rsindex ca17a81..3bcd224 100644--- a/crates/disktree-app/src/tests.rs+++ b/crates/disktree-app/src/tests.rs@@ -1736,6 +1736,15 @@ fn the_power_menu_offers_only_what_the_cpus_can_tell_apart(draw(cx);assert_eq!(read(&view, cx, |app| app.power_menu), Some(1));+ // The pointer takes the highlight, and the check stays on what is saved.+ let miser = cx.debug_bounds(Power::Miser.key()).expect("row");+ cx.simulate_mouse_move(miser.center(), None, Modifiers::none());+ draw(cx);+ assert_eq!(read(&view, cx, |app| app.power_menu), Some(0));+ let balanced = cx.debug_bounds(Power::Balanced.key()).expect("row");+ let check = cx.debug_bounds("power-check").expect("check");+ assert!(balanced.contains(&check.center()), "check on {check:?}");+// A disabled row ignores the click and leaves the menu to be dismissed.let drain = cx.debug_bounds(Power::DrainMyBattery.key()).expect("row");cx.simulate_click(drain.center(), Modifiers::none());diff --git a/crates/disktree-app/src/ui.rs b/crates/disktree-app/src/ui.rsindex 5b6763c..ea715d2 100644--- a/crates/disktree-app/src/ui.rs+++ b/crates/disktree-app/src/ui.rs@@ -73,8 +73,9 @@ pub mod size {pub const SIBLING_MENU: Rems = Rems(24.0);pub const SIBLING_MENU_HEIGHT: Rems = Rems(32.0);/// The Power Efficiency menu: narrower than a sibling menu, since its- /// names are four known words.- pub const POWER_MENU: Rems = Rems(20.0);+ /// names are four known words, but wide enough for Drain My Battery+ /// beside the check, bar and count.+ pub const POWER_MENU: Rems = Rems(22.0);/// One bar of the Power Efficiency gauge.pub const SIGNAL_BAR: Rems = Rems(0.1875);/// A list row's share bar.diff --git a/crates/disktree-app/src/views.rs b/crates/disktree-app/src/views.rsindex f4bb211..88541b8 100644--- a/crates/disktree-app/src/views.rs+++ b/crates/disktree-app/src/views.rs@@ -1106,6 +1106,15 @@ fn power_efficiency(app: &Disktree, cx: &Context<'_, Disktree>) -> Div {.when(index == highlighted && offered, |this| {this.bg(theme.hover_fill())})+ // The saved preset keeps its check wherever the highlight goes;+ // bold alone read as losing to the fill under the pointer.+ .child(div().flex_shrink_0().w(icon::SM).when(current, |this| {+ this.debug_selector(|| "power-check".into()).child(+ gpui_omarchy::icon(gpui_omarchy::IconName::Check)+ .size(icon::SM)+ .text_color(theme.accent),+ )+ })).child(div().flex_1()@@ -1136,12 +1145,18 @@ fn power_efficiency(app: &Disktree, cx: &Context<'_, Disktree>) -> Div {// A preset this machine cannot tell apart from the one below it is// shown, so the scale stays the same everywhere, but not offered.let row = if offered {- row.hover(|style| style.bg(theme.hover_fill())).on_click(- cx.listener(move |this, _, window, cx| {- this.set_power_efficiency(preset, cx);- window.focus(&this.focus, cx);- }),- )+ // The pointer moves the one highlight the arrows move, so two+ // filled rows never compete with the check.+ row.on_hover(cx.listener(move |this, hovered: &bool, _, cx| {+ if *hovered && this.power_menu.is_some() {+ this.power_menu = Some(index);+ cx.notify();+ }+ }))+ .on_click(cx.listener(move |this, _, window, cx| {+ this.set_power_efficiency(preset, cx);+ window.focus(&this.focus, cx);+ }))} else {let below = PowerEfficiency::ALL[index - 1].name();with_tooltip(