making previews work more correctly
This commit is contained in:
parent
8d350edcaa
commit
04e95d8044
|
@ -546,11 +546,9 @@ pub(crate) fn slide_view<'a>(
|
||||||
hide_mouse: bool,
|
hide_mouse: bool,
|
||||||
) -> Element<'a, Message> {
|
) -> Element<'a, Message> {
|
||||||
responsive(move |size| {
|
responsive(move |size| {
|
||||||
let font_size = scale_font(
|
let height = size.width * 9.0 / 16.0;
|
||||||
slide.font_size() as f32,
|
let font_size =
|
||||||
size.width,
|
scale_font(slide.font_size() as f32, size.width, height);
|
||||||
size.height,
|
|
||||||
);
|
|
||||||
let slide_text = slide.text();
|
let slide_text = slide.text();
|
||||||
let lines = slide_text.lines();
|
let lines = slide_text.lines();
|
||||||
// let line_size = lines.clone().count();
|
// let line_size = lines.clone().count();
|
||||||
|
@ -576,9 +574,9 @@ pub(crate) fn slide_view<'a>(
|
||||||
let black = Container::new(Space::new(0, 0))
|
let black = Container::new(Space::new(0, 0))
|
||||||
.style(|_| {
|
.style(|_| {
|
||||||
container::background(Background::Color(Color::BLACK))
|
container::background(Background::Color(Color::BLACK))
|
||||||
})
|
}).clip(true)
|
||||||
.width(size.width)
|
.width(size.width)
|
||||||
.height(size.height);
|
.height(height);
|
||||||
let container = match slide.background().kind {
|
let container = match slide.background().kind {
|
||||||
BackgroundKind::Image => {
|
BackgroundKind::Image => {
|
||||||
let path = slide.background().path.clone();
|
let path = slide.background().path.clone();
|
||||||
|
@ -586,8 +584,9 @@ pub(crate) fn slide_view<'a>(
|
||||||
image(path)
|
image(path)
|
||||||
.content_fit(ContentFit::Cover)
|
.content_fit(ContentFit::Cover)
|
||||||
.width(size.width)
|
.width(size.width)
|
||||||
.height(size.height),
|
.height(height),
|
||||||
)
|
)
|
||||||
|
.clip(true)
|
||||||
}
|
}
|
||||||
BackgroundKind::Video => {
|
BackgroundKind::Video => {
|
||||||
if delegate {
|
if delegate {
|
||||||
|
@ -597,6 +596,7 @@ pub(crate) fn slide_view<'a>(
|
||||||
Color::BLACK,
|
Color::BLACK,
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
.clip(true)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(Length::Fill)
|
||||||
} else if let Some(video) = &video {
|
} else if let Some(video) = &video {
|
||||||
|
@ -604,7 +604,7 @@ pub(crate) fn slide_view<'a>(
|
||||||
VideoPlayer::new(video)
|
VideoPlayer::new(video)
|
||||||
.mouse_hidden(hide_mouse)
|
.mouse_hidden(hide_mouse)
|
||||||
.width(size.width)
|
.width(size.width)
|
||||||
.height(size.width * 9.0 / 16.0)
|
.height(height)
|
||||||
.on_end_of_stream(Message::EndVideo)
|
.on_end_of_stream(Message::EndVideo)
|
||||||
.on_new_frame(Message::VideoFrame)
|
.on_new_frame(Message::VideoFrame)
|
||||||
.on_missing_plugin(Message::MissingPlugin)
|
.on_missing_plugin(Message::MissingPlugin)
|
||||||
|
@ -616,6 +616,7 @@ pub(crate) fn slide_view<'a>(
|
||||||
})
|
})
|
||||||
.content_fit(ContentFit::Cover),
|
.content_fit(ContentFit::Cover),
|
||||||
)
|
)
|
||||||
|
.clip(true)
|
||||||
} else {
|
} else {
|
||||||
Container::new(Space::new(0, 0))
|
Container::new(Space::new(0, 0))
|
||||||
}
|
}
|
||||||
|
@ -623,7 +624,7 @@ pub(crate) fn slide_view<'a>(
|
||||||
};
|
};
|
||||||
stack!(black, container.center(Length::Fill), text_container)
|
stack!(black, container.center(Length::Fill), text_container)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.height(Length::Fill)
|
.height(height)
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
.into()
|
.into()
|
||||||
|
|
|
@ -3,13 +3,13 @@ use std::path::PathBuf;
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
iced::{
|
iced::{
|
||||||
font::{Family, Stretch, Style, Weight},
|
font::{Family, Stretch, Style, Weight},
|
||||||
Font, Length,
|
padding, Font, Length,
|
||||||
},
|
},
|
||||||
iced_widget::row,
|
iced_widget::row,
|
||||||
widget::{
|
widget::{
|
||||||
button, column, combo_box, container, dropdown,
|
button, column, combo_box, container, dropdown,
|
||||||
horizontal_space, icon, text, text_editor, text_input,
|
horizontal_space, icon, scrollable, text, text_editor,
|
||||||
vertical_space,
|
text_input, vertical_space,
|
||||||
},
|
},
|
||||||
Element, Task,
|
Element, Task,
|
||||||
};
|
};
|
||||||
|
@ -165,17 +165,30 @@ impl SongEditor {
|
||||||
let slides = slides
|
let slides = slides
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|slide| {
|
.map(|slide| {
|
||||||
slide_view(
|
container(
|
||||||
slide,
|
slide_view(
|
||||||
&self.video,
|
slide,
|
||||||
self.current_font,
|
&self.video,
|
||||||
false,
|
self.current_font,
|
||||||
false,
|
false,
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.map(|_| Message::None),
|
||||||
)
|
)
|
||||||
.map(|_| Message::None)
|
.height(250)
|
||||||
|
.into()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
column::with_children(slides).into()
|
scrollable(
|
||||||
|
container(
|
||||||
|
column::with_children(slides).spacing(10),
|
||||||
|
)
|
||||||
|
.clip(true)
|
||||||
|
.padding(padding::right(20).left(20)),
|
||||||
|
)
|
||||||
|
.height(Length::Fill)
|
||||||
|
.width(Length::Fill)
|
||||||
|
.into()
|
||||||
} else {
|
} else {
|
||||||
horizontal_space().into()
|
horizontal_space().into()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue