mirror of
https://github.com/narrrl/proton-stream.git
synced 2026-11-03 16:41:26 +01:00
feat(core,player,app): subtitle size, background and colour settings
Plain-text subtitles (SRT) were drawn in mpv's bare default, thin white text that bright scenes swallow. Settings → Playback now picks a size, an outline or a dark box, and white or yellow text. Styled (ASS) tracks keep their own look and take only the size. The box options are mpv 0.38's, so they are set best effort: an older libmpv logs and plays on. The style syncs with the other playback settings, and the Android bridge keeps the stored style instead of resetting it on save.
This commit is contained in:
1 parent
658c620c82
commit
65a669e231
9 files changed
+265
-3
No files matched your search
@@ -235,6 +235,8 @@ pub enum Action {
|
||||
subtitles: bool,
|
||||
subtitle: Option<String>,
|
||||
},
|
||||
/// How plain subtitles look, from the next file.
|
||||
SetSubtitleStyle(pstr_core::prefs::SubtitleStyle),
|
||||
/// Play faster or slower, and keep doing so for the next file.
|
||||
SetSpeed(f64),
|
||||
/// Seek past openings and credits without being asked.
|
||||
@@ -1938,6 +1940,11 @@ impl App {
|
||||
prefs.subtitle_language = subtitle;
|
||||
self.engine.set_playback_prefs(prefs, true);
|
||||
}
|
||||
Action::SetSubtitleStyle(style) => {
|
||||
let mut prefs = self.engine.playback_prefs();
|
||||
prefs.subtitle_style = style;
|
||||
self.engine.set_playback_prefs(prefs, true);
|
||||
}
|
||||
Action::SetAppearance(appearance) => {
|
||||
self.engine.set_appearance(appearance);
|
||||
theme::apply(ctx, appearance);
|
||||
|
||||
@@ -494,6 +494,7 @@ fn from_prefs(
|
||||
.and_then(|p| p.subtitle_language.clone())
|
||||
.or_else(|| prefs.subtitle_language.clone()),
|
||||
subtitles: show.map(|p| p.subtitles).unwrap_or(prefs.subtitles),
|
||||
subtitle_style: prefs.subtitle_style,
|
||||
// Carried from file to file, like the volume: somebody who watches at
|
||||
// 1.25 watches the next episode at 1.25 too.
|
||||
options: vec![("speed".into(), format!("{:.2}", prefs.speed))],
|
||||
|
||||
@@ -7,7 +7,9 @@
|
||||
|
||||
use pstr_core::appearance::{Accent, Appearance, Flavor, Tiles};
|
||||
use pstr_core::metadata::{MetadataConfig, ProviderId, TitleNames};
|
||||
use pstr_core::prefs::PlaybackPrefs;
|
||||
use pstr_core::prefs::{
|
||||
PlaybackPrefs, SubtitleBackdrop, SubtitleColour, SubtitleSize, SubtitleStyle,
|
||||
};
|
||||
use pstr_player::LANGUAGES;
|
||||
|
||||
use crate::app::Action;
|
||||
@@ -315,6 +317,7 @@ fn playback_form(ui: &mut egui::Ui, prefs: Prefs<'_>, actions: &mut Vec<Action>)
|
||||
),
|
||||
|ui| {
|
||||
languages(ui, prefs.playback, actions);
|
||||
subtitle_style(ui, prefs.playback.subtitle_style, actions);
|
||||
let mut autoplay = prefs.autoplay;
|
||||
ui::widgets::settings_row(
|
||||
ui,
|
||||
@@ -428,6 +431,52 @@ fn languages(ui: &mut egui::Ui, playback: &PlaybackPrefs, actions: &mut Vec<Acti
|
||||
);
|
||||
}
|
||||
|
||||
/// How plain subtitles are drawn. A styled track keeps its own look apart
|
||||
/// from the size; see [`pstr_core::prefs::SubtitleStyle`].
|
||||
fn subtitle_style(ui: &mut egui::Ui, style: SubtitleStyle, actions: &mut Vec<Action>) {
|
||||
let mut chosen = style;
|
||||
ui::widgets::settings_row(
|
||||
ui,
|
||||
"Subtitle size",
|
||||
Some("Styled subtitles are scaled too. From the next file."),
|
||||
|ui| {
|
||||
egui::ComboBox::from_id_salt("subtitle-size")
|
||||
.selected_text(chosen.size.label())
|
||||
.show_ui(ui, |ui| {
|
||||
for size in SubtitleSize::ALL {
|
||||
ui.selectable_value(&mut chosen.size, size, size.label());
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
ui::widgets::settings_row(
|
||||
ui,
|
||||
"Subtitle background",
|
||||
Some("A box reads on bright scenes. Plain subtitles only; styled ones keep their own."),
|
||||
|ui| {
|
||||
egui::ComboBox::from_id_salt("subtitle-backdrop")
|
||||
.selected_text(chosen.backdrop.label())
|
||||
.show_ui(ui, |ui| {
|
||||
for backdrop in SubtitleBackdrop::ALL {
|
||||
ui.selectable_value(&mut chosen.backdrop, backdrop, backdrop.label());
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
ui::widgets::settings_row(ui, "Subtitle colour", Some("Plain subtitles only."), |ui| {
|
||||
egui::ComboBox::from_id_salt("subtitle-colour")
|
||||
.selected_text(chosen.colour.label())
|
||||
.show_ui(ui, |ui| {
|
||||
for colour in SubtitleColour::ALL {
|
||||
ui.selectable_value(&mut chosen.colour, colour, colour.label());
|
||||
}
|
||||
});
|
||||
});
|
||||
if chosen != style {
|
||||
actions.push(Action::SetSubtitleStyle(chosen));
|
||||
}
|
||||
}
|
||||
|
||||
/// The streaming cache: how big it may get, and a way to empty it.
|
||||
fn storage_form(ui: &mut egui::Ui, prefs: Prefs<'_>, actions: &mut Vec<Action>) {
|
||||
ui::widgets::settings_group(
|
||||
|
||||
Reference in new issue
Block a user