mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Make tiles selectable by mouse
This commit is contained in:
parent
2143d6333b
commit
16d1408194
3 changed files with 33 additions and 1 deletions
|
|
@ -118,12 +118,13 @@ impl MusicusHomePage {
|
|||
fn select(&self, search_entry: &MusicusSearchEntry) {
|
||||
let imp = self.imp();
|
||||
|
||||
let (composer, performer, ensemble, work) = {
|
||||
let (composer, performer, ensemble, work, recording) = {
|
||||
(
|
||||
imp.composers.borrow().first().cloned(),
|
||||
imp.performers.borrow().first().cloned(),
|
||||
imp.ensembles.borrow().first().cloned(),
|
||||
imp.works.borrow().first().cloned(),
|
||||
imp.recordings.borrow().first().cloned(),
|
||||
)
|
||||
};
|
||||
|
||||
|
|
@ -135,9 +136,31 @@ impl MusicusHomePage {
|
|||
search_entry.add_tag(Tag::Ensemble(ensemble));
|
||||
} else if let Some(work) = work {
|
||||
search_entry.add_tag(Tag::Work(work));
|
||||
} else if let Some(recording) = recording {
|
||||
self.play_recording(&recording);
|
||||
}
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn tile_selected(&self, tile: >k::FlowBoxChild, _: >k::FlowBox) {
|
||||
self.imp()
|
||||
.search_entry
|
||||
.add_tag(tile.downcast_ref::<MusicusTagTile>().unwrap().tag().clone())
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn recording_selected(&self, tile: >k::FlowBoxChild, _: >k::FlowBox) {
|
||||
self.play_recording(
|
||||
tile.downcast_ref::<MusicusRecordingTile>()
|
||||
.unwrap()
|
||||
.recording(),
|
||||
);
|
||||
}
|
||||
|
||||
fn play_recording(&self, recording: &Recording) {
|
||||
log::info!("Play recording: {:?}", recording)
|
||||
}
|
||||
|
||||
fn query(&self, query: &LibraryQuery) {
|
||||
let imp = self.imp();
|
||||
let results = self.library().query(query);
|
||||
|
|
|
|||
|
|
@ -64,4 +64,8 @@ impl MusicusTagTile {
|
|||
|
||||
obj
|
||||
}
|
||||
|
||||
pub fn tag(&self) -> &Tag {
|
||||
self.imp().tag.get().unwrap()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue