Make branch lines take their parent's color

A node's color now flows down the lines to its children, mind-map style:
Watering's teal colors the lines to Rain barrel and Drip line. It used to
color the line from the root down to Watering itself, which also left the
shared bus of a parent's branches in whichever child's color was drawn
last. Branches follow their parent by default, and stay dim when the
parent has no color.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
skkeyeandClaude Opus 5.5 committed 2026-10-01 01:40:24 -04:00
1 parent 3b58d6494d
commit e097e53a85
6 files changed
+49 -17

No files matched your search

+16
View File
@@ -244,6 +244,22 @@ mod tests {
assert_eq!(scene.node_at(crate::view::canvas::ScreenPos::new(30, 5)), Some(g.beds));
}
#[test]
fn branch_lines_take_their_parents_color() {
let (mut doc, g) = garden();
let orange = crate::model::ColorName::parse("orange").unwrap();
doc.edit(|e| e.update(g.beds, |node| node.look.color = Some(orange.clone()))).unwrap();
let theme = Theme::default();
let scene =
Scene::build(&doc, g.soil, Camera::default(), Size::new(52, 8), &theme, SceneOptions::default());
let area = Rect::new(0, 0, 52, 8);
let mut buf = Buffer::empty(area);
scene.render(area, &mut buf);
let color = |col: u16, row: u16| buf[(col, row)].fg;
assert_eq!(color(38, 5), theme.color(&orange), "Raised beds → Cedar: orange, the parent's");
assert_eq!(color(17, 5), theme.muted, "Garden plans → Raised beds: dim, the root has no color");
}
#[test]
fn folded_branches_links_and_far_zoom() {
let (mut doc, g) = garden();
+1 -1
View File
@@ -190,7 +190,7 @@ impl Scene {
let child = &self.nodes[child_index];
let Some(Place::Child { parent, branch }) = doc.place(child.id) else { continue };
let Some(&parent_index) = self.index.get(parent) else { continue };
let style = theme.branch_style(branch, child.color);
let style = theme.branch_style(branch, self.nodes[parent_index].color);
let owner = LineOwner::Branch(child.id);
self.connect(parent_index, child_index, Bend::NearStart, style, owner, None);
}