This commit is contained in:
parent
8c709d97d1
commit
bf774b8cf2
2 changed files with 75 additions and 22 deletions
|
|
@ -34,6 +34,7 @@ pub struct Song {
|
||||||
pub text_alignment: Option<TextAlignment>,
|
pub text_alignment: Option<TextAlignment>,
|
||||||
pub font: Option<String>,
|
pub font: Option<String>,
|
||||||
pub font_size: Option<i32>,
|
pub font_size: Option<i32>,
|
||||||
|
pub stroke_size: Option<i32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Song> for Value {
|
impl From<&Song> for Value {
|
||||||
|
|
@ -160,6 +161,7 @@ impl FromRow<'_, SqliteRow> for Song {
|
||||||
}),
|
}),
|
||||||
font: row.try_get(6)?,
|
font: row.try_get(6)?,
|
||||||
font_size: row.try_get(1)?,
|
font_size: row.try_get(1)?,
|
||||||
|
stroke_size: None,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -790,7 +792,8 @@ You saved my soul"
|
||||||
background: Some(Background::try_from("file:///home/chris/nc/tfc/openlp/CMG - Bright Mountains 01.jpg").unwrap()),
|
background: Some(Background::try_from("file:///home/chris/nc/tfc/openlp/CMG - Bright Mountains 01.jpg").unwrap()),
|
||||||
text_alignment: Some(TextAlignment::MiddleCenter),
|
text_alignment: Some(TextAlignment::MiddleCenter),
|
||||||
font: Some("Quicksand Bold".to_string()),
|
font: Some("Quicksand Bold".to_string()),
|
||||||
font_size: Some(60)
|
font_size: Some(60),
|
||||||
|
stroke_size: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
use std::{io, path::PathBuf, sync::Arc};
|
use std::{io, path::PathBuf, sync::Arc};
|
||||||
|
|
||||||
use cosmic::{
|
use cosmic::{
|
||||||
Element, Task,
|
Apply, Element, Task,
|
||||||
dialog::file_chooser::{FileFilter, open::Dialog},
|
dialog::file_chooser::{FileFilter, open::Dialog},
|
||||||
iced::{Length, alignment::Vertical},
|
iced::{Color, Length, alignment::Vertical},
|
||||||
iced_wgpu::graphics::text::cosmic_text::fontdb,
|
iced_wgpu::graphics::text::cosmic_text::fontdb,
|
||||||
iced_widget::{column, row},
|
iced_widget::{column, row},
|
||||||
theme,
|
theme,
|
||||||
widget::{
|
widget::{
|
||||||
button, combo_box, container, horizontal_space, icon,
|
button, color_picker, combo_box, container, horizontal_space,
|
||||||
progress_bar, scrollable, text, text_editor, text_input,
|
icon, progress_bar, scrollable, spin_button, text,
|
||||||
|
text_editor, text_input, tooltip,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use dirs::font_dir;
|
use dirs::font_dir;
|
||||||
|
|
@ -44,6 +45,8 @@ pub struct SongEditor {
|
||||||
ccli: String,
|
ccli: String,
|
||||||
song_slides: Option<Vec<Slide>>,
|
song_slides: Option<Vec<Slide>>,
|
||||||
slide_state: SlideEditor,
|
slide_state: SlideEditor,
|
||||||
|
stroke_sizes: combo_box::State<i32>,
|
||||||
|
stroke_size: i32,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
|
|
@ -68,6 +71,7 @@ pub enum Message {
|
||||||
None,
|
None,
|
||||||
ChangeAuthor(String),
|
ChangeAuthor(String),
|
||||||
PauseVideo,
|
PauseVideo,
|
||||||
|
UpdateStrokeSize(i32),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SongEditor {
|
impl SongEditor {
|
||||||
|
|
@ -80,6 +84,7 @@ impl SongEditor {
|
||||||
.collect();
|
.collect();
|
||||||
fonts.dedup();
|
fonts.dedup();
|
||||||
fonts.sort();
|
fonts.sort();
|
||||||
|
let stroke_sizes = vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
let font_sizes = vec![
|
let font_sizes = vec![
|
||||||
"5".to_string(),
|
"5".to_string(),
|
||||||
"6".to_string(),
|
"6".to_string(),
|
||||||
|
|
@ -129,6 +134,8 @@ impl SongEditor {
|
||||||
ccli: "8".to_string(),
|
ccli: "8".to_string(),
|
||||||
slide_state: SlideEditor::default(),
|
slide_state: SlideEditor::default(),
|
||||||
song_slides: None,
|
song_slides: None,
|
||||||
|
stroke_sizes: combo_box::State::new(stroke_sizes),
|
||||||
|
stroke_size: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn update(&mut self, message: Message) -> Action {
|
pub fn update(&mut self, message: Message) -> Action {
|
||||||
|
|
@ -270,6 +277,14 @@ impl SongEditor {
|
||||||
video.set_paused(!paused);
|
video.set_paused(!paused);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Message::UpdateStrokeSize(size) => {
|
||||||
|
self.stroke_size = size;
|
||||||
|
if let Some(song) = &mut self.song {
|
||||||
|
song.stroke_size = Some(size);
|
||||||
|
let song = song.to_owned();
|
||||||
|
return self.update_song(song);
|
||||||
|
}
|
||||||
|
}
|
||||||
Message::UpdateSlides(slides) => {
|
Message::UpdateSlides(slides) => {
|
||||||
self.song_slides = Some(slides);
|
self.song_slides = Some(slides);
|
||||||
}
|
}
|
||||||
|
|
@ -404,14 +419,20 @@ order",
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
let font_selector = combo_box(
|
let font_selector = tooltip(
|
||||||
|
combo_box(
|
||||||
&self.fonts_combo,
|
&self.fonts_combo,
|
||||||
"Font",
|
"Font",
|
||||||
Some(selected_font),
|
Some(selected_font),
|
||||||
Message::ChangeFont,
|
Message::ChangeFont,
|
||||||
)
|
)
|
||||||
.width(300);
|
.width(300),
|
||||||
let font_size = combo_box(
|
"Font used in the song",
|
||||||
|
tooltip::Position::Bottom,
|
||||||
|
)
|
||||||
|
.gap(10);
|
||||||
|
let font_size = tooltip(
|
||||||
|
combo_box(
|
||||||
&self.font_sizes,
|
&self.font_sizes,
|
||||||
"Font Size",
|
"Font Size",
|
||||||
selected_font_size,
|
selected_font_size,
|
||||||
|
|
@ -421,8 +442,33 @@ order",
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
.width(theme::active().cosmic().space_xxl()),
|
||||||
|
"Font size",
|
||||||
|
tooltip::Position::Bottom,
|
||||||
|
)
|
||||||
|
.gap(10);
|
||||||
|
|
||||||
|
let stroke_size_button =
|
||||||
|
icon::from_name("./res/text-outline.svg")
|
||||||
|
.symbolic(true)
|
||||||
|
.apply(button::icon)
|
||||||
|
.tooltip("Set the stroke or outline of the text")
|
||||||
|
.on_press(Message::None)
|
||||||
|
.padding(5);
|
||||||
|
let stroke_width_selector = combo_box(
|
||||||
|
&self.stroke_sizes,
|
||||||
|
"0",
|
||||||
|
Some(&self.stroke_size),
|
||||||
|
|v| Message::UpdateStrokeSize(v),
|
||||||
|
)
|
||||||
.width(theme::active().cosmic().space_xxl());
|
.width(theme::active().cosmic().space_xxl());
|
||||||
|
|
||||||
|
let stroke_color_picker = color_picker::color_button(
|
||||||
|
Some(Message::None),
|
||||||
|
Some(Color::BLACK),
|
||||||
|
Length::Fixed(50.0),
|
||||||
|
);
|
||||||
|
|
||||||
let background_selector = button::icon(
|
let background_selector = button::icon(
|
||||||
icon::from_name("folder-pictures-symbolic").scale(2),
|
icon::from_name("folder-pictures-symbolic").scale(2),
|
||||||
)
|
)
|
||||||
|
|
@ -432,10 +478,14 @@ order",
|
||||||
.padding(10);
|
.padding(10);
|
||||||
|
|
||||||
row![
|
row![
|
||||||
text::body("Font:"),
|
// text::body("Font:"),
|
||||||
font_selector,
|
font_selector,
|
||||||
text::body("Font Size:"),
|
// text::body("Font Size:"),
|
||||||
font_size,
|
font_size,
|
||||||
|
text::body("Stroke Size:"),
|
||||||
|
stroke_width_selector,
|
||||||
|
text::body("Stroke Color:"),
|
||||||
|
stroke_color_picker,
|
||||||
horizontal_space(),
|
horizontal_space(),
|
||||||
background_selector
|
background_selector
|
||||||
]
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue