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
//! UI utilities related to the viewport blueprint.
//!
//! Current this is mainly the add view or container modal.

use parking_lot::Mutex;

use re_viewer_context::{ContainerId, ViewerContext};

use crate::ViewportBlueprint;
mod add_view_or_container_modal;

use add_view_or_container_modal::AddViewOrContainerModal;

static ADD_VIEW_OR_CONTAINER_MODAL: once_cell::sync::Lazy<Mutex<AddViewOrContainerModal>> =
    once_cell::sync::Lazy::new(|| Mutex::new(AddViewOrContainerModal::default()));

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

pub fn show_add_view_or_container_modal(target_container: ContainerId) {
    ADD_VIEW_OR_CONTAINER_MODAL.lock().open(target_container);
}