cleanup of a lot of things

This commit is contained in:
Chris Cochrun 2025-02-26 10:16:50 -06:00
parent e596fdfe29
commit a80ab8e9a6
2 changed files with 21 additions and 19 deletions

View file

@ -525,9 +525,7 @@ async fn start_audio(sink: Arc<Sink>, audio: PathBuf) {
debug!(empty, paused, "Finished running"); debug!(empty, paused, "Finished running");
} }
fn scale_font(font_size: f32, width: f32, height: f32) -> f32 { fn scale_font(font_size: f32, width: f32) -> f32 {
let aspect_ratio_true = REFERENCE_WIDTH / REFERENCE_HEIGHT;
let aspect_ratio = width / height;
let scale_factor = (REFERENCE_WIDTH / width).sqrt(); let scale_factor = (REFERENCE_WIDTH / width).sqrt();
// debug!(scale_factor); // debug!(scale_factor);
let font_size = if font_size > 0.0 { let font_size = if font_size > 0.0 {
@ -547,12 +545,10 @@ pub(crate) fn slide_view<'a>(
) -> Element<'a, Message> { ) -> Element<'a, Message> {
responsive(move |size| { responsive(move |size| {
let height = size.width * 9.0 / 16.0; let height = size.width * 9.0 / 16.0;
let font_size = let width = size.height * 16.0 / 9.0;
scale_font(slide.font_size() as f32, size.width, height); let font_size = scale_font(slide.font_size() as f32, width);
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();
// debug!(?lines);
let text: Vec<Element<Message>> = lines let text: Vec<Element<Message>> = lines
.map(|t| { .map(|t| {
rich_text([span(format!("{}\n", t.to_string())) rich_text([span(format!("{}\n", t.to_string()))
@ -576,7 +572,7 @@ pub(crate) fn slide_view<'a>(
container::background(Background::Color(Color::BLACK)) container::background(Background::Color(Color::BLACK))
}) })
.clip(true) .clip(true)
.width(size.width) .width(width)
.height(height); .height(height);
let container = match slide.background().kind { let container = match slide.background().kind {
BackgroundKind::Image => { BackgroundKind::Image => {
@ -584,9 +580,10 @@ pub(crate) fn slide_view<'a>(
Container::new( Container::new(
image(path) image(path)
.content_fit(ContentFit::Cover) .content_fit(ContentFit::Cover)
.width(size.width) .width(width)
.height(height), .height(height),
) )
.center(Length::Shrink)
.clip(true) .clip(true)
} }
BackgroundKind::Video => { BackgroundKind::Video => {
@ -597,6 +594,8 @@ pub(crate) fn slide_view<'a>(
Color::BLACK, Color::BLACK,
)) ))
}) })
.center_x(width)
.center_y(height)
.clip(true) .clip(true)
.width(Length::Fill) .width(Length::Fill)
.height(Length::Fill) .height(Length::Fill)
@ -604,7 +603,7 @@ pub(crate) fn slide_view<'a>(
Container::new( Container::new(
VideoPlayer::new(video) VideoPlayer::new(video)
.mouse_hidden(hide_mouse) .mouse_hidden(hide_mouse)
.width(size.width) .width(width)
.height(height) .height(height)
.on_end_of_stream(Message::EndVideo) .on_end_of_stream(Message::EndVideo)
.on_new_frame(Message::VideoFrame) .on_new_frame(Message::VideoFrame)
@ -617,6 +616,7 @@ pub(crate) fn slide_view<'a>(
}) })
.content_fit(ContentFit::Cover), .content_fit(ContentFit::Cover),
) )
.center(Length::Shrink)
.clip(true) .clip(true)
} else { } else {
Container::new(Space::new(0, 0)) Container::new(Space::new(0, 0))
@ -624,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(width)
.height(height) .height(height)
.into() .into()
}) })

View file

@ -3,13 +3,14 @@ use std::path::PathBuf;
use cosmic::{ use cosmic::{
iced::{ iced::{
font::{Family, Stretch, Style, Weight}, font::{Family, Stretch, Style, Weight},
padding, Font, Length, Font, Length,
}, },
iced_widget::row, iced_widget::row,
theme,
widget::{ widget::{
button, column, combo_box, container, dropdown, button, column, combo_box, container, dropdown,
horizontal_space, icon, scrollable, text, text_editor, horizontal_space, icon, scrollable, text, text_editor,
text_input, vertical_space, text_input,
}, },
Element, Task, Element, Task,
}; };
@ -155,7 +156,8 @@ impl SongEditor {
let column = column::with_children(vec![ let column = column::with_children(vec![
self.toolbar(), self.toolbar(),
row![self.left_column(), slide_preview].into(), row![self.left_column(), slide_preview].into(),
]); ])
.spacing(theme::active().cosmic().space_l());
column.into() column.into()
} }
@ -176,15 +178,15 @@ impl SongEditor {
.map(|_| Message::None), .map(|_| Message::None),
) )
.height(250) .height(250)
.center_x(Length::Shrink)
.padding([0, 20])
.clip(true)
.into() .into()
}) })
.collect(); .collect();
scrollable( scrollable(
container( column::with_children(slides)
column::with_children(slides).spacing(10), .spacing(theme::active().cosmic().space_l()),
)
.clip(true)
.padding(padding::right(20).left(20)),
) )
.height(Length::Fill) .height(Length::Fill)
.width(Length::Fill) .width(Length::Fill)