From b290b81d7352478338b83f0c3b463e110c90ddaa Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Thu, 26 Nov 2026 15:14:57 -0800 Subject: [PATCH] Name the Stroke editor's round cap and join separately --- crates/draw/src/ui/stroke/editor.rs | 4 ++-- crates/draw/src/ui/stroke/words.rs | 4 ++++ crates/draw/tests/it/stroke_editor.rs | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/crates/draw/src/ui/stroke/editor.rs b/crates/draw/src/ui/stroke/editor.rs index 14b0875c82..8db8ddbaf2 100644 --- a/crates/draw/src/ui/stroke/editor.rs +++ b/crates/draw/src/ui/stroke/editor.rs @@ -335,12 +335,12 @@ impl Body<'_> { ]; let cap = [ (LineCap::Butt, "stroke_cap_butt", &words.butt), - (LineCap::Round, "stroke_cap_round", &words.round_cap), + (LineCap::Round, "stroke_cap_round", if icons { &words.round_cap_icon } else { &words.round_cap }), (LineCap::Square, "stroke_cap_square", &words.square), ]; let join = [ (LineJoin::Miter, "stroke_join_miter", &words.miter), - (LineJoin::Round, "stroke_join_round", &words.round_join), + (LineJoin::Round, "stroke_join_round", if icons { &words.round_join_icon } else { &words.round_join }), (LineJoin::Bevel, "stroke_join_bevel", &words.bevel), ]; let event = choice(ui, &words.alignment, "align", held(mixed.align, style.align), &align, self.closed, icons); diff --git a/crates/draw/src/ui/stroke/words.rs b/crates/draw/src/ui/stroke/words.rs index b4e976eb52..9749a53945 100644 --- a/crates/draw/src/ui/stroke/words.rs +++ b/crates/draw/src/ui/stroke/words.rs @@ -30,6 +30,8 @@ craft_ui::words! { butt: "strokeEditor.butt" = "Butt / Flat"; /// The round cap. round_cap: "strokeEditor.roundCap" = "Round"; + /// The tooltip and accessible name of the round cap icon. + round_cap_icon: "strokeEditor.roundCapIcon" = "Round Cap"; /// The square cap. square: "strokeEditor.square" = "Square"; /// The Corners row. @@ -38,6 +40,8 @@ craft_ui::words! { miter: "strokeEditor.miter" = "Miter"; /// The round corner. round_join: "strokeEditor.roundJoin" = "Round"; + /// The tooltip and accessible name of the round join icon. + round_join_icon: "strokeEditor.roundJoinIcon" = "Round Join"; /// The bevelled corner. bevel: "strokeEditor.bevel" = "Bevel"; /// The Miter limit row. diff --git a/crates/draw/tests/it/stroke_editor.rs b/crates/draw/tests/it/stroke_editor.rs index 42f7c421ac..252329b838 100644 --- a/crates/draw/tests/it/stroke_editor.rs +++ b/crates/draw/tests/it/stroke_editor.rs @@ -44,3 +44,22 @@ fn dash_fields_add_after_the_pattern_and_a_cleared_field_ends_it() { type_into(&mut fixture, "Dash 1", ""); assert_eq!(style.borrow().dashes, [4.0], "the first field never clears"); } + +#[trial] +fn round_cap_and_round_join_names_lead_to_their_own_actions() { + use craft_draw::ui::stroke::{LineCap, LineJoin}; + use craft_ui::testing::{access::focused_key, focus::AccessActionKind}; + + let (mut fixture, style) = editor(vec![4.0, 2.0]); + let cap = fixture.by_label("Round Cap").expect("the cap has its own accessible name"); + let join = fixture.by_label("Round Join").expect("the join has its own accessible name"); + assert_ne!(cap.node, join.node, "the names find independent choices"); + fixture.click(&cap).settle(); + assert_eq!(style.borrow().cap, LineCap::Round); + assert_eq!(style.borrow().join, LineJoin::Miter); + fixture.access(AccessActionKind::Focus, &join).settle(); + assert_eq!(focused_key(fixture.tree()), join.node); + fixture.key(Key::Enter, Modifiers::NONE).settle(); + assert_eq!(style.borrow().join, LineJoin::Round); + assert_eq!(style.borrow().cap, LineCap::Round); +}