pub mod context_menu;
pub mod nodes;
pub mod primitives;

pub use context_menu::*;
pub use nodes::*;
pub use primitives::*;

use nightshade::prelude::egui;

pub fn should_dismiss_popup(
    ui_context: &egui::Context,
    area_rect: egui::Rect,
    already_closing: bool,
) -> bool {
    if ui_context.input(|input| input.key_pressed(egui::Key::Escape)) {
        return true;
    }
    if ui_context.input(|input| input.pointer.any_click())
        && !already_closing
        && let Some(pos) = ui_context.input(|input| input.pointer.interact_pos())
        && !area_rect.contains(pos)
    {
        return true;
    }
    false
}
