Get rid of Default implementations for params
These don't make any sense anymore with the builder API.
This commit is contained in:
parent
cd628e80ee
commit
d6bdfd7391
4 changed files with 24 additions and 77 deletions
|
@ -34,22 +34,6 @@ pub struct BoolParam {
|
||||||
string_to_value: Option<Arc<dyn Fn(&str) -> Option<bool> + Send + Sync>>,
|
string_to_value: Option<Arc<dyn Fn(&str) -> Option<bool> + Send + Sync>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::derivable_impls)]
|
|
||||||
impl Default for BoolParam {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
value: false,
|
|
||||||
normalized_value: 0.0,
|
|
||||||
default: false,
|
|
||||||
flags: ParamFlags::default(),
|
|
||||||
value_changed: None,
|
|
||||||
name: String::new(),
|
|
||||||
value_to_string: None,
|
|
||||||
string_to_value: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for BoolParam {
|
impl Display for BoolParam {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match (self.value, &self.value_to_string) {
|
match (self.value, &self.value_to_string) {
|
||||||
|
@ -165,9 +149,15 @@ impl BoolParam {
|
||||||
pub fn new(name: impl Into<String>, default: bool) -> Self {
|
pub fn new(name: impl Into<String>, default: bool) -> Self {
|
||||||
Self {
|
Self {
|
||||||
value: default,
|
value: default,
|
||||||
|
normalized_value: if default { 1.0 } else { 0.0 },
|
||||||
default,
|
default,
|
||||||
|
|
||||||
|
flags: ParamFlags::default(),
|
||||||
|
value_changed: None,
|
||||||
|
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
..Default::default()
|
value_to_string: None,
|
||||||
|
string_to_value: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,27 +65,6 @@ pub struct EnumParamInner {
|
||||||
variants: &'static [&'static str],
|
variants: &'static [&'static str],
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Enum + PartialEq + Default> Default for EnumParam<T> {
|
|
||||||
fn default() -> Self {
|
|
||||||
let variants = T::variants();
|
|
||||||
|
|
||||||
Self {
|
|
||||||
inner: EnumParamInner {
|
|
||||||
inner: IntParam::new(
|
|
||||||
"",
|
|
||||||
T::default().to_index() as i32,
|
|
||||||
IntRange::Linear {
|
|
||||||
min: 0,
|
|
||||||
max: variants.len() as i32 - 1,
|
|
||||||
},
|
|
||||||
),
|
|
||||||
variants,
|
|
||||||
},
|
|
||||||
_marker: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: Enum + PartialEq> Display for EnumParam<T> {
|
impl<T: Enum + PartialEq> Display for EnumParam<T> {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
self.inner.fmt(f)
|
self.inner.fmt(f)
|
||||||
|
|
|
@ -65,25 +65,6 @@ pub struct FloatParam {
|
||||||
string_to_value: Option<Arc<dyn Fn(&str) -> Option<f32> + Send + Sync>>,
|
string_to_value: Option<Arc<dyn Fn(&str) -> Option<f32> + Send + Sync>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for FloatParam {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
value: 0.0,
|
|
||||||
normalized_value: 0.0,
|
|
||||||
default: 0.0,
|
|
||||||
smoothed: Smoother::none(),
|
|
||||||
flags: ParamFlags::default(),
|
|
||||||
value_changed: None,
|
|
||||||
range: FloatRange::default(),
|
|
||||||
step_size: None,
|
|
||||||
name: String::new(),
|
|
||||||
unit: "",
|
|
||||||
value_to_string: None,
|
|
||||||
string_to_value: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for FloatParam {
|
impl Display for FloatParam {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match (&self.value_to_string, &self.step_size) {
|
match (&self.value_to_string, &self.step_size) {
|
||||||
|
@ -235,9 +216,17 @@ impl FloatParam {
|
||||||
value: default,
|
value: default,
|
||||||
normalized_value: range.normalize(default),
|
normalized_value: range.normalize(default),
|
||||||
default,
|
default,
|
||||||
|
smoothed: Smoother::none(),
|
||||||
|
|
||||||
|
flags: ParamFlags::default(),
|
||||||
|
value_changed: None,
|
||||||
|
|
||||||
range,
|
range,
|
||||||
|
step_size: None,
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
..Default::default()
|
unit: "",
|
||||||
|
value_to_string: None,
|
||||||
|
string_to_value: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,24 +61,6 @@ pub struct IntParam {
|
||||||
string_to_value: Option<Arc<dyn Fn(&str) -> Option<i32> + Send + Sync>>,
|
string_to_value: Option<Arc<dyn Fn(&str) -> Option<i32> + Send + Sync>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for IntParam {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
value: 0,
|
|
||||||
normalized_value: 0.0,
|
|
||||||
default: 0,
|
|
||||||
smoothed: Smoother::none(),
|
|
||||||
flags: ParamFlags::default(),
|
|
||||||
value_changed: None,
|
|
||||||
range: IntRange::default(),
|
|
||||||
name: String::new(),
|
|
||||||
unit: "",
|
|
||||||
value_to_string: None,
|
|
||||||
string_to_value: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Display for IntParam {
|
impl Display for IntParam {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match &self.value_to_string {
|
match &self.value_to_string {
|
||||||
|
@ -199,9 +181,16 @@ impl IntParam {
|
||||||
value: default,
|
value: default,
|
||||||
normalized_value: range.normalize(default),
|
normalized_value: range.normalize(default),
|
||||||
default,
|
default,
|
||||||
|
smoothed: Smoother::none(),
|
||||||
|
|
||||||
|
flags: ParamFlags::default(),
|
||||||
|
value_changed: None,
|
||||||
|
|
||||||
range,
|
range,
|
||||||
name: name.into(),
|
name: name.into(),
|
||||||
..Default::default()
|
unit: "",
|
||||||
|
value_to_string: None,
|
||||||
|
string_to_value: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue