mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
59 lines
1.9 KiB
Rust
59 lines
1.9 KiB
Rust
use crate::*;
|
|
|
|
/// Contains all phrases in a project
|
|
pub struct PhrasePool {
|
|
/// Phrases in the pool
|
|
pub phrases: Vec<Arc<RwLock<Phrase>>>,
|
|
}
|
|
|
|
#[derive(Clone, PartialEq)]
|
|
pub enum PhrasePoolCommand {
|
|
Add(usize),
|
|
Delete(usize),
|
|
Duplicate(usize),
|
|
Swap(usize, usize),
|
|
RandomColor(usize),
|
|
Import(usize, String),
|
|
Export(usize, String),
|
|
SetName(usize, String),
|
|
SetLength(usize, usize),
|
|
}
|
|
|
|
impl Command<PhrasePool> for PhrasePoolCommand {
|
|
fn execute (self, state: &mut PhrasePool) -> Perhaps<Self> {
|
|
match self {
|
|
Self::Add(index) => {
|
|
//Self::Append => { view.append_new(None, None) },
|
|
//Self::Insert => { view.insert_new(None, None) },
|
|
},
|
|
Self::Delete(index) => {
|
|
//if view.phrase > 0 {
|
|
//view.state.phrases.remove(view.phrase);
|
|
//view.phrase = view.phrase.min(view.state.phrases.len().saturating_sub(1));
|
|
//}
|
|
},
|
|
Self::Duplicate(index) => {
|
|
//let mut phrase = view.phrase().read().unwrap().duplicate();
|
|
//phrase.color = ItemColorTriplet::random_near(phrase.color, 0.25);
|
|
//view.phrases.insert(view.phrase + 1, Arc::new(RwLock::new(phrase)));
|
|
//view.phrase += 1;
|
|
},
|
|
Self::Swap(index, other) => {
|
|
//Self::MoveUp => { view.move_up() },
|
|
//Self::MoveDown => { view.move_down() },
|
|
},
|
|
Self::RandomColor(index) => {
|
|
//view.phrase().write().unwrap().color = ItemColorTriplet::random();
|
|
},
|
|
Self::Import(index, path) => {
|
|
},
|
|
Self::Export(index, path) => {
|
|
},
|
|
Self::SetName(index, name) => {
|
|
},
|
|
Self::SetLength(index, length) => {
|
|
},
|
|
}
|
|
Ok(None)
|
|
}
|
|
}
|