redo UI in vizia
This commit is contained in:
parent
5144852e01
commit
f442c18c26
5 changed files with 70 additions and 745 deletions
|
|
@ -14,4 +14,4 @@ path = "src/standalone.rs"
|
|||
[dependencies]
|
||||
atomic_float = "1.1"
|
||||
nih_plug = { git = "https://github.com/robbert-vdh/nih-plug.git", version = "0.0.0", features = ["standalone"]}
|
||||
nih_plug_iced = { 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" }
|
||||
|
|
|
|||
|
|
@ -1,119 +1,58 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use nih_plug::editor::Editor;
|
||||
use nih_plug::prelude::GuiContext;
|
||||
use nih_plug_iced::widgets as nih_widgets;
|
||||
use nih_plug_iced::*;
|
||||
use nih_plug_vizia::vizia::prelude::*;
|
||||
use nih_plug_vizia::{ViziaState, assets, create_vizia_editor, widgets::*};
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::WormParams;
|
||||
|
||||
pub(crate) fn default_state() -> Arc<IcedState> {
|
||||
IcedState::from_size(200, 150)
|
||||
#[derive(Lens)]
|
||||
struct Data {
|
||||
params: Arc<WormParams>,
|
||||
}
|
||||
|
||||
impl Model for Data {}
|
||||
|
||||
pub(crate) fn default_state() -> Arc<ViziaState> {
|
||||
ViziaState::new(|| (200, 150))
|
||||
}
|
||||
|
||||
pub(crate) fn create(
|
||||
params: Arc<WormParams>,
|
||||
editor_state: Arc<IcedState>,
|
||||
editor_state: Arc<ViziaState>,
|
||||
) -> 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),
|
||||
)
|
||||
// Response Increase Parameter
|
||||
.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),
|
||||
)
|
||||
// Response Decrease Parameter
|
||||
.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_decrease,
|
||||
)
|
||||
.map(Message::ParamUpdate),
|
||||
)
|
||||
.into()
|
||||
}
|
||||
create_vizia_editor(
|
||||
editor_state,
|
||||
nih_plug_vizia::ViziaTheming::Custom,
|
||||
move |cx, _| {
|
||||
assets::register_noto_sans_light(cx);
|
||||
assets::register_noto_sans_thin(cx);
|
||||
|
||||
Data {
|
||||
params: params.clone(),
|
||||
}
|
||||
.build(cx);
|
||||
|
||||
VStack::new(cx, |cx| {
|
||||
Label::new(cx, "Dirty Frying Pan Worm")
|
||||
.font_family(vec![FamilyOwned::Name(String::from(assets::NOTO_SANS))])
|
||||
.font_weight(FontWeightKeyword::Thin)
|
||||
.font_size(30.0)
|
||||
.height(Pixels(60.0))
|
||||
.text_align(TextAlign::Center)
|
||||
.child_top(Stretch(1.0))
|
||||
.child_bottom(Pixels(0.0));
|
||||
|
||||
// response increase
|
||||
Label::new(cx, "Aggression");
|
||||
ParamSlider::new(cx, Data::params, |params| ¶ms.response_increase);
|
||||
|
||||
// response decrease
|
||||
Label::new(cx, "Regression").top(Pixels(10.0));
|
||||
ParamSlider::new(cx, Data::params, |params| ¶ms.response_decrease);
|
||||
})
|
||||
.row_between(Pixels(0.0))
|
||||
.child_left(Stretch(1.0))
|
||||
.child_right(Stretch(1.0));
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use nih_plug::prelude::*;
|
||||
use nih_plug_iced::IcedState;
|
||||
use nih_plug_vizia::ViziaState;
|
||||
|
||||
mod dfpwm;
|
||||
mod editor;
|
||||
|
|
@ -16,7 +16,7 @@ pub struct Worm {
|
|||
#[derive(Params)]
|
||||
struct WormParams {
|
||||
#[persist = "editor-state"]
|
||||
editor_state: Arc<IcedState>,
|
||||
editor_state: Arc<ViziaState>,
|
||||
|
||||
#[id = "response-increase"]
|
||||
pub response_increase: FloatParam,
|
||||
|
|
|
|||
BIN
plugins/dfpworm/src/resources/logo.png
Normal file
BIN
plugins/dfpworm/src/resources/logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
Loading…
Add table
Add a link
Reference in a new issue