mirror of https://github.com/odrling/Aegisub
Make NumValidator less bizzare
Originally committed to SVN as r5248.
This commit is contained in:
parent
a8ebc1e456
commit
5f0d5757be
|
@ -104,10 +104,8 @@ DialogProperties::DialogProperties (wxWindow *parent, AssFile *subs)
|
||||||
|
|
||||||
// Resolution box
|
// Resolution box
|
||||||
wxSizer *ResSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Resolution"));
|
wxSizer *ResSizer = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Resolution"));
|
||||||
ResXValue = subs->GetScriptInfo(_T("PlayResX"));
|
ResX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,20),0,NumValidator(subs->GetScriptInfo("PlayResX")));
|
||||||
ResYValue = subs->GetScriptInfo(_T("PlayResY"));
|
ResY = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,20),0,NumValidator(subs->GetScriptInfo("PlayResY")));
|
||||||
ResX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,20),0,NumValidator(&ResXValue));
|
|
||||||
ResY = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,20),0,NumValidator(&ResYValue));
|
|
||||||
wxStaticText *ResText = new wxStaticText(this,-1,_T("x"));
|
wxStaticText *ResText = new wxStaticText(this,-1,_T("x"));
|
||||||
wxButton *FromVideo = new wxButton(this,BUTTON_FROM_VIDEO,_("From video"));
|
wxButton *FromVideo = new wxButton(this,BUTTON_FROM_VIDEO,_("From video"));
|
||||||
if (!VideoContext::Get()->IsLoaded()) FromVideo->Enable(false);
|
if (!VideoContext::Get()->IsLoaded()) FromVideo->Enable(false);
|
||||||
|
|
|
@ -91,12 +91,6 @@ class DialogProperties : public wxDialog {
|
||||||
wxCheckBox *ScaleBorder;
|
wxCheckBox *ScaleBorder;
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString ResXValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString ResYValue;
|
|
||||||
|
|
||||||
void OnOK(wxCommandEvent &event);
|
void OnOK(wxCommandEvent &event);
|
||||||
void OnSetFromVideo(wxCommandEvent &event);
|
void OnSetFromVideo(wxCommandEvent &event);
|
||||||
int SetInfoIfDifferent(wxString key,wxString value);
|
int SetInfoIfDifferent(wxString key,wxString value);
|
||||||
|
|
|
@ -99,10 +99,8 @@ DialogResample::DialogResample(agi::Context *c)
|
||||||
wxSizer *ResSizer = new wxBoxSizer(wxHORIZONTAL);
|
wxSizer *ResSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||||
int sw,sh;
|
int sw,sh;
|
||||||
c->ass->GetResolution(sw,sh);
|
c->ass->GetResolution(sw,sh);
|
||||||
ResXValue = wxString::Format(_T("%i"),sw);
|
ResX = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(wxString::Format("%i",sw)));
|
||||||
ResYValue = wxString::Format(_T("%i"),sh);
|
ResY = new wxTextCtrl(this,-1,"",wxDefaultPosition,wxSize(50,-1),0,NumValidator(wxString::Format("%i",sh)));
|
||||||
ResX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,-1),0,NumValidator(&ResXValue));
|
|
||||||
ResY = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(50,-1),0,NumValidator(&ResYValue));
|
|
||||||
wxStaticText *ResText = new wxStaticText(this,-1,_("x"));
|
wxStaticText *ResText = new wxStaticText(this,-1,_("x"));
|
||||||
wxButton *FromVideo = new wxButton(this,BUTTON_DEST_FROM_VIDEO,_("From video"));
|
wxButton *FromVideo = new wxButton(this,BUTTON_DEST_FROM_VIDEO,_("From video"));
|
||||||
if (!VideoContext::Get()->IsLoaded()) FromVideo->Enable(false);
|
if (!VideoContext::Get()->IsLoaded()) FromVideo->Enable(false);
|
||||||
|
|
|
@ -54,11 +54,6 @@ class AssOverrideParameter;
|
||||||
class DialogResample : public wxDialog {
|
class DialogResample : public wxDialog {
|
||||||
agi::Context *c;
|
agi::Context *c;
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString ResXValue,ResYValue;
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
wxTextCtrl *ResX;
|
wxTextCtrl *ResX;
|
||||||
|
|
||||||
|
|
|
@ -108,14 +108,14 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *style, agi::Co
|
||||||
SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24)));
|
SetIcon(BitmapToIcon(GETIMAGE(style_toolbutton_24)));
|
||||||
|
|
||||||
// Prepare control values
|
// Prepare control values
|
||||||
FontSizeValue = AegiFloatToString(style->fontsize);
|
wxString FontSizeValue = AegiFloatToString(style->fontsize);
|
||||||
OutlineValue = AegiFloatToString(style->outline_w);
|
wxString OutlineValue = AegiFloatToString(style->outline_w);
|
||||||
ShadowValue = AegiFloatToString(style->shadow_w);
|
wxString ShadowValue = AegiFloatToString(style->shadow_w);
|
||||||
ScaleXValue = AegiFloatToString(style->scalex);
|
wxString ScaleXValue = AegiFloatToString(style->scalex);
|
||||||
ScaleYValue = AegiFloatToString(style->scaley);
|
wxString ScaleYValue = AegiFloatToString(style->scaley);
|
||||||
AngleValue = AegiFloatToString(style->angle);
|
wxString AngleValue = AegiFloatToString(style->angle);
|
||||||
EncodingValue = AegiIntegerToString(style->encoding);
|
wxString EncodingValue = AegiIntegerToString(style->encoding);
|
||||||
SpacingValue = AegiFloatToString(style->spacing);
|
wxString SpacingValue = AegiFloatToString(style->spacing);
|
||||||
wxString alignValues[9] = { _T("7"),_T("8"),_T("9"),_T("4"),_T("5"),_T("6"),_T("1"),_T("2"),_T("3") };
|
wxString alignValues[9] = { _T("7"),_T("8"),_T("9"),_T("4"),_T("5"),_T("6"),_T("1"),_T("2"),_T("3") };
|
||||||
wxArrayString fontList = wxFontEnumerator::GetFacenames();
|
wxArrayString fontList = wxFontEnumerator::GetFacenames();
|
||||||
fontList.Sort();
|
fontList.Sort();
|
||||||
|
@ -136,7 +136,7 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *style, agi::Co
|
||||||
// Create controls
|
// Create controls
|
||||||
StyleName = new wxTextCtrl(this,-1,style->name);
|
StyleName = new wxTextCtrl(this,-1,style->name);
|
||||||
FontName = new wxComboBox(this,TEXT_FONT_NAME,style->font,wxDefaultPosition,wxSize(150,-1),0,0,wxCB_DROPDOWN);
|
FontName = new wxComboBox(this,TEXT_FONT_NAME,style->font,wxDefaultPosition,wxSize(150,-1),0,0,wxCB_DROPDOWN);
|
||||||
FontSize = new wxTextCtrl(this,TEXT_FONT_SIZE,_T(""),wxDefaultPosition,wxSize(50,-1),0,NumValidator(&FontSizeValue,true,false));
|
FontSize = new wxTextCtrl(this,TEXT_FONT_SIZE,_T(""),wxDefaultPosition,wxSize(50,-1),0,NumValidator(FontSizeValue,true,false));
|
||||||
BoxBold = new wxCheckBox(this,CHECKBOX_STYLE_BOLD,_("Bold"));
|
BoxBold = new wxCheckBox(this,CHECKBOX_STYLE_BOLD,_("Bold"));
|
||||||
BoxItalic = new wxCheckBox(this,CHECKBOX_STYLE_ITALIC,_("Italic"));
|
BoxItalic = new wxCheckBox(this,CHECKBOX_STYLE_ITALIC,_("Italic"));
|
||||||
BoxUnderline = new wxCheckBox(this,CHECKBOX_STYLE_UNDERLINE,_("Underline"));
|
BoxUnderline = new wxCheckBox(this,CHECKBOX_STYLE_UNDERLINE,_("Underline"));
|
||||||
|
@ -152,13 +152,13 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *style, agi::Co
|
||||||
for (int i=0;i<3;i++) margin[i] = new wxSpinCtrl(this,TEXT_MARGIN_L+i,AegiFloatToString(style->Margin[i]),wxDefaultPosition,wxSize(60,-1),wxSP_ARROW_KEYS,0,9999,style->Margin[i]);
|
for (int i=0;i<3;i++) margin[i] = new wxSpinCtrl(this,TEXT_MARGIN_L+i,AegiFloatToString(style->Margin[i]),wxDefaultPosition,wxSize(60,-1),wxSP_ARROW_KEYS,0,9999,style->Margin[i]);
|
||||||
margin[3] = 0;
|
margin[3] = 0;
|
||||||
Alignment = new wxRadioBox(this, RADIO_ALIGNMENT, _("Alignment"), wxDefaultPosition, wxDefaultSize, 9, alignValues, 3, wxRA_SPECIFY_COLS);
|
Alignment = new wxRadioBox(this, RADIO_ALIGNMENT, _("Alignment"), wxDefaultPosition, wxDefaultSize, 9, alignValues, 3, wxRA_SPECIFY_COLS);
|
||||||
Outline = new wxTextCtrl(this,TEXT_OUTLINE,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&OutlineValue,true,false));
|
Outline = new wxTextCtrl(this,TEXT_OUTLINE,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(OutlineValue,true,false));
|
||||||
Shadow = new wxTextCtrl(this,TEXT_SHADOW,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&ShadowValue,true,false));
|
Shadow = new wxTextCtrl(this,TEXT_SHADOW,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(ShadowValue,true,false));
|
||||||
OutlineType = new wxCheckBox(this,CHECKBOX_OUTLINE,_("Opaque box"));
|
OutlineType = new wxCheckBox(this,CHECKBOX_OUTLINE,_("Opaque box"));
|
||||||
ScaleX = new wxTextCtrl(this,TEXT_SCALE_X,_T(""),wxDefaultPosition, wxSize(70,20),0,NumValidator(&ScaleXValue,true,false));
|
ScaleX = new wxTextCtrl(this,TEXT_SCALE_X,_T(""),wxDefaultPosition, wxSize(70,20),0,NumValidator(ScaleXValue,true,false));
|
||||||
ScaleY = new wxTextCtrl(this,TEXT_SCALE_Y,_T(""),wxDefaultPosition, wxSize(70,20),0,NumValidator(&ScaleYValue,true,false));
|
ScaleY = new wxTextCtrl(this,TEXT_SCALE_Y,_T(""),wxDefaultPosition, wxSize(70,20),0,NumValidator(ScaleYValue,true,false));
|
||||||
Angle = new wxTextCtrl(this,TEXT_ANGLE,_T(""),wxDefaultPosition, wxSize(40,20),0,NumValidator(&AngleValue,true,true));
|
Angle = new wxTextCtrl(this,TEXT_ANGLE,_T(""),wxDefaultPosition, wxSize(40,20),0,NumValidator(AngleValue,true,true));
|
||||||
Spacing = new wxTextCtrl(this,TEXT_SPACING,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&SpacingValue,true,true));
|
Spacing = new wxTextCtrl(this,TEXT_SPACING,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(SpacingValue,true,true));
|
||||||
Encoding = new wxComboBox(this,COMBO_ENCODING,_T(""),wxDefaultPosition, wxDefaultSize, encodingStrings,wxCB_READONLY);
|
Encoding = new wxComboBox(this,COMBO_ENCODING,_T(""),wxDefaultPosition, wxDefaultSize, encodingStrings,wxCB_READONLY);
|
||||||
|
|
||||||
// Set control tooltips
|
// Set control tooltips
|
||||||
|
|
|
@ -74,35 +74,6 @@ class DialogStyleEditor : public wxDialog {
|
||||||
/// DOCME
|
/// DOCME
|
||||||
AssStyleStorage *store;
|
AssStyleStorage *store;
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString FontSizeValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString AlignmentValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString OutlineValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString ShadowValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString ScaleXValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString ScaleYValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString AngleValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString EncodingValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString SpacingValue;
|
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
wxTextCtrl *StyleName;
|
wxTextCtrl *StyleName;
|
||||||
|
|
||||||
|
|
|
@ -70,19 +70,19 @@ enum {
|
||||||
DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
|
DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
|
||||||
: wxDialog(c->parent,-1,_("Timing Post-Processor"),wxDefaultPosition,wxSize(400,250),wxDEFAULT_DIALOG_STYLE)
|
: wxDialog(c->parent,-1,_("Timing Post-Processor"),wxDefaultPosition,wxSize(400,250),wxDEFAULT_DIALOG_STYLE)
|
||||||
, c(c)
|
, c(c)
|
||||||
, leadInTime(wxString::Format("%d", OPT_GET("Audio/Lead/IN")->GetInt()))
|
|
||||||
, leadOutTime(wxString::Format("%d", OPT_GET("Audio/Lead/OUT")->GetInt()))
|
|
||||||
, thresStartBefore(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key Start Before")->GetInt()))
|
|
||||||
, thresStartAfter(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key Start After")->GetInt()))
|
|
||||||
, thresEndBefore(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key End Before")->GetInt()))
|
|
||||||
, thresEndAfter(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key End After")->GetInt()))
|
|
||||||
, adjsThresTime(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Adjacent")->GetInt()))
|
|
||||||
{
|
{
|
||||||
SetIcon(BitmapToIcon(GETIMAGE(timing_processor_toolbutton_24)));
|
SetIcon(BitmapToIcon(GETIMAGE(timing_processor_toolbutton_24)));
|
||||||
|
|
||||||
// Set variables
|
// Set variables
|
||||||
|
wxString leadInTime(wxString::Format("%d", OPT_GET("Audio/Lead/IN")->GetInt()));
|
||||||
|
wxString leadOutTime(wxString::Format("%d", OPT_GET("Audio/Lead/OUT")->GetInt()));
|
||||||
|
wxString thresStartBefore(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key Start Before")->GetInt()));
|
||||||
|
wxString thresStartAfter(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key Start After")->GetInt()));
|
||||||
|
wxString thresEndBefore(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key End Before")->GetInt()));
|
||||||
|
wxString thresEndAfter(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Key End After")->GetInt()));
|
||||||
|
wxString adjsThresTime(wxString::Format("%d", OPT_GET("Tool/Timing Post Processor/Threshold/Adjacent")->GetInt()));
|
||||||
|
|
||||||
// Styles box
|
// Styles box
|
||||||
wxSizer *LeftSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Apply to styles"));
|
wxSizer *LeftSizer = new wxStaticBoxSizer(wxVERTICAL,this,_("Apply to styles"));
|
||||||
wxArrayString styles = c->ass->GetStyles();
|
wxArrayString styles = c->ass->GetStyles();
|
||||||
StyleList = new wxCheckListBox(this,TIMING_STYLE_LIST,wxDefaultPosition,wxSize(150,150),styles);
|
StyleList = new wxCheckListBox(this,TIMING_STYLE_LIST,wxDefaultPosition,wxSize(150,150),styles);
|
||||||
|
@ -103,12 +103,12 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
|
||||||
hasLeadIn = new wxCheckBox(this,CHECK_ENABLE_LEADIN,_("Add lead in:"));
|
hasLeadIn = new wxCheckBox(this,CHECK_ENABLE_LEADIN,_("Add lead in:"));
|
||||||
hasLeadIn->SetToolTip(_("Enable adding of lead-ins to lines."));
|
hasLeadIn->SetToolTip(_("Enable adding of lead-ins to lines."));
|
||||||
hasLeadIn->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Lead/IN")->GetBool());
|
hasLeadIn->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Lead/IN")->GetBool());
|
||||||
leadIn = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(80,-1),0,NumValidator(&leadInTime));
|
leadIn = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(80,-1),0,NumValidator(leadInTime));
|
||||||
leadIn->SetToolTip(_("Lead in to be added, in milliseconds."));
|
leadIn->SetToolTip(_("Lead in to be added, in milliseconds."));
|
||||||
hasLeadOut = new wxCheckBox(this,CHECK_ENABLE_LEADOUT,_("Add lead out:"));
|
hasLeadOut = new wxCheckBox(this,CHECK_ENABLE_LEADOUT,_("Add lead out:"));
|
||||||
hasLeadOut->SetToolTip(_("Enable adding of lead-outs to lines."));
|
hasLeadOut->SetToolTip(_("Enable adding of lead-outs to lines."));
|
||||||
hasLeadOut->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Lead/OUT")->GetBool());
|
hasLeadOut->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Lead/OUT")->GetBool());
|
||||||
leadOut = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(80,-1),0,NumValidator(&leadOutTime));
|
leadOut = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(80,-1),0,NumValidator(leadOutTime));
|
||||||
leadOut->SetToolTip(_("Lead out to be added, in milliseconds."));
|
leadOut->SetToolTip(_("Lead out to be added, in milliseconds."));
|
||||||
LeadSizer->Add(hasLeadIn,0,wxRIGHT|wxEXPAND,5);
|
LeadSizer->Add(hasLeadIn,0,wxRIGHT|wxEXPAND,5);
|
||||||
LeadSizer->Add(leadIn,0,wxRIGHT|wxEXPAND,5);
|
LeadSizer->Add(leadIn,0,wxRIGHT|wxEXPAND,5);
|
||||||
|
@ -122,7 +122,7 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
|
||||||
adjsEnable->SetToolTip(_("Enable snapping of subtitles together if they are within a certain distance of each other."));
|
adjsEnable->SetToolTip(_("Enable snapping of subtitles together if they are within a certain distance of each other."));
|
||||||
adjsEnable->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Adjacent")->GetBool());
|
adjsEnable->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Adjacent")->GetBool());
|
||||||
wxStaticText *adjsThresText = new wxStaticText(this,-1,_("Threshold:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
wxStaticText *adjsThresText = new wxStaticText(this,-1,_("Threshold:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
||||||
adjacentThres = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(&adjsThresTime));
|
adjacentThres = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(adjsThresTime));
|
||||||
adjacentThres->SetToolTip(_("Maximum difference between start and end time for two subtitles to be made continuous, in milliseconds."));
|
adjacentThres->SetToolTip(_("Maximum difference between start and end time for two subtitles to be made continuous, in milliseconds."));
|
||||||
adjacentBias = new wxSlider(this,-1,mid(0,int(OPT_GET("Tool/Timing Post Processor/Adjacent Bias")->GetDouble()*100),100),0,100,wxDefaultPosition,wxSize(-1,20));
|
adjacentBias = new wxSlider(this,-1,mid(0,int(OPT_GET("Tool/Timing Post Processor/Adjacent Bias")->GetDouble()*100),100),0,100,wxDefaultPosition,wxSize(-1,20));
|
||||||
adjacentBias->SetToolTip(_("Sets how to set the adjoining of lines. If set totally to left, it will extend start time of the second line; if totally to right, it will extend the end time of the first line."));
|
adjacentBias->SetToolTip(_("Sets how to set the adjoining of lines. If set totally to left, it will extend start time of the second line; if totally to right, it will extend the end time of the first line."));
|
||||||
|
@ -140,16 +140,16 @@ DialogTimingProcessor::DialogTimingProcessor(agi::Context *c)
|
||||||
keysEnable->SetToolTip(_("Enable snapping of subtitles to nearest keyframe, if distance is within threshold."));
|
keysEnable->SetToolTip(_("Enable snapping of subtitles to nearest keyframe, if distance is within threshold."));
|
||||||
keysEnable->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Keyframe")->GetBool());
|
keysEnable->SetValue(OPT_GET("Tool/Timing Post Processor/Enable/Keyframe")->GetBool());
|
||||||
wxStaticText *textStartBefore = new wxStaticText(this,-1,_("Starts before thres.:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
wxStaticText *textStartBefore = new wxStaticText(this,-1,_("Starts before thres.:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
||||||
keysStartBefore = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(&thresStartBefore));
|
keysStartBefore = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(thresStartBefore));
|
||||||
keysStartBefore->SetToolTip(_("Threshold for 'before start' distance, that is, how many frames a subtitle must start before a keyframe to snap to it."));
|
keysStartBefore->SetToolTip(_("Threshold for 'before start' distance, that is, how many frames a subtitle must start before a keyframe to snap to it."));
|
||||||
wxStaticText *textStartAfter = new wxStaticText(this,-1,_("Starts after thres.:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
wxStaticText *textStartAfter = new wxStaticText(this,-1,_("Starts after thres.:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
||||||
keysStartAfter = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(&thresStartAfter));
|
keysStartAfter = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(thresStartAfter));
|
||||||
keysStartAfter->SetToolTip(_("Threshold for 'after start' distance, that is, how many frames a subtitle must start after a keyframe to snap to it."));
|
keysStartAfter->SetToolTip(_("Threshold for 'after start' distance, that is, how many frames a subtitle must start after a keyframe to snap to it."));
|
||||||
wxStaticText *textEndBefore = new wxStaticText(this,-1,_("Ends before thres.:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
wxStaticText *textEndBefore = new wxStaticText(this,-1,_("Ends before thres.:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
||||||
keysEndBefore = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(&thresEndBefore));
|
keysEndBefore = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(thresEndBefore));
|
||||||
keysEndBefore->SetToolTip(_("Threshold for 'before end' distance, that is, how many frames a subtitle must end before a keyframe to snap to it."));
|
keysEndBefore->SetToolTip(_("Threshold for 'before end' distance, that is, how many frames a subtitle must end before a keyframe to snap to it."));
|
||||||
wxStaticText *textEndAfter = new wxStaticText(this,-1,_("Ends after thres.:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
wxStaticText *textEndAfter = new wxStaticText(this,-1,_("Ends after thres.:"),wxDefaultPosition,wxDefaultSize,wxALIGN_CENTRE);
|
||||||
keysEndAfter = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(&thresEndAfter));
|
keysEndAfter = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(60,-1),0,NumValidator(thresEndAfter));
|
||||||
keysEndAfter->SetToolTip(_("Threshold for 'after end' distance, that is, how many frames a subtitle must end after a keyframe to snap to it."));
|
keysEndAfter->SetToolTip(_("Threshold for 'after end' distance, that is, how many frames a subtitle must end after a keyframe to snap to it."));
|
||||||
KeyframesFlexSizer->Add(keysEnable,0,wxRIGHT|wxEXPAND,10);
|
KeyframesFlexSizer->Add(keysEnable,0,wxRIGHT|wxEXPAND,10);
|
||||||
KeyframesFlexSizer->Add(textStartBefore,0,wxRIGHT|wxALIGN_CENTER,5);
|
KeyframesFlexSizer->Add(textStartBefore,0,wxRIGHT|wxALIGN_CENTER,5);
|
||||||
|
|
|
@ -106,21 +106,6 @@ class DialogTimingProcessor : public wxDialog {
|
||||||
/// DOCME
|
/// DOCME
|
||||||
wxButton *ApplyButton;
|
wxButton *ApplyButton;
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString leadInTime,leadOutTime,thresStartBefore,thresStartAfter,thresEndBefore,thresEndAfter,adjsThresTime;
|
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
std::vector<int> KeyFrames;
|
std::vector<int> KeyFrames;
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,6 @@
|
||||||
/// @ingroup custom_control utility
|
/// @ingroup custom_control utility
|
||||||
///
|
///
|
||||||
|
|
||||||
|
|
||||||
///////////
|
|
||||||
// Headers
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
|
@ -46,109 +43,67 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "validators.h"
|
#include "validators.h"
|
||||||
|
|
||||||
|
NumValidator::NumValidator(wxString val, bool isfloat, bool issigned)
|
||||||
/// @brief Constructor
|
: isFloat(isfloat)
|
||||||
/// @param _valPtr
|
, isSigned(issigned)
|
||||||
/// @param isfloat
|
{
|
||||||
/// @param issigned
|
if (isFloat) {
|
||||||
///
|
val.ToDouble(&fValue);
|
||||||
NumValidator::NumValidator(wxString* _valPtr,bool isfloat,bool issigned) {
|
}
|
||||||
isFloat = isfloat;
|
else {
|
||||||
isSigned = issigned;
|
long tLong;
|
||||||
valPtr = _valPtr;
|
val.ToLong(&tLong);
|
||||||
|
iValue = tLong;
|
||||||
// Get value
|
|
||||||
if (valPtr) {
|
|
||||||
if (isFloat) {
|
|
||||||
valPtr->ToDouble(&fValue);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
long tLong;
|
|
||||||
valPtr->ToLong(&tLong);
|
|
||||||
iValue = tLong;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Copy constructor
|
|
||||||
/// @param from
|
|
||||||
///
|
|
||||||
NumValidator::NumValidator(const NumValidator &from)
|
NumValidator::NumValidator(const NumValidator &from)
|
||||||
: wxValidator()
|
: wxValidator()
|
||||||
|
, fValue(from.fValue)
|
||||||
|
, iValue(from.iValue)
|
||||||
|
, isFloat(from.isFloat)
|
||||||
|
, isSigned(from.isSigned)
|
||||||
{
|
{
|
||||||
valPtr = from.valPtr;
|
|
||||||
isFloat = from.isFloat;
|
|
||||||
isSigned = from.isSigned;
|
|
||||||
SetWindow(from.GetWindow());
|
SetWindow(from.GetWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
|
||||||
// Event table
|
|
||||||
BEGIN_EVENT_TABLE(NumValidator, wxValidator)
|
BEGIN_EVENT_TABLE(NumValidator, wxValidator)
|
||||||
EVT_CHAR(NumValidator::OnChar)
|
EVT_CHAR(NumValidator::OnChar)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Clone
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
wxObject* NumValidator::Clone() const {
|
wxObject* NumValidator::Clone() const {
|
||||||
NumValidator *clone = new NumValidator(valPtr,isFloat,isSigned);
|
return new NumValidator(*this);
|
||||||
return clone;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Validate
|
|
||||||
/// @param parent
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
bool NumValidator::Validate(wxWindow* parent) {
|
bool NumValidator::Validate(wxWindow* parent) {
|
||||||
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
||||||
wxString value = ctrl->GetValue();
|
wxString value = ctrl->GetValue();
|
||||||
|
|
||||||
// Is the control enabled?
|
if (!ctrl->IsEnabled()) return true;
|
||||||
if (!ctrl->IsEnabled()) return true;
|
|
||||||
|
|
||||||
// Check length
|
|
||||||
if (value.Length() < 1) return false;
|
if (value.Length() < 1) return false;
|
||||||
|
|
||||||
// Check each character
|
|
||||||
bool gotDecimal = false;
|
bool gotDecimal = false;
|
||||||
for (size_t i=0;i<value.Length();i++) {
|
for (size_t i = 0; i < value.Length(); i++) {
|
||||||
if (!CheckCharacter(value[i],i==0,true,gotDecimal)) return false;
|
if (!CheckCharacter(value[i], !i, true, gotDecimal))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// All clear
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NumValidator::CheckCharacter(int chr, bool isFirst, bool canSign, bool &gotDecimal) {
|
||||||
|
|
||||||
/// @brief Check if a given character is valid
|
|
||||||
/// @param chr
|
|
||||||
/// @param isFirst
|
|
||||||
/// @param canSign
|
|
||||||
/// @param gotDecimal
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
bool NumValidator::CheckCharacter(int chr,bool isFirst,bool canSign,bool &gotDecimal) {
|
|
||||||
// Check sign
|
// Check sign
|
||||||
if (chr == _T('-') || chr == _T('+')) {
|
if (chr == '-' || chr == '+') {
|
||||||
if (!isFirst || !canSign || !isSigned) return false;
|
return isFirst && canSign && isSigned;
|
||||||
else return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't allow anything before a sign
|
// Don't allow anything before a sign
|
||||||
if (isFirst && !canSign) return false;
|
if (isFirst && !canSign) return false;
|
||||||
|
|
||||||
// Check decimal point
|
// Check decimal point
|
||||||
if (chr == _T('.') || chr == _T(',')) {
|
if (chr == '.' || chr == ',') {
|
||||||
if (!isFloat || gotDecimal) return false;
|
if (!isFloat || gotDecimal)
|
||||||
|
return false;
|
||||||
else {
|
else {
|
||||||
gotDecimal = true;
|
gotDecimal = true;
|
||||||
return true;
|
return true;
|
||||||
|
@ -156,16 +111,9 @@ bool NumValidator::CheckCharacter(int chr,bool isFirst,bool canSign,bool &gotDec
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check digit
|
// Check digit
|
||||||
if (chr < _T('0') || chr > _T('9')) return false;
|
return chr >= '0' && chr <= '9';
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Filter keypresses
|
|
||||||
/// @param event
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
void NumValidator::OnChar(wxKeyEvent& event) {
|
void NumValidator::OnChar(wxKeyEvent& event) {
|
||||||
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
||||||
wxString value = ctrl->GetValue();
|
wxString value = ctrl->GetValue();
|
||||||
|
@ -188,15 +136,13 @@ void NumValidator::OnChar(wxKeyEvent& event) {
|
||||||
for (size_t i=0;i<value.Length();i++) {
|
for (size_t i=0;i<value.Length();i++) {
|
||||||
if (i >= (unsigned)from && i < (unsigned)to) continue;
|
if (i >= (unsigned)from && i < (unsigned)to) continue;
|
||||||
curchr = value[i];
|
curchr = value[i];
|
||||||
if (curchr == _T('.') || curchr == _T(',')) decimals++;
|
if (curchr == '.' || curchr == ',') decimals++;
|
||||||
if (curchr == _T('+') || curchr == _T('-')) signs++;
|
if (curchr == '+' || curchr == '-') signs++;
|
||||||
}
|
}
|
||||||
bool gotDecimal = decimals > 0;
|
bool gotDecimal = decimals > 0;
|
||||||
bool isFirst = from == 0;
|
|
||||||
bool canSign = signs == 0;
|
|
||||||
|
|
||||||
// Check character
|
// Check character
|
||||||
if (!CheckCharacter(chr,isFirst,canSign,gotDecimal)) {
|
if (!CheckCharacter(chr,!from,!signs,gotDecimal)) {
|
||||||
if (!wxValidator::IsSilent()) wxBell();
|
if (!wxValidator::IsSilent()) wxBell();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -206,30 +152,21 @@ void NumValidator::OnChar(wxKeyEvent& event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Transfer to window
|
|
||||||
/// @return
|
|
||||||
///
|
|
||||||
bool NumValidator::TransferToWindow() {
|
bool NumValidator::TransferToWindow() {
|
||||||
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
||||||
if (isFloat) ctrl->SetValue(wxString::Format(_T("%g"),fValue));
|
if (isFloat)
|
||||||
else ctrl->SetValue(wxString::Format(_T("%d"),iValue));
|
ctrl->SetValue(wxString::Format("%g",fValue));
|
||||||
|
else
|
||||||
|
ctrl->SetValue(wxString::Format("%d",iValue));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Receive from window
|
|
||||||
///
|
|
||||||
bool NumValidator::TransferFromWindow() {
|
bool NumValidator::TransferFromWindow() {
|
||||||
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
wxTextCtrl *ctrl = (wxTextCtrl*) GetWindow();
|
||||||
wxString value = ctrl->GetValue();
|
wxString value = ctrl->GetValue();
|
||||||
|
|
||||||
// Validate
|
if (!Validate(ctrl)) return false;
|
||||||
bool ok = Validate(ctrl);
|
|
||||||
if (!ok) return false;
|
|
||||||
|
|
||||||
// Transfer
|
// Transfer
|
||||||
if (isFloat) {
|
if (isFloat) {
|
||||||
|
@ -243,5 +180,3 @@ bool NumValidator::TransferFromWindow() {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,11 +34,6 @@
|
||||||
/// @ingroup custom_control utility
|
/// @ingroup custom_control utility
|
||||||
///
|
///
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////
|
|
||||||
// Headers
|
|
||||||
#ifndef AGI_PRE
|
#ifndef AGI_PRE
|
||||||
#include <wx/validate.h>
|
#include <wx/validate.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,38 +41,43 @@
|
||||||
|
|
||||||
/// DOCME
|
/// DOCME
|
||||||
/// @class NumValidator
|
/// @class NumValidator
|
||||||
/// @brief DOCME
|
/// @brief wx validator that only allows valid numbers
|
||||||
///
|
///
|
||||||
/// DOCME
|
/// DOCME
|
||||||
class NumValidator : public wxValidator {
|
class NumValidator : public wxValidator {
|
||||||
private:
|
double fValue; ///< Value if isFloat is true
|
||||||
|
int iValue; ///< Value if isFloat is false
|
||||||
|
bool isFloat; ///< Should decimals be allowed?
|
||||||
|
bool isSigned; ///< Can the number be negative?
|
||||||
|
|
||||||
/// DOCME
|
/// Polymorphic copy
|
||||||
double fValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
int iValue;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
wxString* valPtr;
|
|
||||||
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
bool isFloat;
|
|
||||||
|
|
||||||
/// DOCME
|
|
||||||
bool isSigned;
|
|
||||||
wxObject* Clone() const;
|
wxObject* Clone() const;
|
||||||
|
/// Check if the value in the passed window is valid
|
||||||
bool Validate(wxWindow* parent);
|
bool Validate(wxWindow* parent);
|
||||||
|
/// Copy the currently stored value to the associated window
|
||||||
bool TransferToWindow();
|
bool TransferToWindow();
|
||||||
|
/// Read the value in the associated window and validate it
|
||||||
bool TransferFromWindow();
|
bool TransferFromWindow();
|
||||||
|
|
||||||
|
/// Check a single character
|
||||||
|
/// @param chr Character to check
|
||||||
|
/// @param isFirst Is this the first character in the string?
|
||||||
|
/// @param canSign Can this character be a sign?
|
||||||
|
/// @param gotDecimal[in,out] Has a decimal been found? Set to true if a chr is a decimal
|
||||||
|
/// @return Is this character valid?
|
||||||
bool CheckCharacter(int chr,bool isFirst,bool canSign,bool &gotDecimal);
|
bool CheckCharacter(int chr,bool isFirst,bool canSign,bool &gotDecimal);
|
||||||
|
|
||||||
|
/// wx character event handler
|
||||||
void OnChar(wxKeyEvent& event);
|
void OnChar(wxKeyEvent& event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NumValidator(wxString* valPtr = NULL,bool isfloat=false,bool issigned=false);
|
/// Constructor
|
||||||
|
/// @param val Initial value to set the associated control to
|
||||||
|
/// @param isfloat Allow floats, or just ints?
|
||||||
|
/// @param issigned Allow negative numbers?
|
||||||
|
NumValidator(wxString val = "", bool isfloat=false, bool issigned=false);
|
||||||
|
|
||||||
|
/// Copy constructor
|
||||||
NumValidator(const NumValidator& from);
|
NumValidator(const NumValidator& from);
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE();
|
DECLARE_EVENT_TABLE();
|
||||||
|
|
Loading…
Reference in New Issue