-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
RecordingUri
component (rerun-io#8210)
### What This PR introduces a new `RecordingUri` component (which contains just a string) and assorted UI, which present the URI as a link that opens said component. Also introduce a new `FileSource::Uri` to account for this new way of opening recordings. Note: displaying links is disabled in wasm build, because `DataSource::from_uri()` is not available there. I'm actually not quite sure what the story is to load remote recordings from the web viewer 🤷🏻 <img width="1783" alt="image" src="https://github.com/user-attachments/assets/c5816ad2-36f6-41f5-87a5-38d13a2d5328">
- Loading branch information
There are no files selected for viewing
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,11 @@ | ||
namespace rerun.components; | ||
|
||
// --- | ||
|
||
/// A recording URI (Uniform Resource Identifier). | ||
table RecordingUri ( | ||
"attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Hash", | ||
"attr.docs.unreleased" | ||
) { | ||
recording_uri: rerun.datatypes.Utf8 (order: 100); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,8 @@ | ||
use super::RecordingUri; | ||
|
||
impl RecordingUri { | ||
/// Return the Recording URI contained in this component. | ||
pub fn uri(&self) -> &str { | ||
self.0.as_str() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
use re_types::components::RecordingUri; | ||
use re_viewer_context::{MaybeMutRef, ViewerContext}; | ||
|
||
pub fn singleline_view_recording_uri( | ||
_ctx: &ViewerContext<'_>, | ||
ui: &mut egui::Ui, | ||
value: &mut MaybeMutRef<'_, RecordingUri>, | ||
) -> egui::Response { | ||
let value = value.as_ref(); | ||
|
||
#[cfg(not(target_arch = "wasm32"))] | ||
{ | ||
use re_viewer_context::{SystemCommand, SystemCommandSender}; | ||
|
||
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::Uri, | ||
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 | ||
} | ||
|
||
#[cfg(target_arch = "wasm32")] | ||
{ | ||
re_viewer_context::UiLayout::List.label(ui, value.uri()) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.