Skip to content

Commit 621c35c

Browse files
authored
Group open recordings by origin, dataset/appid and examples (#9377)
### Related * Part of rerun-io/dataplatform#396 ### What Groups items in the recordings panel by their dataset / locally by app id / examples. This doesn't touch the redap browser yet, I'll update that UI in a separate PR. https://github.com/user-attachments/assets/2a3da40e-2135-452c-80ae-068856900aee
1 parent f116944 commit 621c35c

File tree

11 files changed

+312
-99
lines changed

11 files changed

+312
-99
lines changed

crates/viewer/re_redap_browser/src/collections.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ use crate::servers::Command;
1515
/// An id for a [`Collection`].
1616
/// //TODO(ab): this should be a properly defined id provided by the redap server
1717
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
18-
pub struct CollectionId(pub egui::Id);
18+
pub struct CollectionId(egui::Id);
19+
20+
impl From<&re_uri::Origin> for CollectionId {
21+
fn from(origin: &re_uri::Origin) -> Self {
22+
Self(egui::Id::new(origin.clone()).with("__top_level_collection__"))
23+
}
24+
}
1925

2026
/// An individual collection of recordings within a catalog.
2127
pub struct Collection {
@@ -142,8 +148,7 @@ async fn stream_catalog_async(origin: re_uri::Origin) -> Result<Collection, Stre
142148
.await?;
143149

144150
//TODO(ab): ideally this is provided by the server
145-
let collection_id =
146-
CollectionId(egui::Id::new(origin.clone()).with("__top_level_collection__"));
151+
let collection_id = CollectionId::from(&origin);
147152
let collection = Collection {
148153
collection_id,
149154
//TODO(ab): this should be provided by the server

crates/viewer/re_redap_browser/src/servers.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,20 @@ impl RedapServers {
150150
let _ = self.command_sender.send(Command::AddServer(origin));
151151
}
152152

153+
#[allow(clippy::needless_pass_by_value)]
154+
pub fn select_server(&self, origin: re_uri::Origin) {
155+
let _ = self
156+
.command_sender
157+
.send(Command::SelectCollection(CollectionId::from(&origin)));
158+
}
159+
160+
#[allow(clippy::needless_pass_by_value)]
161+
pub fn select_dataset(&self, origin: re_uri::Origin, _dataset: String) {
162+
let _ = self
163+
.command_sender
164+
.send(Command::SelectCollection(CollectionId::from(&origin)));
165+
}
166+
153167
/// Per-frame housekeeping.
154168
///
155169
/// - Process commands from the queue.
318 Bytes
Loading

crates/viewer/re_ui/src/design_tokens.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,14 @@ impl DesignTokens {
337337
24.0
338338
}
339339

340+
pub fn list_header_vertical_offset() -> f32 {
341+
2.0
342+
}
343+
344+
pub fn list_header_font_size() -> f32 {
345+
11.0
346+
}
347+
340348
pub fn native_window_corner_radius() -> u8 {
341349
10
342350
}

crates/viewer/re_ui/src/icons.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ pub const COMPONENT_STATIC: Icon = icon_from_path!("../data/icons/component_stat
122122

123123
pub const APPLICATION: Icon = icon_from_path!("../data/icons/application.png");
124124
pub const DATA_SOURCE: Icon = icon_from_path!("../data/icons/data_source.png");
125+
pub const DATASET: Icon = icon_from_path!("../data/icons/dataset.png");
125126
pub const RECORDING: Icon = icon_from_path!("../data/icons/recording.png");
126127
pub const BLUEPRINT: Icon = icon_from_path!("../data/icons/blueprint.png");
127128

crates/viewer/re_ui/src/list_item/label_content.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use egui::{text::TextWrapping, Align, Align2, NumExt as _, Ui};
1+
use egui::{text::TextWrapping, Align, Align2, NumExt as _, RichText, Ui};
22

33
use super::{ContentContext, DesiredWidth, ListItemContent};
44
use crate::{DesignTokens, Icon, LabelStyle};
@@ -41,6 +41,18 @@ impl<'a> LabelContent<'a> {
4141
}
4242
}
4343

44+
/// Render this as a header item.
45+
///
46+
/// Text will be strong and smaller.
47+
/// For best results, use this with [`super::ListItem::header`].
48+
pub fn header(text: impl Into<RichText>) -> Self {
49+
Self::new(
50+
text.into()
51+
.size(DesignTokens::list_header_font_size())
52+
.strong(),
53+
)
54+
}
55+
4456
/// Set the subdued state of the item.
4557
///
4658
/// Note: takes precedence over [`Self::weak`] if set.

crates/viewer/re_ui/src/list_item/list_item.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ pub struct ListItem {
4949
force_background: Option<egui::Color32>,
5050
pub collapse_openness: Option<f32>,
5151
height: f32,
52+
y_offset: f32,
5253
render_offscreen: bool,
5354
}
5455

@@ -63,6 +64,7 @@ impl Default for ListItem {
6364
force_background: None,
6465
collapse_openness: None,
6566
height: DesignTokens::list_item_height(),
67+
y_offset: 0.0,
6668
render_offscreen: true,
6769
}
6870
}
@@ -142,6 +144,24 @@ impl ListItem {
142144
self
143145
}
144146

147+
/// Set the item's vertical offset.
148+
///
149+
/// NOTE: Can only be positive.
150+
/// Default is 0.0.
151+
#[inline]
152+
pub fn with_y_offset(mut self, y_offset: f32) -> Self {
153+
self.y_offset = y_offset;
154+
self
155+
}
156+
157+
/// Set the item's vertical offset to `DesignTokens::list_header_vertical_offset()`.
158+
/// For best results, use this with [`super::LabelContent::header`].
159+
#[inline]
160+
pub fn header(mut self) -> Self {
161+
self.y_offset = DesignTokens::list_header_vertical_offset();
162+
self
163+
}
164+
145165
/// Controls whether [`Self`] calls [`ListItemContent::ui`] when the item is not currently
146166
/// visible.
147167
///
@@ -287,10 +307,16 @@ impl ListItem {
287307
force_hovered,
288308
force_background,
289309
collapse_openness,
290-
height,
310+
mut height,
311+
y_offset,
291312
render_offscreen,
292313
} = self;
293314

315+
if y_offset != 0.0 {
316+
ui.add_space(y_offset);
317+
height -= y_offset;
318+
}
319+
294320
let collapse_extra = if collapse_openness.is_some() {
295321
DesignTokens::collapsing_triangle_area().x + DesignTokens::text_to_icon_padding()
296322
} else {

crates/viewer/re_viewer/src/app.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,12 @@ impl App {
553553
self.state.display_mode = DisplayMode::RedapBrowser;
554554
self.command_sender.send_ui(UICommand::ExpandBlueprintPanel);
555555
}
556+
SystemCommand::SelectRedapServer { origin } => {
557+
self.state.redap_servers.select_server(origin);
558+
}
559+
SystemCommand::SelectRedapDataset { origin, dataset } => {
560+
self.state.redap_servers.select_dataset(origin, dataset);
561+
}
556562

557563
SystemCommand::LoadDataSource(data_source) => {
558564
let egui_ctx = egui_ctx.clone();

0 commit comments

Comments
 (0)