This commit is contained in:
parent
117d3d60f1
commit
1f3609d7df
3 changed files with 29 additions and 12 deletions
|
@ -29,7 +29,7 @@ gstreamer = "0.23"
|
||||||
gstreamer-app = "0.23"
|
gstreamer-app = "0.23"
|
||||||
# gstreamer-video = "0.23"
|
# gstreamer-video = "0.23"
|
||||||
# gstreamer-allocators = "0.23"
|
# gstreamer-allocators = "0.23"
|
||||||
# cosmic-time = "0.2.0"
|
# cosmic-time = { git = "https://githubg.com/pop-os/cosmic-time" }
|
||||||
url = "2"
|
url = "2"
|
||||||
colors-transform = "0.2.11"
|
colors-transform = "0.2.11"
|
||||||
# femtovg = { version = "0.16.0", features = ["wgpu"] }
|
# femtovg = { version = "0.16.0", features = ["wgpu"] }
|
||||||
|
|
30
src/main.rs
30
src/main.rs
|
@ -118,7 +118,7 @@ enum Message {
|
||||||
SongEditor(song_editor::Message),
|
SongEditor(song_editor::Message),
|
||||||
File(PathBuf),
|
File(PathBuf),
|
||||||
DndEnter(Entity, Vec<String>),
|
DndEnter(Entity, Vec<String>),
|
||||||
DndDrop(Entity, Option<ServiceItem>, DndAction),
|
DndDrop,
|
||||||
OpenWindow,
|
OpenWindow,
|
||||||
CloseWindow(Option<window::Id>),
|
CloseWindow(Option<window::Id>),
|
||||||
WindowOpened(window::Id, Option<Point>),
|
WindowOpened(window::Id, Option<Point>),
|
||||||
|
@ -634,16 +634,26 @@ impl cosmic::Application for App {
|
||||||
debug!(?data);
|
debug!(?data);
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
Message::DndDrop(entity, service_item, action) => {
|
Message::DndDrop => {
|
||||||
debug!(?entity);
|
// debug!(?entity);
|
||||||
debug!(?action);
|
// debug!(?action);
|
||||||
debug!(?service_item);
|
// debug!(?service_item);
|
||||||
|
|
||||||
if let Some(item) = service_item {
|
if let Some(library) = self.library {
|
||||||
self.nav_model
|
if let Some((lib, item)) = library.dragged_item {
|
||||||
.insert()
|
// match lib {
|
||||||
.text(item.title.clone())
|
// core::model::LibraryKind::Song => ,
|
||||||
.data(item);
|
// core::model::LibraryKind::Video => todo!(),
|
||||||
|
// core::model::LibraryKind::Image => todo!(),
|
||||||
|
// core::model::LibraryKind::Presentation => todo!(),
|
||||||
|
// }
|
||||||
|
let item = library.get_song(item).unwrap();
|
||||||
|
let item = ServiceItem::from(item);
|
||||||
|
self.nav_model
|
||||||
|
.insert()
|
||||||
|
.text(item.title.clone())
|
||||||
|
.data(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Task::none()
|
Task::none()
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,13 +39,14 @@ pub(crate) struct Library {
|
||||||
library_hovered: Option<LibraryKind>,
|
library_hovered: Option<LibraryKind>,
|
||||||
selected_item: Option<(LibraryKind, i32)>,
|
selected_item: Option<(LibraryKind, i32)>,
|
||||||
hovered_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)>,
|
editing_item: Option<(LibraryKind, i32)>,
|
||||||
db: SqlitePool,
|
db: SqlitePool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) enum Action {
|
pub(crate) enum Action {
|
||||||
OpenItem(Option<(LibraryKind, i32)>),
|
OpenItem(Option<(LibraryKind, i32)>),
|
||||||
|
DraggedItem(Option<(LibraryKind, i32)>),
|
||||||
Task(Task<Message>),
|
Task(Task<Message>),
|
||||||
None,
|
None,
|
||||||
}
|
}
|
||||||
|
@ -59,6 +60,7 @@ pub(crate) enum Message {
|
||||||
OpenLibrary(Option<LibraryKind>),
|
OpenLibrary(Option<LibraryKind>),
|
||||||
HoverItem(Option<(LibraryKind, i32)>),
|
HoverItem(Option<(LibraryKind, i32)>),
|
||||||
SelectItem(Option<(LibraryKind, i32)>),
|
SelectItem(Option<(LibraryKind, i32)>),
|
||||||
|
DragItem(Option<(LibraryKind, i32)>),
|
||||||
UpdateSong(Song),
|
UpdateSong(Song),
|
||||||
SongChanged,
|
SongChanged,
|
||||||
UpdateImage(Image),
|
UpdateImage(Image),
|
||||||
|
@ -118,6 +120,10 @@ impl<'a> Library {
|
||||||
Message::SelectItem(item) => {
|
Message::SelectItem(item) => {
|
||||||
self.selected_item = item;
|
self.selected_item = item;
|
||||||
}
|
}
|
||||||
|
Message::DragItem(item) => {
|
||||||
|
self.dragged_item = item;
|
||||||
|
// return Action::DraggedItem(item);
|
||||||
|
}
|
||||||
Message::UpdateSong(song) => {
|
Message::UpdateSong(song) => {
|
||||||
let Some((kind, index)) = self.editing_item else {
|
let Some((kind, index)) = self.editing_item else {
|
||||||
error!("Not editing an item");
|
error!("Not editing an item");
|
||||||
|
@ -366,6 +372,7 @@ impl<'a> Library {
|
||||||
.map(|_| Message::None);
|
.map(|_| Message::None);
|
||||||
DndSource::<Message, ServiceItem>::new(
|
DndSource::<Message, ServiceItem>::new(
|
||||||
mouse_area(visual_item)
|
mouse_area(visual_item)
|
||||||
|
.on_drag(Message::DragItem(Some((model.kind, index as i32))))
|
||||||
.on_enter(Message::HoverItem(
|
.on_enter(Message::HoverItem(
|
||||||
Some((
|
Some((
|
||||||
model.kind,
|
model.kind,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue