re_component_ui/
video_timestamp.rsuse re_types::components::VideoTimestamp;
use re_viewer_context::{MaybeMutRef, ViewerContext};
pub fn edit_or_view_timestamp(
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
timestamp: &mut MaybeMutRef<'_, VideoTimestamp>,
) -> egui::Response {
let mut timestamp_secs = timestamp.as_secs();
if let Some(timestamp) = timestamp.as_mut() {
let response = ui.add(
egui::DragValue::new(&mut timestamp_secs)
.clamp_existing_to_range(false)
.range(0.0..=f32::MAX)
.speed(0.01) .custom_formatter(|n, _| re_format::format_timestamp_secs(n))
.custom_parser(re_format::parse_timestamp_secs),
);
if response.changed() {
*timestamp = VideoTimestamp::from_secs(timestamp_secs);
}
response
} else {
ui.label(re_format::format_timestamp_secs(timestamp_secs))
}
.on_hover_text(format!("{}ns", re_format::format_int(timestamp.as_nanos())))
}