Getting closer to a working little system
This commit is contained in:
parent
d9459d6336
commit
c60353f8c8
83
Cargo.lock
generated
83
Cargo.lock
generated
|
@ -1254,6 +1254,18 @@ dependencies = [
|
|||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crisp"
|
||||
version = "0.1.0"
|
||||
source = "git+https://git.tfcconnection.org/chris/crisp#04a470d771bd86646d27ef35811fc7d6a3c7bafb"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"miette",
|
||||
"pretty_assertions",
|
||||
"regex",
|
||||
"rustyline",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-channel"
|
||||
version = "0.5.13"
|
||||
|
@ -1591,6 +1603,12 @@ version = "1.1.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3d8a32ae18130a3c84dd492d4215c3d913c3b07c6b63c2eb3eb7ff1101ab7bf"
|
||||
|
||||
[[package]]
|
||||
name = "endian-type"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c34f04666d835ff5d62e058c3995147c06f42fe86ff053337632bca83e42702d"
|
||||
|
||||
[[package]]
|
||||
name = "enumflags2"
|
||||
version = "0.7.10"
|
||||
|
@ -1739,6 +1757,17 @@ version = "2.1.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
|
||||
|
||||
[[package]]
|
||||
name = "fd-lock"
|
||||
version = "4.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e5768da2206272c81ef0b5e951a41862938a6070da63bcea197899942d3b947"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rustix 0.38.37",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fdeflate"
|
||||
version = "0.3.5"
|
||||
|
@ -3268,6 +3297,7 @@ name = "lumina"
|
|||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"crisp",
|
||||
"dirs",
|
||||
"iced_video_player",
|
||||
"lexpr",
|
||||
|
@ -3582,6 +3612,15 @@ dependencies = [
|
|||
"jni-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nibble_vec"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77a5d83df9f36fe23f0c3648c6bbb8b0298bb5f1939c8f2704431371f4b84d43"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.26.4"
|
||||
|
@ -3594,6 +3633,18 @@ dependencies = [
|
|||
"memoffset 0.7.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.28.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"cfg-if",
|
||||
"cfg_aliases 0.1.1",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nix"
|
||||
version = "0.29.0"
|
||||
|
@ -4493,6 +4544,16 @@ dependencies = [
|
|||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "radix_trie"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c069c179fcdc6a2fe24d8d18305cf085fdbd4f922c041943e203685d6a1c58fd"
|
||||
dependencies = [
|
||||
"endian-type",
|
||||
"nibble_vec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.8.5"
|
||||
|
@ -4823,6 +4884,28 @@ dependencies = [
|
|||
"unicode-script",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustyline"
|
||||
version = "14.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7803e8936da37efd9b6d4478277f4b2b9bb5cdb37a113e8d63222e58da647e63"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"cfg-if",
|
||||
"clipboard-win",
|
||||
"fd-lock",
|
||||
"home",
|
||||
"libc",
|
||||
"log",
|
||||
"memchr",
|
||||
"nix 0.28.0",
|
||||
"radix_trie",
|
||||
"unicode-segmentation",
|
||||
"unicode-width",
|
||||
"utf8parse",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.18"
|
||||
|
|
|
@ -23,3 +23,4 @@ ron = "0.8.1"
|
|||
sqlx = { version = "0.8.2", features = ["sqlite"] }
|
||||
dirs = "5.0.1"
|
||||
tokio = "1.41.1"
|
||||
crisp = { git = "https://git.tfcconnection.org/chris/crisp" }
|
||||
|
|
4
justfile
4
justfile
|
@ -2,8 +2,8 @@ default:
|
|||
just --list
|
||||
build:
|
||||
RUST_LOG=debug cargo build
|
||||
run:
|
||||
RUST_LOG=debug cargo run -- -i ~/dev/lumina-iced/test_presentation.lisp
|
||||
run ui=' ' file='~/dev/lumina-iced/test_presentation.lisp':
|
||||
RUST_LOG=debug cargo run -- {{ui}} {{file}}
|
||||
clean:
|
||||
RUST_LOG=debug cargo clean
|
||||
test:
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
use lexpr::{
|
||||
parse::{from_str_elisp, Options},
|
||||
Parser, Value,
|
||||
};
|
||||
use crisp::types::{Keyword, Value};
|
||||
use miette::{miette, IntoDiagnostic, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{
|
||||
|
@ -187,6 +184,36 @@ impl Slide {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<Value> for Slide {
|
||||
fn from(value: Value) -> Self {
|
||||
match value {
|
||||
Value::List(list) => lisp_to_slide(list),
|
||||
_ => Slide::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn lisp_to_slide(lisp: Vec<Value>) -> Slide {
|
||||
let mut slide = SlideBuilder::new();
|
||||
let background_position = if let Some(background) =
|
||||
lisp.position(|v| Value::Keyword(Keyword::from("background")))
|
||||
{
|
||||
background + 1
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
||||
if let Some(background) = lisp.get(background_position) {
|
||||
slide.background(lisp_to_background(background));
|
||||
} else {
|
||||
slide.background(Background::default());
|
||||
}
|
||||
}
|
||||
|
||||
fn lisp_to_background(lisp: &Value) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone, Debug, Default, PartialEq, Serialize, Deserialize,
|
||||
)]
|
||||
|
|
14
src/lisp.rs
Normal file
14
src/lisp.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use crisp::{
|
||||
env::Environment,
|
||||
types::{Symbol, Value},
|
||||
};
|
||||
|
||||
use crate::{Slide, SlideBuilder};
|
||||
|
||||
pub fn setup_env() {
|
||||
let mut env = Environment::new();
|
||||
env.insert_symbol(
|
||||
Symbol::from("slide"),
|
||||
Value::func(|args| Ok(Value::from(args))),
|
||||
)
|
||||
}
|
127
src/main.rs
127
src/main.rs
|
@ -1,26 +1,25 @@
|
|||
use clap::{command, Parser};
|
||||
use cosmic::app::{Core, Settings, Task};
|
||||
use cosmic::dialog::ashpd::url::Url;
|
||||
use cosmic::iced::keyboard::Key;
|
||||
use cosmic::iced::window::Position;
|
||||
use cosmic::iced::{
|
||||
self, event, window, ContentFit, Font, Length, Point,
|
||||
};
|
||||
use cosmic::iced::{self, event, window, Font, Length, Point};
|
||||
use cosmic::iced_core::SmolStr;
|
||||
use cosmic::iced_widget::{column, row, stack};
|
||||
use cosmic::widget::icon;
|
||||
use cosmic::prelude::*;
|
||||
use cosmic::widget::tooltip::Position as TPosition;
|
||||
use cosmic::widget::{button, image, nav_bar, text, tooltip, Space};
|
||||
use cosmic::widget::{
|
||||
button, image, nav_bar, text, tooltip, Responsive, Space,
|
||||
};
|
||||
use cosmic::widget::{icon, slider};
|
||||
use cosmic::{executor, Application, ApplicationExt, Element};
|
||||
use cosmic::{widget::Container, Theme};
|
||||
use iced_video_player::{Video, VideoPlayer};
|
||||
use miette::{miette, Result};
|
||||
use std::path::PathBuf;
|
||||
use tracing::error;
|
||||
use tracing::{debug, level_filters::LevelFilter};
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
pub mod core;
|
||||
pub mod lisp;
|
||||
pub mod ui;
|
||||
use core::slide::*;
|
||||
use ui::presenter::{self, Presenter};
|
||||
|
@ -93,7 +92,7 @@ impl Default for App {
|
|||
.build()
|
||||
.expect("oops slide");
|
||||
let slides = vec![initial_slide.clone()];
|
||||
let presenter = Presenter::with_app_slides(slides.clone());
|
||||
let presenter = Presenter::with_slides(slides.clone());
|
||||
Self {
|
||||
presenter,
|
||||
core: Core::default(),
|
||||
|
@ -152,7 +151,7 @@ impl cosmic::Application for App {
|
|||
.unwrap(),
|
||||
)
|
||||
.expect("oops video")
|
||||
.text("Hello")
|
||||
.text("")
|
||||
.font("Quicksand")
|
||||
.font_size(50)
|
||||
.text_alignment(TextAlignment::MiddleCenter)
|
||||
|
@ -179,12 +178,26 @@ impl cosmic::Application for App {
|
|||
.build()
|
||||
.expect("oops slide");
|
||||
|
||||
let slides = vec![
|
||||
initial_slide.clone(),
|
||||
second_slide.clone(),
|
||||
second_slide.clone(),
|
||||
];
|
||||
let presenter = Presenter::with_app_slides(slides.clone());
|
||||
let tetrary_slide = SlideBuilder::new()
|
||||
.background(
|
||||
PathBuf::from("/home/chris/pics/wojaks/reddit_the_xenomorph_s bigass wojak folder/Chads/ChristianChad_x16_drawing.png")
|
||||
.canonicalize()
|
||||
.unwrap(),
|
||||
)
|
||||
.expect("oops video")
|
||||
.text("Hello")
|
||||
.font("Quicksand")
|
||||
.font_size(50)
|
||||
.text_alignment(TextAlignment::MiddleCenter)
|
||||
.video_loop(false)
|
||||
.video_start_time(0.0)
|
||||
.video_end_time(0.0)
|
||||
.build()
|
||||
.expect("oops slide");
|
||||
|
||||
let slides =
|
||||
vec![initial_slide.clone(), second_slide, tetrary_slide];
|
||||
let presenter = Presenter::with_slides(slides.clone());
|
||||
let mut app = App {
|
||||
presenter,
|
||||
core,
|
||||
|
@ -347,7 +360,7 @@ impl cosmic::Application for App {
|
|||
) -> cosmic::Task<cosmic::app::Message<Message>> {
|
||||
match message {
|
||||
Message::Present(message) => {
|
||||
self.presenter.update(message);
|
||||
let _ = self.presenter.update(message);
|
||||
// self.core.nav_bar_toggle();
|
||||
Task::none()
|
||||
}
|
||||
|
@ -403,9 +416,47 @@ impl cosmic::Application for App {
|
|||
// Main window view
|
||||
fn view(&self) -> Element<Message> {
|
||||
debug!("Main view");
|
||||
let preview = self.presenter.view();
|
||||
let icon_left = icon::from_name("arrow-left");
|
||||
let icon_right = icon::from_name("arrow-right");
|
||||
|
||||
let video_range: f32 =
|
||||
if let Some(video) = &self.presenter.video {
|
||||
let duration = video.duration();
|
||||
duration.as_secs_f32()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
let video_pos = if let Some(video) = &self.presenter.video {
|
||||
let range = video.position();
|
||||
range.as_secs_f32()
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
|
||||
let video_button_icon =
|
||||
if let Some(video) = &self.presenter.video {
|
||||
if video.paused() {
|
||||
button::icon(icon::from_name("media-play"))
|
||||
.tooltip("Play")
|
||||
.on_press(Message::Present(
|
||||
presenter::Message::StartVideo,
|
||||
))
|
||||
} else {
|
||||
button::icon(icon::from_name("media-pause"))
|
||||
.tooltip("Pause")
|
||||
.on_press(Message::Present(
|
||||
presenter::Message::StartVideo,
|
||||
))
|
||||
}
|
||||
} else {
|
||||
button::icon(icon::from_name("media-play"))
|
||||
.tooltip("Play")
|
||||
.on_press(Message::Present(
|
||||
presenter::Message::StartVideo,
|
||||
))
|
||||
};
|
||||
|
||||
let row = row![
|
||||
Container::new(
|
||||
button::icon(icon_left)
|
||||
|
@ -419,13 +470,43 @@ impl cosmic::Application for App {
|
|||
.center_y(Length::Fill)
|
||||
.align_right(Length::Fill)
|
||||
.width(Length::FillPortion(1)),
|
||||
Container::new(column![
|
||||
Space::with_height(Length::Fill),
|
||||
Responsive::new(move |size| {
|
||||
let height = size.width * 9.0 / 16.0;
|
||||
Container::new(
|
||||
Container::new(preview.map(|m| Message::Present(m)))
|
||||
.center(Length::Fill)
|
||||
.max_height(270)
|
||||
self.presenter
|
||||
.view()
|
||||
.map(|m| Message::Present(m)),
|
||||
)
|
||||
.width(Length::Fill)
|
||||
.height(height)
|
||||
.into()
|
||||
}),
|
||||
Container::new(
|
||||
row![
|
||||
video_button_icon,
|
||||
Container::new(slider(
|
||||
0.0..=video_range,
|
||||
video_pos,
|
||||
|pos| {
|
||||
Message::Present(
|
||||
presenter::Message::VideoPos(pos),
|
||||
)
|
||||
}
|
||||
))
|
||||
.center_x(Length::Fill)
|
||||
.padding([7, 0, 0, 0])
|
||||
]
|
||||
.padding(5)
|
||||
)
|
||||
.align_top(Length::Shrink)
|
||||
.height(Length::Shrink)
|
||||
.center_x(Length::Fill),
|
||||
Space::with_height(Length::Fill)
|
||||
])
|
||||
.center_y(Length::Fill)
|
||||
.width(Length::FillPortion(3)),
|
||||
.center_x(Length::FillPortion(3)),
|
||||
Container::new(
|
||||
button::icon(icon_right)
|
||||
.icon_size(128)
|
||||
|
@ -526,7 +607,6 @@ fn test_slide<'a>() -> Element<'a, Message> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
|
@ -539,7 +619,6 @@ mod test {
|
|||
// fn test_lisp() {
|
||||
// let slide = test_slide();
|
||||
// if let Ok(data) = lexpr::parse::from_str_elisp(slide.as_str()) {
|
||||
// println!("{data:?}");
|
||||
// assert_eq!(slide, data)
|
||||
// } else {
|
||||
// assert!(false)
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
pub mod presenter;
|
||||
pub mod slide_preview;
|
||||
|
|
|
@ -1,40 +1,43 @@
|
|||
use std::{path::PathBuf, rc::Rc};
|
||||
use std::{path::PathBuf, rc::Rc, time::Duration};
|
||||
|
||||
use cosmic::{
|
||||
dialog::ashpd::url::Url,
|
||||
iced::{widget::text, ContentFit, Length},
|
||||
iced_widget::{row, stack, Stack},
|
||||
iced::{widget::text, Background, Color, ContentFit, Length},
|
||||
iced_widget::stack,
|
||||
prelude::*,
|
||||
widget::{
|
||||
button, container, icon::Named, image, Container, Row, Space,
|
||||
},
|
||||
widget::{container, image, Container, Row, Space},
|
||||
Task,
|
||||
};
|
||||
use iced_video_player::{Video, VideoPlayer};
|
||||
use iced_video_player::{Position, Video, VideoPlayer};
|
||||
use miette::{Context, IntoDiagnostic, Result};
|
||||
use tracing::{debug, error};
|
||||
use tracing::{debug, error, info};
|
||||
|
||||
use crate::{core::slide::Slide, BackgroundKind};
|
||||
|
||||
// #[derive(Default, Clone, Debug)]
|
||||
pub(crate) struct Presenter {
|
||||
pub slides: Vec<Slide>,
|
||||
pub current_slide: i16,
|
||||
pub current_slide: Slide,
|
||||
pub current_slide_index: u16,
|
||||
pub video: Option<Video>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub(crate) enum Message {
|
||||
NextSlide,
|
||||
PrevSlide,
|
||||
SlideChange(u8),
|
||||
SlideChange(u16),
|
||||
EndVideo,
|
||||
StartVideo,
|
||||
VideoPos(f32),
|
||||
}
|
||||
|
||||
impl Presenter {
|
||||
pub fn with_app_slides(slides: Vec<Slide>) -> Self {
|
||||
pub fn with_slides(slides: Vec<Slide>) -> Self {
|
||||
Self {
|
||||
slides: slides.clone(),
|
||||
current_slide: 0,
|
||||
current_slide: slides[0].clone(),
|
||||
current_slide_index: 0,
|
||||
video: {
|
||||
if let Some(slide) = slides.get(0) {
|
||||
let path = slide.background().path.clone();
|
||||
|
@ -42,7 +45,10 @@ impl Presenter {
|
|||
let url = Url::from_file_path(path).unwrap();
|
||||
let result = Video::new(&url);
|
||||
match result {
|
||||
Ok(v) => Some(v),
|
||||
Ok(mut v) => {
|
||||
v.set_paused(true);
|
||||
Some(v)
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Had an error creating the video object: {e}");
|
||||
None
|
||||
|
@ -57,29 +63,6 @@ impl Presenter {
|
|||
},
|
||||
}
|
||||
}
|
||||
// pub fn with_initial_slide(slide: Slide) -> Self {
|
||||
// Self {
|
||||
// slides: vec![slide.clone()],
|
||||
// current_slide: 0,
|
||||
// video: {
|
||||
// let path = slide.background().path.clone();
|
||||
// if path.exists() {
|
||||
// let url = Url::from_file_path(path).unwrap();
|
||||
// let result = Video::new(&url);
|
||||
// match result {
|
||||
// Ok(v) => Some(v),
|
||||
// Err(e) => {
|
||||
// error!("Had an error creating the video object: {e}");
|
||||
// None
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// error!("File doesn't exist: ");
|
||||
// None
|
||||
// }
|
||||
// },
|
||||
// }
|
||||
// }
|
||||
|
||||
pub fn update(
|
||||
&mut self,
|
||||
|
@ -88,24 +71,75 @@ impl Presenter {
|
|||
match message {
|
||||
Message::NextSlide => {
|
||||
debug!("next slide");
|
||||
if let Some(video) = &mut self.video {
|
||||
let _ = video.restart_stream();
|
||||
if self.slides.len() as u16 - 1
|
||||
== self.current_slide_index
|
||||
{
|
||||
debug!("no more slides");
|
||||
return Task::none();
|
||||
}
|
||||
self.current_slide += 1;
|
||||
self.reset_video();
|
||||
Task::none()
|
||||
self.current_slide_index += 1;
|
||||
self.update(Message::SlideChange(
|
||||
self.current_slide_index,
|
||||
))
|
||||
}
|
||||
Message::PrevSlide => {
|
||||
debug!("prev slide");
|
||||
if let Some(video) = &mut self.video {
|
||||
let _ = video.restart_stream();
|
||||
if 0 == self.current_slide_index {
|
||||
debug!("beginning slides");
|
||||
return Task::none();
|
||||
}
|
||||
self.current_slide -= 1;
|
||||
self.reset_video();
|
||||
Task::none()
|
||||
self.current_slide_index -= 1;
|
||||
self.update(Message::SlideChange(
|
||||
self.current_slide_index,
|
||||
))
|
||||
}
|
||||
Message::SlideChange(id) => {
|
||||
debug!(id, "slide changed");
|
||||
if let Some(slide) = self.slides.get(id as usize) {
|
||||
self.current_slide = slide.clone();
|
||||
}
|
||||
if let Some(video) = &mut self.video {
|
||||
let _ = video.restart_stream();
|
||||
}
|
||||
self.reset_video();
|
||||
Task::none()
|
||||
}
|
||||
Message::EndVideo => {
|
||||
// if self.current_slide.video_loop() {
|
||||
// if let Some(video) = &mut self.video {
|
||||
// match video.restart_stream() {
|
||||
// Ok(_) => info!("Restarting video"),
|
||||
// Err(e) => {
|
||||
// error!("Couldn't restart video: {e}")
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
Task::none()
|
||||
}
|
||||
Message::StartVideo => {
|
||||
if let Some(video) = &mut self.video {
|
||||
video.set_paused(false);
|
||||
video
|
||||
.set_looping(self.current_slide.video_loop());
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
Message::VideoPos(position) => {
|
||||
if let Some(video) = &mut self.video {
|
||||
let position = Position::Time(
|
||||
Duration::from_secs_f32(position),
|
||||
);
|
||||
match video.seek(position, false) {
|
||||
Ok(_) => debug!(
|
||||
"Video position changed: {:?}",
|
||||
position
|
||||
),
|
||||
Err(e) => error!(
|
||||
"Problem changing video position: {e}"
|
||||
),
|
||||
}
|
||||
}
|
||||
Task::none()
|
||||
}
|
||||
}
|
||||
|
@ -114,25 +148,30 @@ impl Presenter {
|
|||
pub fn view(&self) -> Element<Message> {
|
||||
let text = text!("This is frodo").size(50);
|
||||
let text = Container::new(text).center(Length::Fill);
|
||||
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)
|
||||
let black = Container::new(Space::new(0, 0))
|
||||
.style(|_| {
|
||||
container::background(Background::Color(Color::BLACK))
|
||||
})
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill);
|
||||
let container = match self.current_slide.background().kind {
|
||||
crate::BackgroundKind::Image => {
|
||||
let path =
|
||||
self.current_slide.background().path.clone();
|
||||
Container::new(
|
||||
image(path)
|
||||
.content_fit(ContentFit::Contain)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill),
|
||||
),
|
||||
)
|
||||
}
|
||||
crate::BackgroundKind::Video => {
|
||||
if let Some(video) = &self.video {
|
||||
Container::new(
|
||||
VideoPlayer::new(video)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.on_end_of_stream(Message::EndVideo)
|
||||
.content_fit(ContentFit::Cover),
|
||||
)
|
||||
} else {
|
||||
|
@ -140,7 +179,7 @@ impl Presenter {
|
|||
}
|
||||
}
|
||||
};
|
||||
stack!(container, text)
|
||||
stack!(black, container.center(Length::Fill), text)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.into()
|
||||
|
@ -169,7 +208,7 @@ impl Presenter {
|
|||
Container::new(Space::new(Length::Fill, Length::Fill))
|
||||
}
|
||||
};
|
||||
stack!(container, text)
|
||||
stack!(container.center(Length::Fill), text)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill)
|
||||
.into()
|
||||
|
@ -177,7 +216,7 @@ impl Presenter {
|
|||
|
||||
fn reset_video(&mut self) {
|
||||
if let Some(slide) =
|
||||
self.slides.get(self.current_slide as usize)
|
||||
self.slides.get(self.current_slide_index as usize)
|
||||
{
|
||||
match slide.background().kind {
|
||||
BackgroundKind::Image => self.video = None,
|
||||
|
@ -201,34 +240,3 @@ impl Presenter {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn slide_view<'a>(
|
||||
slide: &'a Slide,
|
||||
video: &'a Option<Video>,
|
||||
) -> Stack<'a, crate::Message, cosmic::Theme> {
|
||||
let text = text!("{}", slide.text()).size(50);
|
||||
let text = Container::new(text).center(Length::Fill);
|
||||
let container = match slide.background().kind {
|
||||
crate::BackgroundKind::Image => Container::new(
|
||||
image("/home/chris/pics/frodo.jpg")
|
||||
.content_fit(ContentFit::Cover)
|
||||
.width(Length::Fill)
|
||||
.height(Length::Fill),
|
||||
),
|
||||
crate::BackgroundKind::Video => {
|
||||
if let Some(video) = video {
|
||||
Container::new(
|
||||
VideoPlayer::new(video)
|
||||
.width(Length::Shrink)
|
||||
.height(Length::Fill)
|
||||
.content_fit(ContentFit::Cover),
|
||||
)
|
||||
} else {
|
||||
Container::new(Space::new(Length::Fill, Length::Fill))
|
||||
}
|
||||
}
|
||||
};
|
||||
stack!(container, text)
|
||||
// .width(Length::Fill)
|
||||
// .height(Length::Fill)
|
||||
}
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
use crate::Slide;
|
||||
|
||||
pub struct SlidePreview<'a> {
|
||||
slides: Vec<&'a Slide>,
|
||||
}
|
Loading…
Reference in a new issue