Give rundown timing cells unique widget IDs
This commit is contained in:
parent
588c2a8e71
commit
b25eb0a481
|
|
@ -1407,42 +1407,46 @@ impl App {
|
|||
);
|
||||
}
|
||||
if compact {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(105.0);
|
||||
ui.set_min_height(row_height);
|
||||
for (label, value, inferred) in [
|
||||
("Start", &row.start, row.inferred_start),
|
||||
("End", &row.end, row.inferred_end),
|
||||
("Dur.", &row.duration, row.inferred_duration),
|
||||
] {
|
||||
ui.colored_label(
|
||||
if inferred && !ignored && !row.gap {
|
||||
PREVIEW_INFERRED
|
||||
} else {
|
||||
color
|
||||
},
|
||||
format!("{label} {value}"),
|
||||
);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (value, inferred) in [
|
||||
(&row.start, row.inferred_start),
|
||||
(&row.end, row.inferred_end),
|
||||
(&row.duration, row.inferred_duration),
|
||||
] {
|
||||
ui.push_id((row.row, row.gap_key.as_deref(), "compact_timing"), |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(105.0);
|
||||
ui.set_min_height(row_height);
|
||||
ui.add(
|
||||
egui::Label::new(RichText::new(value).color(
|
||||
for (label, value, inferred) in [
|
||||
("Start", &row.start, row.inferred_start),
|
||||
("End", &row.end, row.inferred_end),
|
||||
("Dur.", &row.duration, row.inferred_duration),
|
||||
] {
|
||||
ui.colored_label(
|
||||
if inferred && !ignored && !row.gap {
|
||||
PREVIEW_INFERRED
|
||||
} else {
|
||||
color
|
||||
},
|
||||
))
|
||||
.extend(),
|
||||
);
|
||||
format!("{label} {value}"),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
for (role, value, inferred) in [
|
||||
("start", &row.start, row.inferred_start),
|
||||
("end", &row.end, row.inferred_end),
|
||||
("duration", &row.duration, row.inferred_duration),
|
||||
] {
|
||||
ui.push_id((row.row, row.gap_key.as_deref(), role), |ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_min_height(row_height);
|
||||
ui.add(
|
||||
egui::Label::new(RichText::new(value).color(
|
||||
if inferred && !ignored && !row.gap {
|
||||
PREVIEW_INFERRED
|
||||
} else {
|
||||
color
|
||||
},
|
||||
))
|
||||
.extend(),
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1877,6 +1881,22 @@ mod tests {
|
|||
render(&mut app, &ctx, [860.0, 620.0], vec![]);
|
||||
let labels = render(&mut app, &ctx, [860.0, 620.0], vec![]);
|
||||
assert!(labels.iter().any(|(text, _)| text == "Inferred timing"));
|
||||
let timing = labels
|
||||
.iter()
|
||||
.find(|(text, _)| text == "09:10:00")
|
||||
.unwrap()
|
||||
.1
|
||||
.center();
|
||||
render(
|
||||
&mut app,
|
||||
&ctx,
|
||||
[860.0, 620.0],
|
||||
vec![egui::Event::PointerMoved(timing)],
|
||||
);
|
||||
let labels = render(&mut app, &ctx, [860.0, 620.0], vec![]);
|
||||
assert!(!labels.iter().any(|(text, _)| {
|
||||
text.contains("use of widget ID") || text.contains("Widget is above this text")
|
||||
}));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in New Issue