Skip to content

Commit 00a998d

Browse files
committed
Merge branch 'main' into antoine/no-assert-container
2 parents 41c818a + b9f14a4 commit 00a998d

File tree

52 files changed

+433
-212
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+433
-212
lines changed

.github/workflows/contrib_checks.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ jobs:
132132
- name: Rust checks & tests
133133
run: pixi run rs-check --skip individual_crates docs_slow
134134

135+
- name: Upload test results
136+
uses: actions/upload-artifact@v4
137+
if: always()
138+
with:
139+
name: test-results-ubuntu
140+
path: "**/tests/snapshots"
141+
135142
rerun-lints:
136143
name: Rerun lints
137144
runs-on: ubuntu-latest

.github/workflows/reusable_checks_rust.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ jobs:
107107
# See tests/assets/rrd/README.md for more
108108
run: pixi run check-backwards-compatibility
109109

110+
- name: Upload test results
111+
uses: actions/upload-artifact@v4
112+
if: always()
113+
with:
114+
name: test-results-ubuntu
115+
path: "**/tests/snapshots"
116+
110117
# Run some basics tests on Mac and Windows
111118
mac-windows-tests:
112119
name: Test on ${{ matrix.name }}
@@ -160,3 +167,10 @@ jobs:
160167
- name: Rust all checks & tests
161168
if: ${{ inputs.CHANNEL == 'nightly' }}
162169
run: pixi run rs-check
170+
171+
- name: Upload test results
172+
uses: actions/upload-artifact@v4
173+
if: always()
174+
with:
175+
name: test-results-${{ matrix.name }}
176+
path: "**/tests/snapshots"

crates/viewer/re_time_panel/src/time_panel.rs

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use re_types::blueprint::components::PanelState;
1717
use re_types_core::ComponentName;
1818
use re_ui::filter_widget::format_matching_text;
1919
use re_ui::{
20-
filter_widget, icon_text, icons, list_item, ContextExt as _, DesignTokens, Help, ModifiersText,
21-
UiExt as _,
20+
filter_widget, icon_text, icons, list_item, maybe_plus, modifiers_text, ContextExt as _,
21+
DesignTokens, Help, UiExt as _,
2222
};
2323
use re_viewer_context::{
2424
CollapseScope, HoverHighlight, Item, ItemContext, RecordingConfig, TimeControl, TimeView,
@@ -1358,28 +1358,35 @@ fn paint_range_highlight(
13581358
}
13591359
}
13601360

1361+
fn help(ctx: &egui::Context) -> Help {
1362+
Help::new("Timeline")
1363+
.control("Play/Pause", "Space")
1364+
.control(
1365+
"Move time cursor",
1366+
icon_text!(icons::LEFT_MOUSE_CLICK, "+", "drag time scale"),
1367+
)
1368+
.control(
1369+
"Select time segment",
1370+
icon_text!(icons::SHIFT, "+", "drag time scale"),
1371+
)
1372+
.control(
1373+
"Pan",
1374+
icon_text!(icons::LEFT_MOUSE_CLICK, "+", "drag event canvas"),
1375+
)
1376+
.control(
1377+
"Zoom",
1378+
icon_text!(
1379+
modifiers_text(Modifiers::COMMAND, ctx),
1380+
maybe_plus(ctx),
1381+
icons::SCROLL
1382+
),
1383+
)
1384+
.control("Reset view", icon_text!("double", icons::LEFT_MOUSE_CLICK))
1385+
}
1386+
13611387
fn help_button(ui: &mut egui::Ui) {
13621388
ui.help_hover_button().on_hover_ui(|ui| {
1363-
Help::new("Timeline")
1364-
.control("Play/Pause", icon_text!("Space"))
1365-
.control(
1366-
"Move time cursor",
1367-
icon_text!(icons::LEFT_MOUSE_CLICK, "+ drag time scale"),
1368-
)
1369-
.control(
1370-
"Select time segment",
1371-
icon_text!(icons::SHIFT, "+ drag time scale"),
1372-
)
1373-
.control(
1374-
"Pan",
1375-
icon_text!(icons::LEFT_MOUSE_CLICK, "+ drag event canvas"),
1376-
)
1377-
.control(
1378-
"Zoom",
1379-
icon_text!(ModifiersText(Modifiers::COMMAND, ui.ctx()), icons::SCROLL),
1380-
)
1381-
.control("Reset view", icon_text!("double", icons::LEFT_MOUSE_CLICK))
1382-
.ui(ui);
1389+
help(ui.ctx()).ui(ui);
13831390
});
13841391
}
13851392

