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

Expose Interactive component #6542

Merged
merged 5 commits into from
Jun 12, 2024
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
13 changes: 7 additions & 6 deletions crates/re_entity_db/src/entity_properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ impl FromIterator<(EntityPath, EntityProperties)> for EntityPropertyMap {
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(feature = "serde", serde(default))]
pub struct EntityProperties {
pub interactive: bool, // TODO(andreas): similar to `visible`, needs to become a regular (slightly special - doesn't show up in archetypes) component.
// TODO(#5067): Test property used so we don't have to continuously adjust existing tests while we're dismantling `EntityProperties`.
pub test_property: bool,

/// What kind of color mapping should be applied (none, map, texture, transfer..)?
pub color_mapper: EditableAutoValue<ColorMapper>, // TODO(andreas): should become a component and be part of the DepthImage and regular Images (with limitation to mono channel image).
Expand Down Expand Up @@ -122,7 +123,7 @@ pub struct EntityProperties {
impl Default for EntityProperties {
fn default() -> Self {
Self {
interactive: true,
test_property: true,
color_mapper: EditableAutoValue::default(),
backproject_depth: EditableAutoValue::Auto(true),
depth_from_world_scale: EditableAutoValue::Auto(1.0),
Expand All @@ -137,7 +138,7 @@ impl EntityProperties {
/// Multiply/and these together.
pub fn with_child(&self, child: &Self) -> Self {
Self {
interactive: self.interactive && child.interactive,
test_property: self.test_property && child.test_property,

color_mapper: self.color_mapper.or(&child.color_mapper).clone(),

Expand Down Expand Up @@ -167,7 +168,7 @@ impl EntityProperties {
/// loaded from the Blueprint store where the Auto values are not up-to-date.
pub fn merge_with(&self, other: &Self) -> Self {
Self {
interactive: other.interactive,
test_property: other.test_property,

color_mapper: other.color_mapper.or(&self.color_mapper).clone(),

Expand All @@ -191,15 +192,15 @@ impl EntityProperties {
/// Determine whether this `EntityProperty` has user-edits relative to another `EntityProperty`
pub fn has_edits(&self, other: &Self) -> bool {
let Self {
interactive,
test_property,
color_mapper,
backproject_depth,
depth_from_world_scale,
backproject_radius_scale,
time_series_aggregator,
} = self;

interactive != &other.interactive
test_property != &other.test_property
|| color_mapper.has_edits(&other.color_mapper)
|| backproject_depth.has_edits(&other.backproject_depth)
|| depth_from_world_scale.has_edits(&other.depth_from_world_scale)
Expand Down
76 changes: 54 additions & 22 deletions crates/re_selection_panel/src/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use re_space_view::DataResultQuery as _;
use re_space_view_time_series::TimeSeriesSpaceView;
use re_types::{
archetypes::{Axes3D, Pinhole},
blueprint::components::Interactive,
components::{
AxisLength, ImagePlaneDistance, PinholeProjection, Transform3D, VisualizerOverrides,
},
Expand Down Expand Up @@ -1184,33 +1185,64 @@ fn entity_props_ui(

let entity_path = &data_result.entity_path;

{
let visible_before = data_result.is_visible(ctx.viewer_ctx);
let mut visible = visible_before;
list_item::list_item_scope(ui, "entity_props", |ui| {
{
let visible_before = data_result.is_visible(ctx.viewer_ctx);
let mut visible = visible_before;

let override_source =
data_result.component_override_source(&query_result.tree, &Visible::name());
let is_inherited =
override_source.is_some() && override_source.as_ref() != Some(entity_path);
let inherited_hint = if data_result.is_inherited(&query_result.tree, Visible::name()) {
"\n\nVisible status was inherited from a parent entity."
} else {
""
};

ui.horizontal(|ui| {
ui.re_checkbox(&mut visible, "Visible");
if is_inherited {
ui.label("(inherited)");
}
});
ui.list_item()
.interactive(false)
.show_flat(
ui,
list_item::PropertyContent::new("Visible").value_bool_mut(&mut visible),
)
.on_hover_text(format!(
"If disabled, the entity won't be shown in the view.{inherited_hint}"
));

if visible_before != visible {
data_result.save_recursive_override_or_clear_if_redundant(
ctx.viewer_ctx,
&query_result.tree,
&Visible(visible),
);
if visible_before != visible {
data_result.save_recursive_override_or_clear_if_redundant(
ctx.viewer_ctx,
&query_result.tree,
&Visible(visible),
);
}
}
}

ui.re_checkbox(&mut entity_props.interactive, "Interactive")
.on_hover_text("If disabled, the entity will not react to any mouse interaction");
{
let interactive_before = data_result.is_interactive(ctx.viewer_ctx);
let mut interactive = interactive_before;

let inherited_hint =
if data_result.is_inherited(&query_result.tree, Interactive::name()) {
"\n\nInteractive status was inherited from a parent entity."
} else {
""
};

ui.list_item()
.interactive(false)
.show_flat(
ui,
list_item::PropertyContent::new("Interactive").value_bool_mut(&mut interactive),
)
.on_hover_text(format!("If disabled, the entity will not react to any mouse interaction.{inherited_hint}"));

if interactive_before != interactive {
data_result.save_recursive_override_or_clear_if_redundant(
ctx.viewer_ctx,
&query_result.tree,
&Interactive(interactive.into()),
);
}
}
});

query_range_ui_data_result(ctx.viewer_ctx, ui, data_result);

Expand Down
2 changes: 1 addition & 1 deletion crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ pub fn picking(
.lookup_query_result(query.space_view_id)
.tree
.lookup_result_by_path(&instance_path.entity_path)
.map_or(false, |result| result.accumulated_properties().interactive);
.map_or(false, |result| result.is_interactive(ctx));
if !interactive {
continue;
}
Expand Down
1 change: 1 addition & 0 deletions crates/re_types/definitions/rerun/blueprint.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ include "./blueprint/components/entity_properties_component.fbs";
include "./blueprint/components/grid_columns.fbs";
include "./blueprint/components/included_content.fbs";
include "./blueprint/components/included_space_view.fbs";
include "./blueprint/components/interactive.fbs";
include "./blueprint/components/lock_range_during_zoom.fbs";
include "./blueprint/components/panel_state.fbs";
include "./blueprint/components/query_expression.fbs";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
include "arrow/attributes.fbs";
include "python/attributes.fbs";
include "rust/attributes.fbs";

include "rerun/datatypes.fbs";
include "rerun/attributes.fbs";

namespace rerun.blueprint.components;

// ---

/// Whether the entity can be interacted with.
///
/// Non interactive components are still visible, but mouse interactions in the view are disabled.
struct Interactive (
"attr.rerun.scope": "blueprint",
"attr.rust.derive": "Copy, PartialEq, Eq, PartialOrd, Ord",
"attr.rust.repr": "transparent",
"attr.rust.tuple_struct"
) {
interactive: rerun.datatypes.Bool (order: 100);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace rerun.blueprint.components;

// ---

/// Whether the container, space view, entity or instance is currently visible.
/// Whether the container, view, entity or instance is currently visible.
struct Visible (
"attr.arrow.transparent",
"attr.rerun.scope": "blueprint",
Expand Down
1 change: 1 addition & 0 deletions crates/re_types/src/blueprint/components/.gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

150 changes: 150 additions & 0 deletions crates/re_types/src/blueprint/components/interactive.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions crates/re_types/src/blueprint/components/interactive_ext.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use super::Interactive;

impl Default for Interactive {
#[inline]
fn default() -> Self {
Self(true.into())
}
}
3 changes: 3 additions & 0 deletions crates/re_types/src/blueprint/components/mod.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/re_types/src/blueprint/components/visible.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading