authorgravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-02 02:18:47-07:00
committergravatar for git@paperclover.netclover caruso <git@paperclover.net> 2026-10-02 03:11:20-07:00
logd9ea057da7515d9c04cf4b7e62287edea50c7f22
treed0b46eb024ad03b71407f5e73c5eed04cf2c4451
parent0aabcf30b762dc823a9b403a7a514e5a86f62fd5
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

fix: the sidebar opens on its folds as they stand

Every notebook and section group eased open from nothing each time the sidebar opened, and again as a notebook's sections arrived, because the rows' height was unknown on the frame they first showed. Rows that appear with the tree now show at once, open or folded as they were left; only folding or unfolding one eases. Assisted-by: claude-opus-5.5

1 files changed, 18 insertions(+), 9 deletions(-)

crates/snowbound/src/sidebar.rs+18-9
...@@ -538,22 +538,31 @@ fn gap(ui: &mut Ui, tree: &mut Tree, folder: &str, before: Option<&str>) {...@@ -538,22 +538,31 @@ fn gap(ui: &mut Ui, tree: &mut Tree, folder: &str, before: Option<&str>) {
538}538}
539539
540/// Opens the boxes a notebook's or group's rows ease open and shut in, where they show:540/// Opens the boxes a notebook's or group's rows ease open and shut in, where they show:
541/// the caller builds the rows and closes both.541/// the caller builds the rows and closes both. Rows appearing with the tree, as the sidebar
542/// opens or a notebook's sections arrive, show as they stand; only a toggle eases.
542fn unfolding(ui: &mut Ui, part: impl std::hash::Hash, unfolded: bool) -> bool {543fn unfolding(ui: &mut Ui, part: impl std::hash::Hash, unfolded: bool) -> bool {
543 let outer = ui.id(part);544 let outer = ui.id(part);
544 let rows = ui545 let height = if ui.lasted(outer.child("shown"), true).is_zero() {
545 .rect(outer.child("rows"))546 if !unfolded {
546 .map_or(0.0, |rect| rect[3] - rect[1]);547 return false;
547 let height = ui.animate(outer, if unfolded { rows } else { 0.0 });548 }
548 if !unfolded && height == 0.0 {549 ui::children()
549 return false;550 } else {
550 }551 let rows = ui
552 .rect(outer.child("rows"))
553 .map_or(0.0, |rect| rect[3] - rect[1]);
554 let height = ui.animate(outer, if unfolded { rows } else { 0.0 });
555 if !unfolded && height == 0.0 {
556 return false;
557 }
558 px(height)
559 };
551 ui.open_as(560 ui.open_as(
552 outer,561 outer,
553 Spec {562 Spec {
554 flags: Flags::CLIP,563 flags: Flags::CLIP,
555 axis: Axis::Y,564 axis: Axis::Y,
556 size: [fill(), px(height)],565 size: [fill(), height],
557 ..Spec::default()566 ..Spec::default()
558 },567 },
559 );568 );