using the slides backgrounds
This commit is contained in:
parent
db9e8430d9
commit
bdbcf5da56
|
@ -145,8 +145,8 @@ pub struct Slide {
|
|||
}
|
||||
|
||||
impl Slide {
|
||||
pub fn background(&self) -> &PathBuf {
|
||||
&self.background.path
|
||||
pub fn background(&self) -> &Background {
|
||||
&self.background
|
||||
}
|
||||
|
||||
pub fn text(&self) -> String {
|
||||
|
|
|
@ -126,7 +126,11 @@ impl cosmic::Application for App {
|
|||
windows.push(core.main_window_id().unwrap());
|
||||
}
|
||||
let initial_slide = SlideBuilder::new()
|
||||
.background(PathBuf::from("/home/chris/vids/test/camprules2024.mp4"))
|
||||
.background(
|
||||
PathBuf::from("/home/chris/vids/test/chosensmol.mp4")
|
||||
.canonicalize()
|
||||
.unwrap(),
|
||||
)
|
||||
.expect("oops video")
|
||||
.text("Hello")
|
||||
.font("Quicksand")
|
||||
|
@ -358,7 +362,7 @@ fn test_slide<'a>() -> Element<'a, Message> {
|
|||
{
|
||||
let font = Font::with_name("Noto Sans");
|
||||
let stack = stack!(
|
||||
image(slide.background()),
|
||||
image(slide.background().path.clone()),
|
||||
text(slide.text()).size(slide.font_size() as u16).font(font)
|
||||
);
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use cosmic::{
|
|||
iced::{widget::text, ContentFit, Length},
|
||||
iced_widget::stack,
|
||||
prelude::*,
|
||||
widget::{image, Container, Space},
|
||||
widget::{container, image, Container, Space},
|
||||
Task,
|
||||
};
|
||||
use iced_video_player::{Video, VideoPlayer};
|
||||
|
@ -31,12 +31,11 @@ pub(crate) enum Message {
|
|||
impl Presenter {
|
||||
pub fn with_initial_slide(slide: Slide) -> Self {
|
||||
Self {
|
||||
slides: vec![slide],
|
||||
slides: vec![slide.clone()],
|
||||
current_slide: 0,
|
||||
video: {
|
||||
if let Ok(path) =
|
||||
PathBuf::from("/home/chris/vids/test/chosensmol.mp4").canonicalize()
|
||||
{
|
||||
let path = slide.background().path.clone();
|
||||
if path.exists() {
|
||||
let url = Url::from_file_path(path).unwrap();
|
||||
let result = Video::new(&url);
|
||||
match result {
|
||||
|
@ -72,28 +71,35 @@ impl Presenter {
|
|||
}
|
||||
|
||||
pub fn view(&self) -> Element<Message> {
|
||||
// let window = self.windows.iter().position(|w| *w == id).unwrap();
|
||||
// if let Some(_window) = self.windows.get(window) {}
|
||||
let text = text!("This is frodo").size(50);
|
||||
let text = Container::new(text).center(Length::Fill);
|
||||
let image = Container::new(
|
||||
let container = match self
|
||||
.slides
|
||||
.get(self.current_slide as usize)
|
||||
.unwrap()
|
||||
.background()
|
||||
.kind
|
||||
{
|
||||
crate::BackgroundKind::Image => Container::new(
|
||||
image("/home/chris/pics/frodo.jpg")
|
||||
.content_fit(ContentFit::Cover)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill),
|
||||
);
|
||||
let vid_container;
|
||||
),
|
||||
crate::BackgroundKind::Video => {
|
||||
if let Some(video) = &self.video {
|
||||
vid_container = Container::new(
|
||||
Container::new(
|
||||
VideoPlayer::new(video)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.content_fit(ContentFit::Cover),
|
||||
);
|
||||
)
|
||||
} else {
|
||||
vid_container = Container::new(Space::new(0, 0));
|
||||
Container::new(Space::new(0, 0))
|
||||
}
|
||||
let stack = stack!(image, vid_container, text)
|
||||
}
|
||||
};
|
||||
let stack = stack!(container, text)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill);
|
||||
stack.into()
|
||||
|
|
Loading…
Reference in a new issue