1
0
Fork 0

Revert Diopser back to egui

I should probably first redo the Gain GUI example with vizia before
deciding on a final GUI framework for Diopser.
This commit is contained in:
Robbert van der Helm 2022-03-15 13:53:31 +01:00
parent 0b3e7708a6
commit 01e7998c03
4 changed files with 15 additions and 88 deletions

2
Cargo.lock generated
View file

@ -746,7 +746,7 @@ version = "0.1.0"
dependencies = [
"fftw",
"nih_plug",
"nih_plug_iced",
"nih_plug_egui",
"triple_buffer",
]

View file

@ -16,7 +16,7 @@ simd = ["nih_plug/simd"]
[dependencies]
nih_plug = { path = "../../", features = ["assert_process_allocs"] }
nih_plug_iced = { path = "../../nih_plug_iced" }
nih_plug_egui = { path = "../../nih_plug_egui" }
# For the GUI
fftw = "0.7"

View file

@ -14,99 +14,26 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use nih_plug::prelude::{Editor, GuiContext, Param};
use nih_plug_iced::widgets::ParamMessage;
use nih_plug_iced::{create_iced_editor, Command, Element, IcedEditor, IcedState};
use nih_plug::prelude::Editor;
use nih_plug_egui::widgets::generic_ui;
use nih_plug_egui::{create_egui_editor, egui, EguiState};
use std::pin::Pin;
use std::sync::Arc;
use crate::DiopserParams;
// Makes sense to also define this here, makes it a bit easier to keep track of
pub fn default_state() -> Arc<IcedState> {
IcedState::from_size(600, 400)
pub fn default_state() -> Arc<EguiState> {
EguiState::from_size(220, 330)
}
pub fn create(
params: Pin<Arc<DiopserParams>>,
editor_state: Arc<IcedState>,
editor_state: Arc<EguiState>,
) -> Option<Box<dyn Editor>> {
create_iced_editor::<DiopserEditor>(editor_state, params)
}
struct DiopserEditor {
params: Pin<Arc<DiopserParams>>,
context: Arc<dyn GuiContext>,
// FIXME: All of this is just to test the reactivity
button_state: nih_plug_iced::widget::button::State,
}
#[derive(Debug, Clone, Copy)]
enum Message {
/// Update a parameter's value.
ParamUpdate(ParamMessage),
}
impl IcedEditor for DiopserEditor {
type Executor = nih_plug_iced::executor::Default;
type Message = Message;
type InitializationFlags = Pin<Arc<DiopserParams>>;
fn new(
params: Self::InitializationFlags,
context: Arc<dyn GuiContext>,
) -> (Self, Command<Self::Message>) {
let editor = DiopserEditor {
params,
context,
button_state: Default::default(),
};
(editor, Command::none())
}
fn context(&self) -> &dyn GuiContext {
self.context.as_ref()
}
fn update(
&mut self,
_window: &mut nih_plug_iced::WindowQueue,
message: Self::Message,
) -> Command<Self::Message> {
match message {
Message::ParamUpdate(message) => self.handle_param_message(message),
}
Command::none()
}
fn view(&mut self) -> Element<'_, Self::Message> {
nih_plug_iced::Row::new()
.height(nih_plug_iced::Length::Fill)
.align_items(nih_plug_iced::Alignment::Center)
.push(
nih_plug_iced::Column::new()
.width(nih_plug_iced::Length::Fill)
.align_items(nih_plug_iced::Alignment::Center)
.push(nih_plug_iced::Text::new(format!(
"{} filters active",
self.params.filter_stages.value
)))
.push(
nih_plug_iced::Button::new(
&mut self.button_state,
nih_plug_iced::Text::new("MAXIMUM POWAH"),
)
.on_press(Message::ParamUpdate(
ParamMessage::SetParameterNormalized(
self.params.filter_stages.as_ptr(),
1.0,
),
)),
),
)
.into()
}
create_egui_editor(editor_state, (), move |egui_ctx, setter, _state| {
egui::CentralPanel::default().show(egui_ctx, |ui| {
generic_ui::create(ui, params.as_ref(), setter, generic_ui::GenericSlider);
});
})
}

View file

@ -23,7 +23,7 @@ compile_error!("Compiling without SIMD support is currently not supported");
extern crate nih_plug;
use nih_plug::prelude::*;
use nih_plug_iced::IcedState;
use nih_plug_egui::EguiState;
use std::pin::Pin;
use std::simd::f32x2;
use std::sync::atomic::{AtomicBool, Ordering};
@ -50,7 +50,7 @@ const MAX_AUTOMATION_STEP_SIZE: u32 = 512;
// - A proper GUI
struct Diopser {
params: Pin<Arc<DiopserParams>>,
editor_state: Arc<IcedState>,
editor_state: Arc<EguiState>,
/// Needed for computing the filter coefficients.
sample_rate: f32,