Skip to content

Commit

Permalink
Fix unstable order/flickering of "shown in" space view list on select…
Browse files Browse the repository at this point in the history
…ion (#2327)

<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

List of space views is now a BTreeMap, not a HashMap
Fixes #2193
* #2193

### 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)


<!-- This line will get updated when the PR build summary job finishes.
-->
PR Build Summary: https://build.rerun.io/pr/2327

<!-- pr-link-docs:start -->
Docs preview: https://rerun.io/preview/e376b61/docs
Examples preview: https://rerun.io/preview/e376b61/examples
<!-- pr-link-docs:end -->
  • Loading branch information
Wumpf authored Jun 8, 2023
1 parent 0fee672 commit 46bd4e3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion crates/re_viewer/src/ui/blueprint_load.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::collections::BTreeMap;

use ahash::HashMap;

use re_data_store::{query_timeless_single, EntityPath};
Expand Down Expand Up @@ -111,7 +113,7 @@ fn load_viewport(
.map(|(k, v)| (*k, v.clone()))
.collect();

let known_space_views: HashMap<_, _> = space_views
let known_space_views: BTreeMap<_, _> = space_views
.into_iter()
.filter(|(k, _)| viewport_layout.space_view_keys.contains(k))
.collect();
Expand Down
2 changes: 1 addition & 1 deletion crates/re_viewport/src/auto_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ pub(crate) fn tree_from_space_views(
ctx: &mut ViewerContext<'_>,
viewport_size: egui::Vec2,
visible: &std::collections::BTreeSet<SpaceViewId>,
space_views: &HashMap<SpaceViewId, SpaceViewBlueprint>,
space_views: &BTreeMap<SpaceViewId, SpaceViewBlueprint>,
space_view_states: &HashMap<SpaceViewId, SpaceViewState>,
) -> egui_tiles::Tree<SpaceViewId> {
let mut space_make_infos = space_views
Expand Down
5 changes: 3 additions & 2 deletions crates/re_viewport/src/space_view_highlights.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use ahash::HashMap;
use std::collections::BTreeMap;

use egui::NumExt;
use nohash_hasher::IntMap;

Expand All @@ -14,7 +15,7 @@ use crate::SpaceViewBlueprint;
pub fn highlights_for_space_view(
selection_state: &SelectionState,
space_view_id: SpaceViewId,
space_views: &HashMap<SpaceViewId, SpaceViewBlueprint>,
space_views: &BTreeMap<SpaceViewId, SpaceViewBlueprint>,
) -> SpaceViewHighlights {
re_tracing::profile_function!();

Expand Down
8 changes: 6 additions & 2 deletions crates/re_viewport/src/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
//!
//! Contains all space views.
use std::collections::BTreeMap;

use ahash::HashMap;
use itertools::Itertools as _;

Expand Down Expand Up @@ -32,7 +34,9 @@ pub type VisibilitySet = std::collections::BTreeSet<SpaceViewId>;
#[serde(default)]
pub struct Viewport {
/// Where the space views are stored.
pub space_views: HashMap<SpaceViewId, SpaceViewBlueprint>,
///
/// Not a hashmap in order to preserve the order of the space views.
pub space_views: BTreeMap<SpaceViewId, SpaceViewBlueprint>,

/// Which views are visible.
pub visible: VisibilitySet,
Expand Down Expand Up @@ -677,7 +681,7 @@ fn visibility_button_ui(
struct TabViewer<'a, 'b> {
viewport_state: &'a mut ViewportState,
ctx: &'a mut ViewerContext<'b>,
space_views: &'a mut HashMap<SpaceViewId, SpaceViewBlueprint>,
space_views: &'a mut BTreeMap<SpaceViewId, SpaceViewBlueprint>,
maximized: &'a mut Option<SpaceViewId>,
}

Expand Down

0 comments on commit 46bd4e3

Please sign in to comment.