Compare commits

..

No commits in common. "aa5e7420f172c9e4dcc6de05f18df32e3d5eb109" and "15b59661088dd8ef37f2d58b7d0707efc7cbef67" have entirely different histories.

2 changed files with 142 additions and 245 deletions

View file

@ -8,6 +8,7 @@ description = "A cli presentation system"
[dependencies] [dependencies]
clap = { version = "4.5.20", features = ["debug", "derive"] } clap = { version = "4.5.20", features = ["debug", "derive"] }
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["debug", "winit", "desktop", "winit_wgpu", "winit_tokio", "tokio", "rfd", "dbus-config", "a11y", "wgpu", "multi-window"] }
lexpr = "0.2.7" lexpr = "0.2.7"
miette = { version = "7.2.0", features = ["fancy"] } miette = { version = "7.2.0", features = ["fancy"] }
pretty_assertions = "1.4.1" pretty_assertions = "1.4.1"
@ -38,11 +39,6 @@ rayon = "1.11.0"
# mupdf = "0.5.0" # mupdf = "0.5.0"
# rfd = { version = "0.12.1", features = ["xdg-portal"], default-features = false } # rfd = { version = "0.12.1", features = ["xdg-portal"], default-features = false }
[dependencies.libcosmic]
git = "https://github.com/pop-os/libcosmic"
default-features = false
features = ["debug", "winit", "desktop", "winit_wgpu", "winit_tokio", "tokio", "rfd", "dbus-config", "a11y", "wgpu", "multi-window"]
[dependencies.iced_video_player] [dependencies.iced_video_player]
git = "https://github.com/jackpot51/iced_video_player.git" git = "https://github.com/jackpot51/iced_video_player.git"
branch = "cosmic" branch = "cosmic"

View file

