diff --git a/src/base_grid.cpp b/src/base_grid.cpp index 4961e90d6..89ddb004a 100644 --- a/src/base_grid.cpp +++ b/src/base_grid.cpp @@ -159,6 +159,7 @@ void BaseGrid::OnShowColMenu(wxCommandEvent &event) { int item = event.GetId() - MENU_SHOW_COL; bool new_value = !columns_visible[item]; + columns_visible.resize(columns.size(), true); columns_visible[item] = new_value; OPT_SET("Subtitle/Grid/Column")->SetListBool(columns_visible); columns[item]->SetVisible(new_value); diff --git a/src/grid_column.cpp b/src/grid_column.cpp index 07b79c98d..551646979 100644 --- a/src/grid_column.cpp +++ b/src/grid_column.cpp @@ -250,6 +250,9 @@ wxColor blend(wxColor fg, wxColor bg, double alpha) { class GridColumnCPS final : public GridColumn { const agi::OptionValue *ignore_whitespace = OPT_GET("Subtitle/Character Counter/Ignore Whitespace"); const agi::OptionValue *ignore_punctuation = OPT_GET("Subtitle/Character Counter/Ignore Punctuation"); + const agi::OptionValue *cps_warn = OPT_GET("Subtitle/Character Counter/CPS Warning Threshold"); + const agi::OptionValue *cps_error = OPT_GET("Subtitle/Character Counter/CPS Error Threshold"); + const agi::OptionValue *bg_color = OPT_GET("Colour/Subtitle Grid/CPS Error"); public: COLUMN_HEADER(_("CPS")) @@ -289,12 +292,11 @@ public: wxSize ext = dc.GetTextExtent(str); auto tc = dc.GetTextForeground(); - int cps_min = 15; - int cps_max = 30; + int cps_min = cps_warn->GetInt(); + int cps_max = std::max(cps_min, cps_error->GetInt()); if (cps > cps_min) { double alpha = std::min((double)(cps - cps_min + 1) / (cps_max - cps_min + 1), 1.0); - auto bg = dc.GetBrush().GetColour(); - dc.SetBrush(wxBrush(blend(wxColor(255, 0, 0), bg, alpha))); + dc.SetBrush(wxBrush(blend(to_wx(bg_color->GetColor()), dc.GetBrush().GetColour(), alpha))); dc.SetPen(*wxTRANSPARENT_PEN); dc.DrawRectangle(x, y + 1, width, ext.GetHeight() + 3); dc.SetTextForeground(blend(*wxBLACK, tc, alpha)); diff --git a/src/libresrc/default_config.json b/src/libresrc/default_config.json index 19b97358e..5c26e32b2 100644 --- a/src/libresrc/default_config.json +++ b/src/libresrc/default_config.json @@ -216,6 +216,7 @@ "Selection" : "rgb(206, 255, 231)" }, "Collision" : "rgb(255,0,0)", + "CPS Error" : "rgb(255,0,0)", "Header" : "rgb(165, 207, 231)", "Left Column" : "rgb(196, 236, 201)", "Lines" : "rgb(190,190,190)", @@ -352,7 +353,9 @@ "Subtitle" : { "Character Counter" : { "Ignore Whitespace" : true, - "Ignore Punctuation" : true + "Ignore Punctuation" : true, + "CPS Warning Threshold" : 15, + "CPS Error Threshold" : 30 }, "Character Limit" : 40, "Default Resolution" : { @@ -366,15 +369,6 @@ }, "Grid" : { "Column" : [ - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, {"bool" : true} ], "Focus Allow" : true, diff --git a/src/libresrc/osx/default_config.json b/src/libresrc/osx/default_config.json index 8236175a0..f20c0bf42 100644 --- a/src/libresrc/osx/default_config.json +++ b/src/libresrc/osx/default_config.json @@ -216,6 +216,7 @@ "Selection" : "rgb(206, 255, 231)" }, "Collision" : "rgb(255,0,0)", + "CPS Error" : "rgb(255,0,0)", "Header" : "rgb(165, 207, 231)", "Left Column" : "rgb(196, 236, 201)", "Lines" : "rgb(190,190,190)", @@ -352,7 +353,9 @@ "Subtitle" : { "Character Counter" : { "Ignore Whitespace" : true, - "Ignore Punctuation" : true + "Ignore Punctuation" : true, + "CPS Warning Threshold" : 15, + "CPS Error Threshold" : 30 }, "Character Limit" : 40, "Default Resolution" : { @@ -366,15 +369,6 @@ }, "Grid" : { "Column" : [ - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, - {"bool" : true}, {"bool" : true} ], "Focus Allow" : true, diff --git a/src/preferences.cpp b/src/preferences.cpp index 06608f443..2d2f4093c 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -194,6 +194,8 @@ Interface::Interface(wxTreebook *book, Preferences *parent): OptionPage(book, pa wxFlexGridSizer *character_count = PageSizer(_("Character Counter")); OptionAdd(character_count, _("Maximum characters per line"), "Subtitle/Character Limit", 0, 1000); + OptionAdd(character_count, _("Characters Per Second Warning Threshold"), "Subtitle/Character Counter/CPS Warning Threshold", 0, 1000); + OptionAdd(character_count, _("Characters Per Second Error Threshold"), "Subtitle/Character Counter/CPS Error Threshold", 0, 1000); OptionAdd(character_count, _("Ignore whitespace"), "Subtitle/Character Counter/Ignore Whitespace"); OptionAdd(character_count, _("Ignore punctuation"), "Subtitle/Character Counter/Ignore Punctuation"); @@ -255,6 +257,7 @@ Interface_Colours::Interface_Colours(wxTreebook *book, Preferences *parent): Opt OptionAdd(grid, _("Left Column"), "Colour/Subtitle Grid/Left Column"); OptionAdd(grid, _("Active Line Border"), "Colour/Subtitle Grid/Active Border"); OptionAdd(grid, _("Lines"), "Colour/Subtitle Grid/Lines"); + OptionAdd(grid, _("CPS Error"), "Colour/Subtitle Grid/CPS Error"); sizer = main_sizer;