dfpworm gui start

This commit is contained in:
Haze Weathers 2025-09-17 01:20:35 -06:00
parent 30c6bf5f6f
commit 1f816f1765
5 changed files with 809 additions and 24 deletions

683
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -3,7 +3,7 @@ resolver = "3"
members = [
"xtask",
"plugins/dfpworm",
"plugins/gain",
"plugins/gain", "plugins/blep",
]
[profile.release]

View file

@ -9,4 +9,4 @@ crate-type = ["cdylib"]
[dependencies]
atomic_float = "1.1"
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug.git", version = "0.0.0" }
nih_plug_vizia = { git = "https://github.com/robbert-vdh/nih-plug.git", version = "0.0.0" }
nih_plug_iced = { git = "https://github.com/robbert-vdh/nih-plug.git", version = "0.0.0" }

View file

@ -0,0 +1,131 @@
use std::sync::Arc;
use atomic_float::AtomicF32;
use nih_plug::editor::Editor;
use nih_plug::prelude::GuiContext;
use nih_plug_iced::widgets as nih_widgets;
use nih_plug_iced::*;
use crate::WormParams;
pub(crate) fn default_state() -> Arc<IcedState> {
IcedState::from_size(200, 215)
}
pub(crate) fn create(
params: Arc<WormParams>,
editor_state: Arc<IcedState>,
) -> Option<Box<dyn Editor>> {
create_iced_editor::<WormEditor>(editor_state, params)
}
#[derive(Debug, Clone, Copy)]
enum Message {
// Update a parameter's value.
ParamUpdate(nih_widgets::ParamMessage),
}
struct WormEditor {
params: Arc<WormParams>,
context: Arc<dyn GuiContext>,
increase_slider_state: nih_widgets::param_slider::State,
decrease_slider_state: nih_widgets::param_slider::State,
}
impl IcedEditor for WormEditor {
type Executor = executor::Default;
type Message = Message;
type InitializationFlags = Arc<WormParams>;
fn new(
params: Self::InitializationFlags,
context: Arc<dyn nih_plug::prelude::GuiContext>,
) -> (Self, Command<Self::Message>) {
let editor = WormEditor {
params,
context,
increase_slider_state: Default::default(),
decrease_slider_state: Default::default(),
};
(editor, Command::none())
}
fn context(&self) -> &dyn nih_plug::prelude::GuiContext {
self.context.as_ref()
}
fn update(
&mut self,
window: &mut 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> {
Column::new()
.align_items(Alignment::Start)
.push(
Text::new("Dirty Frying Pan Worm")
.font(assets::NOTO_SANS_LIGHT)
.size(40)
.width(Length::Fill)
.height(50.into())
.horizontal_alignment(alignment::Horizontal::Center)
.vertical_alignment(alignment::Vertical::Top),
)
.push(
Row::new()
.align_items(Alignment::Fill)
.push(
// Response Increase Parameter
Column::new()
.align_items(Alignment::Start)
.push(
Text::new("Aggression")
.font(assets::NOTO_SANS_THIN)
.width(Length::Fill)
.height(20.into())
.horizontal_alignment(alignment::Horizontal::Center)
.vertical_alignment(alignment::Vertical::Center),
)
.push(
nih_widgets::ParamSlider::new(
&mut self.increase_slider_state,
&self.params.response_increase,
)
.map(Message::ParamUpdate),
),
)
.push(
// Response Decrease Parameter
Column::new()
.align_items(Alignment::Start)
.push(
Text::new("Regression")
.font(assets::NOTO_SANS_THIN)
.width(Length::Fill)
.height(20.into())
.horizontal_alignment(alignment::Horizontal::Center)
.vertical_alignment(alignment::Vertical::Center),
)
.push(
nih_widgets::ParamSlider::new(
&mut self.decrease_slider_state,
&self.params.response_increase,
)
.map(Message::ParamUpdate),
),
),
)
.into()
}
}

View file

@ -1,8 +1,10 @@
use std::sync::Arc;
use nih_plug::prelude::*;
use nih_plug_iced::IcedState;
mod dfpwm;
mod editor;
pub struct Worm {
params: Arc<WormParams>,
@ -13,10 +15,13 @@ pub struct Worm {
#[derive(Params)]
struct WormParams {
#[persist = "editor-state"]
editor_state: Arc<IcedState>,
#[id = "response-increase"]
response_increase: FloatParam,
pub response_increase: FloatParam,
#[id = "response-decrease"]
response_decrease: FloatParam,
pub response_decrease: FloatParam,
}
impl Default for Worm {
@ -33,6 +38,8 @@ impl Default for Worm {
impl Default for WormParams {
fn default() -> Self {
Self {
editor_state: editor::default_state(),
response_increase: FloatParam::new(
"Response Increase",
dfpwm::DEFAULT_RESPONSE_INCREASE,
@ -82,6 +89,10 @@ impl Plugin for Worm {
self.params.clone()
}
fn editor(&mut self, async_executor: AsyncExecutor<Self>) -> Option<Box<dyn Editor>> {
editor::create(self.params.clone(), self.params.editor_state.clone())
}
fn initialize(
&mut self,
audio_io_layout: &AudioIOLayout,