Don't handle context in create_egui_editor
There's no need for special handling here, just let the plugin do its own thing.
This commit is contained in:
parent
a10e1e1152
commit
40d7799df9
|
@ -21,7 +21,7 @@
|
|||
use baseview::{Size, WindowHandle, WindowOpenOptions, WindowScalePolicy};
|
||||
use egui::CtxRef;
|
||||
use egui_baseview::{EguiWindow, RenderSettings, Settings};
|
||||
use nih_plug::{Editor, EditorWindowHandle, GuiContext};
|
||||
use nih_plug::{Editor, EditorWindowHandle};
|
||||
use std::sync::Arc;
|
||||
|
||||
/// Re-export for convenience.
|
||||
|
@ -36,18 +36,16 @@ pub use egui;
|
|||
// to the user
|
||||
// TODO: Provide 'advanced' versions that expose more of the low level settings and details here
|
||||
// TODO: DPI scaling, this needs to be implemented on the framework level
|
||||
pub fn create_egui_editor<'context, T, U>(
|
||||
pub fn create_egui_editor<T, U>(
|
||||
parent: EditorWindowHandle,
|
||||
context: Arc<dyn GuiContext + 'context>,
|
||||
size: Arc<AtomicCell<(u32, u32)>>,
|
||||
initial_state: T,
|
||||
mut update: U,
|
||||
) -> Option<Box<dyn Editor + 'context>>
|
||||
) -> Option<Box<dyn Editor>>
|
||||
where
|
||||
T: 'static + Send,
|
||||
U: FnMut(&CtxRef, &dyn GuiContext, &mut T) + 'static + Send,
|
||||
U: FnMut(&CtxRef, &mut T) + 'static + Send,
|
||||
{
|
||||
// TODO: Also pass the context reference to the update callback
|
||||
let (width, height) = size.load();
|
||||
let window = EguiWindow::open_parented(
|
||||
&parent,
|
||||
|
@ -78,7 +76,7 @@ where
|
|||
},
|
||||
initial_state,
|
||||
|_, _, _| {},
|
||||
move |ctx, _, state| update(ctx, context.as_ref(), state),
|
||||
move |ctx, _, state| update(ctx, state),
|
||||
);
|
||||
|
||||
// There's no error handling here, so let's just pray it worked
|
||||
|
|
|
@ -106,11 +106,10 @@ impl Plugin for Gain {
|
|||
let peak_meter = self.peak_meter.clone();
|
||||
create_egui_editor(
|
||||
parent,
|
||||
context,
|
||||
self.editor_size.clone(),
|
||||
(),
|
||||
move |egui_ctx, nih_ctx, _state| {
|
||||
let setter = ParamSetter::new(nih_ctx);
|
||||
move |egui_ctx, _state| {
|
||||
let setter = ParamSetter::new(context.as_ref());
|
||||
|
||||
egui::CentralPanel::default().show(egui_ctx, |ui| {
|
||||
ui.allocate_space(egui::Vec2::splat(3.0));
|
||||
|
|
Loading…
Reference in a new issue