This commit is contained in:
parent
77af1ebaf4
commit
53555087a7
2 changed files with 84 additions and 59 deletions
|
@ -1,23 +1,27 @@
|
||||||
use std::{io, path::PathBuf};
|
use std::{io, path::PathBuf};
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
iced::{Color, Font},
|
iced::{Color, Font, Length},
|
||||||
|
prelude::*,
|
||||||
widget::{
|
widget::{
|
||||||
self,
|
self,
|
||||||
canvas::{self, Program, Stroke},
|
canvas::{self, Program, Stroke},
|
||||||
|
container, Canvas,
|
||||||
},
|
},
|
||||||
Renderer,
|
Renderer,
|
||||||
};
|
};
|
||||||
|
use tracing::debug;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct State {
|
struct State {
|
||||||
cache: canvas::Cache,
|
cache: canvas::Cache,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Default)]
|
||||||
struct SlideEditor<'a> {
|
pub struct SlideEditor {
|
||||||
state: &'a State,
|
state: State,
|
||||||
font: &'a Font,
|
font: Font,
|
||||||
|
program: EditorProgram,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -45,23 +49,33 @@ pub enum SlideError {
|
||||||
IOError(io::ErrorKind),
|
IOError(io::ErrorKind),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
#[derive(Debug, Default)]
|
||||||
|
struct EditorProgram {}
|
||||||
|
|
||||||
|
impl SlideEditor {
|
||||||
pub fn view<'a>(
|
pub fn view<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
font: &'a Font,
|
font: Font,
|
||||||
) -> cosmic::iced::Element<'a, SlideWidget> {
|
) -> cosmic::Element<'a, SlideWidget> {
|
||||||
widget::canvas(SlideEditor { state: self, font }).into()
|
container(
|
||||||
|
widget::canvas(&self.program)
|
||||||
|
.height(Length::Fill)
|
||||||
|
.width(Length::Fill),
|
||||||
|
)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Program<SlideWidget> for SlideEditor<'a> {
|
impl<'a> Program<SlideWidget, cosmic::Theme, cosmic::Renderer>
|
||||||
|
for EditorProgram
|
||||||
|
{
|
||||||
type State = ();
|
type State = ();
|
||||||
|
|
||||||
fn draw(
|
fn draw(
|
||||||
&self,
|
&self,
|
||||||
state: &Self::State,
|
state: &Self::State,
|
||||||
renderer: &Renderer,
|
renderer: &Renderer,
|
||||||
theme: &cosmic::iced_runtime::core::Theme,
|
theme: &cosmic::Theme,
|
||||||
bounds: cosmic::iced::Rectangle,
|
bounds: cosmic::iced::Rectangle,
|
||||||
cursor: cosmic::iced_core::mouse::Cursor,
|
cursor: cosmic::iced_core::mouse::Cursor,
|
||||||
) -> Vec<canvas::Geometry<Renderer>> {
|
) -> Vec<canvas::Geometry<Renderer>> {
|
||||||
|
@ -93,23 +107,27 @@ impl<'a> Program<SlideWidget> for SlideEditor<'a> {
|
||||||
) -> (canvas::event::Status, Option<SlideWidget>) {
|
) -> (canvas::event::Status, Option<SlideWidget>) {
|
||||||
match event {
|
match event {
|
||||||
canvas::Event::Mouse(event) => match event {
|
canvas::Event::Mouse(event) => match event {
|
||||||
cosmic::iced::mouse::Event::CursorEntered => todo!(),
|
cosmic::iced::mouse::Event::CursorEntered => {
|
||||||
cosmic::iced::mouse::Event::CursorLeft => todo!(),
|
debug!("cursor entered")
|
||||||
|
}
|
||||||
|
cosmic::iced::mouse::Event::CursorLeft => {
|
||||||
|
debug!("cursor left")
|
||||||
|
}
|
||||||
cosmic::iced::mouse::Event::CursorMoved {
|
cosmic::iced::mouse::Event::CursorMoved {
|
||||||
position,
|
position,
|
||||||
} => todo!(),
|
} => debug!(?position, "cursor moved"),
|
||||||
cosmic::iced::mouse::Event::ButtonPressed(button) => {
|
cosmic::iced::mouse::Event::ButtonPressed(button) => {
|
||||||
todo!()
|
debug!(?button, "mouse button pressed")
|
||||||
}
|
}
|
||||||
cosmic::iced::mouse::Event::ButtonReleased(
|
cosmic::iced::mouse::Event::ButtonReleased(
|
||||||
button,
|
button,
|
||||||
) => todo!(),
|
) => debug!(?button, "mouse button released"),
|
||||||
cosmic::iced::mouse::Event::WheelScrolled {
|
cosmic::iced::mouse::Event::WheelScrolled {
|
||||||
delta,
|
delta,
|
||||||
} => todo!(),
|
} => debug!(?delta, "scroll wheel"),
|
||||||
},
|
},
|
||||||
canvas::Event::Touch(event) => todo!(),
|
canvas::Event::Touch(event) => debug!("test"),
|
||||||
canvas::Event::Keyboard(event) => todo!(),
|
canvas::Event::Keyboard(event) => debug!("test"),
|
||||||
}
|
}
|
||||||
(canvas::event::Status::Ignored, None)
|
(canvas::event::Status::Ignored, None)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ use tracing::{debug, error};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
core::{service_items::ServiceTrait, songs::Song},
|
core::{service_items::ServiceTrait, songs::Song},
|
||||||
|
ui::slide_editor::{self, SlideEditor},
|
||||||
Background, BackgroundKind,
|
Background, BackgroundKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -45,6 +46,7 @@ pub struct SongEditor {
|
||||||
video: Option<Video>,
|
video: Option<Video>,
|
||||||
current_font: Font,
|
current_font: Font,
|
||||||
ccli: String,
|
ccli: String,
|
||||||
|
slide_state: SlideEditor,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
|
@ -133,6 +135,7 @@ impl SongEditor {
|
||||||
video: None,
|
video: None,
|
||||||
current_font: cosmic::font::default(),
|
current_font: cosmic::font::default(),
|
||||||
ccli: "8".to_owned(),
|
ccli: "8".to_owned(),
|
||||||
|
slide_state: SlideEditor::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn update(&mut self, message: Message) -> Action {
|
pub fn update(&mut self, message: Message) -> Action {
|
||||||
|
@ -285,46 +288,50 @@ impl SongEditor {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn slide_preview(&self) -> Element<Message> {
|
fn slide_preview(&self) -> Element<Message> {
|
||||||
if let Some(song) = &self.song {
|
// if let Some(song) = &self.song {
|
||||||
if let Ok(slides) = song.to_slides() {
|
// if let Ok(slides) = song.to_slides() {
|
||||||
let slides = slides
|
// let slides = slides
|
||||||
.iter()
|
// .iter()
|
||||||
.enumerate()
|
// .enumerate()
|
||||||
.map(|(index, slide)| {
|
// .map(|(index, slide)| {
|
||||||
container(
|
// container(
|
||||||
slide_view(
|
// slide_view(
|
||||||
slide.clone(),
|
// slide.clone(),
|
||||||
if index == 0 {
|
// if index == 0 {
|
||||||
&self.video
|
// &self.video
|
||||||
} else {
|
// } else {
|
||||||
&None
|
// &None
|
||||||
},
|
// },
|
||||||
self.current_font,
|
// self.current_font,
|
||||||
false,
|
// false,
|
||||||
false,
|
// false,
|
||||||
)
|
// )
|
||||||
.map(|_| Message::None),
|
// .map(|_| Message::None),
|
||||||
)
|
// )
|
||||||
.height(250)
|
// .height(250)
|
||||||
.center_x(Length::Fill)
|
// .center_x(Length::Fill)
|
||||||
.padding([0, 20])
|
// .padding([0, 20])
|
||||||
.clip(true)
|
// .clip(true)
|
||||||
.into()
|
// .into()
|
||||||
})
|
// })
|
||||||
.collect();
|
// .collect();
|
||||||
scrollable(
|
// scrollable(
|
||||||
column::with_children(slides)
|
// column::with_children(slides)
|
||||||
.spacing(theme::active().cosmic().space_l()),
|
// .spacing(theme::active().cosmic().space_l()),
|
||||||
)
|
// )
|
||||||
.height(Length::Fill)
|
// .height(Length::Fill)
|
||||||
.width(Length::Fill)
|
// .width(Length::Fill)
|
||||||
.into()
|
// .into()
|
||||||
} else {
|
// } else {
|
||||||
horizontal_space().into()
|
// horizontal_space().into()
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
horizontal_space().into()
|
// horizontal_space().into()
|
||||||
}
|
// }
|
||||||
|
self.slide_state
|
||||||
|
.view(Font::with_name("Quicksand Bold"))
|
||||||
|
.map(|_s| Message::None)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn left_column(&self) -> Element<Message> {
|
fn left_column(&self) -> Element<Message> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue