Repository navigation
Canvas: grip menu on hover, GRIPSNAP, RECTANG width/height boxes, typed text by the cursor #2325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 54 commits
002947d
de73d8c
ef9c473
76b1b16
94a360d
4c04b8c
a0a18d1
718048f
eeb1222
fe5be53
9897e54
683eb87
43087b5
cd10baa
45da144
d7cf446
1280841
8675424
94466c2
76bf204
10b310c
33482cd
6bd69d3
3bcfb17
dcd60dd
064310a
01102de
3aba223
a5d564a
d967399
4b92bc6
eba4e10
998db73
6c3e3c2
f20306e
e0f9985
e79503c
d77b743
bc9f24c
4253dec
ec32ad2
2fc041b
3e517bb
6e40889
3c69d24
a12a614
5f9d69d
6680260
49df904
09ec3bf
c289fcd
5bffe09
5409c6b
0a45648
ae9e57f
41645f6
750e994
47d6c2a
04c277a
e28737b
9ac8697
98139c3
e2299cd
23568d0
8443f64
ff2a0da
a7fe1f0
3ac7cc7
7281cdd
828b78b
f475b44
90c9d06
780f469
08f2741
d8dcb42
8a42adf
466fe69
5c965ba
b829b85
88d7c30
ffa7310
eb87356
64adbbe
0eddb92
bbf5631
60709f6
b444f5a
a776702
2ff5635
5fe9571
cd81110
fca338a
591850d
a082bd3
eabfb2f
1f6e3c8
7135d68
37801d5
944dcf0
0e9d55d
3bf07c1
748d920
748888f
09aba50
5b73861
a85bb33
0450894
791d0e7
cae8088
35d956d
792899d
c8589d8
2144528
f22ff80
e8ecfee
57d41d2
c86bca5
89042bc
0b9483c
80eb426
a14ae3c
0c0d027
6b4c98d
91b9212
13c7fad
ee07aa2
28e171e
2526ae6
2437fbf
3829c8a
420d851
682bf1d
970ee44
7eba127
a4804e6
2cf6415
2bef0ac
6107496
57783dc
d8abe2b
1f1478a
2236ff9
b0dd905
95b0aa1
4c6774c
7825737
aea1a77
9909021
cd38b21
49fe34d
9205745
ba6d190
b4ce898
768ae6d
c5966cb
f35bfd6
f90cf50
d48d599
7210b1f
2611352
fa8d70d
2a62409
ad91c71
2e943c5
484005a
dcbc229
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,7 +217,11 @@ fn bounds_in<'a>(d: &'a Drawing, e: &Entity, depth: usize, blocks: &mut HashMap< | |
| b | ||
| } | ||
| EntityKind::MLeader(m) => { | ||
| let mut b = Bounds2::from_points(m.leaders.iter().flatten().map(|v| v.xy()).chain(std::iter::once(m.landing.xy()))); | ||
| // Hidden leader lines (leader type None) and their landing take no room. | ||
| let content = m.text.as_ref().map(|t| t.insert.xy()).or_else(|| m.block.as_ref().map(|i| i.insert.xy())); | ||
| let start = if m.no_leader { content.unwrap_or(m.landing.xy()) } else { m.landing.xy() }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Return empty bounds for a hidden, content-free MLeader. If
|
||
| let shown = m.leaders.iter().filter(|_| !m.no_leader).flatten().map(|v| v.xy()); | ||
| let mut b = Bounds2::from_points(shown.chain(std::iter::once(start))); | ||
| if let Some(t) = &m.text { | ||
| b.add(t.insert.xy()); | ||
| if !blank(&t.contents) { | ||
|
|
@@ -325,6 +329,7 @@ mod tests { | |
|
|
||
| fn text(halign: HAlign, valign: VAlign) -> Text { | ||
| Text { | ||
| formula: None, | ||
| insert: Vec3::new(0.0, 0.0, 0.0), | ||
| align_pt: Some(Vec3::new(0.0, 0.0, 0.0)), | ||
| height: 1.0, | ||
|
|
@@ -344,6 +349,7 @@ mod tests { | |
|
|
||
| fn mtext(contents: &str, width: f64) -> crate::MText { | ||
| crate::MText { | ||
| formula: None, | ||
| insert: Vec3::new(10.0, 10.0, 0.0), | ||
| height: 2.5, | ||
| width, | ||
|
|
@@ -410,6 +416,7 @@ mod tests { | |
| #[test] | ||
| fn multileader_text_is_inside_its_bounds() { | ||
| let mtext = crate::MText { | ||
| formula: None, | ||
| insert: Vec3::new(25.45, 0.0, 0.0), | ||
| height: 5.0, | ||
| width: 0.0, | ||
|
|
@@ -422,6 +429,8 @@ mod tests { | |
| columns: None, | ||
| }; | ||
| let ml = crate::MLeader { | ||
| arrow: String::new(), | ||
| no_leader: false, | ||
| leaders: vec![vec![Vec3::new(0.0, 0.0, 0.0)]], | ||
| landing: Vec3::new(25.0, 0.0, 0.0), | ||
| dogleg: 0.45, | ||
|
|
@@ -434,8 +443,16 @@ mod tests { | |
| let b = bounds(EntityKind::MLeader(ml.clone())); | ||
| // The glyph spans x 25.45..28.78, y -2.5..2.5. | ||
| assert!(b.min.x <= 0.0 && b.max.x >= 28.79 && b.min.y <= -2.5 && b.max.y >= 2.5); | ||
| let mut empty = ml; | ||
| let mut empty = ml.clone(); | ||
| empty.text = Some(crate::MText { contents: " ".into(), ..mtext }); | ||
| assert!(bounds(EntityKind::MLeader(empty)).max.x < 26.0); | ||
| // Leader type None: the hidden leader line and landing take no room. | ||
| let hidden = | ||
| crate::MLeader { no_leader: true, leaders: vec![vec![Vec3::new(-500.0, -500.0, 0.0), Vec3::new(-400.0, -500.0, 0.0)]], ..ml.clone() }; | ||
| let b = bounds(EntityKind::MLeader(hidden.clone())); | ||
| assert!(b.min.x >= 25.0 && b.min.y > -10.0, "{b:?}"); | ||
| assert!(EntityKind::MLeader(hidden).prims().is_empty(), "no snaps on hidden lines"); | ||
| let shown = crate::MLeader { leaders: vec![vec![Vec3::new(0.0, 0.0, 0.0), Vec3::new(10.0, 0.0, 0.0)]], ..ml }; | ||
| assert!(!EntityKind::MLeader(shown).prims().is_empty()); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: storytold/cadcraft
Length of output: 6183
Script executed:
Repository: storytold/cadcraft
Length of output: 25009
Script executed:
Repository: storytold/cadcraft
Length of output: 13397
Use one grip-index contract for hidden MLeaders.
For a hidden MLeader with text,
EntityKind::grips()returns[landing, text]. The MLeader stretch mapper still checks every leader vertex first, andMLeader::text_grip()still returnsleader_vertex_count + 1. Grip 0 can therefore move a hidden leader vertex, and the text grip is not recognized.Skip hidden leader vertices in both consumers.
Suggested fix