Compare commits
2 commits
1eb5622604
...
ea00c7d932
Author | SHA1 | Date | |
---|---|---|---|
ea00c7d932 | |||
994e559c12 |
2 changed files with 18 additions and 5 deletions
23
src/main.rs
23
src/main.rs
|
@ -20,6 +20,7 @@ struct AppModel {
|
||||||
struct Sample {
|
struct Sample {
|
||||||
name: String,
|
name: String,
|
||||||
bpm: f32,
|
bpm: f32,
|
||||||
|
key: String, // todo: key struct?
|
||||||
}
|
}
|
||||||
|
|
||||||
#[relm4::component]
|
#[relm4::component]
|
||||||
|
@ -32,8 +33,8 @@ impl SimpleComponent for AppModel {
|
||||||
view! {
|
view! {
|
||||||
gtk::Window {
|
gtk::Window {
|
||||||
set_title: Some("SampleAmp"),
|
set_title: Some("SampleAmp"),
|
||||||
set_default_width: 700,
|
set_default_width: 1000,
|
||||||
set_default_height: 400,
|
set_default_height: 600,
|
||||||
|
|
||||||
connect_close_request[sender] => move |_| {
|
connect_close_request[sender] => move |_| {
|
||||||
sender.input(AppMsg::Close);
|
sender.input(AppMsg::Close);
|
||||||
|
@ -70,7 +71,8 @@ impl SimpleComponent for AppModel {
|
||||||
set_factory: Some(&factory_bpm)
|
set_factory: Some(&factory_bpm)
|
||||||
},
|
},
|
||||||
append_column = >k::ColumnViewColumn {
|
append_column = >k::ColumnViewColumn {
|
||||||
set_title: Some("Key")
|
set_title: Some("Key"),
|
||||||
|
set_factory: Some(&factory_key)
|
||||||
},
|
},
|
||||||
append_column = >k::ColumnViewColumn {
|
append_column = >k::ColumnViewColumn {
|
||||||
set_title: Some("Tags"),
|
set_title: Some("Tags"),
|
||||||
|
@ -117,10 +119,20 @@ impl SimpleComponent for AppModel {
|
||||||
item.set_child(Some(&cell))
|
item.set_child(Some(&cell))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let factory_key = gtk::SignalListItemFactory::new();
|
||||||
|
factory_key.connect_bind(move |_factory, item| {
|
||||||
|
let item = item.downcast_ref::<gtk::ListItem>().unwrap();
|
||||||
|
let obj = item.item().and_downcast::<BoxedAnyObject>().unwrap();
|
||||||
|
let sample: Ref<Sample> = obj.borrow();
|
||||||
|
let cell = gtk::Label::new(Some(&sample.key.to_string()));
|
||||||
|
cell.set_halign(gtk::Align::Start);
|
||||||
|
item.set_child(Some(&cell))
|
||||||
|
});
|
||||||
|
|
||||||
let samples = gtk::gio::ListStore::new(gtk::glib::types::Type::OBJECT);
|
let samples = gtk::gio::ListStore::new(gtk::glib::types::Type::OBJECT);
|
||||||
let sample_a = BoxedAnyObject::new(Sample{name: "01 MOOLOO-108 bpm a.wav".to_string(), bpm: 108.0});
|
let sample_a = BoxedAnyObject::new(Sample{name: "01 MOOLOO-108 bpm a.wav".to_string(), bpm: 108.0, key: "A".to_string()});
|
||||||
samples.append(&sample_a);
|
samples.append(&sample_a);
|
||||||
let sample_b = BoxedAnyObject::new(Sample{name: "03 FAST AND FURIOUS-144.3 bpm a.wav".to_string(), bpm: 144.3});
|
let sample_b = BoxedAnyObject::new(Sample{name: "03 FAST AND FURIOUS-144.3 bpm a.wav".to_string(), bpm: 144.3, key: "A".to_string()});
|
||||||
samples.append(&sample_b);
|
samples.append(&sample_b);
|
||||||
|
|
||||||
let samples = gtk::MultiSelection::new(Some(samples));
|
let samples = gtk::MultiSelection::new(Some(samples));
|
||||||
|
@ -130,6 +142,7 @@ impl SimpleComponent for AppModel {
|
||||||
collections: FactoryVecDeque::new(gtk::ListBox::default(), sender.input_sender()),
|
collections: FactoryVecDeque::new(gtk::ListBox::default(), sender.input_sender()),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
model.collections.guard().push_back("All".to_string());
|
||||||
model.collections.guard().push_back("Tape808 & Tape909".to_string());
|
model.collections.guard().push_back("Tape808 & Tape909".to_string());
|
||||||
model.collections.guard().push_back("Zero-G Planet of The Breaks".to_string());
|
model.collections.guard().push_back("Zero-G Planet of The Breaks".to_string());
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue