Skip to content

Commit

Permalink
Add RecordingUri component and an assorted custom ui
Browse files Browse the repository at this point in the history
  • Loading branch information
abey79 committed Nov 22, 2024
1 parent 8992f8f commit 5d97c41
Show file tree
Hide file tree
Showing 21 changed files with 323 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5365,8 +5365,11 @@ dependencies = [
"egui",
"egui_extras",
"egui_plot",
"re_data_source",
"re_data_ui",
"re_format",
"re_log",
"re_log_types",
"re_tracing",
"re_types",
"re_types_blueprint",
Expand Down
1 change: 1 addition & 0 deletions crates/store/re_types/definitions/rerun/components.fbs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace rerun.components;

// ---

/// A recording URI (Uniform Resource Identifier).
table RecordingUri (
"attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Hash"
) {
recording_uri: rerun.datatypes.Utf8 (order: 100);
}
1 change: 1 addition & 0 deletions crates/store/re_types/src/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions crates/store/re_types/src/components/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions crates/store/re_types/src/components/recording_uri.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions crates/store/re_types/src/components/recording_uri_ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use super::RecordingUri;

impl RecordingUri {
/// Return the Recording URI contained in this component.
pub fn uri(&self) -> &str {
self.0.as_str()
}
}
3 changes: 3 additions & 0 deletions crates/viewer/re_component_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ all-features = true

[dependencies]
re_data_ui.workspace = true # Needed for `item_ui`.
re_data_source.workspace = true
re_format.workspace = true
re_log.workspace = true
re_log_types.workspace = true
re_tracing.workspace = true
re_types = { workspace = true, features = [
"egui_plot", # Needed to draw marker shapes.
Expand Down
3 changes: 3 additions & 0 deletions crates/viewer/re_component_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ mod map_provider;
mod marker_shape;
mod pinhole;
mod radius;
mod recording_uri;
mod resolution;
mod response_utils;
mod timeline;
Expand Down Expand Up @@ -157,6 +158,8 @@ pub fn create_component_ui_registry() -> re_viewer_context::ComponentUiRegistry
registry.add_singleline_edit_or_view(pinhole::singleline_view_pinhole);
registry.add_multiline_edit_or_view(pinhole::multiline_view_pinhole);

registry.add_singleline_edit_or_view(recording_uri::singleline_view_recording_uri);

line_strip::register_linestrip_component_ui(&mut registry);
geo_line_string::register_geo_line_string_component_ui(&mut registry);

Expand Down
40 changes: 40 additions & 0 deletions crates/viewer/re_component_ui/src/recording_uri.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
use re_types::components::RecordingUri;
use re_viewer_context::{MaybeMutRef, SystemCommand, SystemCommandSender, ViewerContext};

pub fn singleline_view_recording_uri(
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
value: &mut MaybeMutRef<'_, RecordingUri>,
) -> egui::Response {
let value = value.as_ref();

let response = ui
.scope(|ui| {
if ui.style().wrap_mode.is_none() {
ui.style_mut().wrap_mode = Some(if ui.is_sizing_pass() {
egui::TextWrapMode::Extend
} else {
egui::TextWrapMode::Truncate
});
}

ui.link(value.uri())
})
.inner;

if response.clicked() {
let data_source = re_data_source::DataSource::from_uri(
re_log_types::FileSource::Cli,
value.uri().to_owned(),
);

match data_source.stream(None) {
Ok(rx) => ctx
.command_sender
.send_system(SystemCommand::AddReceiver(rx)),
Err(err) => re_log::warn!("Could not open recording URI: {err}"),
}
}

response
}
8 changes: 8 additions & 0 deletions crates/viewer/re_viewer/src/reflection/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/content/reference/types/components.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/content/reference/types/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions docs/content/reference/types/components/recording_uri.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/content/reference/types/datatypes/utf8.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rerun_cpp/src/rerun/components.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rerun_cpp/src/rerun/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions rerun_cpp/src/rerun/components/recording_uri.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5d97c41

Please sign in to comment.