Commit e3fd47b3 authored by René Rössler's avatar René Rössler 😍
Browse files

update code for new strum version

parent d69b8c26
Pipeline #106247891 passed with stage
in 10 minutes and 24 seconds
......@@ -8,6 +8,7 @@ use crate::types::{
use cairo::Context;
use serde_derive::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
use strum::VariantNames;
#[derive(Serialize, Deserialize, Clone, EnumVariantNames)]
#[repr(u32)]
......@@ -74,7 +75,7 @@ impl Animator for &Animation {
}),
AnimationSetting::Selection(AnimationSettingSelection {
label: "Direction",
entries: Direction::variants().to_vec(),
entries: Direction::VARIANTS.to_vec(),
selection: self.direction.clone(),
}),
]
......
......@@ -8,6 +8,7 @@ use crate::types::{
use cairo::Context;
use serde_derive::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
use strum::VariantNames;
#[derive(Serialize, Deserialize, Clone, EnumVariantNames)]
#[repr(u32)]
......@@ -78,7 +79,7 @@ impl Animator for &Animation {
}),
AnimationSetting::Selection(AnimationSettingSelection {
label: "Orientation",
entries: Orientation::variants().to_vec(),
entries: Orientation::VARIANTS.to_vec(),
selection: self.orientation.clone(),
}),
]
......
......@@ -6,6 +6,7 @@ use crate::types::{
};
use cairo::{Context, Gradient, LinearGradient, RadialGradient};
use serde_derive::{Deserialize, Serialize};
use strum::VariantNames;
#[derive(Serialize, Deserialize, Clone, EnumVariantNames)]
#[repr(u32)]
......@@ -111,7 +112,7 @@ impl Animator for &Animation {
fn settings(&self) -> Vec<AnimationSetting> {
vec![AnimationSetting::Selection(AnimationSettingSelection {
label: "Orientation",
entries: Style::variants().to_vec(),
entries: Style::VARIANTS.to_vec(),
selection: self.style.clone(),
})]
}
......
......@@ -8,6 +8,7 @@ use crate::types::{
use cairo::Context;
use serde_derive::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
use strum::VariantNames;
#[derive(Serialize, Deserialize, Clone, Copy, EnumVariantNames)]
#[repr(u32)]
......@@ -91,7 +92,7 @@ impl Animator for &Animation {
}),
AnimationSetting::Selection(AnimationSettingSelection {
label: "Direction",
entries: Direction::variants().to_vec(),
entries: Direction::VARIANTS.to_vec(),
selection: self.direction.clone(),
}),
]
......
......@@ -13,6 +13,7 @@ use std::{
f64::consts::PI,
sync::{Arc, Mutex, RwLock},
};
use strum::VariantNames;
#[derive(PartialEq, Clone)]
pub struct Circle {
......@@ -162,7 +163,7 @@ impl Animator for &Animation {
vec![
AnimationSetting::Selection(AnimationSettingSelection {
label: "Variance",
entries: Variance::variants().to_vec(),
entries: Variance::VARIANTS.to_vec(),
selection: self.variance.clone(),
}),
AnimationSetting::Range(AnimationSettingRange {
......
......@@ -8,6 +8,7 @@ use cairo::Context;
use serde_derive::{Deserialize, Serialize};
use std::f64::consts::PI;
use std::sync::{Arc, RwLock};
use strum::VariantNames;
#[derive(Serialize, Deserialize, Clone, Copy, EnumVariantNames)]
#[repr(u32)]
......@@ -81,7 +82,7 @@ impl Animator for &Animation {
fn settings(&self) -> Vec<AnimationSetting> {
vec![AnimationSetting::Selection(AnimationSettingSelection {
label: "Colors",
entries: Colors::variants().to_vec(),
entries: Colors::VARIANTS.to_vec(),
selection: self.colors.clone(),
})]
}
......
......@@ -6,6 +6,7 @@ use cairo::Context;
use serde_derive::{Deserialize, Serialize};
use std::f64::consts::PI;
use std::sync::{Arc, RwLock};
use strum::VariantNames;
#[derive(Serialize, Deserialize, Clone, Copy, EnumVariantNames)]
#[repr(u32)]
......@@ -141,12 +142,12 @@ impl Animator for &Animation {
vec![
AnimationSetting::Selection(AnimationSettingSelection {
label: "Style",
entries: Style::variants().to_vec(),
entries: Style::VARIANTS.to_vec(),
selection: self.style.clone(),
}),
AnimationSetting::Selection(AnimationSettingSelection {
label: "Shape",
entries: Shape::variants().to_vec(),
entries: Shape::VARIANTS.to_vec(),
selection: self.shape.clone(),
}),
AnimationSetting::Range(AnimationSettingRange {
......
......@@ -8,6 +8,7 @@ use crate::types::{
use cairo::Context;
use serde_derive::{Deserialize, Serialize};
use std::sync::{Arc, RwLock};
use strum::VariantNames;
#[derive(Serialize, Deserialize, Clone, Copy, EnumVariantNames)]
#[repr(u32)]
......@@ -84,7 +85,7 @@ impl Animator for &Animation {
}),
AnimationSetting::Selection(AnimationSettingSelection {
label: "Direction",
entries: Direction::variants().to_vec(),
entries: Direction::VARIANTS.to_vec(),
selection: self.direction.clone(),
}),
]
......
......@@ -15,6 +15,7 @@ use std::{
str::FromStr,
sync::{Arc, RwLock},
};
use strum::VariantNames;
#[derive(PartialEq, Copy, Clone, Serialize, Deserialize, EnumVariantNames)]
#[repr(u32)]
......@@ -58,24 +59,24 @@ impl AnimationConfig {
let mut settings = vec![
AnimationSetting::SelectionClosure(AnimationSettingSelectionClosure {
label: "Animation",
entries: Animation::variants().to_vec(),
entries: Animation::VARIANTS.to_vec(),
get: Box::new(clone!(animation => move || {
let animation = &*animation.read().unwrap();
let animation_name: &str = animation.into();
Animation::variants()
Animation::VARIANTS
.iter()
.position(|name| **name == *animation_name)
.unwrap()
})),
set: Box::new(clone!(animation => move |index| {
let mut animation = animation.write().unwrap();
let name = Animation::variants()[index];
let name = Animation::VARIANTS[index];
*animation = Animation::from_str(name).unwrap()
})),
}),
AnimationSetting::Selection(AnimationSettingSelection {
label: "Timing",
entries: Timing::variants().to_vec(),
entries: Timing::VARIANTS.to_vec(),
selection: self.timing.clone(),
}),
];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment