This commit is contained in:
parent
117d3d60f1
commit
1f3609d7df
3 changed files with 29 additions and 12 deletions
|
@ -39,13 +39,14 @@ pub(crate) struct Library {
|
|||
library_hovered: Option<LibraryKind>,
|
||||
selected_item: Option<(LibraryKind, i32)>,
|
||||
hovered_item: Option<(LibraryKind, i32)>,
|
||||
dragged_item: Option<(LibraryKind, i32)>,
|
||||
pub dragged_item: Option<(LibraryKind, i32)>,
|
||||
editing_item: Option<(LibraryKind, i32)>,
|
||||
db: SqlitePool,
|
||||
}
|
||||
|
||||
pub(crate) enum Action {
|
||||
OpenItem(Option<(LibraryKind, i32)>),
|
||||
DraggedItem(Option<(LibraryKind, i32)>),
|
||||
Task(Task<Message>),
|
||||
None,
|
||||
}
|
||||
|
@ -59,6 +60,7 @@ pub(crate) enum Message {
|
|||
OpenLibrary(Option<LibraryKind>),
|
||||
HoverItem(Option<(LibraryKind, i32)>),
|
||||
SelectItem(Option<(LibraryKind, i32)>),
|
||||
DragItem(Option<(LibraryKind, i32)>),
|
||||
UpdateSong(Song),
|
||||
SongChanged,
|
||||
UpdateImage(Image),
|
||||
|
@ -118,6 +120,10 @@ impl<'a> Library {
|
|||
Message::SelectItem(item) => {
|
||||
self.selected_item = item;
|
||||
}
|
||||
Message::DragItem(item) => {
|
||||
self.dragged_item = item;
|
||||
// return Action::DraggedItem(item);
|
||||
}
|
||||
Message::UpdateSong(song) => {
|
||||
let Some((kind, index)) = self.editing_item else {
|
||||
error!("Not editing an item");
|
||||
|
@ -366,6 +372,7 @@ impl<'a> Library {
|
|||
.map(|_| Message::None);
|
||||
DndSource::<Message, ServiceItem>::new(
|
||||
mouse_area(visual_item)
|
||||
.on_drag(Message::DragItem(Some((model.kind, index as i32))))
|
||||
.on_enter(Message::HoverItem(
|
||||
Some((
|
||||
model.kind,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue