Keep activation borders above message label backplates
This commit is contained in:
@@ -1621,17 +1621,9 @@ impl Scene {
|
||||
.iter()
|
||||
.find(|line| {
|
||||
!line.label.is_empty()
|
||||
&& (Rectangle::new(
|
||||
line.label_at,
|
||||
Size::new(
|
||||
(line.label.chars().count() as f32 * 6.8 + 8.).min(225.),
|
||||
25.,
|
||||
),
|
||||
)
|
||||
.contains(point)
|
||||
|| line.points.windows(2).any(|p| {
|
||||
crate::diagram::distance_to_segment(point, p[0], p[1]) < 1.5
|
||||
}))
|
||||
&& line.points.windows(2).any(|p| {
|
||||
crate::diagram::distance_to_segment(point, p[0], p[1]) < 1.5
|
||||
})
|
||||
})
|
||||
.map(|line| line.id)
|
||||
})
|
||||
@@ -1642,6 +1634,22 @@ impl Scene {
|
||||
.find(|b| b.rect.contains(point))
|
||||
.map(|b| b.call)
|
||||
})
|
||||
.or_else(|| {
|
||||
self.lines
|
||||
.iter()
|
||||
.find(|line| {
|
||||
!line.label.is_empty()
|
||||
&& Rectangle::new(
|
||||
line.label_at,
|
||||
Size::new(
|
||||
(line.label.chars().count() as f32 * 6.8 + 8.).min(225.),
|
||||
25.,
|
||||
),
|
||||
)
|
||||
.contains(point)
|
||||
})
|
||||
.map(|line| line.id)
|
||||
})
|
||||
// The generous message tolerance must not steal the exposed
|
||||
// shoulder of another call's execution when the view is zoomed out.
|
||||
.or_else(|| {
|
||||
@@ -1973,6 +1981,18 @@ impl canvas::Program<Message> for Scene {
|
||||
.with_width(if guide.id == self.selected { 2.5 } else { 1.2 }),
|
||||
);
|
||||
}
|
||||
// Label backplates clear guides, but must not erase execution borders
|
||||
// or message geometry. Their text remains in the foreground below.
|
||||
for line in self.lines.iter().filter(|line| !line.label.is_empty()) {
|
||||
f.fill_rectangle(
|
||||
line.label_at,
|
||||
Size::new(
|
||||
(line.label.chars().count() as f32 * 6.8 + 8.).min(225.),
|
||||
22.,
|
||||
),
|
||||
Color::WHITE,
|
||||
);
|
||||
}
|
||||
for activation in &self.activations {
|
||||
let path = Path::rectangle(activation.rect.position(), activation.rect.size());
|
||||
f.fill(&path, Color::from_rgb8(243, 248, 248));
|
||||
@@ -2054,11 +2074,6 @@ impl canvas::Program<Message> for Scene {
|
||||
}),
|
||||
Stroke::default().with_color(color),
|
||||
);
|
||||
f.fill_rectangle(
|
||||
l.label_at,
|
||||
Size::new((l.label.chars().count() as f32 * 6.8 + 8.).min(225.), 22.),
|
||||
Color::WHITE,
|
||||
);
|
||||
f.fill_text(Text {
|
||||
content: short(&l.label, 32),
|
||||
position: l.label_at,
|
||||
|
||||
Reference in New Issue
Block a user