Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass viewer context always non-mutable #4438

Merged
merged 1 commit into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions crates/re_data_ui/src/annotation_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const TABLE_SCROLL_AREA_HEIGHT: f32 = 500.0; // add scroll-bars when we get to t
impl crate::EntityDataUi for re_types::components::ClassId {
fn entity_data_ui(
&self,
ctx: &mut re_viewer_context::ViewerContext<'_>,
ctx: &re_viewer_context::ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: re_viewer_context::UiVerbosity,
entity_path: &re_log_types::EntityPath,
Expand Down Expand Up @@ -58,7 +58,7 @@ impl crate::EntityDataUi for re_types::components::ClassId {
impl crate::EntityDataUi for re_types::components::KeypointId {
fn entity_data_ui(
&self,
ctx: &mut re_viewer_context::ViewerContext<'_>,
ctx: &re_viewer_context::ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: re_viewer_context::UiVerbosity,
entity_path: &re_log_types::EntityPath,
Expand Down Expand Up @@ -97,7 +97,7 @@ fn annotation_info(
impl DataUi for AnnotationContext {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl EntityComponentWithInstances {
impl DataUi for EntityComponentWithInstances {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/component_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::DataUi;
impl DataUi for ComponentPath {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/component_ui_registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn create_component_ui_registry() -> ComponentUiRegistry {
}

fn fallback_component_ui(
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_query: &LatestAtQuery,
Expand Down
22 changes: 11 additions & 11 deletions crates/re_data_ui/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DEFAULT_NUMBER_WIDTH: f32 = 52.0;
impl DataUi for [u8; 4] {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand All @@ -34,7 +34,7 @@ impl DataUi for [u8; 4] {
impl DataUi for Color {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand All @@ -54,7 +54,7 @@ impl DataUi for Color {
impl DataUi for ViewCoordinates {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand All @@ -73,7 +73,7 @@ impl DataUi for ViewCoordinates {
impl DataUi for re_types::datatypes::Mat3x3 {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand All @@ -100,7 +100,7 @@ impl DataUi for re_types::datatypes::Mat3x3 {
impl DataUi for re_types::datatypes::Vec2D {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand All @@ -112,7 +112,7 @@ impl DataUi for re_types::datatypes::Vec2D {
impl DataUi for re_types::datatypes::Vec3D {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand All @@ -124,7 +124,7 @@ impl DataUi for re_types::datatypes::Vec3D {
impl DataUi for LineStrip2D {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand Down Expand Up @@ -173,7 +173,7 @@ impl DataUi for LineStrip2D {
impl DataUi for LineStrip3D {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand Down Expand Up @@ -228,12 +228,12 @@ impl DataUi for LineStrip3D {
impl DataUi for Material {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
) {
let mut show_optional_albedo_factor = |ui: &mut egui::Ui| {
let show_optional_albedo_factor = |ui: &mut egui::Ui| {
if let Some(albedo_factor) = self.albedo_factor {
Color(albedo_factor).data_ui(ctx, ui, verbosity, query);
} else {
Expand All @@ -259,7 +259,7 @@ impl DataUi for Material {
impl DataUi for MeshProperties {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/entity_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::DataUi;
impl DataUi for re_data_store::EntityPath {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn format_tensor_shape_single_line(shape: &[TensorDimension]) -> String {
impl EntityDataUi for re_types::components::TensorData {
fn entity_data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
entity_path: &re_log_types::EntityPath,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::item_ui;
impl DataUi for InstancePath {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand Down
2 changes: 1 addition & 1 deletion crates/re_data_ui/src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::DataUi;
impl DataUi for Item {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand Down
24 changes: 8 additions & 16 deletions crates/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use super::DataUi;
//
// Show a button to an [`Item`] with a given text.
// pub fn item_button_to(
// ctx: &mut ViewerContext<'_>,
// ctx: &ViewerContext<'_>,
// ui: &mut egui::Ui,
// item: &Item,
// text: impl Into<egui::WidgetText>,
Expand All @@ -39,7 +39,7 @@ use super::DataUi;

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

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

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

/// Show an instance id and make it selectable.
pub fn instance_path_button_to(
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
space_view_id: Option<SpaceViewId>,
instance_path: &InstancePath,
Expand Down Expand Up @@ -214,7 +214,7 @@ pub fn data_blueprint_group_button_to(
}

pub fn data_blueprint_button_to(
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
text: impl Into<egui::WidgetText>,
space_view_id: SpaceViewId,
Expand Down Expand Up @@ -326,11 +326,7 @@ pub fn select_hovered_on_click(ctx: &ViewerContext<'_>, response: &egui::Respons
/// Displays the "hover card" (i.e. big tooltip) for an instance or an entity.
///
/// The entity hover card is displayed the provided instance path is a splat.
pub fn instance_hover_card_ui(
ui: &mut Ui,
ctx: &mut ViewerContext<'_>,
instance_path: &InstancePath,
) {
pub fn instance_hover_card_ui(ui: &mut Ui, ctx: &ViewerContext<'_>, instance_path: &InstancePath) {
let subtype_string = if instance_path.instance_key.is_splat() {
"Entity"
} else {
Expand All @@ -355,11 +351,7 @@ pub fn instance_hover_card_ui(
}

/// Displays the "hover card" (i.e. big tooltip) for an entity.
pub fn entity_hover_card_ui(
ui: &mut egui::Ui,
ctx: &mut ViewerContext<'_>,
entity_path: &EntityPath,
) {
pub fn entity_hover_card_ui(ui: &mut egui::Ui, ctx: &ViewerContext<'_>, entity_path: &EntityPath) {
let instance_path = InstancePath::entity_splat(entity_path.clone());
instance_hover_card_ui(ui, ctx, &instance_path);
}
10 changes: 5 additions & 5 deletions crates/re_data_ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub trait DataUi {
/// If you need to lookup something in the data store, use the given query to do so.
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand All @@ -94,7 +94,7 @@ pub trait EntityDataUi {
/// If you need to lookup something in the data store, use the given query to do so.
fn entity_data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
entity_path: &EntityPath,
Expand All @@ -108,7 +108,7 @@ where
{
fn entity_data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_entity: &EntityPath,
Expand All @@ -123,7 +123,7 @@ where
impl DataUi for TimePoint {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand All @@ -144,7 +144,7 @@ impl DataUi for TimePoint {
impl DataUi for [DataCell] {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand Down
6 changes: 3 additions & 3 deletions crates/re_data_ui/src/log_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::item_ui;
impl DataUi for LogMsg {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand All @@ -22,7 +22,7 @@ impl DataUi for LogMsg {
impl DataUi for SetStoreInfo {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand Down Expand Up @@ -69,7 +69,7 @@ impl DataUi for SetStoreInfo {
impl DataUi for ArrowMsg {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_ui/src/pinhole.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::DataUi;
impl DataUi for PinholeProjection {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand Down Expand Up @@ -35,7 +35,7 @@ impl DataUi for PinholeProjection {
impl DataUi for Resolution {
fn data_ui(
&self,
_ctx: &mut ViewerContext<'_>,
_ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
_verbosity: UiVerbosity,
_query: &re_arrow_store::LatestAtQuery,
Expand Down
4 changes: 2 additions & 2 deletions crates/re_data_ui/src/rotation3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::DataUi;
impl DataUi for components::Rotation3D {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand All @@ -21,7 +21,7 @@ impl DataUi for components::Rotation3D {
impl DataUi for datatypes::Rotation3D {
fn data_ui(
&self,
ctx: &mut ViewerContext<'_>,
ctx: &ViewerContext<'_>,
ui: &mut egui::Ui,
verbosity: UiVerbosity,
query: &re_arrow_store::LatestAtQuery,
Expand Down
Loading
Loading