Merge pull request #3182 from nrq6993-a11y/stream/vc-feat1-g1-type-area-measure

G1: Area type drag shows width and height in measurement labels
This commit is contained in:
BFlat
2026-10-21 16:14:08 +07:00
committed by GitHub
2 changed files with 19 additions and 1 deletions
+5 -1
View File
@@ -826,7 +826,11 @@ impl Tool for TypeTool {
fn overlays(&self, cx: &ToolContext) -> Vec<Overlay> {
let mut o = self.snap.guides().to_vec();
if let (Some((_, s)), Some(d)) = (self.press, self.drag) {
o.push(Overlay::Marquee(Rect::from_points(s, d)));
let r = Rect::from_points(s, d);
o.push(Overlay::Marquee(r));
if cx.measurement_labels {
o.push(Overlay::Measure { p: d, text: cx.size_label(r.width(), r.height()) });
}
}
// Overflow markers on selected text.
for id in &cx.selection.objects {
+14
View File
@@ -559,6 +559,20 @@ fn new_type_snaps_to_smart_guides() {
assert!(acts.iter().any(|a| matches!(a, Action::Exec(cmd, v) if cmd == "text.create" && v["x"] == 100.0 && v["area"] == area)), "{acts:?}");
}
#[test]
fn area_type_drag_measure_labels_honor_preference() {
let (d, _) = crate::testutil::doc_with_rect();
let (sel, p) = (Selection::default(), paint());
let on = ToolContext { measurement_labels: true, ..cx(&d, &sel, &p) };
let off = ToolContext { measurement_labels: false, ..cx(&d, &sel, &p) };
let mut tool = TypeTool::new("type");
tool.pointer(&on, &PointerEvent::new(PointerKind::Down, 100.0, 100.0));
tool.pointer(&on, &PointerEvent::new(PointerKind::Drag, 200.0, 150.0));
let want = on.size_label(100.0, 50.0);
assert!(tool.overlays(&on).iter().any(|o| matches!(o, Overlay::Measure { text, .. } if text == &want)));
assert!(!tool.overlays(&off).iter().any(|o| matches!(o, Overlay::Measure { .. })));
}
#[test]
fn layout_cache_follows_fonts_added_later() {
// Other tests can load system fonts; this assertion needs its own process-wide database.