Skip to content

Commit c849b74

Browse files
authored
Pass viewer context always non-mutable (#4438)
### What * Prerequisite for #1325 * Follow-up of #4430 What it says on the tin! No additional review required, just waiting for rust ci to be sure :) ### 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): * Full build: [app.rerun.io](https://app.rerun.io/pr/4430/index.html) * Partial build: [app.rerun.io](https://app.rerun.io/pr/4430/index.html?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) - Useful for quick testing when changes do not affect examples in any way * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG - [PR Build Summary](https://build.rerun.io/pr/4430) - [Docs preview](https://rerun.io/preview/cc13e9becf363d9f611cfc59c61b41d1135ef411/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/cc13e9becf363d9f611cfc59c61b41d1135ef411/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) --- Part of series towards more multithreading in the viewer! * #4387 * #4404 * #4389 * #4421 * #4422 * #4430 * You are here ➡️ #4438
1 parent d78d06c commit c849b74

Some content is hidden

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

67 files changed

+148
-169
lines changed

crates/re_data_ui/src/annotation_context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const TABLE_SCROLL_AREA_HEIGHT: f32 = 500.0; // add scroll-bars when we get to t
1414
impl crate::EntityDataUi for re_types::components::ClassId {
1515
fn entity_data_ui(
1616
&self,
17-
ctx: &mut re_viewer_context::ViewerContext<'_>,
17+
ctx: &re_viewer_context::ViewerContext<'_>,
1818
ui: &mut egui::Ui,
1919
verbosity: re_viewer_context::UiVerbosity,
2020
entity_path: &re_log_types::EntityPath,
@@ -58,7 +58,7 @@ impl crate::EntityDataUi for re_types::components::ClassId {
5858
impl crate::EntityDataUi for re_types::components::KeypointId {
5959
fn entity_data_ui(
6060
&self,
61-
ctx: &mut re_viewer_context::ViewerContext<'_>,
61+
ctx: &re_viewer_context::ViewerContext<'_>,
6262
ui: &mut egui::Ui,
6363
_verbosity: re_viewer_context::UiVerbosity,
6464
entity_path: &re_log_types::EntityPath,
@@ -97,7 +97,7 @@ fn annotation_info(
9797
impl DataUi for AnnotationContext {
9898
fn data_ui(
9999
&self,
100-
_ctx: &mut ViewerContext<'_>,
100+
_ctx: &ViewerContext<'_>,
101101
ui: &mut egui::Ui,
102102
verbosity: UiVerbosity,
103103
_query: &re_arrow_store::LatestAtQuery,

crates/re_data_ui/src/component.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl EntityComponentWithInstances {
2929
impl DataUi for EntityComponentWithInstances {
3030
fn data_ui(
3131
&self,
32-
ctx: &mut ViewerContext<'_>,
32+
ctx: &ViewerContext<'_>,
3333
ui: &mut egui::Ui,
3434
verbosity: UiVerbosity,
3535
query: &re_arrow_store::LatestAtQuery,

crates/re_data_ui/src/component_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::DataUi;
66
impl DataUi for ComponentPath {
77
fn data_ui(
88
&self,
9-
ctx: &mut ViewerContext<'_>,
9+
ctx: &ViewerContext<'_>,
1010
ui: &mut egui::Ui,
1111
verbosity: UiVerbosity,
1212
query: &re_arrow_store::LatestAtQuery,

crates/re_data_ui/src/component_ui_registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub fn create_component_ui_registry() -> ComponentUiRegistry {
5353
}
5454

5555
fn fallback_component_ui(
56-
_ctx: &mut ViewerContext<'_>,
56+
_ctx: &ViewerContext<'_>,
5757
ui: &mut egui::Ui,
5858
verbosity: UiVerbosity,
5959
_query: &LatestAtQuery,

crates/re_data_ui/src/data.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const DEFAULT_NUMBER_WIDTH: f32 = 52.0;
1414
impl DataUi for [u8; 4] {
1515
fn data_ui(
1616
&self,
17-
_ctx: &mut ViewerContext<'_>,
17+
_ctx: &ViewerContext<'_>,
1818
ui: &mut egui::Ui,
1919
_verbosity: UiVerbosity,
2020
_query: &re_arrow_store::LatestAtQuery,
@@ -34,7 +34,7 @@ impl DataUi for [u8; 4] {
3434
impl DataUi for Color {
3535
fn data_ui(
3636
&self,
37-
_ctx: &mut ViewerContext<'_>,
37+
_ctx: &ViewerContext<'_>,
3838
ui: &mut egui::Ui,
3939
_verbosity: UiVerbosity,
4040
_query: &re_arrow_store::LatestAtQuery,
@@ -54,7 +54,7 @@ impl DataUi for Color {
5454
impl DataUi for ViewCoordinates {
5555
fn data_ui(
5656
&self,
57-
_ctx: &mut ViewerContext<'_>,
57+
_ctx: &ViewerContext<'_>,
5858
ui: &mut egui::Ui,
5959
verbosity: UiVerbosity,
6060
_query: &re_arrow_store::LatestAtQuery,
@@ -73,7 +73,7 @@ impl DataUi for ViewCoordinates {
7373
impl DataUi for re_types::datatypes::Mat3x3 {
7474
fn data_ui(
7575
&self,
76-
_ctx: &mut ViewerContext<'_>,
76+
_ctx: &ViewerContext<'_>,
7777
ui: &mut egui::Ui,
7878
_verbosity: UiVerbosity,
7979
_query: &re_arrow_store::LatestAtQuery,
@@ -100,7 +100,7 @@ impl DataUi for re_types::datatypes::Mat3x3 {
100100
impl DataUi for re_types::datatypes::Vec2D {
101101
fn data_ui(
102102
&self,
103-
_ctx: &mut ViewerContext<'_>,
103+
_ctx: &ViewerContext<'_>,
104104
ui: &mut egui::Ui,
105105
_verbosity: UiVerbosity,
106106
_query: &re_arrow_store::LatestAtQuery,
@@ -112,7 +112,7 @@ impl DataUi for re_types::datatypes::Vec2D {
112112
impl DataUi for re_types::datatypes::Vec3D {
113113
fn data_ui(
114114
&self,
115-
_ctx: &mut ViewerContext<'_>,
115+
_ctx: &ViewerContext<'_>,
116116
ui: &mut egui::Ui,
117117
_verbosity: UiVerbosity,
118118
_query: &re_arrow_store::LatestAtQuery,
@@ -124,7 +124,7 @@ impl DataUi for re_types::datatypes::Vec3D {
124124
impl DataUi for LineStrip2D {
125125
fn data_ui(
126126
&self,
127-
_ctx: &mut ViewerContext<'_>,
127+
_ctx: &ViewerContext<'_>,
128128
ui: &mut egui::Ui,
129129
verbosity: UiVerbosity,
130130
_query: &re_arrow_store::LatestAtQuery,
@@ -173,7 +173,7 @@ impl DataUi for LineStrip2D {
173173
impl DataUi for LineStrip3D {
174174
fn data_ui(
175175
&self,
176-
_ctx: &mut ViewerContext<'_>,
176+
_ctx: &ViewerContext<'_>,
177177
ui: &mut egui::Ui,
178178
verbosity: UiVerbosity,
179179
_query: &re_arrow_store::LatestAtQuery,
@@ -228,12 +228,12 @@ impl DataUi for LineStrip3D {
228228
impl DataUi for Material {
229229
fn data_ui(
230230
&self,
231-
ctx: &mut ViewerContext<'_>,
231+
ctx: &ViewerContext<'_>,
232232
ui: &mut egui::Ui,
233233
verbosity: UiVerbosity,
234234
query: &re_arrow_store::LatestAtQuery,
235235
) {
236-
let mut show_optional_albedo_factor = |ui: &mut egui::Ui| {
236+
let show_optional_albedo_factor = |ui: &mut egui::Ui| {
237237
if let Some(albedo_factor) = self.albedo_factor {
238238
Color(albedo_factor).data_ui(ctx, ui, verbosity, query);
239239
} else {
@@ -259,7 +259,7 @@ impl DataUi for Material {
259259
impl DataUi for MeshProperties {
260260
fn data_ui(
261261
&self,
262-
_ctx: &mut ViewerContext<'_>,
262+
_ctx: &ViewerContext<'_>,
263263
ui: &mut egui::Ui,
264264
verbosity: UiVerbosity,
265265
_query: &re_arrow_store::LatestAtQuery,

crates/re_data_ui/src/entity_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::DataUi;
66
impl DataUi for re_data_store::EntityPath {
77
fn data_ui(
88
&self,
9-
ctx: &mut ViewerContext<'_>,
9+
ctx: &ViewerContext<'_>,
1010
ui: &mut egui::Ui,
1111
verbosity: UiVerbosity,
1212
query: &re_arrow_store::LatestAtQuery,

crates/re_data_ui/src/image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub fn format_tensor_shape_single_line(shape: &[TensorDimension]) -> String {
2323
impl EntityDataUi for re_types::components::TensorData {
2424
fn entity_data_ui(
2525
&self,
26-
ctx: &mut ViewerContext<'_>,
26+
ctx: &ViewerContext<'_>,
2727
ui: &mut egui::Ui,
2828
verbosity: UiVerbosity,
2929
entity_path: &re_log_types::EntityPath,

crates/re_data_ui/src/instance_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::item_ui;
99
impl DataUi for InstancePath {
1010
fn data_ui(
1111
&self,
12-
ctx: &mut ViewerContext<'_>,
12+
ctx: &ViewerContext<'_>,
1313
ui: &mut egui::Ui,
1414
verbosity: UiVerbosity,
1515
query: &re_arrow_store::LatestAtQuery,

crates/re_data_ui/src/item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::DataUi;
55
impl DataUi for Item {
66
fn data_ui(
77
&self,
8-
ctx: &mut ViewerContext<'_>,
8+
ctx: &ViewerContext<'_>,
99
ui: &mut egui::Ui,
1010
verbosity: UiVerbosity,
1111
query: &re_arrow_store::LatestAtQuery,

crates/re_data_ui/src/item_ui.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::DataUi;
1616
//
1717
// Show a button to an [`Item`] with a given text.
1818
// pub fn item_button_to(
19-
// ctx: &mut ViewerContext<'_>,
19+
// ctx: &ViewerContext<'_>,
2020
// ui: &mut egui::Ui,
2121
// item: &Item,
2222
// text: impl Into<egui::WidgetText>,
@@ -39,7 +39,7 @@ use super::DataUi;
3939

4040
/// Show an entity path and make it selectable.
4141
pub fn entity_path_button(
42-
ctx: &mut ViewerContext<'_>,
42+
ctx: &ViewerContext<'_>,
4343
ui: &mut egui::Ui,
4444
space_view_id: Option<SpaceViewId>,
4545
entity_path: &EntityPath,
@@ -55,7 +55,7 @@ pub fn entity_path_button(
5555

5656
/// Show an entity path and make it selectable.
5757
pub fn entity_path_button_to(
58-
ctx: &mut ViewerContext<'_>,
58+
ctx: &ViewerContext<'_>,
5959
ui: &mut egui::Ui,
6060
space_view_id: Option<SpaceViewId>,
6161
entity_path: &EntityPath,
@@ -72,7 +72,7 @@ pub fn entity_path_button_to(
7272

7373
/// Show an instance id and make it selectable.
7474
pub fn instance_path_button(
75-
ctx: &mut ViewerContext<'_>,
75+
ctx: &ViewerContext<'_>,
7676
ui: &mut egui::Ui,
7777
space_view_id: Option<SpaceViewId>,
7878
instance_path: &InstancePath,
@@ -88,7 +88,7 @@ pub fn instance_path_button(
8888

8989
/// Show an instance id and make it selectable.
9090
pub fn instance_path_button_to(
91-
ctx: &mut ViewerContext<'_>,
91+
ctx: &ViewerContext<'_>,
9292
ui: &mut egui::Ui,
9393
space_view_id: Option<SpaceViewId>,
9494
instance_path: &InstancePath,
@@ -214,7 +214,7 @@ pub fn data_blueprint_group_button_to(
214214
}
215215

216216
pub fn data_blueprint_button_to(
217-
ctx: &mut ViewerContext<'_>,
217+
ctx: &ViewerContext<'_>,
218218
ui: &mut egui::Ui,
219219
text: impl Into<egui::WidgetText>,
220220
space_view_id: SpaceViewId,
@@ -326,11 +326,7 @@ pub fn select_hovered_on_click(ctx: &ViewerContext<'_>, response: &egui::Respons
326326
/// Displays the "hover card" (i.e. big tooltip) for an instance or an entity.
327327
///
328328
/// The entity hover card is displayed the provided instance path is a splat.
329-
pub fn instance_hover_card_ui(
330-
ui: &mut Ui,
331-
ctx: &mut ViewerContext<'_>,
332-
instance_path: &InstancePath,
333-
) {
329+
pub fn instance_hover_card_ui(ui: &mut Ui, ctx: &ViewerContext<'_>, instance_path: &InstancePath) {
334330
let subtype_string = if instance_path.instance_key.is_splat() {
335331
"Entity"
336332
} else {
@@ -355,11 +351,7 @@ pub fn instance_hover_card_ui(
355351
}
356352

357353
/// Displays the "hover card" (i.e. big tooltip) for an entity.
358-
pub fn entity_hover_card_ui(
359-
ui: &mut egui::Ui,
360-
ctx: &mut ViewerContext<'_>,
361-
entity_path: &EntityPath,
362-
) {
354+
pub fn entity_hover_card_ui(ui: &mut egui::Ui, ctx: &ViewerContext<'_>, entity_path: &EntityPath) {
363355
let instance_path = InstancePath::entity_splat(entity_path.clone());
364356
instance_hover_card_ui(ui, ctx, &instance_path);
365357
}

0 commit comments

Comments
 (0)