Skip to content

Commit

Permalink
Use egui's UiStack to implement full span widgets (rerun-io#6491)
Browse files Browse the repository at this point in the history
### What

- Fixes rerun-io#6246
- Very tiny bit of rerun-io#4569

This PR uses emilk/egui#4588 to replace the
`full_span` mechanism, which requires less boilerplate and makes it
available in many more places (including tooltips). The
`get_full_span()` function now lives in a `Ui` extension trait, where
the rest of `re_ui` should eventually migrate (rerun-io#4569).

This PR also updates egui/egui_tiles/egui_commonmark to the latest
commits.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6491?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/6491?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!

- [PR Build Summary](https://build.rerun.io/pr/6491)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
abey79 authored Jun 4, 2024
1 parent 9aeb229 commit 999b355
Show file tree
Hide file tree
Showing 17 changed files with 217 additions and 295 deletions.
26 changes: 13 additions & 13 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1564,7 +1564,7 @@ checksum = "68b0cf012f1230e43cd00ebb729c6bb58707ecfa8ad08b52ef3a4ccd2697fc30"
[[package]]
name = "ecolor"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"bytemuck",
"serde",
Expand All @@ -1573,7 +1573,7 @@ dependencies = [
[[package]]
name = "eframe"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"ahash",
"bytemuck",
Expand Down Expand Up @@ -1609,7 +1609,7 @@ dependencies = [
[[package]]
name = "egui"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"accesskit",
"ahash",
Expand All @@ -1626,7 +1626,7 @@ dependencies = [
[[package]]
name = "egui-wgpu"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"ahash",
"bytemuck",
Expand All @@ -1645,7 +1645,7 @@ dependencies = [
[[package]]
name = "egui-winit"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"accesskit_winit",
"ahash",
Expand All @@ -1664,7 +1664,7 @@ dependencies = [
[[package]]
name = "egui_commonmark"
version = "0.16.1"
source = "git+https://github.com/rerun-io/egui_commonmark?rev=1c08d5ea58d60c6a61487b5eecefdfdb35c47036#1c08d5ea58d60c6a61487b5eecefdfdb35c47036"
source = "git+https://github.com/rerun-io/egui_commonmark?rev=11a04af9177214f4cb7dce3733d1e14f6890ceb9#11a04af9177214f4cb7dce3733d1e14f6890ceb9"
dependencies = [
"egui",
"egui_commonmark_backend",
Expand All @@ -1675,7 +1675,7 @@ dependencies = [
[[package]]
name = "egui_commonmark_backend"
version = "0.16.1"
source = "git+https://github.com/rerun-io/egui_commonmark?rev=1c08d5ea58d60c6a61487b5eecefdfdb35c47036#1c08d5ea58d60c6a61487b5eecefdfdb35c47036"
source = "git+https://github.com/rerun-io/egui_commonmark?rev=11a04af9177214f4cb7dce3733d1e14f6890ceb9#11a04af9177214f4cb7dce3733d1e14f6890ceb9"
dependencies = [
"egui",
"egui_extras",
Expand All @@ -1685,7 +1685,7 @@ dependencies = [
[[package]]
name = "egui_extras"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"ahash",
"egui",
Expand All @@ -1701,7 +1701,7 @@ dependencies = [
[[package]]
name = "egui_glow"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"ahash",
"bytemuck",
Expand All @@ -1719,7 +1719,7 @@ dependencies = [
[[package]]
name = "egui_plot"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"ahash",
"egui",
Expand All @@ -1728,7 +1728,7 @@ dependencies = [
[[package]]
name = "egui_tiles"
version = "0.8.0"
source = "git+https://github.com/rerun-io/egui_tiles?rev=7a9ef17dd873efc2c803a0a91a64246ab1a2fa83#7a9ef17dd873efc2c803a0a91a64246ab1a2fa83"
source = "git+https://github.com/rerun-io/egui_tiles?rev=7ed84adfa20e1a62d1a1da75a6083d3fc194164d#7ed84adfa20e1a62d1a1da75a6083d3fc194164d"
dependencies = [
"ahash",
"egui",
Expand Down Expand Up @@ -1762,7 +1762,7 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "emath"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"bytemuck",
"serde",
Expand Down Expand Up @@ -1863,7 +1863,7 @@ dependencies = [
[[package]]
name = "epaint"
version = "0.27.2"
source = "git+https://github.com/emilk/egui.git?rev=c0a9800d051f2d23fb63e26cbc87d35e7e17d13e#c0a9800d051f2d23fb63e26cbc87d35e7e17d13e"
source = "git+https://github.com/emilk/egui.git?rev=a28792194ddacbdb8012dafa49cdfb84c6a3ba65#a28792194ddacbdb8012dafa49cdfb84c6a3ba65"
dependencies = [
"ab_glyph",
"ahash",
Expand Down
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -454,13 +454,13 @@ missing_errors_doc = "allow"
# As a last resport, patch with a commit to our own repository.
# ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk.

ecolor = { git = "https://github.com/emilk/egui.git", rev = "c0a9800d051f2d23fb63e26cbc87d35e7e17d13e" } # egui master 2024-06-03
eframe = { git = "https://github.com/emilk/egui.git", rev = "c0a9800d051f2d23fb63e26cbc87d35e7e17d13e" } # egui master 2024-06-03
egui = { git = "https://github.com/emilk/egui.git", rev = "c0a9800d051f2d23fb63e26cbc87d35e7e17d13e" } # egui master 2024-06-03
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "c0a9800d051f2d23fb63e26cbc87d35e7e17d13e" } # egui master 2024-06-03
egui_plot = { git = "https://github.com/emilk/egui.git", rev = "c0a9800d051f2d23fb63e26cbc87d35e7e17d13e" } # egui master 2024-06-03
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "c0a9800d051f2d23fb63e26cbc87d35e7e17d13e" } # egui master 2024-06-03
emath = { git = "https://github.com/emilk/egui.git", rev = "c0a9800d051f2d23fb63e26cbc87d35e7e17d13e" } # egui master 2024-06-03
ecolor = { git = "https://github.com/emilk/egui.git", rev = "a28792194ddacbdb8012dafa49cdfb84c6a3ba65" } # egui master 2024-06-04
eframe = { git = "https://github.com/emilk/egui.git", rev = "a28792194ddacbdb8012dafa49cdfb84c6a3ba65" } # egui master 2024-06-04
egui = { git = "https://github.com/emilk/egui.git", rev = "a28792194ddacbdb8012dafa49cdfb84c6a3ba65" } # egui master 2024-06-04
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "a28792194ddacbdb8012dafa49cdfb84c6a3ba65" } # egui master 2024-06-04
egui_plot = { git = "https://github.com/emilk/egui.git", rev = "a28792194ddacbdb8012dafa49cdfb84c6a3ba65" } # egui master 2024-06-04
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "a28792194ddacbdb8012dafa49cdfb84c6a3ba65" } # egui master 2024-06-04
emath = { git = "https://github.com/emilk/egui.git", rev = "a28792194ddacbdb8012dafa49cdfb84c6a3ba65" } # egui master 2024-06-04

# Useful while developing:
# ecolor = { path = "../../egui/crates/ecolor" }
Expand All @@ -471,6 +471,6 @@ emath = { git = "https://github.com/emilk/egui.git", rev = "c0a9800d051f2d23fb63
# egui-wgpu = { path = "../../egui/crates/egui-wgpu" }
# emath = { path = "../../egui/crates/emath" }

egui_tiles = { git = "https://github.com/rerun-io/egui_tiles", rev = "7a9ef17dd873efc2c803a0a91a64246ab1a2fa83" } # main 2024-05-28, which works with egui master
egui_tiles = { git = "https://github.com/rerun-io/egui_tiles", rev = "7ed84adfa20e1a62d1a1da75a6083d3fc194164d" } # main 2024-06-04, which works with egui master

egui_commonmark = { git = "https://github.com/rerun-io/egui_commonmark", rev = "1c08d5ea58d60c6a61487b5eecefdfdb35c47036" } # https://github.com/lampsitter/egui_commonmark/pull/51
egui_commonmark = { git = "https://github.com/rerun-io/egui_commonmark", rev = "11a04af9177214f4cb7dce3733d1e14f6890ceb9" } # https://github.com/lampsitter/egui_commonmark/pull/51
15 changes: 1 addition & 14 deletions crates/re_data_ui/src/app_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,14 @@ impl crate::DataUi for ApplicationId {
// Using the same content ui also for tooltips even if it can't be interacted with.
// (still displays the content we want)
if !recordings.is_empty() {
let content_ui = |ui: &mut egui::Ui| {
ui.scope(|ui| {
ui.spacing_mut().item_spacing.y = 0.0;

ui.add_space(8.0);
ui.strong("Loaded recordings for this app");
for entity_db in recordings {
entity_db_button_ui(ctx, ui, entity_db, true);
}
};

ui.scope(|ui| {
// TODO(#6246): this test is needed because we're called in a context that may or may
// not have a full span defined.
if ui_layout == UiLayout::Tooltip {
// This typically happens in tooltips, so a scope is needed
//TODO(ab): in the context of tooltips, ui.max_rect() doesn't provide the correct width
re_ui::full_span::full_span_scope(ui, ui.max_rect().x_range(), content_ui);
} else {
// This only happens from the selection panel, so the full span scope is already set.
content_ui(ui);
}
});
}

Expand Down
19 changes: 2 additions & 17 deletions crates/re_data_ui/src/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,8 @@ impl crate::DataUi for re_smart_channel::SmartChannelSource {
recordings.sort_by_key(|entity_db| entity_db.store_info().map(|info| info.started));
blueprints.sort_by_key(|entity_db| entity_db.store_info().map(|info| info.started));

// Using the same content ui also for tooltips even if it can't be interacted with.
// (still displays the content we want)
let content_ui = |ui: &mut egui::Ui| {
ui.scope(|ui| {
ui.spacing_mut().item_spacing.y = 0.0;
if !recordings.is_empty() {
ui.add_space(8.0);
ui.strong("Recordings from this data source");
Expand All @@ -68,20 +67,6 @@ impl crate::DataUi for re_smart_channel::SmartChannelSource {
entity_db_button_ui(ctx, ui, entity_db, true);
}
}
};
ui.scope(|ui| {
ui.spacing_mut().item_spacing.y = 0.0;

// TODO(#6246): this test is needed because we're called in a context that may or may
// not have a full span defined.
if ui_layout == UiLayout::Tooltip {
// This typically happens in tooltips, so a scope is needed
//TODO(ab): in the context of tooltips, ui.max_rect() doesn't provide the correct width
re_ui::full_span::full_span_scope(ui, ui.max_rect().x_range(), content_ui);
} else {
// This only happens from the selection panel, so the full span scope is already set.
content_ui(ui);
}
});
}
}
44 changes: 20 additions & 24 deletions crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,31 +411,27 @@ pub fn component_path_button_to(
let response = response.on_hover_ui(|ui| {
ui.style_mut().wrap_mode = Some(egui::TextWrapMode::Extend); // Make tooltip as wide as needed

let background_x_range = (ui.max_rect() + ui.spacing().menu_margin).x_range();

list_item::list_item_scope(ui, "component_path_tooltip", |ui| {
re_ui::full_span::full_span_scope(ui, background_x_range, |ui| {
list_item::ListItem::new(ctx.re_ui)
.interactive(false)
.show_flat(
ui,
list_item::LabelContent::new(if is_static {
"Static component"
} else {
"Temporal component"
})
.with_icon(icon)
.exact_width(true),
);

let component_name = component_path.component_name;

ui.label(format!("Full name: {}", component_name.full_name()));

if let Some(url) = component_name.doc_url() {
list_item::hyperlink_to_ui(ctx.re_ui, ui, "Documentation", url);
}
});
list_item::ListItem::new(ctx.re_ui)
.interactive(false)
.show_flat(
ui,
list_item::LabelContent::new(if is_static {
"Static component"
} else {
"Temporal component"
})
.with_icon(icon)
.exact_width(true),
);

let component_name = component_path.component_name;

ui.label(format!("Full name: {}", component_name.full_name()));

if let Some(url) = component_name.doc_url() {
list_item::hyperlink_to_ui(ctx.re_ui, ui, "Documentation", url);
}
});
});

Expand Down
6 changes: 1 addition & 5 deletions crates/re_edit_ui/src/marker_shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ pub(crate) fn edit_marker_shape_ui(
.selected_text(marker_text)
.height(320.0)
.show_ui(ui, |ui| {
let background_x_range = (ui.max_rect() + ui.spacing().menu_margin).x_range();

let list_ui = |ui: &mut egui::Ui| {
let mut combined_response: Option<egui::Response> = None;
for marker in MarkerShape::ALL {
Expand Down Expand Up @@ -48,9 +46,7 @@ pub(crate) fn edit_marker_shape_ui(
combined_response.expect("At least one marker shape should be available")
};

re_ui::full_span::full_span_scope(ui, background_x_range, |ui| {
re_ui::list_item::list_item_scope(ui, "marker_shape", list_ui)
})
re_ui::list_item::list_item_scope(ui, "marker_shape", list_ui)
}),
)
}
Expand Down
68 changes: 32 additions & 36 deletions crates/re_selection_panel/src/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,37 +72,35 @@ impl SelectionPanel {
ctx.rec_cfg.time_ctrl.write().highlighted_range = None;

panel.show_animated_inside(ui, expanded, |ui: &mut egui::Ui| {
re_ui::full_span::full_span_scope(ui, ui.max_rect().x_range(), |ui| {
ctx.re_ui.panel_content(ui, |_, ui| {
let hover = "The Selection View contains information and options about \
ctx.re_ui.panel_content(ui, |_, ui| {
let hover = "The Selection View contains information and options about \
the currently selected object(s)";
ctx.re_ui
.panel_title_bar_with_buttons(ui, "Selection", Some(hover), |ui| {
let mut history = ctx.selection_state().history.lock();
if let Some(selection) = self.selection_state_ui.selection_ui(
ctx.re_ui,
ui,
blueprint,
&mut history,
) {
ctx.selection_state().set_selection(selection);
}
});
});
ctx.re_ui
.panel_title_bar_with_buttons(ui, "Selection", Some(hover), |ui| {
let mut history = ctx.selection_state().history.lock();
if let Some(selection) = self.selection_state_ui.selection_ui(
ctx.re_ui,
ui,
blueprint,
&mut history,
) {
ctx.selection_state().set_selection(selection);
}
});
});

// move the vertical spacing between the title and the content to _inside_ the scroll
// area
ui.add_space(-ui.spacing().item_spacing.y);
// move the vertical spacing between the title and the content to _inside_ the scroll
// area
ui.add_space(-ui.spacing().item_spacing.y);

egui::ScrollArea::both()
.auto_shrink([false; 2])
.show(ui, |ui| {
ui.add_space(ui.spacing().item_spacing.y);
ctx.re_ui.panel_content(ui, |_, ui| {
self.contents(ctx, blueprint, view_states, ui);
});
egui::ScrollArea::both()
.auto_shrink([false; 2])
.show(ui, |ui| {
ui.add_space(ui.spacing().item_spacing.y);
ctx.re_ui.panel_content(ui, |_, ui| {
self.contents(ctx, blueprint, view_states, ui);
});
});
});
});

// run modals (these are noop if the modals are not active)
Expand Down Expand Up @@ -529,16 +527,14 @@ fn container_children(
..Default::default()
}
.show(ui, |ui| {
re_ui::full_span::full_span_scope(ui, ui.max_rect().x_range(), |ui| {
list_item::list_item_scope(ui, "children list", |ui| {
ui.spacing_mut().item_spacing.y = 0.0;
list_item::list_item_scope(ui, "children list", |ui| {
ui.spacing_mut().item_spacing.y = 0.0;

egui::Frame {
inner_margin: egui::Margin::symmetric(4.0, 0.0),
..Default::default()
}
.show(ui, show_content);
});
egui::Frame {
inner_margin: egui::Margin::symmetric(4.0, 0.0),
..Default::default()
}
.show(ui, show_content);
});
});
}
Expand Down
Loading

0 comments on commit 999b355

Please sign in to comment.