back to song_editor looking right
This commit is contained in:
parent
b03382f687
commit
b9a9dda233
3 changed files with 72 additions and 55 deletions
|
@ -129,7 +129,6 @@ impl<'a> Library {
|
||||||
|
|
||||||
pub fn update(&'a mut self, message: Message) -> Action {
|
pub fn update(&'a mut self, message: Message) -> Action {
|
||||||
match message {
|
match message {
|
||||||
Message::AddItem => (),
|
|
||||||
Message::None => (),
|
Message::None => (),
|
||||||
Message::DeleteItem((kind, index)) => {
|
Message::DeleteItem((kind, index)) => {
|
||||||
match kind {
|
match kind {
|
||||||
|
@ -164,6 +163,27 @@ impl<'a> Library {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Message::AddItem => {
|
||||||
|
let kind =
|
||||||
|
self.library_open.unwrap_or(LibraryKind::Song);
|
||||||
|
let item = match kind {
|
||||||
|
LibraryKind::Song => {
|
||||||
|
let song = Song::default();
|
||||||
|
self.song_library
|
||||||
|
.add_item(song)
|
||||||
|
.map(|_| {
|
||||||
|
let index =
|
||||||
|
self.song_library.items.len();
|
||||||
|
(LibraryKind::Song, index as i32)
|
||||||
|
})
|
||||||
|
.ok()
|
||||||
|
}
|
||||||
|
LibraryKind::Video => todo!(),
|
||||||
|
LibraryKind::Image => todo!(),
|
||||||
|
LibraryKind::Presentation => todo!(),
|
||||||
|
};
|
||||||
|
return self.update(Message::OpenItem(item));
|
||||||
|
}
|
||||||
Message::OpenItem(item) => {
|
Message::OpenItem(item) => {
|
||||||
debug!(?item);
|
debug!(?item);
|
||||||
self.editing_item = item;
|
self.editing_item = item;
|
||||||
|
@ -516,6 +536,7 @@ impl<'a> Library {
|
||||||
let library_toolbar = rowm!(
|
let library_toolbar = rowm!(
|
||||||
text_input("Search...", ""),
|
text_input("Search...", ""),
|
||||||
button::icon(icon::from_name("add"))
|
button::icon(icon::from_name("add"))
|
||||||
|
.on_press(Message::AddItem)
|
||||||
);
|
);
|
||||||
let library_column =
|
let library_column =
|
||||||
column![library_toolbar, items].spacing(3);
|
column![library_toolbar, items].spacing(3);
|
||||||
|
|
|
@ -397,9 +397,8 @@ impl Presenter {
|
||||||
|
|
||||||
pub fn view(&self) -> Element<Message> {
|
pub fn view(&self) -> Element<Message> {
|
||||||
slide_view(
|
slide_view(
|
||||||
&self.current_slide,
|
self.current_slide.clone(),
|
||||||
&self.video,
|
&self.video,
|
||||||
self.current_font,
|
|
||||||
false,
|
false,
|
||||||
true,
|
true,
|
||||||
)
|
)
|
||||||
|
@ -407,9 +406,8 @@ impl Presenter {
|
||||||
|
|
||||||
pub fn view_preview(&self) -> Element<Message> {
|
pub fn view_preview(&self) -> Element<Message> {
|
||||||
slide_view(
|
slide_view(
|
||||||
&self.current_slide,
|
self.current_slide.clone(),
|
||||||
&self.video,
|
&self.video,
|
||||||
self.current_font,
|
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
)
|
)
|
||||||
|
@ -443,9 +441,8 @@ impl Presenter {
|
||||||
);
|
);
|
||||||
|
|
||||||
let container = slide_view(
|
let container = slide_view(
|
||||||
slide,
|
slide.clone(),
|
||||||
&self.video,
|
&self.video,
|
||||||
font,
|
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -705,9 +702,8 @@ fn scale_font(font_size: f32, width: f32) -> f32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn slide_view<'a>(
|
pub(crate) fn slide_view<'a>(
|
||||||
slide: &'a Slide,
|
slide: Slide,
|
||||||
video: &'a Option<Video>,
|
video: &'a Option<Video>,
|
||||||
font: Font,
|
|
||||||
delegate: bool,
|
delegate: bool,
|
||||||
hide_mouse: bool,
|
hide_mouse: bool,
|
||||||
) -> Element<'a, Message> {
|
) -> Element<'a, Message> {
|
||||||
|
|
|
@ -11,7 +11,7 @@ use cosmic::{
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
button, column, combo_box, container, horizontal_space, icon,
|
button, column, combo_box, container, horizontal_space, icon,
|
||||||
text, text_editor, text_input,
|
scrollable, text, text_editor, text_input,
|
||||||
},
|
},
|
||||||
Element, Task,
|
Element, Task,
|
||||||
};
|
};
|
||||||
|
@ -20,8 +20,9 @@ use iced_video_player::Video;
|
||||||
use tracing::{debug, error};
|
use tracing::{debug, error};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
core::songs::Song, ui::slide_editor::SlideEditor, Background,
|
core::{service_items::ServiceTrait, songs::Song},
|
||||||
BackgroundKind,
|
ui::{presenter::slide_view, slide_editor::SlideEditor},
|
||||||
|
Background, BackgroundKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -282,49 +283,48 @@ 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: Vec<Element<Message>> = slides
|
||||||
// .iter()
|
.into_iter()
|
||||||
// .enumerate()
|
.enumerate()
|
||||||
// .map(|(index, slide)| {
|
.map(|(index, slide)| {
|
||||||
// container(
|
container(
|
||||||
// slide_view(
|
slide_view(
|
||||||
// slide.clone(),
|
slide,
|
||||||
// if index == 0 {
|
if index == 0 {
|
||||||
// &self.video
|
&self.video
|
||||||
// } else {
|
} else {
|
||||||
// &None
|
&None
|
||||||
// },
|
},
|
||||||
// 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
|
||||||
self.slide_state
|
// .view(Font::with_name("Quicksand Bold"))
|
||||||
.view(Font::with_name("Quicksand Bold"))
|
// .map(|_s| Message::None)
|
||||||
.map(|_s| Message::None)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn left_column(&self) -> Element<Message> {
|
fn left_column(&self) -> Element<Message> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue