From 58730c9ffc55f29eaf69f6daa3b1c6f2c35d0c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Thu, 2 Jan 2025 17:27:00 +0100 Subject: [PATCH 1/8] Add clickable URI component The component can be clicked in the tooltip and in the selection panel. --- .../re_types/definitions/rerun/components.fbs | 1 + .../definitions/rerun/components/uri.fbs | 12 ++ .../re_types/src/components/.gitattributes | 1 + crates/store/re_types/src/components/mod.rs | 3 + crates/store/re_types/src/components/uri.rs | 106 ++++++++++++++++++ .../store/re_types/src/components/uri_ext.rs | 8 ++ crates/store/re_types/src/reflection/mod.rs | 8 ++ crates/viewer/re_component_ui/src/lib.rs | 5 +- .../src/{recording_uri.rs => uri.rs} | 11 +- docs/content/reference/types/components.md | 1 + .../reference/types/components/.gitattributes | 1 + .../content/reference/types/components/uri.md | 24 ++++ .../content/reference/types/datatypes/utf8.md | 1 + rerun_cpp/src/rerun/components.hpp | 1 + rerun_cpp/src/rerun/components/.gitattributes | 1 + rerun_cpp/src/rerun/components/uri.hpp | 75 +++++++++++++ .../rerun_sdk/rerun/components/.gitattributes | 1 + .../rerun_sdk/rerun/components/__init__.py | 3 + rerun_py/rerun_sdk/rerun/components/uri.py | 37 ++++++ 19 files changed, 297 insertions(+), 3 deletions(-) create mode 100644 crates/store/re_types/definitions/rerun/components/uri.fbs create mode 100644 crates/store/re_types/src/components/uri.rs create mode 100644 crates/store/re_types/src/components/uri_ext.rs rename crates/viewer/re_component_ui/src/{recording_uri.rs => uri.rs} (84%) create mode 100644 docs/content/reference/types/components/uri.md create mode 100644 rerun_cpp/src/rerun/components/uri.hpp create mode 100644 rerun_py/rerun_sdk/rerun/components/uri.py diff --git a/crates/store/re_types/definitions/rerun/components.fbs b/crates/store/re_types/definitions/rerun/components.fbs index c08679c587bc..931d6a8c54d8 100644 --- a/crates/store/re_types/definitions/rerun/components.fbs +++ b/crates/store/re_types/definitions/rerun/components.fbs @@ -58,6 +58,7 @@ include "./components/transform_mat3x3.fbs"; include "./components/transform_relation.fbs"; include "./components/translation3d.fbs"; include "./components/triangle_indices.fbs"; +include "./components/uri.fbs"; include "./components/value_range.fbs"; include "./components/vector2d.fbs"; include "./components/vector3d.fbs"; diff --git a/crates/store/re_types/definitions/rerun/components/uri.fbs b/crates/store/re_types/definitions/rerun/components/uri.fbs new file mode 100644 index 000000000000..eb529bcbadc1 --- /dev/null +++ b/crates/store/re_types/definitions/rerun/components/uri.fbs @@ -0,0 +1,12 @@ +namespace rerun.components; + +// --- + +/// A general URI (Uniform Resource Identifier). +/// +/// To specify a recording, use `RecordingUri`. +table Uri ( + "attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Hash" +) { + uri: rerun.datatypes.Utf8 (order: 100); +} diff --git a/crates/store/re_types/src/components/.gitattributes b/crates/store/re_types/src/components/.gitattributes index f6c27200d3ff..310885866fea 100644 --- a/crates/store/re_types/src/components/.gitattributes +++ b/crates/store/re_types/src/components/.gitattributes @@ -66,6 +66,7 @@ transform_mat3x3.rs linguist-generated=true transform_relation.rs linguist-generated=true translation3d.rs linguist-generated=true triangle_indices.rs linguist-generated=true +uri.rs linguist-generated=true value_range.rs linguist-generated=true vector2d.rs linguist-generated=true vector3d.rs linguist-generated=true diff --git a/crates/store/re_types/src/components/mod.rs b/crates/store/re_types/src/components/mod.rs index d1a4df006de3..226c6a776e42 100644 --- a/crates/store/re_types/src/components/mod.rs +++ b/crates/store/re_types/src/components/mod.rs @@ -116,6 +116,8 @@ mod translation3d; mod translation3d_ext; mod triangle_indices; mod triangle_indices_ext; +mod uri; +mod uri_ext; mod value_range; mod value_range_ext; mod vector2d; @@ -191,6 +193,7 @@ pub use self::transform_mat3x3::TransformMat3x3; pub use self::transform_relation::TransformRelation; pub use self::translation3d::Translation3D; pub use self::triangle_indices::TriangleIndices; +pub use self::uri::Uri; pub use self::value_range::ValueRange; pub use self::vector2d::Vector2D; pub use self::vector3d::Vector3D; diff --git a/crates/store/re_types/src/components/uri.rs b/crates/store/re_types/src/components/uri.rs new file mode 100644 index 000000000000..1e595366e460 --- /dev/null +++ b/crates/store/re_types/src/components/uri.rs @@ -0,0 +1,106 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/rust/api.rs +// Based on "crates/store/re_types/definitions/rerun/components/uri.fbs". + +#![allow(unused_imports)] +#![allow(unused_parens)] +#![allow(clippy::clone_on_copy)] +#![allow(clippy::cloned_instead_of_copied)] +#![allow(clippy::map_flatten)] +#![allow(clippy::needless_question_mark)] +#![allow(clippy::new_without_default)] +#![allow(clippy::redundant_closure)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::too_many_lines)] + +use ::re_types_core::external::arrow2; +use ::re_types_core::SerializationResult; +use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; +use ::re_types_core::{ComponentDescriptor, ComponentName}; +use ::re_types_core::{DeserializationError, DeserializationResult}; + +/// **Component**: A general URI (Uniform Resource Identifier). +/// +/// To specify a recording, use `RecordingUri`. +#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] +pub struct Uri(pub crate::datatypes::Utf8); + +impl ::re_types_core::Component for Uri { + #[inline] + fn descriptor() -> ComponentDescriptor { + ComponentDescriptor::new("rerun.components.Uri") + } +} + +::re_types_core::macros::impl_into_cow!(Uri); + +impl ::re_types_core::Loggable for Uri { + #[inline] + fn arrow_datatype() -> arrow::datatypes::DataType { + crate::datatypes::Utf8::arrow_datatype() + } + + fn to_arrow_opt<'a>( + data: impl IntoIterator>>>, + ) -> SerializationResult + where + Self: Clone + 'a, + { + crate::datatypes::Utf8::to_arrow_opt(data.into_iter().map(|datum| { + datum.map(|datum| match datum.into() { + ::std::borrow::Cow::Borrowed(datum) => ::std::borrow::Cow::Borrowed(&datum.0), + ::std::borrow::Cow::Owned(datum) => ::std::borrow::Cow::Owned(datum.0), + }) + })) + } + + fn from_arrow2_opt( + arrow_data: &dyn arrow2::array::Array, + ) -> DeserializationResult>> + where + Self: Sized, + { + crate::datatypes::Utf8::from_arrow2_opt(arrow_data) + .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) + } +} + +impl> From for Uri { + fn from(v: T) -> Self { + Self(v.into()) + } +} + +impl std::borrow::Borrow for Uri { + #[inline] + fn borrow(&self) -> &crate::datatypes::Utf8 { + &self.0 + } +} + +impl std::ops::Deref for Uri { + type Target = crate::datatypes::Utf8; + + #[inline] + fn deref(&self) -> &crate::datatypes::Utf8 { + &self.0 + } +} + +impl std::ops::DerefMut for Uri { + #[inline] + fn deref_mut(&mut self) -> &mut crate::datatypes::Utf8 { + &mut self.0 + } +} + +impl ::re_byte_size::SizeBytes for Uri { + #[inline] + fn heap_size_bytes(&self) -> u64 { + self.0.heap_size_bytes() + } + + #[inline] + fn is_pod() -> bool { + ::is_pod() + } +} diff --git a/crates/store/re_types/src/components/uri_ext.rs b/crates/store/re_types/src/components/uri_ext.rs new file mode 100644 index 000000000000..6a87c5cf3ed8 --- /dev/null +++ b/crates/store/re_types/src/components/uri_ext.rs @@ -0,0 +1,8 @@ +use super::Uri; + +impl Uri { + /// Return the URI contained in this component. + pub fn uri(&self) -> &str { + self.0.as_str() + } +} diff --git a/crates/store/re_types/src/reflection/mod.rs b/crates/store/re_types/src/reflection/mod.rs index 31cc885c6114..1341e3aefcac 100644 --- a/crates/store/re_types/src/reflection/mod.rs +++ b/crates/store/re_types/src/reflection/mod.rs @@ -871,6 +871,14 @@ fn generate_component_reflection() -> Result::name(), + ComponentReflection { + docstring_md: "A general URI (Uniform Resource Identifier).\n\nTo specify a recording, use `RecordingUri`.", + custom_placeholder: None, + datatype: Uri::arrow2_datatype(), + }, + ), ( ::name(), ComponentReflection { diff --git a/crates/viewer/re_component_ui/src/lib.rs b/crates/viewer/re_component_ui/src/lib.rs index bbed24bfd956..fce123ffd1a0 100644 --- a/crates/viewer/re_component_ui/src/lib.rs +++ b/crates/viewer/re_component_ui/src/lib.rs @@ -16,11 +16,11 @@ mod marker_shape; mod pinhole; mod plane3d; mod radius; -mod recording_uri; mod resolution; mod response_utils; mod timeline; mod transforms; +mod uri; mod video_timestamp; mod view_coordinates; mod visual_bounds2d; @@ -165,7 +165,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); + registry.add_singleline_edit_or_view(uri::singleline_view_uri); + registry.add_singleline_edit_or_view(uri::singleline_view_recording_uri); line_strip::register_linestrip_component_ui(&mut registry); geo_line_string::register_geo_line_string_component_ui(&mut registry); diff --git a/crates/viewer/re_component_ui/src/recording_uri.rs b/crates/viewer/re_component_ui/src/uri.rs similarity index 84% rename from crates/viewer/re_component_ui/src/recording_uri.rs rename to crates/viewer/re_component_ui/src/uri.rs index 465c6d543bfd..1a10aabfb351 100644 --- a/crates/viewer/re_component_ui/src/recording_uri.rs +++ b/crates/viewer/re_component_ui/src/uri.rs @@ -1,6 +1,15 @@ -use re_types::components::RecordingUri; +use re_types::components::{RecordingUri, Uri}; use re_viewer_context::{MaybeMutRef, ViewerContext}; +pub fn singleline_view_uri( + _ctx: &ViewerContext<'_>, + ui: &mut egui::Ui, + value: &mut MaybeMutRef<'_, Uri>, +) -> egui::Response { + let value = value.as_ref(); + ui.hyperlink(value.uri()) +} + pub fn singleline_view_recording_uri( _ctx: &ViewerContext<'_>, ui: &mut egui::Ui, diff --git a/docs/content/reference/types/components.md b/docs/content/reference/types/components.md index 7e57967c10dc..05ace65c4174 100644 --- a/docs/content/reference/types/components.md +++ b/docs/content/reference/types/components.md @@ -78,6 +78,7 @@ on [Entities and Components](../../concepts/entity-component.md). * [`TransformRelation`](components/transform_relation.md): Specifies relation a spatial transform describes. * [`Translation3D`](components/translation3d.md): A translation vector in 3D space. * [`TriangleIndices`](components/triangle_indices.md): The three indices of a triangle in a triangle mesh. +* [`Uri`](components/uri.md): A general URI (Uniform Resource Identifier). * [`ValueRange`](components/value_range.md): Range of expected or valid values, specifying a lower and upper bound. * [`Vector2D`](components/vector2d.md): A vector in 2D space. * [`Vector3D`](components/vector3d.md): A vector in 3D space. diff --git a/docs/content/reference/types/components/.gitattributes b/docs/content/reference/types/components/.gitattributes index 6606aeac1aaa..bcd9cebcabaf 100644 --- a/docs/content/reference/types/components/.gitattributes +++ b/docs/content/reference/types/components/.gitattributes @@ -66,6 +66,7 @@ transform_mat3x3.md linguist-generated=true transform_relation.md linguist-generated=true translation3d.md linguist-generated=true triangle_indices.md linguist-generated=true +uri.md linguist-generated=true value_range.md linguist-generated=true vector2d.md linguist-generated=true vector3d.md linguist-generated=true diff --git a/docs/content/reference/types/components/uri.md b/docs/content/reference/types/components/uri.md new file mode 100644 index 000000000000..65b0dc8af65a --- /dev/null +++ b/docs/content/reference/types/components/uri.md @@ -0,0 +1,24 @@ +--- +title: "Uri" +--- + + +A general URI (Uniform Resource Identifier). + +To specify a recording, use `RecordingUri`. + +## Rerun datatype +[`Utf8`](../datatypes/utf8.md) + + +## Arrow datatype +``` +utf8 +``` + +## API reference links + * 🌊 [C++ API docs for `Uri`](https://ref.rerun.io/docs/cpp/stable/structrerun_1_1components_1_1Uri.html) + * 🐍 [Python API docs for `Uri`](https://ref.rerun.io/docs/python/stable/common/components#rerun.components.Uri) + * 🦀 [Rust API docs for `Uri`](https://docs.rs/rerun/latest/rerun/components/struct.Uri.html) + + diff --git a/docs/content/reference/types/datatypes/utf8.md b/docs/content/reference/types/datatypes/utf8.md index 092555b91625..526acdb71d74 100644 --- a/docs/content/reference/types/datatypes/utf8.md +++ b/docs/content/reference/types/datatypes/utf8.md @@ -26,5 +26,6 @@ utf8 * [`RecordingUri`](../components/recording_uri.md) * [`TextLogLevel`](../components/text_log_level.md) * [`Text`](../components/text.md) +* [`Uri`](../components/uri.md) * [`Utf8Pair`](../datatypes/utf8pair.md) * [`VisibleTimeRange`](../datatypes/visible_time_range.md) diff --git a/rerun_cpp/src/rerun/components.hpp b/rerun_cpp/src/rerun/components.hpp index 27e6377cc73d..f808080c169f 100644 --- a/rerun_cpp/src/rerun/components.hpp +++ b/rerun_cpp/src/rerun/components.hpp @@ -67,6 +67,7 @@ #include "components/transform_relation.hpp" #include "components/translation3d.hpp" #include "components/triangle_indices.hpp" +#include "components/uri.hpp" #include "components/value_range.hpp" #include "components/vector2d.hpp" #include "components/vector3d.hpp" diff --git a/rerun_cpp/src/rerun/components/.gitattributes b/rerun_cpp/src/rerun/components/.gitattributes index 2f773028d7c8..2bfa90d220eb 100644 --- a/rerun_cpp/src/rerun/components/.gitattributes +++ b/rerun_cpp/src/rerun/components/.gitattributes @@ -77,6 +77,7 @@ transform_relation.cpp linguist-generated=true transform_relation.hpp linguist-generated=true translation3d.hpp linguist-generated=true triangle_indices.hpp linguist-generated=true +uri.hpp linguist-generated=true value_range.hpp linguist-generated=true vector2d.hpp linguist-generated=true vector3d.hpp linguist-generated=true diff --git a/rerun_cpp/src/rerun/components/uri.hpp b/rerun_cpp/src/rerun/components/uri.hpp new file mode 100644 index 000000000000..843c962cad23 --- /dev/null +++ b/rerun_cpp/src/rerun/components/uri.hpp @@ -0,0 +1,75 @@ +// DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/cpp/mod.rs +// Based on "crates/store/re_types/definitions/rerun/components/uri.fbs". + +#pragma once + +#include "../component_descriptor.hpp" +#include "../datatypes/utf8.hpp" +#include "../result.hpp" + +#include +#include +#include +#include + +namespace rerun::components { + /// **Component**: A general URI (Uniform Resource Identifier). + /// + /// To specify a recording, use `RecordingUri`. + struct Uri { + rerun::datatypes::Utf8 uri; + + public: + Uri() = default; + + Uri(rerun::datatypes::Utf8 uri_) : uri(std::move(uri_)) {} + + Uri& operator=(rerun::datatypes::Utf8 uri_) { + uri = std::move(uri_); + return *this; + } + + Uri(std::string value_) : uri(std::move(value_)) {} + + Uri& operator=(std::string value_) { + uri = std::move(value_); + return *this; + } + + /// Cast to the underlying Utf8 datatype + operator rerun::datatypes::Utf8() const { + return uri; + } + }; +} // namespace rerun::components + +namespace rerun { + static_assert(sizeof(rerun::datatypes::Utf8) == sizeof(components::Uri)); + + /// \private + template <> + struct Loggable { + static constexpr ComponentDescriptor Descriptor = "rerun.components.Uri"; + + /// Returns the arrow data type this type corresponds to. + static const std::shared_ptr& arrow_datatype() { + return Loggable::arrow_datatype(); + } + + /// Serializes an array of `rerun::components::Uri` into an arrow array. + static Result> to_arrow( + const components::Uri* instances, size_t num_instances + ) { + if (num_instances == 0) { + return Loggable::to_arrow(nullptr, 0); + } else if (instances == nullptr) { + return rerun::Error( + ErrorCode::UnexpectedNullArgument, + "Passed array instances is null when num_elements> 0." + ); + } else { + return Loggable::to_arrow(&instances->uri, num_instances); + } + } + }; +} // namespace rerun diff --git a/rerun_py/rerun_sdk/rerun/components/.gitattributes b/rerun_py/rerun_sdk/rerun/components/.gitattributes index 4940e2de0da1..e5fa698caaa3 100644 --- a/rerun_py/rerun_sdk/rerun/components/.gitattributes +++ b/rerun_py/rerun_sdk/rerun/components/.gitattributes @@ -67,6 +67,7 @@ transform_mat3x3.py linguist-generated=true transform_relation.py linguist-generated=true translation3d.py linguist-generated=true triangle_indices.py linguist-generated=true +uri.py linguist-generated=true value_range.py linguist-generated=true vector2d.py linguist-generated=true vector3d.py linguist-generated=true diff --git a/rerun_py/rerun_sdk/rerun/components/__init__.py b/rerun_py/rerun_sdk/rerun/components/__init__.py index f8ab31dbcb49..22ec17f3ee20 100644 --- a/rerun_py/rerun_sdk/rerun/components/__init__.py +++ b/rerun_py/rerun_sdk/rerun/components/__init__.py @@ -87,6 +87,7 @@ ) from .translation3d import Translation3D, Translation3DBatch from .triangle_indices import TriangleIndices, TriangleIndicesBatch +from .uri import Uri, UriBatch from .value_range import ValueRange, ValueRangeBatch from .vector2d import Vector2D, Vector2DBatch from .vector3d import Vector3D, Vector3DBatch @@ -246,6 +247,8 @@ "Translation3DBatch", "TriangleIndices", "TriangleIndicesBatch", + "Uri", + "UriBatch", "ValueRange", "ValueRangeBatch", "Vector2D", diff --git a/rerun_py/rerun_sdk/rerun/components/uri.py b/rerun_py/rerun_sdk/rerun/components/uri.py new file mode 100644 index 000000000000..684326adf621 --- /dev/null +++ b/rerun_py/rerun_sdk/rerun/components/uri.py @@ -0,0 +1,37 @@ +# DO NOT EDIT! This file was auto-generated by crates/build/re_types_builder/src/codegen/python/mod.rs +# Based on "crates/store/re_types/definitions/rerun/components/uri.fbs". + +# You can extend this class by creating a "UriExt" class in "uri_ext.py". + +from __future__ import annotations + +from .. import datatypes +from .._baseclasses import ( + ComponentBatchMixin, + ComponentDescriptor, + ComponentMixin, +) + +__all__ = ["Uri", "UriBatch"] + + +class Uri(datatypes.Utf8, ComponentMixin): + """ + **Component**: A general URI (Uniform Resource Identifier). + + To specify a recording, use `RecordingUri`. + """ + + _BATCH_TYPE = None + # You can define your own __init__ function as a member of UriExt in uri_ext.py + + # Note: there are no fields here because Uri delegates to datatypes.Utf8 + pass + + +class UriBatch(datatypes.Utf8Batch, ComponentBatchMixin): + _COMPONENT_DESCRIPTOR: ComponentDescriptor = ComponentDescriptor("rerun.components.Uri") + + +# This is patched in late to avoid circular dependencies. +Uri._BATCH_TYPE = UriBatch # type: ignore[assignment] From 731756c9c6d52d44608cbc30860865261ad4f49b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 3 Jan 2025 08:42:29 +0100 Subject: [PATCH 2/8] Mark as `docs.attribute.unreleased` --- crates/store/re_types/definitions/rerun/components/uri.fbs | 3 ++- docs/content/reference/types/components/uri.md | 6 +++--- docs/content/reference/types/datatypes/utf8.md | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/components/uri.fbs b/crates/store/re_types/definitions/rerun/components/uri.fbs index eb529bcbadc1..82552110d883 100644 --- a/crates/store/re_types/definitions/rerun/components/uri.fbs +++ b/crates/store/re_types/definitions/rerun/components/uri.fbs @@ -6,7 +6,8 @@ namespace rerun.components; /// /// To specify a recording, use `RecordingUri`. table Uri ( - "attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Hash" + "attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Hash", + "attr.docs.unreleased" ) { uri: rerun.datatypes.Utf8 (order: 100); } diff --git a/docs/content/reference/types/components/uri.md b/docs/content/reference/types/components/uri.md index 65b0dc8af65a..5bef649694ac 100644 --- a/docs/content/reference/types/components/uri.md +++ b/docs/content/reference/types/components/uri.md @@ -17,8 +17,8 @@ utf8 ``` ## API reference links - * 🌊 [C++ API docs for `Uri`](https://ref.rerun.io/docs/cpp/stable/structrerun_1_1components_1_1Uri.html) - * 🐍 [Python API docs for `Uri`](https://ref.rerun.io/docs/python/stable/common/components#rerun.components.Uri) - * 🦀 [Rust API docs for `Uri`](https://docs.rs/rerun/latest/rerun/components/struct.Uri.html) + * 🌊 [C++ API docs for `Uri`](https://ref.rerun.io/docs/cpp/stable/structrerun_1_1components_1_1Uri.html?speculative-link) + * 🐍 [Python API docs for `Uri`](https://ref.rerun.io/docs/python/stable/common/components?speculative-link#rerun.components.Uri) + * 🦀 [Rust API docs for `Uri`](https://docs.rs/rerun/latest/rerun/components/struct.Uri.html?speculative-link) diff --git a/docs/content/reference/types/datatypes/utf8.md b/docs/content/reference/types/datatypes/utf8.md index 526acdb71d74..86566c0a7a3d 100644 --- a/docs/content/reference/types/datatypes/utf8.md +++ b/docs/content/reference/types/datatypes/utf8.md @@ -26,6 +26,6 @@ utf8 * [`RecordingUri`](../components/recording_uri.md) * [`TextLogLevel`](../components/text_log_level.md) * [`Text`](../components/text.md) -* [`Uri`](../components/uri.md) +* [`Uri`](../components/uri.md?speculative-link) * [`Utf8Pair`](../datatypes/utf8pair.md) * [`VisibleTimeRange`](../datatypes/visible_time_range.md) From ab082ad9e74867f2f3ccf050054eb11466e5413e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 3 Jan 2025 08:55:15 +0100 Subject: [PATCH 3/8] Update snapshots --- .../snapshots/all_components_list_item_narrow/Uri_simple.png | 3 +++ .../snapshots/all_components_list_item_wide/Uri_simple.png | 3 +++ crates/viewer/re_component_ui/tests/test_all_components_ui.rs | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png create mode 100644 crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png diff --git a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png new file mode 100644 index 000000000000..d15bd68dcd62 --- /dev/null +++ b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e37bf2ee953fe4844b3670420b25ed639dbb4933f0e4461326bba604cbfe09d6 +size 4449 diff --git a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png new file mode 100644 index 000000000000..b93fc17ba556 --- /dev/null +++ b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ff80ffa7af61934c38617125131fb5bf2dbe5f109c1e3e2976e61aea474054b9 +size 5121 diff --git a/crates/viewer/re_component_ui/tests/test_all_components_ui.rs b/crates/viewer/re_component_ui/tests/test_all_components_ui.rs index 5b230215cf56..dd24ad1ef88a 100644 --- a/crates/viewer/re_component_ui/tests/test_all_components_ui.rs +++ b/crates/viewer/re_component_ui/tests/test_all_components_ui.rs @@ -14,7 +14,7 @@ use re_component_ui::create_component_ui_registry; use re_log_types::{EntityPath, Timeline}; use re_types::{ blueprint::components::{ComponentColumnSelector, QueryExpression}, - components::{self, GraphEdge, GraphNode, ImageFormat, RecordingUri, Text}, + components::{self, GraphEdge, GraphNode, ImageFormat, RecordingUri, Text, Uri}, datatypes::{ChannelDatatype, PixelFormat}, }; use re_types_core::{reflection::Reflection, Component, ComponentName, LoggableBatch}; @@ -68,6 +68,7 @@ fn test_cases(reflection: &Reflection) -> Vec { RecordingUri::from("rerun://0.0.0.0:1234/recordings/XYZ"), "simple", ), + TestCase::from_component(Uri::from("https://rerun.io"), "simple"), TestCase::from_component(Text::from("Hello World!"), "simple"), ]; From 55246edd37bad5cb1b0dd1b15911f6ae2112248c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Fri, 3 Jan 2025 12:21:49 +0100 Subject: [PATCH 4/8] Add check to `check_all_components_ui.py` --- tests/python/release_checklist/check_all_components_ui.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/python/release_checklist/check_all_components_ui.py b/tests/python/release_checklist/check_all_components_ui.py index d5fb1629d430..a194847d5b7e 100644 --- a/tests/python/release_checklist/check_all_components_ui.py +++ b/tests/python/release_checklist/check_all_components_ui.py @@ -239,6 +239,12 @@ def alternatives(self) -> list[Any] | None: ), "Translation3DBatch": TestCase(batch=[(1, 2, 3), (4, 5, 6), (7, 8, 9)]), "TriangleIndicesBatch": TestCase(batch=[(0, 1, 2), (3, 4, 5), (6, 7, 8)]), + "UriBatch": TestCase( + batch=[ + rr.components.Uri("https://rerun.io"), + rr.components.Uri("https://rerun.io/careers"), + ] + ), "ValueRangeBatch": TestCase((0, 5)), "Vector2DBatch": TestCase(batch=[(0, 1), (2, 3), (4, 5)]), "Vector3DBatch": TestCase(batch=[(0, 3, 4), (1, 4, 5), (2, 5, 6)]), From ff8df79c74d40baeee56f25ae1381b50e1b50a78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 7 Jan 2025 12:10:57 +0100 Subject: [PATCH 5/8] Mimic API from `egui` --- crates/viewer/re_component_ui/src/uri.rs | 3 ++- crates/viewer/re_data_ui/src/component_name.rs | 2 +- .../viewer/re_time_panel/src/time_control_ui.rs | 2 +- crates/viewer/re_ui/src/ui_ext.rs | 17 ++++++++++++++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/crates/viewer/re_component_ui/src/uri.rs b/crates/viewer/re_component_ui/src/uri.rs index 1a10aabfb351..7453eb748d02 100644 --- a/crates/viewer/re_component_ui/src/uri.rs +++ b/crates/viewer/re_component_ui/src/uri.rs @@ -1,4 +1,5 @@ use re_types::components::{RecordingUri, Uri}; +use re_ui::UiExt as _; use re_viewer_context::{MaybeMutRef, ViewerContext}; pub fn singleline_view_uri( @@ -7,7 +8,7 @@ pub fn singleline_view_uri( value: &mut MaybeMutRef<'_, Uri>, ) -> egui::Response { let value = value.as_ref(); - ui.hyperlink(value.uri()) + ui.re_hyperlink(value.uri()) } pub fn singleline_view_recording_uri( diff --git a/crates/viewer/re_data_ui/src/component_name.rs b/crates/viewer/re_data_ui/src/component_name.rs index 7e771facb081..f788baee248d 100644 --- a/crates/viewer/re_data_ui/src/component_name.rs +++ b/crates/viewer/re_data_ui/src/component_name.rs @@ -38,7 +38,7 @@ impl DataUi for ComponentName { } if let Some(url) = self.doc_url() { - ui.re_hyperlink("Full documentation", url); + ui.re_hyperlink_to("Full documentation", url); } }); } diff --git a/crates/viewer/re_time_panel/src/time_control_ui.rs b/crates/viewer/re_time_panel/src/time_control_ui.rs index b802aa088dea..086288c52630 100644 --- a/crates/viewer/re_time_panel/src/time_control_ui.rs +++ b/crates/viewer/re_time_panel/src/time_control_ui.rs @@ -58,7 +58,7 @@ You can also define your own timelines, e.g. for sensor time or camera frame num .trim(), ); - ui.re_hyperlink( + ui.re_hyperlink_to( "Full documentation", "https://rerun.io/docs/concepts/timelines", ); diff --git a/crates/viewer/re_ui/src/ui_ext.rs b/crates/viewer/re_ui/src/ui_ext.rs index 706f9311c6aa..73dbb5d541a8 100644 --- a/crates/viewer/re_ui/src/ui_ext.rs +++ b/crates/viewer/re_ui/src/ui_ext.rs @@ -955,7 +955,22 @@ pub trait UiExt { } /// Helper for adding a list-item hyperlink. - fn re_hyperlink( + fn re_hyperlink(&mut self, url: impl ToString) -> egui::Response { + let ui = self.ui_mut(); + let response = ListItem::new() + .show_flat( + ui, + LabelContent::new(url).with_icon(&crate::icons::EXTERNAL_LINK), + ) + .on_hover_cursor(egui::CursorIcon::PointingHand); + if response.clicked() { + ui.ctx().open_url(egui::OpenUrl::new_tab(url)); + } + response + } + + /// Helper for adding a list-item hyperlink with text. + fn re_hyperlink_to( &mut self, text: impl Into, url: impl ToString, From a217b55ec53942ac2a9560d50149f1d2de999705 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 7 Jan 2025 12:17:21 +0100 Subject: [PATCH 6/8] Add icon to URL to show that it is clickable --- .../snapshots/all_components_list_item_narrow/Uri_simple.png | 4 ++-- .../snapshots/all_components_list_item_wide/Uri_simple.png | 4 ++-- crates/viewer/re_ui/src/ui_ext.rs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png index d15bd68dcd62..da29da2ae40d 100644 --- a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png +++ b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e37bf2ee953fe4844b3670420b25ed639dbb4933f0e4461326bba604cbfe09d6 -size 4449 +oid sha256:b95aae34def1088c12053f440fd3dab8e76bce14bf14e897b112e2326eafad8f +size 4383 diff --git a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png index b93fc17ba556..9bcc65018789 100644 --- a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png +++ b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ff80ffa7af61934c38617125131fb5bf2dbe5f109c1e3e2976e61aea474054b9 -size 5121 +oid sha256:8dab316463e3f9af9c191eabc0f8e8419a4f235b292a3fa17b3e80c93d2c2d8a +size 5347 diff --git a/crates/viewer/re_ui/src/ui_ext.rs b/crates/viewer/re_ui/src/ui_ext.rs index 73dbb5d541a8..b4be0384c43b 100644 --- a/crates/viewer/re_ui/src/ui_ext.rs +++ b/crates/viewer/re_ui/src/ui_ext.rs @@ -960,7 +960,7 @@ pub trait UiExt { let response = ListItem::new() .show_flat( ui, - LabelContent::new(url).with_icon(&crate::icons::EXTERNAL_LINK), + LabelContent::new(url.to_string()).with_icon(&crate::icons::EXTERNAL_LINK), ) .on_hover_cursor(egui::CursorIcon::PointingHand); if response.clicked() { From 027af222717509495724ca8fd724a23859e21d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Tue, 7 Jan 2025 13:53:31 +0100 Subject: [PATCH 7/8] Docs --- .../re_types/definitions/rerun/components/uri.fbs | 2 +- crates/store/re_types/src/components/uri.rs | 10 +++++----- crates/store/re_types/src/reflection/mod.rs | 4 ++-- docs/content/reference/types/components/uri.md | 2 +- rerun_cpp/src/rerun/components/uri.hpp | 2 +- rerun_py/rerun_sdk/rerun/components/uri.py | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/store/re_types/definitions/rerun/components/uri.fbs b/crates/store/re_types/definitions/rerun/components/uri.fbs index 82552110d883..2a4b4e0f6f98 100644 --- a/crates/store/re_types/definitions/rerun/components/uri.fbs +++ b/crates/store/re_types/definitions/rerun/components/uri.fbs @@ -4,7 +4,7 @@ namespace rerun.components; /// A general URI (Uniform Resource Identifier). /// -/// To specify a recording, use `RecordingUri`. +/// To specify a recording, use [archetypes.RecordingUri]. table Uri ( "attr.rust.derive": "PartialEq, Eq, PartialOrd, Ord, Hash", "attr.docs.unreleased" diff --git a/crates/store/re_types/src/components/uri.rs b/crates/store/re_types/src/components/uri.rs index 1e595366e460..83e10c7e08fd 100644 --- a/crates/store/re_types/src/components/uri.rs +++ b/crates/store/re_types/src/components/uri.rs @@ -12,7 +12,7 @@ #![allow(clippy::too_many_arguments)] #![allow(clippy::too_many_lines)] -use ::re_types_core::external::arrow2; +use ::re_types_core::external::arrow; use ::re_types_core::SerializationResult; use ::re_types_core::{ComponentBatch, ComponentBatchCowWithDescriptor}; use ::re_types_core::{ComponentDescriptor, ComponentName}; @@ -20,7 +20,7 @@ use ::re_types_core::{DeserializationError, DeserializationResult}; /// **Component**: A general URI (Uniform Resource Identifier). /// -/// To specify a recording, use `RecordingUri`. +/// To specify a recording, use [archetypes.RecordingUri]. #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Uri(pub crate::datatypes::Utf8); @@ -53,13 +53,13 @@ impl ::re_types_core::Loggable for Uri { })) } - fn from_arrow2_opt( - arrow_data: &dyn arrow2::array::Array, + fn from_arrow_opt( + arrow_data: &dyn arrow::array::Array, ) -> DeserializationResult>> where Self: Sized, { - crate::datatypes::Utf8::from_arrow2_opt(arrow_data) + crate::datatypes::Utf8::from_arrow_opt(arrow_data) .map(|v| v.into_iter().map(|v| v.map(Self)).collect()) } } diff --git a/crates/store/re_types/src/reflection/mod.rs b/crates/store/re_types/src/reflection/mod.rs index 678a55f4e917..c3cb55c91760 100644 --- a/crates/store/re_types/src/reflection/mod.rs +++ b/crates/store/re_types/src/reflection/mod.rs @@ -874,9 +874,9 @@ fn generate_component_reflection() -> Result::name(), ComponentReflection { - docstring_md: "A general URI (Uniform Resource Identifier).\n\nTo specify a recording, use `RecordingUri`.", + docstring_md: "A general URI (Uniform Resource Identifier).\n\nTo specify a recording, use [archetypes.RecordingUri].", custom_placeholder: None, - datatype: Uri::arrow2_datatype(), + datatype: Uri::arrow_datatype(), }, ), ( diff --git a/docs/content/reference/types/components/uri.md b/docs/content/reference/types/components/uri.md index 5bef649694ac..2ebaf4311954 100644 --- a/docs/content/reference/types/components/uri.md +++ b/docs/content/reference/types/components/uri.md @@ -5,7 +5,7 @@ title: "Uri" A general URI (Uniform Resource Identifier). -To specify a recording, use `RecordingUri`. +To specify a recording, use [archetypes.RecordingUri]. ## Rerun datatype [`Utf8`](../datatypes/utf8.md) diff --git a/rerun_cpp/src/rerun/components/uri.hpp b/rerun_cpp/src/rerun/components/uri.hpp index 843c962cad23..19166ba9b54a 100644 --- a/rerun_cpp/src/rerun/components/uri.hpp +++ b/rerun_cpp/src/rerun/components/uri.hpp @@ -15,7 +15,7 @@ namespace rerun::components { /// **Component**: A general URI (Uniform Resource Identifier). /// - /// To specify a recording, use `RecordingUri`. + /// To specify a recording, use [archetypes.RecordingUri]. struct Uri { rerun::datatypes::Utf8 uri; diff --git a/rerun_py/rerun_sdk/rerun/components/uri.py b/rerun_py/rerun_sdk/rerun/components/uri.py index 684326adf621..d4b13017f702 100644 --- a/rerun_py/rerun_sdk/rerun/components/uri.py +++ b/rerun_py/rerun_sdk/rerun/components/uri.py @@ -19,7 +19,7 @@ class Uri(datatypes.Utf8, ComponentMixin): """ **Component**: A general URI (Uniform Resource Identifier). - To specify a recording, use `RecordingUri`. + To specify a recording, use [archetypes.RecordingUri]. """ _BATCH_TYPE = None From dc93588838aaf64cc5d2064e5ed0ea3336bf993b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jochen=20G=C3=B6rtler?= Date: Wed, 8 Jan 2025 11:06:02 +0100 Subject: [PATCH 8/8] Truncate --- crates/viewer/re_component_ui/src/uri.rs | 13 ++++++++++++- .../all_components_list_item_narrow/Uri_simple.png | 4 ++-- .../all_components_list_item_wide/Uri_simple.png | 2 +- crates/viewer/re_ui/src/ui_ext.rs | 8 ++++++-- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/crates/viewer/re_component_ui/src/uri.rs b/crates/viewer/re_component_ui/src/uri.rs index 7453eb748d02..8109e6f51d29 100644 --- a/crates/viewer/re_component_ui/src/uri.rs +++ b/crates/viewer/re_component_ui/src/uri.rs @@ -8,7 +8,18 @@ pub fn singleline_view_uri( value: &mut MaybeMutRef<'_, Uri>, ) -> egui::Response { let value = value.as_ref(); - ui.re_hyperlink(value.uri()) + 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.re_hyperlink(value.uri()) + }) + .inner } pub fn singleline_view_recording_uri( diff --git a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png index da29da2ae40d..c2a918ced92e 100644 --- a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png +++ b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_narrow/Uri_simple.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b95aae34def1088c12053f440fd3dab8e76bce14bf14e897b112e2326eafad8f -size 4383 +oid sha256:dce54881d4843c114269710614a9c5530146e168a6b758a2022e871f3a0ad1b3 +size 4243 diff --git a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png index 9bcc65018789..bd9ea4309e4c 100644 --- a/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png +++ b/crates/viewer/re_component_ui/tests/snapshots/all_components_list_item_wide/Uri_simple.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8dab316463e3f9af9c191eabc0f8e8419a4f235b292a3fa17b3e80c93d2c2d8a +oid sha256:0c51f5e9aa5c3bf3d34d752c83d18ecd63d459321a19fb69557aadd05cc05392 size 5347 diff --git a/crates/viewer/re_ui/src/ui_ext.rs b/crates/viewer/re_ui/src/ui_ext.rs index 1d68fe78a178..e3716465ddfe 100644 --- a/crates/viewer/re_ui/src/ui_ext.rs +++ b/crates/viewer/re_ui/src/ui_ext.rs @@ -962,7 +962,9 @@ pub trait UiExt { let response = ListItem::new() .show_flat( ui, - LabelContent::new(url.to_string()).with_icon(&crate::icons::EXTERNAL_LINK), + LabelContent::new(url.to_string()) + .truncate(true) + .with_icon(&crate::icons::EXTERNAL_LINK), ) .on_hover_cursor(egui::CursorIcon::PointingHand); if response.clicked() { @@ -981,7 +983,9 @@ pub trait UiExt { let response = ListItem::new() .show_flat( ui, - LabelContent::new(text).with_icon(&crate::icons::EXTERNAL_LINK), + LabelContent::new(text) + .truncate(true) + .with_icon(&crate::icons::EXTERNAL_LINK), ) .on_hover_cursor(egui::CursorIcon::PointingHand); if response.clicked() {