Make the CPS warning thresholds and color customizable

This commit is contained in:
Thomas Goyne 2014-04-21 11:01:39 -07:00
parent 7bc35cecb7
commit 1bd3572054
5 changed files with 18 additions and 24 deletions

View File

@ -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);

View File

@ -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<int>(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));

View File

@ -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,

View File

@ -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,

View File

@ -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;