mirror of
https://github.com/storytold/soundcraft.git
synced 2026-12-02 20:22:27 -05:00
fix(ui): add hover tooltip for overflowing track names and assert exact center position in test
This commit is contained in:
1 parent
6a4c055094
commit
76f58fcb81
2 files changed
+10
-4
No files matched your search
@@ -121,7 +121,12 @@ fn name_plate(app: &mut SoundApp, ui: &mut Ui, track: &Track, head: Rect, select
|
||||
let (text_pos, align) =
|
||||
if overflows { (pos2(name_r.min.x + 1.5, name_r.center().y), Align2::LEFT_CENTER) } else { (name_r.center(), Align2::CENTER_CENTER) };
|
||||
ui.painter().with_clip_rect(name_r).text(text_pos, align, &shown_name, font, name_color);
|
||||
let nresp = ui.interact(name_r, ui.scope_id().with(("name", id.0)), Sense::click_and_drag());
|
||||
let mut nresp = ui.interact(name_r, ui.scope_id().with(("name", id.0)), Sense::click_and_drag());
|
||||
if overflows {
|
||||
nresp = nresp.on_hover_ui(|ui| {
|
||||
ui.label(&shown_name);
|
||||
});
|
||||
}
|
||||
if nresp.double_clicked() {
|
||||
app.dialogs.open_rename_track(id, &track.name);
|
||||
} else if nresp.clicked() {
|
||||
|
||||
@@ -1540,7 +1540,7 @@ fn short_track_name_is_centered_and_long_name_is_left_aligned() {
|
||||
let r1 = row(&h, 1);
|
||||
|
||||
let first_text = h.output().shapes.iter().find_map(|s| match &s.shape {
|
||||
Shape::Text(t) if t.galley.text() == "Vocal" && s.clip_rect.intersects(r0) => Some(t.pos),
|
||||
Shape::Text(t) if t.galley.text() == "Vocal" && s.clip_rect.intersects(r0) => Some((t.pos, t.galley.size())),
|
||||
_ => None,
|
||||
});
|
||||
let long_text = h.output().shapes.iter().find_map(|s| match &s.shape {
|
||||
@@ -1548,9 +1548,10 @@ fn short_track_name_is_centered_and_long_name_is_left_aligned() {
|
||||
_ => None,
|
||||
});
|
||||
|
||||
let first_pos = first_text.expect("short track name should be rendered in edit header");
|
||||
let (first_pos, first_size) = first_text.expect("short track name should be rendered in edit header");
|
||||
let long_pos = long_text.expect("long track name should be rendered in edit header");
|
||||
|
||||
assert_eq!(long_pos.x, r1.min.x + 17.5);
|
||||
assert!(first_pos.x > r0.min.x + 25.0, "short name should be centered (was at {})", first_pos.x);
|
||||
let first_center_x = first_pos.x + first_size.x * 0.5;
|
||||
assert!((first_center_x - (r0.min.x + 64.5)).abs() <= 0.1, "short name should be centered (center was at {first_center_x})");
|
||||
}
|
||||
Reference in new issue
Block a user