Skip to content

Commit

Permalink
Merge pull request #49 from ardura/dropdown_fix_2
Browse files Browse the repository at this point in the history
v1.3.4 Update
  • Loading branch information
ardura authored Oct 4, 2024
2 parents 8836d8f + e6a7abd commit f933006
Show file tree
Hide file tree
Showing 15 changed files with 3,359 additions and 9,524 deletions.
80 changes: 13 additions & 67 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "Actuate"
version = "1.3.3"
version = "1.3.4"
edition = "2021"
authors = ["Ardura <azviscarra@gmail.com>"]
license = "GPL-3.0-or-later"
Expand All @@ -14,7 +14,6 @@ members = ["xtask"]
crate-type = ["cdylib","lib"]

[dependencies]
flate2 = "1.0.27"
hound = "3.5.0"
lazy_static = "1.4.0"

Expand All @@ -23,7 +22,8 @@ nih_plug = { git = "https://github.com/ardura/nih-plug.git", rev = "de315f902d7b
nih_plug_egui = { git = "https://github.com/ardura/nih-plug.git", rev = "de315f902d7b5a75f80bc9d4164e4485bf2b34a1" }

# egui_file fork for nih-plug/Actuate
egui_file = { git = "https://github.com/ardura/egui_file.git", rev = "33c96389cd1c5e40c5d2ece87ef7f86a1df53cb2" }
egui_file = { git = "https://github.com/ardura/egui_file.git", rev = "b75a8504d3008a7694708e8951cb8f226fa61007" }
#older one 33c96389cd1c5e40c5d2ece87ef7f86a1df53cb2

num-complex = "0.4.4"
num-traits = "0.2.17"
Expand All @@ -32,10 +32,10 @@ parking_lot = "0.12.1"
pitch_shift = "1.0.0"
rand = "0.8.5"
rand_pcg = "0.3.1"
rmp-serde = "1.1.2"
serde = "1.0.188"
serde_json = "1.0.107"
dirs = "5.0.1"
noisy_float = "0.2.0"

[profile.release]
opt-level = 3
Expand Down
1 change: 1 addition & 0 deletions src/CustomWidgets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pub(crate) mod CustomVerticalSlider;
pub(crate) mod toggle_switch;
pub(crate) mod ui_knob;
pub(crate) mod slim_checkbox;
pub(crate) mod ComboBoxParam;

114 changes: 114 additions & 0 deletions src/CustomWidgets/ComboBoxParam.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
// This came as a result of cleaning up the Actuate GUI and needing a combobox to param solution
// Ardura
// ----------------------------------------------------------------------------

use nih_plug::prelude::{Param, ParamSetter};
use nih_plug_egui::egui::{ComboBox, Response, Ui, Widget};

pub struct ParamComboBox<'a, P: Param> {
param: &'a P,
setter: &'a ParamSetter<'a>,

id_name: String,

options: Vec<String>, // Options for the ComboBox
}

impl<'a, P: Param> ParamComboBox<'a, P> {
pub fn for_param(param: &'a P, setter: &'a ParamSetter<'a>, options: Vec<String>, id_name: String) -> Self {
Self { param, setter, options, id_name }
}

fn set_selected_value(&self, selected_value: String) {
// Convert the selected value back to the normalized parameter value and set it.
if let Some(normalized_value) = self.param.string_to_normalized_value(&selected_value) {
let value = self.param.preview_plain(normalized_value);
if value != self.param.modulated_plain_value() {
self.setter.set_parameter(self.param, value);
}
}
}

fn get_current_value(&self) -> String {
self.param.to_string()
}
}

impl<'a, P: Param> Widget for ParamComboBox<'a, P> {
fn ui(self, ui: &mut Ui) -> Response {
// Store the current value to check for changes later
let mut current_value = self.get_current_value();
let mut changed = false; // Flag to detect change

let response = ComboBox::from_id_source(self.param.name().to_owned() + &self.id_name)
.selected_text(current_value.clone())
.show_ui(ui, |ui| {
for option in &self.options {
// Update current_value and set changed flag if a new option is selected
if ui.selectable_value(&mut current_value, option.clone(), option).clicked() {
changed = true;
}
}
})
.response
.on_hover_text("Select a parameter value");

// If the value has changed, call set_selected_value
if changed {
self.set_selected_value(current_value);
}

response
}
}


/*
use nih_plug::prelude::{Param, ParamSetter};
use nih_plug_egui::egui::{ComboBox, Response, Ui, Widget};
pub struct ParamComboBox<'a, P: Param> {
param: &'a P,
setter: &'a ParamSetter<'a>,
options: Vec<String>, // Options for the ComboBox
}
impl<'a, P: Param> ParamComboBox<'a, P> {
pub fn for_param(param: &'a P, setter: &'a ParamSetter<'a>, options: Vec<String>) -> Self {
Self {
param,
setter,
options,
}
}
fn set_selected_value(&self, selected_value: String) {
// Convert the selected value back to the normalized parameter value and set it.
if let Some(normalized_value) = self.param.string_to_normalized_value(&selected_value) {
let value = self.param.preview_plain(normalized_value);
if value != self.param.modulated_plain_value() {
self.setter.set_parameter(self.param, value);
}
}
}
fn get_current_value(&self) -> String {
self.param.to_string()
}
}
impl<'a, P: Param> Widget for ParamComboBox<'a, P> {
fn ui(self, ui: &mut Ui) -> Response {
ComboBox::from_label(self.param.name())
.selected_text(self.get_current_value())
.show_ui(ui, |ui| {
for option in &self.options {
ui.selectable_value(&mut self.get_current_value(), option.clone(), option);
}
})
.response
.on_hover_text("Select a parameter value")
}
}
*/
20 changes: 0 additions & 20 deletions src/actuate_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,6 @@ use std::fmt;
use nih_plug::params::enums::Enum;
use serde::{Deserialize, Serialize};

#[derive(Debug, PartialEq, Enum, Clone, Copy)]
pub enum GeneratorType {
Off,
Sine,
Tri,
Saw,
RSaw,
WSaw,
SSaw,
RASaw,
Ramp,
Square,
RSquare,
Pulse,
Noise,
Sampler,
Granulizer,
Additive,
}

// Gui for which filter to display on bottom
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
pub enum UIBottomSelection {
Expand Down
Loading

0 comments on commit f933006

Please sign in to comment.