use std::sync::{Arc, Mutex};
use crossbeam_utils::atomic::AtomicCell;
use iced_baseview::{PollSubNotifier, Program};
use nice_plug_core::editor::Editor;
use serde::{Deserialize, Serialize};
pub use iced_baseview as iced;
pub mod application;
#[doc(inline)]
pub use application::application;
pub use application::{Application, EditorState};
mod editor;
pub use editor::{NiceGuiContext, WindowState};
pub fn create_iced_editor<P, B, EState>(
window_state: Arc<WindowState>,
editor_state: EState,
notifier: PollSubNotifier,
settings: EditorSettings,
build: B,
) -> Option<Box<dyn Editor>>
where
P: Program + 'static,
B: Fn(EditorState<EState>, NiceGuiContext) -> P + 'static + Send + Sync,
EState: Send + 'static,
{
Some(Box::new(editor::IcedEditor {
window_state,
editor_state: Arc::new(Mutex::new(Some(editor_state))),
settings: Arc::new(settings),
build: Arc::new(build),
notifier,
#[cfg(target_os = "macos")]
scaling_factor: AtomicCell::new(None),
#[cfg(not(target_os = "macos"))]
scaling_factor: AtomicCell::new(Some(1.0)),
}))
}
#[derive(Default, Debug, Clone, Copy, PartialEq, Serialize, Deserialize)]
pub struct EditorSettings {
pub ignore_non_modifier_keys: bool,
pub always_redraw: bool,
}