diff --git a/Cargo.lock b/Cargo.lock index f22f7f67cc4d..c1dd79967978 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4205,6 +4205,24 @@ dependencies = [ "serde", ] +[[package]] +name = "re_time_panel" +version = "0.7.0-alpha.0" +dependencies = [ + "egui", + "itertools", + "puffin", + "re_arrow_store", + "re_data_store", + "re_data_ui", + "re_log_types", + "re_ui", + "re_viewer_context", + "serde", + "time", + "vec1", +] + [[package]] name = "re_tuid" version = "0.7.0-alpha.0" @@ -4282,6 +4300,7 @@ dependencies = [ "re_renderer", "re_smart_channel", "re_tensor_ops", + "re_time_panel", "re_ui", "re_viewer_context", "re_ws_comms", @@ -4292,7 +4311,6 @@ dependencies = [ "smallvec", "thiserror", "time", - "vec1", "wasm-bindgen-futures", "web-sys", "web-time", diff --git a/Cargo.toml b/Cargo.toml index 45f3ff42031d..8c2588b95b29 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ re_sdk_comms = { path = "crates/re_sdk_comms", version = "0.7.0-alpha.0", defaul re_smart_channel = { path = "crates/re_smart_channel", version = "0.7.0-alpha.0", default-features = false } re_string_interner = { path = "crates/re_string_interner", version = "0.7.0-alpha.0", default-features = false } re_tensor_ops = { path = "crates/re_tensor_ops", version = "0.7.0-alpha.0", default-features = false } +re_time_panel = { path = "crates/re_time_panel", version = "=0.7.0-alpha.0", default-features = false } re_tuid = { path = "crates/re_tuid", version = "0.7.0-alpha.0", default-features = false } re_ui = { path = "crates/re_ui", version = "0.7.0-alpha.0", default-features = false } re_viewer = { path = "crates/re_viewer", version = "0.7.0-alpha.0", default-features = false } diff --git a/crates/re_data_ui/src/instance_path.rs b/crates/re_data_ui/src/instance_path.rs index 4f3256f3fc64..7d7f6e79deb3 100644 --- a/crates/re_data_ui/src/instance_path.rs +++ b/crates/re_data_ui/src/instance_path.rs @@ -55,10 +55,9 @@ impl DataUi for InstancePath { UiVerbosity::All => {} } - item_ui::component_path_button_to( + item_ui::component_path_button( ctx, ui, - component_name.short_name(), &ComponentPath::new(self.entity_path.clone(), component_name), ); diff --git a/crates/re_data_ui/src/item_ui.rs b/crates/re_data_ui/src/item_ui.rs index e2e132943ce6..ad31a487d7e0 100644 --- a/crates/re_data_ui/src/item_ui.rs +++ b/crates/re_data_ui/src/item_ui.rs @@ -112,6 +112,20 @@ pub fn instance_path_button_to( cursor_interact_with_selectable(ctx.selection_state_mut(), response, item) } +/// Show a component path and make it selectable. +pub fn component_path_button( + ctx: &mut ViewerContext<'_>, + ui: &mut egui::Ui, + component_path: &ComponentPath, +) -> egui::Response { + component_path_button_to( + ctx, + ui, + component_path.component_name.short_name(), + component_path, + ) +} + /// Show a component path and make it selectable. pub fn component_path_button_to( ctx: &mut ViewerContext<'_>, diff --git a/crates/re_time_panel/Cargo.toml b/crates/re_time_panel/Cargo.toml new file mode 100644 index 000000000000..8ac4161b49b2 --- /dev/null +++ b/crates/re_time_panel/Cargo.toml @@ -0,0 +1,33 @@ +[package] +authors.workspace = true +description = "The time panel of the Rerun Viewer, allowing to control the displayed timeline & time." +edition.workspace = true +homepage.workspace = true +license.workspace = true +name = "re_time_panel" +publish = true +readme = "README.md" +repository.workspace = true +rust-version.workspace = true +version.workspace = true +include = ["../../LICENSE-APACHE", "../../LICENSE-MIT", "**/*.rs", "Cargo.toml"] + +[package.metadata.docs.rs] +all-features = true + +[dependencies] +re_arrow_store.workspace = true +re_data_store.workspace = true +re_data_ui.workspace = true +re_log_types.workspace = true +re_ui.workspace = true +re_viewer_context.workspace = true + +egui.workspace = true +itertools.workspace = true +serde = "1.0" +time.workspace = true +vec1 = "1.8" + +[target.'cfg(not(target_arch = "wasm32"))'.dependencies] +puffin.workspace = true diff --git a/crates/re_time_panel/README.md b/crates/re_time_panel/README.md new file mode 100644 index 000000000000..e16c2eee844e --- /dev/null +++ b/crates/re_time_panel/README.md @@ -0,0 +1,10 @@ +# re_time_panel + +Part of the [`rerun`](https://github.com/rerun-io/rerun) family of crates. + +[![Latest version](https://img.shields.io/crates/v/re_data_ui.svg)](https://crates.io/crates/re_data_ui) +[![Documentation](https://docs.rs/re_data_ui/badge.svg)](https://docs.rs/re_data_ui) +![MIT](https://img.shields.io/badge/license-MIT-blue.svg) +![Apache](https://img.shields.io/badge/license-Apache-blue.svg) + +The time panel of the Rerun Viewer, allowing to control the displayed timeline & time. diff --git a/crates/re_viewer/src/ui/time_panel/data_density_graph.rs b/crates/re_time_panel/src/data_density_graph.rs similarity index 96% rename from crates/re_viewer/src/ui/time_panel/data_density_graph.rs rename to crates/re_time_panel/src/data_density_graph.rs index 5c70e729a6cb..696e04bfb1d6 100644 --- a/crates/re_viewer/src/ui/time_panel/data_density_graph.rs +++ b/crates/re_time_panel/src/data_density_graph.rs @@ -8,12 +8,10 @@ use std::ops::RangeInclusive; use egui::{epaint::Vertex, lerp, pos2, remap, Color32, NumExt as _, Rect, Shape}; use re_data_store::TimeHistogram; -use re_data_ui::DataUi; +use re_data_ui::{item_ui, DataUi}; use re_log_types::{TimeInt, TimeRange, TimeReal}; use re_viewer_context::{Item, UiVerbosity, ViewerContext}; -use crate::ui::Blueprint; - use super::time_ranges_ui::TimeRangesUi; // ---------------------------------------------------------------------------- @@ -365,7 +363,6 @@ fn smooth(density: &[f32]) -> Vec { pub fn data_density_graph_ui( data_dentity_graph_painter: &mut DataDensityGraphPainter, ctx: &mut ViewerContext<'_>, - blueprint: &mut Blueprint, time_area_response: &egui::Response, time_area_painter: &egui::Painter, ui: &mut egui::Ui, @@ -489,7 +486,6 @@ pub fn data_density_graph_ui( } else if !ui.ctx().memory(|mem| mem.is_anything_being_dragged()) { show_row_ids_tooltip( ctx, - blueprint, ui.ctx(), &item, hovered_time_range, @@ -519,7 +515,6 @@ fn make_brighter(color: Color32) -> Color32 { fn show_row_ids_tooltip( ctx: &mut ViewerContext<'_>, - blueprint: &mut Blueprint, egui_ctx: &egui::Context, item: &Item, time_range: TimeRange, @@ -536,8 +531,19 @@ fn show_row_ids_tooltip( ui.label(format!("{num_messages} messages")); } - ui.add_space(8.0); - crate::ui::selection_panel::what_is_selected_ui(ui, ctx, blueprint, item); + match item { + Item::ComponentPath(path) => { + item_ui::component_path_button(ctx, ui, path); + } + Item::InstancePath(_, path) => { + item_ui::instance_path_button(ctx, ui, None, path); + } + Item::SpaceView(_) | Item::DataBlueprintGroup(_, _) => { + // No extra info. This should never happen, but not worth printing a warning over. + // Even if it does go here, the ui after will still look ok. + } + } + ui.add_space(8.0); let timeline = *ctx.rec_cfg.time_ctrl.timeline(); diff --git a/crates/re_viewer/src/misc/format_time.rs b/crates/re_time_panel/src/format_time.rs similarity index 100% rename from crates/re_viewer/src/misc/format_time.rs rename to crates/re_time_panel/src/format_time.rs diff --git a/crates/re_viewer/src/ui/time_panel/mod.rs b/crates/re_time_panel/src/lib.rs similarity index 95% rename from crates/re_viewer/src/ui/time_panel/mod.rs rename to crates/re_time_panel/src/lib.rs index c241795ed37f..e36ae5f67da2 100644 --- a/crates/re_viewer/src/ui/time_panel/mod.rs +++ b/crates/re_time_panel/src/lib.rs @@ -1,23 +1,29 @@ +//! Rerun Time Panel +//! +//! This crate provides a panel that shows allows to control time & timelines, +//! as well as all necessary ui elements that make it up. + mod data_density_graph; +mod format_time; // TODO(andreas): Move to re_format mod paint_ticks; mod time_axis; +mod time_control_ui; mod time_ranges_ui; mod time_selection_ui; +pub use format_time::{format_time_compact, next_grid_tick_magnitude_ns}; + use std::ops::RangeInclusive; use egui::{pos2, Color32, CursorIcon, NumExt, PointerButton, Rect, Shape, Vec2}; use re_data_store::{EntityTree, InstancePath, TimeHistogram}; -use re_data_ui::{item_ui, DataUi}; +use re_data_ui::item_ui; use re_log_types::{ComponentPath, EntityPathPart, TimeInt, TimeRange, TimeReal}; -use re_viewer_context::{Item, TimeControl, TimeView, UiVerbosity, ViewerContext}; - -use crate::misc::TimeControlUi; - -use super::{selection_panel::what_is_selected_ui, Blueprint}; +use re_viewer_context::{Item, TimeControl, TimeView, ViewerContext}; use time_axis::TimelineAxis; +use time_control_ui::TimeControlUi; use time_ranges_ui::TimeRangesUi; /// A panel that shows entity names to the left, time on the top. @@ -25,7 +31,7 @@ use time_ranges_ui::TimeRangesUi; /// This includes the timeline controls and streams view. #[derive(serde::Deserialize, serde::Serialize)] #[serde(default)] -pub(crate) struct TimePanel { +pub struct TimePanel { data_dentity_graph_painter: data_density_graph::DataDensityGraphPainter, /// Width of the entity name columns previous frame. @@ -59,14 +65,14 @@ impl TimePanel { pub fn show_panel( &mut self, ctx: &mut ViewerContext<'_>, - blueprint: &mut Blueprint, ui: &mut egui::Ui, + time_panel_expanded: bool, ) { let top_bar_height = 28.0; let margin = ctx.re_ui.bottom_panel_margin(); let mut panel_frame = ctx.re_ui.bottom_panel_frame(); - if blueprint.time_panel_expanded { + if time_panel_expanded { // Since we use scroll bars we want to fill the whole vertical space downwards: panel_frame.inner_margin.bottom = 0.0; @@ -92,7 +98,7 @@ impl TimePanel { egui::TopBottomPanel::show_animated_between_inside( ui, - blueprint.time_panel_expanded, + time_panel_expanded, collapsed, expanded, |ui: &mut egui::Ui, expansion: f32| { @@ -134,7 +140,7 @@ impl TimePanel { let mut top_rop_frame = egui::Frame::default(); top_rop_frame.inner_margin.left = 8.0; top_rop_frame.show(ui, |ui| { - self.expanded_ui(ctx, blueprint, ui); + self.expanded_ui(ctx, ui); }); }); } @@ -184,12 +190,7 @@ impl TimePanel { } } - fn expanded_ui( - &mut self, - ctx: &mut ViewerContext<'_>, - blueprint: &mut Blueprint, - ui: &mut egui::Ui, - ) { + fn expanded_ui(&mut self, ctx: &mut ViewerContext<'_>, ui: &mut egui::Ui) { crate::profile_function!(); self.data_dentity_graph_painter.begin_frame(ui.ctx()); @@ -299,13 +300,7 @@ impl TimePanel { )); // All the entity rows and their data density graphs: - self.tree_ui( - ctx, - blueprint, - &time_area_response, - &lower_time_area_painter, - ui, - ); + self.tree_ui(ctx, &time_area_response, &lower_time_area_painter, ui); { // Paint a shadow between the stream names on the left @@ -348,7 +343,6 @@ impl TimePanel { fn tree_ui( &mut self, ctx: &mut ViewerContext<'_>, - blueprint: &mut Blueprint, time_area_response: &egui::Response, time_area_painter: &egui::Painter, ui: &mut egui::Ui, @@ -367,7 +361,6 @@ impl TimePanel { } self.show_children( ctx, - blueprint, time_area_response, time_area_painter, &ctx.log_db.entity_db.tree, @@ -380,7 +373,6 @@ impl TimePanel { fn show_tree( &mut self, ctx: &mut ViewerContext<'_>, - blueprint: &mut Blueprint, time_area_response: &egui::Response, time_area_painter: &egui::Painter, last_path_part: &EntityPathPart, @@ -414,14 +406,7 @@ impl TimePanel { item_ui::entity_path_button_to(ctx, ui, None, &tree.path, text) }) .body(|ui| { - self.show_children( - ctx, - blueprint, - time_area_response, - time_area_painter, - tree, - ui, - ); + self.show_children(ctx, time_area_response, time_area_painter, tree, ui); }); let is_closed = body_returned.is_none(); @@ -458,7 +443,6 @@ impl TimePanel { data_density_graph::data_density_graph_ui( &mut self.data_dentity_graph_painter, ctx, - blueprint, time_area_response, time_area_painter, ui, @@ -474,7 +458,6 @@ impl TimePanel { fn show_children( &mut self, ctx: &mut ViewerContext<'_>, - blueprint: &mut Blueprint, time_area_response: &egui::Response, time_area_painter: &egui::Painter, tree: &EntityTree, @@ -483,7 +466,6 @@ impl TimePanel { for (last_component, child) in &tree.children { self.show_tree( ctx, - blueprint, time_area_response, time_area_painter, last_component, @@ -516,12 +498,7 @@ impl TimePanel { 2.0, ui.visuals().text_color(), ); - item_ui::component_path_button_to( - ctx, - ui, - component_name.short_name(), - &component_path, - ); + item_ui::component_path_button(ctx, ui, &component_path); }) .response; @@ -537,24 +514,23 @@ impl TimePanel { let is_visible = ui.is_rect_visible(full_width_rect); if is_visible { + let empty_messages_over_time = TimeHistogram::default(); + let messages_over_time = data + .times + .get(ctx.rec_cfg.time_ctrl.timeline()) + .unwrap_or(&empty_messages_over_time); + + // `data.times` does not contain timeless. Need to add those manually: + let total_num_messages = + messages_over_time.total_count() + data.num_timeless_messages() as u64; response.on_hover_ui(|ui| { - let item = Item::ComponentPath(component_path.clone()); - what_is_selected_ui(ui, ctx, blueprint, &item); - ui.add_space(8.0); - let query = ctx.current_query(); - component_path.data_ui(ctx, ui, UiVerbosity::Small, &query); + ui.label(format!("Number of events: {total_num_messages}")); }); // show the data in the time area: let item = Item::ComponentPath(component_path); paint_streams_guide_line(ctx, &item, ui, response_rect); - let empty_messages_over_time = TimeHistogram::default(); - let messages_over_time = data - .times - .get(ctx.rec_cfg.time_ctrl.timeline()) - .unwrap_or(&empty_messages_over_time); - let row_rect = Rect::from_x_y_ranges( time_area_response.rect.x_range(), response_rect.y_range(), @@ -563,7 +539,6 @@ impl TimePanel { data_density_graph::data_density_graph_ui( &mut self.data_dentity_graph_painter, ctx, - blueprint, time_area_response, time_area_painter, ui, @@ -690,7 +665,8 @@ fn paint_streams_guide_line( } fn help_button(ui: &mut egui::Ui) { - crate::misc::help_hover_button(ui).on_hover_text( + // TODO(andreas): Nicer help text like on space views. + re_ui::help_hover_button(ui).on_hover_text( "\ In the top row you can drag to move the time, or shift-drag to select a loop region.\n\ \n\ @@ -1128,3 +1104,25 @@ pub fn paint_time_cursor( )); painter.vline(x, (y_min + w)..=y_max, stroke); } + +// --------------------------------------------------------------------------- + +/// Profiling macro for feature "puffin" +#[doc(hidden)] +#[macro_export] +macro_rules! profile_function { + ($($arg: tt)*) => { + #[cfg(not(target_arch = "wasm32"))] + puffin::profile_function!($($arg)*); + }; +} + +/// Profiling macro for feature "puffin" +#[doc(hidden)] +#[macro_export] +macro_rules! profile_scope { + ($($arg: tt)*) => { + #[cfg(not(target_arch = "wasm32"))] + puffin::profile_scope!($($arg)*); + }; +} diff --git a/crates/re_viewer/src/ui/time_panel/paint_ticks.rs b/crates/re_time_panel/src/paint_ticks.rs similarity index 97% rename from crates/re_viewer/src/ui/time_panel/paint_ticks.rs rename to crates/re_time_panel/src/paint_ticks.rs index 253f23c6ec44..c4636d52698d 100644 --- a/crates/re_viewer/src/ui/time_panel/paint_ticks.rs +++ b/crates/re_time_panel/src/paint_ticks.rs @@ -4,7 +4,7 @@ use egui::{lerp, pos2, remap_clamp, Align2, Color32, Rect, Rgba, Shape, Stroke}; use re_log_types::{Time, TimeRangeF, TimeReal, TimeType}; -use crate::misc::format_time::next_grid_tick_magnitude_ns; +use crate::format_time::{format_time_compact, next_grid_tick_magnitude_ns}; use super::time_ranges_ui::TimeRangesUi; @@ -69,7 +69,7 @@ fn paint_time_range_ticks( &ui.clip_rect(), time_range, // ns next_grid_tick_magnitude_ns, - |ns| crate::misc::format_time::format_time_compact(Time::from_ns_since_epoch(ns)), + |ns| format_time_compact(Time::from_ns_since_epoch(ns)), ) } TimeType::Sequence => { diff --git a/crates/re_viewer/src/ui/time_panel/time_axis.rs b/crates/re_time_panel/src/time_axis.rs similarity index 100% rename from crates/re_viewer/src/ui/time_panel/time_axis.rs rename to crates/re_time_panel/src/time_axis.rs diff --git a/crates/re_viewer/src/misc/time_control_ui.rs b/crates/re_time_panel/src/time_control_ui.rs similarity index 100% rename from crates/re_viewer/src/misc/time_control_ui.rs rename to crates/re_time_panel/src/time_control_ui.rs diff --git a/crates/re_viewer/src/ui/time_panel/time_ranges_ui.rs b/crates/re_time_panel/src/time_ranges_ui.rs similarity index 100% rename from crates/re_viewer/src/ui/time_panel/time_ranges_ui.rs rename to crates/re_time_panel/src/time_ranges_ui.rs diff --git a/crates/re_viewer/src/ui/time_panel/time_selection_ui.rs b/crates/re_time_panel/src/time_selection_ui.rs similarity index 100% rename from crates/re_viewer/src/ui/time_panel/time_selection_ui.rs rename to crates/re_time_panel/src/time_selection_ui.rs diff --git a/crates/re_ui/src/lib.rs b/crates/re_ui/src/lib.rs index 1dbb38ccffa8..d0aee384b8f7 100644 --- a/crates/re_ui/src/lib.rs +++ b/crates/re_ui/src/lib.rs @@ -672,3 +672,9 @@ pub fn native_window_buttons_ui(frame: &mut eframe::Frame, ui: &mut egui::Ui) { frame.set_minimized(true); } } + +pub fn help_hover_button(ui: &mut egui::Ui) -> egui::Response { + ui.add( + egui::Label::new("❓").sense(egui::Sense::click()), // sensing clicks also gives hover effect + ) +} diff --git a/crates/re_viewer/Cargo.toml b/crates/re_viewer/Cargo.toml index 41d2f3ee9c96..0397d4dff886 100644 --- a/crates/re_viewer/Cargo.toml +++ b/crates/re_viewer/Cargo.toml @@ -57,6 +57,7 @@ re_renderer = { workspace = true, default-features = false, features = [ ] } re_smart_channel.workspace = true re_tensor_ops.workspace = true +re_time_panel.workspace = true re_ui = { workspace = true, features = ["eframe"] } re_viewer_context.workspace = true re_ws_comms = { workspace = true, features = ["client"] } @@ -104,7 +105,6 @@ slotmap.workspace = true smallvec = { workspace = true, features = ["serde"] } thiserror.workspace = true time = { workspace = true, features = ["formatting"] } -vec1 = "1.8" web-time.workspace = true wgpu.workspace = true diff --git a/crates/re_viewer/src/app.rs b/crates/re_viewer/src/app.rs index ee795c711a96..a13e6f748dca 100644 --- a/crates/re_viewer/src/app.rs +++ b/crates/re_viewer/src/app.rs @@ -1059,7 +1059,7 @@ struct AppState { panel_selection: PanelSelection, selection_panel: crate::selection_panel::SelectionPanel, - time_panel: crate::time_panel::TimePanel, + time_panel: re_time_panel::TimePanel, #[cfg(not(target_arch = "wasm32"))] #[serde(skip)] @@ -1116,7 +1116,7 @@ impl AppState { render_ctx, }; - time_panel.show_panel(&mut ctx, blueprint, ui); + time_panel.show_panel(&mut ctx, ui, blueprint.time_panel_expanded); selection_panel.show_panel(viewport_state, &mut ctx, ui, blueprint); let central_panel_frame = egui::Frame { diff --git a/crates/re_viewer/src/lib.rs b/crates/re_viewer/src/lib.rs index 9c6d3b70193c..c9c4aecc947e 100644 --- a/crates/re_viewer/src/lib.rs +++ b/crates/re_viewer/src/lib.rs @@ -14,7 +14,7 @@ mod viewer_analytics; pub(crate) use misc::mesh_loader; use re_log_types::PythonVersion; -pub(crate) use ui::{memory_panel, selection_panel, time_panel}; +pub(crate) use ui::{memory_panel, selection_panel}; // TODO(jleibs): Do we want to expose this pub use ui::{SpaceView, ViewCategory}; diff --git a/crates/re_viewer/src/misc/mod.rs b/crates/re_viewer/src/misc/mod.rs index 35f57c29ecb0..07ce1c97fedf 100644 --- a/crates/re_viewer/src/misc/mod.rs +++ b/crates/re_viewer/src/misc/mod.rs @@ -1,10 +1,8 @@ -pub mod format_time; mod mesh_cache; pub(crate) mod mesh_loader; pub mod queries; pub(crate) mod space_info; mod space_view_highlights; -mod time_control_ui; mod transform_cache; pub mod instance_hash_conversions; @@ -13,18 +11,9 @@ pub mod instance_hash_conversions; pub(crate) mod profiler; pub use mesh_cache::MeshCache; -pub use time_control_ui::TimeControlUi; pub use transform_cache::{TransformCache, UnreachableTransform}; pub use space_view_highlights::{ highlights_for_space_view, OptionalSpaceViewEntityHighlight, SpaceViewHighlights, SpaceViewOutlineMasks, }; - -// ---------------------------------------------------------------------------- - -pub fn help_hover_button(ui: &mut egui::Ui) -> egui::Response { - ui.add( - egui::Label::new("❓").sense(egui::Sense::click()), // sensing clicks also gives hover effect - ) -} diff --git a/crates/re_viewer/src/ui/mod.rs b/crates/re_viewer/src/ui/mod.rs index 398f9217e396..747091043af9 100644 --- a/crates/re_viewer/src/ui/mod.rs +++ b/crates/re_viewer/src/ui/mod.rs @@ -18,7 +18,6 @@ mod viewport; pub(crate) mod memory_panel; pub(crate) mod selection_panel; -pub(crate) mod time_panel; pub mod view_spatial; diff --git a/crates/re_viewer/src/ui/selection_panel.rs b/crates/re_viewer/src/ui/selection_panel.rs index 27c0a1656e7a..1c6cb463014e 100644 --- a/crates/re_viewer/src/ui/selection_panel.rs +++ b/crates/re_viewer/src/ui/selection_panel.rs @@ -12,7 +12,7 @@ use crate::ui::Blueprint; use super::{ selection_history_ui::SelectionHistoryUi, space_view::ViewState, - view_spatial::SpatialNavigationMode, ViewportState, + view_spatial::SpatialNavigationMode, Viewport, ViewportState, }; // --- @@ -101,7 +101,7 @@ impl SelectionPanel { let selection = ctx.selection().to_vec(); for (i, item) in selection.iter().enumerate() { ui.push_id(i, |ui| { - what_is_selected_ui(ui, ctx, blueprint, item); + what_is_selected_ui(ui, ctx, &mut blueprint.viewport, item); if has_data_section(item) { ctx.re_ui.large_collapsing_header(ui, "Data", true, |ui| { @@ -132,10 +132,10 @@ fn has_data_section(item: &Item) -> bool { } /// What is selected? Not the contents, just the short id of it. -pub fn what_is_selected_ui( +fn what_is_selected_ui( ui: &mut egui::Ui, ctx: &mut ViewerContext<'_>, - blueprint: &mut Blueprint, + viewport: &mut Viewport, item: &Item, ) { match item { @@ -157,7 +157,7 @@ pub fn what_is_selected_ui( }); } Item::SpaceView(space_view_id) => { - if let Some(space_view) = blueprint.viewport.space_view_mut(space_view_id) { + if let Some(space_view) = viewport.space_view_mut(space_view_id) { ui.horizontal(|ui| { ui.label("Space view:"); ui.text_edit_singleline(&mut space_view.display_name); @@ -175,7 +175,7 @@ pub fn what_is_selected_ui( ui.end_row(); if let Some(space_view_id) = space_view_id { - if let Some(space_view) = blueprint.viewport.space_view_mut(space_view_id) { + if let Some(space_view) = viewport.space_view_mut(space_view_id) { ui.label("in Space View:"); super::item_ui::space_view_button(ctx, ui, space_view); ui.end_row(); @@ -184,7 +184,7 @@ pub fn what_is_selected_ui( }); } Item::DataBlueprintGroup(space_view_id, data_blueprint_group_handle) => { - if let Some(space_view) = blueprint.viewport.space_view_mut(space_view_id) { + if let Some(space_view) = viewport.space_view_mut(space_view_id) { if let Some(group) = space_view .data_blueprint .group_mut(*data_blueprint_group_handle) diff --git a/crates/re_viewer/src/ui/view_time_series/ui.rs b/crates/re_viewer/src/ui/view_time_series/ui.rs index 3a0ec03d7e75..08894ee35365 100644 --- a/crates/re_viewer/src/ui/view_time_series/ui.rs +++ b/crates/re_viewer/src/ui/view_time_series/ui.rs @@ -4,18 +4,16 @@ use egui::{ }; use re_arrow_store::TimeType; +use re_time_panel::next_grid_tick_magnitude_ns; use re_viewer_context::ViewerContext; use super::SceneTimeSeries; -use crate::{ - misc::format_time::next_grid_tick_magnitude_ns, - ui::{ - spaceview_controls::{ - HORIZONTAL_SCROLL_MODIFIER, MOVE_TIME_CURSOR_BUTTON, RESET_VIEW_BUTTON_TEXT, - SELECTION_RECT_ZOOM_BUTTON, ZOOM_SCROLL_MODIFIER, - }, - view_time_series::scene::PlotSeriesKind, +use crate::ui::{ + spaceview_controls::{ + HORIZONTAL_SCROLL_MODIFIER, MOVE_TIME_CURSOR_BUTTON, RESET_VIEW_BUTTON_TEXT, + SELECTION_RECT_ZOOM_BUTTON, ZOOM_SCROLL_MODIFIER, }, + view_time_series::scene::PlotSeriesKind, }; // --- @@ -181,12 +179,7 @@ pub(crate) fn view_time_series( } else { ui.visuals().widgets.inactive.fg_stroke }; - crate::ui::time_panel::paint_time_cursor( - ui.painter(), - time_x, - response.rect.y_range(), - stroke, - ); + re_time_panel::paint_time_cursor(ui.painter(), time_x, response.rect.y_range(), stroke); } response @@ -195,7 +188,7 @@ pub(crate) fn view_time_series( fn format_time(time_type: TimeType, time_int: i64) -> String { if time_type == TimeType::Time { let time = re_log_types::Time::from_ns_since_epoch(time_int); - crate::misc::format_time::format_time_compact(time) + re_time_panel::format_time_compact(time) } else { time_type.format(re_log_types::TimeInt::from(time_int)) } diff --git a/crates/re_viewer/src/ui/viewport.rs b/crates/re_viewer/src/ui/viewport.rs index 511ea7acde2b..5f3136f3f027 100644 --- a/crates/re_viewer/src/ui/viewport.rs +++ b/crates/re_viewer/src/ui/viewport.rs @@ -770,7 +770,7 @@ fn help_text_ui(ui: &mut egui::Ui, re_ui: &re_ui::ReUi, space_view: &SpaceView) }; if let Some(help_text) = help_text { - crate::misc::help_hover_button(ui).on_hover_text(help_text); + re_ui::help_hover_button(ui).on_hover_text(help_text); } }