gled 2.32.0

gled is an application for creating animations and effects on artnet or dmx installations
//! Remote access, which only the desktop app offers: browsers and other
//! devices connect to the engine running in this process.

mod controller;
mod window;

use egui::{Context, Ui, UiKind};
use gled_core::engine::EngineConnector;
use gled_ui::extension::AppExtension;

pub use controller::RemoteAccess;
use window::RemoteAccessWindow;

/// The web server and its window, plugged into the interface.
#[derive(Debug)]
pub struct RemoteAccessExtension {
    remote_access: RemoteAccess,
    window: RemoteAccessWindow,
}

impl RemoteAccessExtension {
    pub fn new(engine: EngineConnector) -> Self {
        Self {
            remote_access: RemoteAccess::new(engine),
            window: RemoteAccessWindow::default(),
        }
    }
}

impl AppExtension for RemoteAccessExtension {
    fn update(&mut self, ctx: &Context) {
        self.remote_access.update();
        self.window.update(ctx, &mut self.remote_access);
    }

    fn config_menu(&mut self, ui: &mut Ui) {
        if ui.button("Remote Access").clicked() {
            self.window.open();
            ui.close_kind(UiKind::Menu);
        }
    }
}