diff --git a/crates/color-ui/src/ui/wheel.rs b/crates/color-ui/src/ui/wheel.rs index c07be84fb..24c6e5e33 100644 --- a/crates/color-ui/src/ui/wheel.rs +++ b/crates/color-ui/src/ui/wheel.rs @@ -552,10 +552,14 @@ impl Component for ColorWheel<'_> { } for (index, color) in self.markers.iter().enumerate() { let node = access.node(MARKER.at(index as u64), Role::BUTTON); - node.name = Name::Text(match self.marker_names.get(index) { - Some(name) => cx.env.resolve(name).as_str().to_owned(), - None => color.to_hex(), - }); + match self.marker_names.get(index) { + // A named marker speaks its colour as its value; an unnamed one is named by it. + Some(name) => { + node.name = Name::Text(cx.env.resolve(name).as_str().to_owned()); + node.value(color.to_hex()); + } + None => node.name = Name::Text(color.to_hex()), + } } } diff --git a/crates/color-ui/tests/it/color_parts.rs b/crates/color-ui/tests/it/color_parts.rs index e6d25bcae..532eb88c3 100644 --- a/crates/color-ui/tests/it/color_parts.rs +++ b/crates/color-ui/tests/it/color_parts.rs @@ -202,8 +202,9 @@ impl WheelRig { } } -/// A square wheel hands a press between the square and the ring to the square; its markers pick on a click and a press -/// held on one still drags the ring; Shift snaps a ring drag to 45 degrees, in both variants. +/// A square wheel hands a press between the square and the ring to the square; its named markers speak their colour, +/// pick on a click, and a press held on one still drags the ring; Shift snaps a ring drag to 45 degrees, in both +/// variants. #[trial] fn a_square_wheel_hands_the_inner_press_to_the_square_and_its_markers_pick() { let mut rig = WheelRig::new(WheelInner::Square, 3); @@ -215,7 +216,10 @@ fn a_square_wheel_hands_the_inner_press_to_the_square_and_its_markers_pick() { assert_eq!(saturation, 100.0, "beside the square's right edge is full saturation"); assert!((brightness - 50.0).abs() < 4.0, "level with the square's middle is half brightness: {brightness}"); - let warm = rig.fixture.by_label("Warm").expect("marker").center(); + let warm = rig.fixture.by_label("Warm").expect("marker"); + let hex = Srgba::rgb(0.9, 0.2, 0.2).to_hex(); + assert_eq!(rig.fixture.tree().value_of(warm.node), Some(hex.as_str()), "a named marker speaks its colour as its value"); + let warm = warm.center(); rig.fixture.click_at(warm); rig.fixture.idle(2); assert_eq!(rig.picked.get(), Some(0), "a click on a marker picks it");