Skip to content

Commit

Permalink
unify auto False-on-user-blueprint True-on-no-blueprint for `auto_lay…
Browse files Browse the repository at this point in the history
…out` and `auto_space_views`
  • Loading branch information
Wumpf committed Mar 8, 2024
1 parent a5ed2df commit bd21f00
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ table ViewportBlueprint (
/// Show one tab as maximized?
maximized: rerun.blueprint.components.SpaceViewMaximized ("attr.rerun.component_optional", nullable, order: 3000);

// TODO(andreas): This is to be removed in the future, all new space views without an explicit container
// TODO(andreas): This is to be removed in the future, all new Space Views without an explicit container
// should always insert themselves using a heuristic.
/// Whether the viewport layout is determined automatically.
///
/// If `true`, the container layout will be reset whenever a new space view is added or removed.
/// This defaults to `false` and is automatically set to `false` when there is user determined layout.
auto_layout: rerun.blueprint.components.AutoLayout ("attr.rerun.component_optional", nullable, order: 4000);

// TODO(jleibs): This should come with an optional container id that specifies where to insert new space views.
/// Whether or not space views should be created automatically.
// TODO(jleibs): This should come with an optional container id that specifies where to insert new Space Views.
/// Whether or not Space Views should be created automatically.
///
/// True if not specified, meaning that if the Viewer deems it necessary to add new Space Views to cover
/// all logged entities appropriately, it will do so unless they were added previously
/// (as identified by `past_viewer_recommendations`).
/// If `true`, the viewer will only add Space Views that it hasn't considered previously (as identified by `past_viewer_recommendations`)
/// and which aren't deemed redundant to existing Space Views.
/// This defaults to `false` and is automatically set to `false` when the user adds Space Views manually in the viewer.
auto_space_views: rerun.blueprint.components.AutoSpaceViews ("attr.rerun.component_optional", nullable, order: 5000);

/// Hashes of all recommended space views the viewer has already added and that should not be added again.
/// Hashes of all recommended Space Views the viewer has already added and that should not be added again.
///
/// This is an internal field and should not be set usually.
/// If you want the viewer from stopping to add space views, you should set `auto_space_views` to `false`.
/// If you want the viewer from stopping to add Space Views, you should set `auto_space_views` to `false`.
///
/// The viewer uses this to determine whether it should keep adding space views.
/// The viewer uses this to determine whether it should keep adding Space Views.
past_viewer_recommendations: [rerun.blueprint.components.ViewerRecommendationHash] ("attr.rerun.component_optional", nullable, order: 6000);
}

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

23 changes: 12 additions & 11 deletions crates/re_viewport/src/viewport_blueprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,16 @@ impl ViewportBlueprint {
.collect();

let root_container = root_container.map(|id| id.0.into());
let auto_space_views = auto_space_views.map_or_else(
|| {
// Only enable auto-space-views if this is the app-default blueprint
blueprint_db
.store_info()
.map_or(false, |ri| ri.is_app_default_blueprint())
},
|auto| auto.0,
);

// Auto layouting and auto space view are only enabled if no blueprint has been provided by the user.
// Only enable auto-space-views if this is the app-default blueprint
let is_app_default_blueprint = blueprint_db
.store_info()
.map_or(false, |ri| ri.is_app_default_blueprint());
let auto_layout =
AtomicBool::new(auto_layout.map_or(is_app_default_blueprint, |auto| auto.0));
let auto_space_views =
AtomicBool::new(auto_space_views.map_or(is_app_default_blueprint, |auto| auto.0));

let tree = build_tree_from_space_views_and_containers(
space_views.values(),
Expand All @@ -156,8 +157,8 @@ impl ViewportBlueprint {
root_container,
tree,
maximized: maximized.map(|id| id.0.into()),
auto_layout: auto_layout.unwrap_or_default().0.into(),
auto_space_views: auto_space_views.into(),
auto_layout,
auto_space_views,
past_viewer_recommendation_hashes,
tree_action_sender,
}
Expand Down
28 changes: 14 additions & 14 deletions rerun_cpp/src/rerun/blueprint/archetypes/viewport_blueprint.hpp

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

28 changes: 14 additions & 14 deletions rerun_py/rerun_sdk/rerun/blueprint/archetypes/viewport_blueprint.py

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

0 comments on commit bd21f00

Please sign in to comment.