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

Fix unstable order/flickering of "shown in" space view list on selection #2327

Merged
merged 1 commit into from
Jun 8, 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
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