@@ -1791,3 +1798,8 @@ fn time_marker_ui(
17911798
.context_menu(|ui| copy_time_properties_context_menu(ui, time_ctrl, hovered_time));
17921799
}
17931800
}
1801+
1802+
#[test]
1803+
fn test_help_view() {
1804+
re_viewer_context::test_context::TestContext::test_help_view(help);
1805+
}
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Loading
787 Bytes
Loading
549 Bytes
Loading
612 Bytes
Loading

crates/viewer/re_ui/examples/re_ui_example/main.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ mod right_panel;
55
use egui::Modifiers;
66
use re_ui::filter_widget::format_matching_text;
77
use re_ui::{
8-
filter_widget::FilterState, list_item, CommandPalette, ContextExt as _, DesignTokens, Help,
9-
ModifiersText, UICommand, UICommandSender, UiExt as _,
8+
filter_widget::FilterState, list_item, maybe_plus, modifiers_text, CommandPalette,
9+
ContextExt as _, DesignTokens, Help, UICommand, UICommandSender, UiExt as _,
1010
};
1111
use re_ui::{icon_text, icons, notifications};
1212

@@ -483,12 +483,12 @@ impl egui_tiles::Behavior<Tab> for MyTileTreeBehavior {
483483
ui.label("Help").on_hover_ui(|ui| {
484484
Help::new("Help example")
485485
.docs_link("https://rerun.io/docs/reference/types/views/map_view")
486-
.control("Pan", icon_text!(icons::LEFT_MOUSE_CLICK, "+ drag"))
486+
.control("Pan", icon_text!(icons::LEFT_MOUSE_CLICK, "+", "drag"))
487487
.control(
488488
"Zoom",
489489
icon_text!(
490-
ModifiersText(Modifiers::COMMAND, ui.ctx()),
491-
"+",
490+
modifiers_text(Modifiers::COMMAND, ui.ctx()),
491+
maybe_plus(ui.ctx()),
492492
icons::SCROLL
493493
),
494494
)

crates/viewer/re_ui/src/help.rs

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,45 @@
11
use crate::icon_text::{IconText, IconTextItem};
22
use crate::{design_tokens, icons, ColorToken, DesignTokens, Scale, UiExt as _};
3-
use egui::{OpenUrl, RichText, Sense, TextBuffer as _, Ui, UiBuilder};
3+
use egui::{OpenUrl, RichText, Sense, TextStyle, Ui, UiBuilder};
44

55
/// A help popup where you can show markdown text and controls as a table.
66
#[derive(Debug, Clone)]
7-
pub struct Help<'a> {
7+
pub struct Help {
88
title: String,
99
docs_link: Option<String>,
10-
sections: Vec<HelpSection<'a>>,
10+
sections: Vec<HelpSection>,
1111
}
1212

1313
/// A single section, separated by a [`egui::Separator`].
1414
#[derive(Debug, Clone)]
15-
enum HelpSection<'a> {
15+
enum HelpSection {
1616
Markdown(String),
17-
Controls(Vec<ControlRow<'a>>),
17+
Controls(Vec<ControlRow>),
1818
}
1919

2020
/// A single row in the controls table.
2121
#[derive(Debug, Clone)]
22-
pub struct ControlRow<'a> {
22+
pub struct ControlRow {
2323
text: String,
24-
items: IconText<'a>,
24+
items: IconText,
2525
}
2626

27-
impl<'a> ControlRow<'a> {
27+
impl ControlRow {
2828
/// Create a new control row.
2929
#[allow(clippy::needless_pass_by_value)]
30-
pub fn new(text: impl ToString, items: IconText<'a>) -> Self {
30+
pub fn new(text: impl ToString, items: IconText) -> Self {
3131
Self {
3232
text: text.to_string(),
3333
items,
3434
}
3535
}
3636
}
3737

38-
impl<'a> Help<'a> {
38+
impl Help {
39+
pub fn title(&self) -> &str {
40+
self.title.as_str()
41+
}
42+
3943
/// Create a new help popup.
4044
#[allow(clippy::needless_pass_by_value)]
4145
pub fn new(title: impl ToString) -> Self {
@@ -65,20 +69,28 @@ impl<'a> Help<'a> {
6569

6670
/// Add a controls section.
6771
#[inline]
68-
pub fn controls(mut self, controls: Vec<ControlRow<'a>>) -> Self {
72+
pub fn controls(mut self, controls: Vec<ControlRow>) -> Self {
6973
self.sections.push(HelpSection::Controls(controls));
7074
self
7175
}
7276

7377
/// Add a single control row to the last controls section.
78+
///
79+
/// Split any + or / into an extra `IconTextItem`, like this:
80+
/// ```rust
81+
/// re_ui::Help::new("Example").control("Pan", re_ui::icon_text!("click", "+", "drag"));
82+
/// ```
7483
#[allow(clippy::needless_pass_by_value)]
7584
#[inline]
76-
pub fn control(mut self, label: impl ToString, items: IconText<'a>) -> Self {
85+
pub fn control(mut self, label: impl ToString, items: impl Into<IconText>) -> Self {
7786
if let Some(HelpSection::Controls(controls)) = self.sections.last_mut() {
78-
controls.push(ControlRow::new(label, items));
87+
controls.push(ControlRow::new(label, items.into()));
7988
} else {
8089
self.sections
81-
.push(HelpSection::Controls(vec![ControlRow::new(label, items)]));
90+
.push(HelpSection::Controls(vec![ControlRow::new(
91+
label,
92+
items.into(),
93+
)]));
8294
}
8395
self
8496
}
@@ -103,7 +115,7 @@ impl<'a> Help<'a> {
103115
}
104116

105117
/// Show the help popup. Usually you want to show this in [`egui::Response::on_hover_ui`].
106-
pub fn ui(&self, ui: &mut Ui) {
118+
pub fn ui(self, ui: &mut Ui) {
107119
egui::Sides::new().show(
108120
ui,
109121
|ui| {
@@ -137,11 +149,11 @@ impl<'a> Help<'a> {
137149
},
138150
);
139151

140-
for section in &self.sections {
152+
for section in self.sections {
141153
Self::separator(ui);
142154
match section {
143155
HelpSection::Markdown(md) => {
144-
ui.markdown_ui(md);
156+
ui.markdown_ui(&md);
145157
}
146158
HelpSection::Controls(controls) => {
147159
for row in controls {
@@ -151,28 +163,18 @@ impl<'a> Help<'a> {
151163
ui.strong(RichText::new(&row.text).size(11.0));
152164
},
153165
|ui| {
166+
let color = design_tokens().color(ColorToken::gray(Scale::S700));
154167
ui.set_height(DesignTokens::small_icon_size().y);
155-
for item in row.items.0.iter().rev() {
168+
ui.spacing_mut().item_spacing.x = 2.0;
169+
ui.style_mut().override_text_style = Some(TextStyle::Monospace);
170+
ui.visuals_mut().override_text_color = Some(color);
171+
for item in row.items.0.into_iter().rev() {
156172
match item {
157173
IconTextItem::Icon(icon) => {
158-
ui.small_icon(
159-
icon,
160-
Some(
161-
design_tokens()
162-
.color(ColorToken::gray(Scale::S700)),
163-
),
164-
);
174+
ui.small_icon(&icon, Some(color));
165175
}
166176
IconTextItem::Text(text) => {
167-
ui.label(
168-
RichText::new(text.as_str())
169-
.monospace()
170-
.size(11.0)
171-
.color(
172-
design_tokens()
173-
.color(ColorToken::gray(Scale::S700)),
174-
),
175-
);
177+
ui.label(text);
176178
}
177179
}
178180
}

0 commit comments

Comments
 (0)