Add font family selector for watermark text
This commit is contained in:
@@ -66,6 +66,7 @@ pub struct JobConfig {
|
||||
pub watermark_opacity: f32,
|
||||
pub watermark_font_size: f32,
|
||||
pub watermark_color: [u8; 4],
|
||||
pub watermark_font_family: String,
|
||||
pub watermark_use_image: bool,
|
||||
// Rename
|
||||
pub rename_enabled: bool,
|
||||
@@ -360,6 +361,7 @@ fn build_ui(app: &adw::Application) {
|
||||
watermark_opacity: 0.5,
|
||||
watermark_font_size: 24.0,
|
||||
watermark_color: [255, 255, 255, 255],
|
||||
watermark_font_family: String::new(),
|
||||
watermark_use_image: false,
|
||||
rename_enabled: if remember { sess_state.rename_enabled.unwrap_or(false) } else { false },
|
||||
rename_prefix: String::new(),
|
||||
@@ -1666,6 +1668,7 @@ fn run_processing(_window: &adw::ApplicationWindow, ui: &WizardUi) {
|
||||
font_size: cfg.watermark_font_size,
|
||||
opacity: cfg.watermark_opacity,
|
||||
color: cfg.watermark_color,
|
||||
font_family: if cfg.watermark_font_family.is_empty() { None } else { Some(cfg.watermark_font_family.clone()) },
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2595,6 +2598,7 @@ fn build_preset_from_config(cfg: &JobConfig, name: &str) -> pixstrip_core::prese
|
||||
font_size: cfg.watermark_font_size,
|
||||
opacity: cfg.watermark_opacity,
|
||||
color: cfg.watermark_color,
|
||||
font_family: if cfg.watermark_font_family.is_empty() { None } else { Some(cfg.watermark_font_family.clone()) },
|
||||
})
|
||||
} else {
|
||||
None
|
||||
|
||||
@@ -61,7 +61,31 @@ pub fn build_watermark_page(state: &AppState) -> adw::NavigationPage {
|
||||
.adjustment(>k::Adjustment::new(cfg.watermark_font_size as f64, 8.0, 200.0, 1.0, 10.0, 0.0))
|
||||
.build();
|
||||
|
||||
// Font family picker
|
||||
let font_row = adw::ActionRow::builder()
|
||||
.title("Font Family")
|
||||
.subtitle("Choose a typeface for the watermark text")
|
||||
.build();
|
||||
|
||||
let font_dialog = gtk::FontDialog::builder()
|
||||
.title("Choose Watermark Font")
|
||||
.modal(true)
|
||||
.build();
|
||||
let font_button = gtk::FontDialogButton::builder()
|
||||
.dialog(&font_dialog)
|
||||
.valign(gtk::Align::Center)
|
||||
.build();
|
||||
|
||||
// Set initial font if one was previously selected
|
||||
if !cfg.watermark_font_family.is_empty() {
|
||||
let desc = gtk::pango::FontDescription::from_string(&cfg.watermark_font_family);
|
||||
font_button.set_font_desc(&desc);
|
||||
}
|
||||
|
||||
font_row.add_suffix(&font_button);
|
||||
|
||||
text_group.add(&text_row);
|
||||
text_group.add(&font_row);
|
||||
text_group.add(&font_size_row);
|
||||
content.append(&text_group);
|
||||
|
||||
@@ -415,6 +439,16 @@ pub fn build_watermark_page(state: &AppState) -> adw::NavigationPage {
|
||||
jc.borrow_mut().watermark_font_size = row.value() as f32;
|
||||
});
|
||||
}
|
||||
// Wire font family picker
|
||||
{
|
||||
let jc = state.job_config.clone();
|
||||
font_button.connect_font_desc_notify(move |btn| {
|
||||
let desc = btn.font_desc();
|
||||
if let Some(family) = desc.family() {
|
||||
jc.borrow_mut().watermark_font_family = family.to_string();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Wire position grid buttons
|
||||
for (i, btn) in buttons.iter().enumerate() {
|
||||
let jc = state.job_config.clone();
|
||||
|
||||
Reference in New Issue
Block a user