diff --git a/Changelog.txt b/Changelog.txt index 97eba352a..528d11723 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -4,6 +4,7 @@ * NEW: * Add "Text To Speech" - thx darnn/cvrle77/msjsc001 * Add burn-in batch mode - thx Leon/David + * Add new LRC with milliseconds format - thx eadmaster * IMPROVED: * Update Portuguese translation - thx hugok79 * Update Bulgarian translation - thx Калин @@ -20,6 +21,7 @@ * Fix possible crash in teletext reading - thx yellobyte * Fix unwanted text boxes background color change - thx Leon * Fix Whisper on selection in waveform in "translation mode" - thx rRobis + * Fix image export shadow when border is zero - thx pixelhunterX 4.0.5 (13th April 2024) diff --git a/LanguageBaseEnglish.xml b/LanguageBaseEnglish.xml index 7543a0b61..ee2497507 100644 --- a/LanguageBaseEnglish.xml +++ b/LanguageBaseEnglish.xml @@ -2129,6 +2129,8 @@ Download and continue? Even-numbered lines Duration less than Duration greater than + CPS less than + CPS greater than Exactly one line Exactly two lines More than two lines diff --git a/src/ui/Forms/ModifySelection.cs b/src/ui/Forms/ModifySelection.cs index 2419ff755..63957bdba 100644 --- a/src/ui/Forms/ModifySelection.cs +++ b/src/ui/Forms/ModifySelection.cs @@ -28,13 +28,15 @@ namespace Nikse.SubtitleEdit.Forms private const int FunctionEven = 7; private const int FunctionDurationLessThan = 8; private const int FunctionDurationGreaterThan = 9; - private const int FunctionExactlyOneLine = 10; - private const int FunctionExactlyTwoLines = 11; - private const int FunctionMoreThanTwoLines = 12; - private const int FunctionBookmarked = 13; - private const int FunctionBlankLines = 14; - private const int FunctionStyle = 15; - private const int FunctionActor = 16; + private const int FunctionCpsLessThan = 10; + private const int FunctionCpsGreaterThan = 11; + private const int FunctionExactlyOneLine = 12; + private const int FunctionExactlyTwoLines = 13; + private const int FunctionMoreThanTwoLines = 14; + private const int FunctionBookmarked = 15; + private const int FunctionBlankLines = 16; + private const int FunctionStyle = 17; + private const int FunctionActor = 18; private const string ContainsString = "Contains"; private const string StartsWith = "Starts with"; @@ -46,6 +48,8 @@ namespace Nikse.SubtitleEdit.Forms private const string Even = "Even"; private const string DurationLessThan = "Duration <"; private const string DurationGreaterThan = "Duration >"; + private const string CpsLessThan = "CPS <"; + private const string CpsGreaterThan = "CPS >"; private const string ExactlyOneLine = "Exactly one line"; private const string ExactlyTwoLines = "Exactly two lines"; private const string MoreThanTwoLines = "More than two lines"; @@ -97,6 +101,8 @@ namespace Nikse.SubtitleEdit.Forms comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.EvenLines); comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.DurationLessThan); comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.DurationGreaterThan); + comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.CpsLessThan); + comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.CpsGreaterThan); comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.ExactlyOneLine); comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.ExactlyTwoLines); comboBoxRule.Items.Add(LanguageSettings.Current.ModifySelection.MoreThanTwoLines); @@ -142,6 +148,12 @@ namespace Nikse.SubtitleEdit.Forms case DurationGreaterThan: comboBoxRule.SelectedIndex = FunctionDurationGreaterThan; break; + case CpsLessThan: + comboBoxRule.SelectedIndex = FunctionCpsLessThan; + break; + case CpsGreaterThan: + comboBoxRule.SelectedIndex = FunctionCpsGreaterThan; + break; case ExactlyOneLine: comboBoxRule.SelectedIndex = FunctionExactlyOneLine; break; @@ -226,6 +238,12 @@ namespace Nikse.SubtitleEdit.Forms case FunctionDurationGreaterThan: Configuration.Settings.Tools.ModifySelectionRule = DurationGreaterThan; break; + case FunctionCpsLessThan: + Configuration.Settings.Tools.ModifySelectionRule = CpsLessThan; + break; + case FunctionCpsGreaterThan: + Configuration.Settings.Tools.ModifySelectionRule = CpsGreaterThan; + break; case FunctionExactlyOneLine: Configuration.Settings.Tools.ModifySelectionRule = ExactlyOneLine; break; @@ -311,7 +329,7 @@ namespace Nikse.SubtitleEdit.Forms } } - for (int i = 0; i < _subtitle.Paragraphs.Count; i++) + for (var i = 0; i < _subtitle.Paragraphs.Count; i++) { if ((radioButtonSubtractFromSelection.Checked || radioButtonIntersect.Checked) && _subtitleListView.Items[i].Selected || !radioButtonSubtractFromSelection.Checked && !radioButtonIntersect.Checked) @@ -397,6 +415,20 @@ namespace Nikse.SubtitleEdit.Forms listViewItems.Add(MakeListViewItem(p, i)); } } + else if (comboBoxRule.SelectedIndex == FunctionCpsLessThan) // Cps less than + { + if (Utilities.GetCharactersPerSecond(p) < (double)numericUpDownDuration.Value) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } + else if (comboBoxRule.SelectedIndex == FunctionCpsGreaterThan) // Cps greater than + { + if (Utilities.GetCharactersPerSecond(p) > (double)numericUpDownDuration.Value) + { + listViewItems.Add(MakeListViewItem(p, i)); + } + } else if (comboBoxRule.SelectedIndex == FunctionExactlyOneLine) { if (p.Text.SplitToLines().Count == 1) @@ -504,28 +536,37 @@ namespace Nikse.SubtitleEdit.Forms { textBoxText.Visible = true; listViewStyles.Visible = false; - numericUpDownDuration.Visible = comboBoxRule.SelectedIndex == FunctionDurationLessThan || comboBoxRule.SelectedIndex == FunctionDurationGreaterThan; + numericUpDownDuration.Visible = + comboBoxRule.SelectedIndex == FunctionDurationLessThan || + comboBoxRule.SelectedIndex == FunctionDurationGreaterThan || + comboBoxRule.SelectedIndex == FunctionCpsLessThan || + comboBoxRule.SelectedIndex == FunctionCpsGreaterThan; + if (comboBoxRule.SelectedIndex == FunctionRegEx) // RegEx { - // creat new context menu only if textBoxText doesn't already has one, this will prevent unnecessary + // create new context menu only if textBoxText doesn't already has one, this will prevent unnecessary // allocation regex option is already selected and user re-select it - textBoxText.ContextMenuStrip = textBoxText.ContextMenuStrip ?? + textBoxText.ContextMenuStrip = textBoxText.ContextMenuStrip ?? FindReplaceDialogHelper.GetRegExContextMenu(new NativeTextBoxAdapter(textBoxText)); checkBoxCaseSensitive.Enabled = false; } - else if (comboBoxRule.SelectedIndex == FunctionOdd || - comboBoxRule.SelectedIndex == FunctionEven || - comboBoxRule.SelectedIndex == FunctionExactlyOneLine || - comboBoxRule.SelectedIndex == FunctionExactlyTwoLines || - comboBoxRule.SelectedIndex == FunctionMoreThanTwoLines || - comboBoxRule.SelectedIndex == FunctionBookmarked || + else if (comboBoxRule.SelectedIndex == FunctionOdd || + comboBoxRule.SelectedIndex == FunctionEven || + comboBoxRule.SelectedIndex == FunctionExactlyOneLine || + comboBoxRule.SelectedIndex == FunctionExactlyTwoLines || + comboBoxRule.SelectedIndex == FunctionMoreThanTwoLines || + comboBoxRule.SelectedIndex == FunctionBookmarked || comboBoxRule.SelectedIndex == FunctionBlankLines) { checkBoxCaseSensitive.Enabled = false; textBoxText.ContextMenuStrip = null; textBoxText.Visible = false; } - else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan || comboBoxRule.SelectedIndex == FunctionDurationGreaterThan || comboBoxRule.SelectedIndex == FunctionAllUppercase) + else if (comboBoxRule.SelectedIndex == FunctionDurationLessThan || + comboBoxRule.SelectedIndex == FunctionDurationGreaterThan || + comboBoxRule.SelectedIndex == FunctionCpsLessThan || + comboBoxRule.SelectedIndex == FunctionCpsGreaterThan || + comboBoxRule.SelectedIndex == FunctionAllUppercase) { checkBoxCaseSensitive.Enabled = false; listViewStyles.Visible = false; @@ -539,7 +580,7 @@ namespace Nikse.SubtitleEdit.Forms numericUpDownDuration.Value = Configuration.Settings.General.SubtitleMinimumDisplayMilliseconds; } } - else + else if (comboBoxRule.SelectedIndex == FunctionDurationGreaterThan) { if (numericUpDownDuration.Value == 0 && Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds >= numericUpDownDuration.Minimum && @@ -548,6 +589,14 @@ namespace Nikse.SubtitleEdit.Forms numericUpDownDuration.Value = Configuration.Settings.General.SubtitleMaximumDisplayMilliseconds; } } + else if (comboBoxRule.SelectedIndex == FunctionCpsLessThan) + { + numericUpDownDuration.Value = (int)Math.Round(Math.Max(10, Configuration.Settings.General.SubtitleOptimalCharactersPerSeconds - 5), MidpointRounding.AwayFromZero); + } + else if (comboBoxRule.SelectedIndex == FunctionCpsGreaterThan) + { + numericUpDownDuration.Value = (int)Math.Round(Configuration.Settings.General.SubtitleMaximumCharactersPerSeconds, MidpointRounding.AwayFromZero); + } } else if (comboBoxRule.SelectedIndex == FunctionStyle) { diff --git a/src/ui/Logic/Language.cs b/src/ui/Logic/Language.cs index 44da8cc9c..3c387d048 100644 --- a/src/ui/Logic/Language.cs +++ b/src/ui/Logic/Language.cs @@ -2461,6 +2461,8 @@ namespace Nikse.SubtitleEdit.Logic EvenLines = "Even-numbered lines", DurationLessThan = "Duration less than", DurationGreaterThan = "Duration greater than", + CpsLessThan = "CPS less than", + CpsGreaterThan = "CPS greater than", ExactlyOneLine = "Exactly one line", ExactlyTwoLines = "Exactly two lines", MoreThanTwoLines = "More than two lines", diff --git a/src/ui/Logic/LanguageDeserializer.cs b/src/ui/Logic/LanguageDeserializer.cs index 643f3c6d8..0314a86ec 100644 --- a/src/ui/Logic/LanguageDeserializer.cs +++ b/src/ui/Logic/LanguageDeserializer.cs @@ -5770,6 +5770,12 @@ namespace Nikse.SubtitleEdit.Logic case "ModifySelection/DurationGreaterThan": language.ModifySelection.DurationGreaterThan = reader.Value; break; + case "ModifySelection/CpsLessThan": + language.ModifySelection.CpsLessThan = reader.Value; + break; + case "ModifySelection/CpsGreaterThan": + language.ModifySelection.CpsGreaterThan = reader.Value; + break; case "ModifySelection/ExactlyOneLine": language.ModifySelection.ExactlyOneLine = reader.Value; break; diff --git a/src/ui/Logic/LanguageStructure.cs b/src/ui/Logic/LanguageStructure.cs index 4a7e81594..a90171f46 100644 --- a/src/ui/Logic/LanguageStructure.cs +++ b/src/ui/Logic/LanguageStructure.cs @@ -2271,6 +2271,8 @@ public string EvenLines { get; set; } public string DurationLessThan { get; set; } public string DurationGreaterThan { get; set; } + public string CpsLessThan { get; set; } + public string CpsGreaterThan { get; set; } public string ExactlyOneLine { get; set; } public string ExactlyTwoLines { get; set; } public string MoreThanTwoLines { get; set; }