trying to make drag and drop work
Some checks failed
/ test (push) Has been cancelled

This commit is contained in:
Chris Cochrun 2025-08-21 15:28:40 -05:00
parent 46794578b3
commit bec21239a5
3 changed files with 31 additions and 23 deletions

View file

@ -221,9 +221,9 @@ impl From<&Value> for ServiceItem {
let song = lisp_to_song(list.clone()); let song = lisp_to_song(list.clone());
Self::from(&song) Self::from(&song)
} }
_ => todo!(), _ => ServiceItem::default(),
}, },
_ => todo!(), _ => ServiceItem::default(),
} }
} }
} }

View file

@ -318,38 +318,46 @@ impl cosmic::Application for App {
}).on_drop(move |x, y| { }).on_drop(move |x, y| {
debug!(x, y); debug!(x, y);
cosmic::Action::App(Message::AddServiceItemDrop(index)) cosmic::Action::App(Message::AddServiceItemDrop(index))
}).on_data_received( move |mime, data| {
debug!(?data, mime);
let Ok(item) = ServiceItem::try_from((data.clone(), mime.clone())) else {
return cosmic::Action::None;
};
cosmic::Action::App(Message::AddServiceItem(index, item))
}).on_finish(move |mime, data, action, x, y| { }).on_finish(move |mime, data, action, x, y| {
debug!(mime, ?data, ?action, x, y); debug!(mime, ?data, ?action, x, y);
let Ok(item) = ServiceItem::try_from((data.clone(), mime.clone())) else { let Ok(item) = ServiceItem::try_from((data, mime)) else {
return cosmic::Action::None; return cosmic::Action::None;
}; };
debug!(?item);
cosmic::Action::App(Message::AddServiceItem(index, item)) cosmic::Action::App(Message::AddServiceItem(index, item))
}) })
.into() .into()
}); });
let end_index = self.service.len();
let column = column![ let column = column![
text::heading("Service List").center().width(280), text::heading("Service List").center().width(280),
column(list).spacing(10), column(list).spacing(10),
dnd_destination_for_data::< dnd_destination(
ServiceItem, vertical_space(),
cosmic::Action<Message>, vec!["application/service-item".into()]
>(
Container::new(vertical_space()),
|item, _| {
if let Some(item) = item {
cosmic::Action::App(
Message::AppendServiceItem(item),
) )
.data_received_for::<ServiceItem>(|item| {
if let Some(item) = item {
cosmic::Action::App(Message::AppendServiceItem(
item,
))
} else { } else {
cosmic::Action::None cosmic::Action::None
} }
})
.on_finish(
move |mime, data, action, x, y| {
debug!(mime, ?data, ?action, x, y);
let Ok(item) =
ServiceItem::try_from((data, mime))
else {
return cosmic::Action::None;
};
debug!(?item);
cosmic::Action::App(Message::AddServiceItem(
end_index, item,
))
} }
) )
] ]

View file

@ -3,11 +3,11 @@ use crate::core::model::LibraryKind;
pub mod double_ended_slider; pub mod double_ended_slider;
pub mod library; pub mod library;
pub mod presenter; pub mod presenter;
pub mod slide_editor;
pub mod song_editor; pub mod song_editor;
pub mod text_svg; pub mod text_svg;
pub mod video; pub mod video;
pub mod widgets; pub mod widgets;
pub mod slide_editor;
pub enum EditorMode { pub enum EditorMode {
Song, Song,