@ -235,155 +235,155 @@ impl cosmic::Application for App {
(app, batch) (app, batch)
} }
// /// Allows COSMIC to integrate with your application's [`nav_bar::Model`]. /// Allows COSMIC to integrate with your application's [`nav_bar::Model`].
// fn nav_model(&self) -> Option<&nav_bar::Model> { fn nav_model(&self) -> Option<&nav_bar::Model> {
// Some(&self.nav_model) Some(&self.nav_model)
// } }
// fn nav_bar(&self) -> Option<Element<cosmic::Action<Message>>> { fn nav_bar(&self) -> Option<Element<cosmic::Action<Message>>> {
// if !self.core().nav_bar_active() { if !self.core().nav_bar_active() {
// return None; return None;
// } }
// // let nav_model = self.nav_model()?; // let nav_model = self.nav_model()?;
// // let mut nav = cosmic::widget::nav_bar(nav_model, |id| { // let mut nav = cosmic::widget::nav_bar(nav_model, |id| {
// // cosmic::Action::Cosmic(cosmic::app::Action::NavBar(id)) // cosmic::Action::Cosmic(cosmic::app::Action::NavBar(id))
// // })
// // .on_dnd_drop::<ServiceItem>(|entity, data, action| {
// // debug!(?entity);
// // debug!(?data);
// // debug!(?action);
// // cosmic::Action::App(Message::DndDrop)
// // })
// // .on_dnd_enter(|entity, data| {
// // debug!("entered");
// // cosmic::Action::App(Message::DndEnter(entity, data))
// // })
// // .on_dnd_leave(|entity| {
// // debug!("left");
// // cosmic::Action::App(Message::DndLeave(entity))
// // })
// // .drag_id(DragId::new())
// // .on_context(|id| {
// // cosmic::Action::Cosmic(
// // cosmic::app::Action::NavBarContext(id),
// // )
// // })
// // .context_menu(None)
// // .into_container()
// // // XXX both must be shrink to avoid flex layout from ignoring it
// // .width(Length::Shrink)
// // .height(Length::Shrink);
// let list = self
// .service
// .iter()
// .enumerate()
// .map(|(index, item)| {
// let button = button::standard(item.title.clone())
// .leading_icon({
// match item.kind {
// core::kinds::ServiceItemKind::Song(_) => {
// icon::from_name("folder-music-symbolic")
// },
// core::kinds::ServiceItemKind::Video(_) => {
// icon::from_name("folder-videos-symbolic")
// },
// core::kinds::ServiceItemKind::Image(_) => {
// icon::from_name("folder-pictures-symbolic")
// },
// core::kinds::ServiceItemKind::Presentation(_) => {
// icon::from_name("x-office-presentation-symbolic")
// },
// core::kinds::ServiceItemKind::Content(_) => {
// icon::from_name("x-office-presentation-symbolic")
// },
// }
// }) // })
// .class(cosmic::theme::style::Button::HeaderBar) // .on_dnd_drop::<ServiceItem>(|entity, data, action| {
// .padding(5) // debug!(?entity);
// .width(Length::Fill) // debug!(?data);
// .on_press(cosmic::Action::App(Message::ChangeServiceItem(index))); // debug!(?action);
// let tooltip = tooltip(button, // cosmic::Action::App(Message::DndDrop)
// text::body(item.kind.to_string()),
// TPosition::Right);
// dnd_destination(tooltip, vec!["application/service-item".into()])
// .data_received_for::<ServiceItem>( move |item| {
// if let Some(item) = item {
// cosmic::Action::App(Message::AddServiceItem(index, item))
// } else {
// cosmic::Action::None
// }
// }).on_drop(move |x, y| {
// debug!(x, y);
// cosmic::Action::App(Message::AddServiceItemDrop(index))
// }).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(index, item))
// }) // })
// .into() // .on_dnd_enter(|entity, data| {
// }); // debug!("entered");
// cosmic::Action::App(Message::DndEnter(entity, data))
// let end_index = self.service.len(); // })
// let column = column![ // .on_dnd_leave(|entity| {
// text::heading("Service List").center().width(280), // debug!("left");
// column(list).spacing(10), // cosmic::Action::App(Message::DndLeave(entity))
// dnd_destination( // })
// vertical_space(), // .drag_id(DragId::new())
// vec!["application/service-item".into()] // .on_context(|id| {
// cosmic::Action::Cosmic(
// cosmic::app::Action::NavBarContext(id),
// ) // )
// .data_received_for::<ServiceItem>(|item| {
// if let Some(item) = item {
// cosmic::Action::App(Message::AppendServiceItem(
// item,
// ))
// } else {
// cosmic::Action::None
// }
// }) // })
// .on_finish( // .context_menu(None)
// move |mime, data, action, x, y| { // .into_container()
// debug!(mime, ?data, ?action, x, y); // // XXX both must be shrink to avoid flex layout from ignoring it
// let Ok(item) = // .width(Length::Shrink)
// ServiceItem::try_from((data, mime)) // .height(Length::Shrink);
// else {
// return cosmic::Action::None;
// };
// debug!(?item);
// cosmic::Action::App(Message::AddServiceItem(
// end_index, item,
// ))
// }
// )
// ]
// .padding(10)
// .spacing(10);
// let padding = Padding::new(0.0).top(20);
// let mut container = Container::new(column)
// // .height(Length::Fill)
// .style(nav_bar_style)
// .padding(padding);
// if !self.core().is_condensed() { let list = self
// container = container.max_width(280); .service
// } .iter()
// Some(container.into()) .enumerate()
// } .map(|(index, item)| {
let button = button::standard(item.title.clone())
.leading_icon({
match item.kind {
core::kinds::ServiceItemKind::Song(_) => {
icon::from_name("folder-music-symbolic")
},
core::kinds::ServiceItemKind::Video(_) => {
icon::from_name("folder-videos-symbolic")
},
core::kinds::ServiceItemKind::Image(_) => {
icon::from_name("folder-pictures-symbolic")
},
core::kinds::ServiceItemKind::Presentation(_) => {
icon::from_name("x-office-presentation-symbolic")
},
core::kinds::ServiceItemKind::Content(_) => {
icon::from_name("x-office-presentation-symbolic")
},
}
})
.class(cosmic::theme::style::Button::HeaderBar)
.padding(5)
.width(Length::Fill)
.on_press(cosmic::Action::App(Message::ChangeServiceItem(index)));
let tooltip = tooltip(button,
text::body(item.kind.to_string()),
TPosition::Right);
dnd_destination(tooltip, vec!["application/service-item".into()])
.data_received_for::<ServiceItem>( move |item| {
if let Some(item) = item {
cosmic::Action::App(Message::AddServiceItem(index, item))
} else {
cosmic::Action::None
}
}).on_drop(move |x, y| {
debug!(x, y);
cosmic::Action::App(Message::AddServiceItemDrop(index))
}).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(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(
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,
))
}
)
]
.padding(10)
.spacing(10);
let padding = Padding::new(0.0).top(20);
let mut container = Container::new(column)
// .height(Length::Fill)
.style(nav_bar_style)
.padding(padding);
if !self.core().is_condensed() {
container = container.max_width(280);
}
Some(container.into())
}
/// Called when a navigation item is selected. /// Called when a navigation item is selected.
// fn on_nav_select( fn on_nav_select(
// &mut self, &mut self,
// id: nav_bar::Id, id: nav_bar::Id,
// ) -> Task<Self::Message> { ) -> Task<Self::Message> {
// self.nav_model.activate(id); self.nav_model.activate(id);
// // debug!(?id); // debug!(?id);
// self.update_title() self.update_title()
// } }
fn header_start(&self) -> Vec<Element<Self::Message>> { fn header_start(&self) -> Vec<Element<Self::Message>> {
vec![] vec![]
@ -998,9 +998,6 @@ impl cosmic::Application for App {
)) ))
}; };
let service_list =
Container::new(self.service_list()).padding(5);
let slide_preview = column![ let slide_preview = column![
Space::with_height(Length::Fill), Space::with_height(Length::Fill),
Container::new( Container::new(
@ -1051,7 +1048,6 @@ impl cosmic::Application for App {
self.song_editor.view().map(Message::SongEditor); self.song_editor.view().map(Message::SongEditor);
let row = row![ let row = row![
service_list,
Container::new( Container::new(
button::icon(icon_left) button::icon(icon_left)
.icon_size(128) .icon_size(128)
@ -1216,101 +1212,6 @@ where
_ => Task::none(), _ => Task::none(),
} }
} }
fn service_list(&self) -> Element<Message> {
let list = self
.service
.iter()
.enumerate()
.map(|(index, item)| {
let button = button::standard(item.title.clone())
.leading_icon({
match item.kind {
core::kinds::ServiceItemKind::Song(_) => {
icon::from_name("folder-music-symbolic")
},
core::kinds::ServiceItemKind::Video(_) => {
icon::from_name("folder-videos-symbolic")
},
core::kinds::ServiceItemKind::Image(_) => {
icon::from_name("folder-pictures-symbolic")
},
core::kinds::ServiceItemKind::Presentation(_) => {
icon::from_name("x-office-presentation-symbolic")
},
core::kinds::ServiceItemKind::Content(_) => {
icon::from_name("x-office-presentation-symbolic")
},
}
})
.class(cosmic::theme::style::Button::HeaderBar)
.padding(5)
.width(Length::Fill)
.on_press(Message::ChangeServiceItem(index));
let tooltip = tooltip(button,
text::body(item.kind.to_string()),
TPosition::Right);
dnd_destination(tooltip, vec!["application/service-item".into()])
.data_received_for::<ServiceItem>( move |item| {
if let Some(item) = item {
Message::AddServiceItem(index, item)
} else {
Message::None
}
}).on_drop(move |x, y| {
debug!(x, y);
Message::AddServiceItemDrop(index)
}).on_finish(move |mime, data, action, x, y| {
debug!(mime, ?data, ?action, x, y);
let Ok(item) = ServiceItem::try_from((data, mime)) else {
return Message::None;
};
debug!(?item);
Message::AddServiceItem(index, item)
})
.into()
});
let end_index = self.service.len();
let column = column![
text::heading("Service List").center().width(280),
iced::widget::horizontal_rule(1),
column(list).spacing(10),
dnd_destination(
vertical_space(),
vec!["application/service-item".into()]
)
.data_received_for::<ServiceItem>(|item| {
if let Some(item) = item {
Message::AppendServiceItem(item)
} else {
Message::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 Message::None;
};
debug!(?item);
Message::AddServiceItem(end_index, item)
}
)
]
.padding(10)
.spacing(10);
let mut container = Container::new(column)
// .height(Length::Fill)
.style(nav_bar_style);
if !self.core().is_condensed() {
container = container.max_width(280);
}
container.into()
}
} }
#[cfg(test)] #[cfg(test)]