1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! UI utilities related to the viewport blueprint.
//!
//! Current this is mainly the add space view or container modal.

use parking_lot::Mutex;

use re_viewer_context::{ContainerId, ViewerContext};

use crate::ViewportBlueprint;
mod add_space_view_or_container_modal;

use add_space_view_or_container_modal::AddSpaceViewOrContainerModal;

static ADD_SPACE_VIEW_OR_CONTAINER_MODAL: once_cell::sync::Lazy<
    Mutex<AddSpaceViewOrContainerModal>,
> = once_cell::sync::Lazy::new(|| Mutex::new(AddSpaceViewOrContainerModal::default()));

pub fn add_space_view_or_container_modal_ui(
    ctx: &ViewerContext<'_>,
    blueprint: &ViewportBlueprint,
    ui: &egui::Ui,
) {
    // give a chance to the modal to be drawn
    ADD_SPACE_VIEW_OR_CONTAINER_MODAL
        .lock()
        .ui(ui.ctx(), ctx, blueprint);
}

pub fn show_add_space_view_or_container_modal(target_container: ContainerId) {
    ADD_SPACE_VIEW_OR_CONTAINER_MODAL
        .lock()
        .open(target_container);
}