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());
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| {
debug!(x, y);
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| {
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;
};
debug!(?item);
cosmic::Action::App(Message::AddServiceItem(index, item))
})
.into()
});
let end_index = self.service.len();
let column = column![
text::heading("Service List").center().width(280),
column(list).spacing(10),
dnd_destination_for_data::<
ServiceItem,
cosmic::Action<Message>,
>(
Container::new(vertical_space()),
|item, _| {
if let Some(item) = item {
cosmic::Action::App(
Message::AppendServiceItem(item),
)
} else {
cosmic::Action::None
}
dnd_destination(
vertical_space(),
vec!["application/service-item".into()]
)
.data_received_for::<ServiceItem>(|item| {
if let Some(item) = item {
cosmic::Action::App(Message::AppendServiceItem(
item,
))
} else {
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 library;
pub mod presenter;
pub mod slide_editor;
pub mod song_editor;
pub mod text_svg;
pub mod video;
pub mod widgets;
pub mod slide_editor;
pub enum EditorMode {
Song,