diff --git a/core/ass_override.cpp b/core/ass_override.cpp index 34435f2b7..39e123b66 100644 --- a/core/ass_override.cpp +++ b/core/ass_override.cpp @@ -390,7 +390,7 @@ void AssOverrideTagProto::LoadProtos () { // \fs proto.push_back(AssOverrideTagProto()); proto.back().name = _T("\\fs"); - proto.back().params.push_back(AssOverrideParamProto(VARDATA_INT,NOT_OPTIONAL,PARCLASS_ABSOLUTE_SIZE)); + proto.back().params.push_back(AssOverrideParamProto(VARDATA_FLOAT,NOT_OPTIONAL,PARCLASS_ABSOLUTE_SIZE)); // \an proto.push_back(AssOverrideTagProto()); diff --git a/core/ass_style.cpp b/core/ass_style.cpp index ba3517108..cac8672e4 100644 --- a/core/ass_style.cpp +++ b/core/ass_style.cpp @@ -36,8 +36,9 @@ //////////// // Includes -#include "ass_style.h" #include +#include "ass_style.h" +#include "utils.h" ///////////////////////// AssColor ////////////////////////// @@ -302,14 +303,14 @@ bool AssStyle::Parse(wxString rawData,bool IsSSA) { // Read scale x if (!tkn.HasMoreTokens()) return false; temp = tkn.GetNextToken(); - temp.ToLong(&templ); - scalex = templ; + temp.ToDouble(&scalex); + //scalex = templ; // Read scale y if (!tkn.HasMoreTokens()) return false; temp = tkn.GetNextToken(); - temp.ToLong(&templ); - scaley = templ; + temp.ToDouble(&scaley); + //scaley = templ; // Read spacing if (!tkn.HasMoreTokens()) return false; @@ -412,32 +413,32 @@ void AssStyle::UpdateData() { font.Replace(_T(","),_T(";")); final += name + _T(","); final += font + _T(","); - final += wxString::Format(_T("%i"),fontsize) + _T(","); + final += FloatToString(fontsize) + _T(","); final += primary.GetASSFormatted(true,false,true) + _T(","); final += secondary.GetASSFormatted(true,false,true) + _T(","); final += outline.GetASSFormatted(true,false,true) + _T(","); final += shadow.GetASSFormatted(true,false,true) + _T(","); - final += wxString::Format(_T("%i"),bold?-1:0) + _T(","); - final += wxString::Format(_T("%i"),italic?-1:0) + _T(","); - final += wxString::Format(_T("%i"),underline?-1:0) + _T(","); - final += wxString::Format(_T("%i"),strikeout?-1:0) + _T(","); + final += IntToString(bold?-1:0) + _T(","); + final += IntToString(italic?-1:0) + _T(","); + final += IntToString(underline?-1:0) + _T(","); + final += IntToString(strikeout?-1:0) + _T(","); - final += wxString::Format(_T("%i"),scalex) + _T(","); - final += wxString::Format(_T("%i"),scaley) + _T(","); - final += wxString::Format(_T("%.2f"),spacing) + _T(","); + final += FloatToString(scalex) + _T(","); + final += FloatToString(scaley) + _T(","); + final += FloatToString(spacing) + _T(","); - final += wxString::Format(_T("%.2f"),angle) + _T(","); - final += wxString::Format(_T("%i"),borderstyle) + _T(","); - final += wxString::Format(_T("%.2f"),outline_w) + _T(","); - final += wxString::Format(_T("%.2f"),shadow_w) + _T(","); + final += FloatToString(angle) + _T(","); + final += IntToString(borderstyle) + _T(","); + final += FloatToString(outline_w) + _T(","); + final += FloatToString(shadow_w) + _T(","); - final += wxString::Format(_T("%i"),alignment) + _T(","); - final += wxString::Format(_T("%i"),MarginL) + _T(","); - final += wxString::Format(_T("%i"),MarginR) + _T(","); - final += wxString::Format(_T("%i"),MarginV) + _T(","); - final += wxString::Format(_T("%i"),encoding); + final += IntToString(alignment) + _T(","); + final += IntToString(MarginL) + _T(","); + final += IntToString(MarginR) + _T(","); + final += IntToString(MarginV) + _T(","); + final += IntToString(encoding); SetEntryData(final); } @@ -488,19 +489,19 @@ wxString AssStyle::GetSSAText() { font.Replace(_T(","),_T(";")); output += name + _T(","); output += font + _T(","); - output += wxString::Format(_T("%i"),fontsize) + _T(","); + output += FloatToString(fontsize) + _T(","); output += primary.GetSSAFormatted() + _T(","); output += secondary.GetSSAFormatted() + _T(","); output += _T("0,"); output += shadow.GetSSAFormatted() + _T(","); - output += wxString::Format(_T("%i"),bold?-1:0) + _T(","); - output += wxString::Format(_T("%i"),italic?-1:0) + _T(","); + output += IntToString(bold?-1:0) + _T(","); + output += IntToString(italic?-1:0) + _T(","); - output += wxString::Format(_T("%i"),borderstyle) + _T(","); - output += wxString::Format(_T("%.2f"),outline_w) + _T(","); - output += wxString::Format(_T("%.2f"),shadow_w) + _T(","); + output += IntToString(borderstyle) + _T(","); + output += FloatToString(outline_w) + _T(","); + output += FloatToString(shadow_w) + _T(","); int align = 0; switch (alignment) { @@ -514,13 +515,13 @@ wxString AssStyle::GetSSAText() { case 8: align = 6; break; case 9: align = 7; break; } - output += wxString::Format(_T("%i"),align) + _T(","); + output += IntToString(align) + _T(","); - output += wxString::Format(_T("%i"),MarginL) + _T(","); - output += wxString::Format(_T("%i"),MarginR) + _T(","); - output += wxString::Format(_T("%i"),MarginV) + _T(","); + output += IntToString(MarginL) + _T(","); + output += IntToString(MarginR) + _T(","); + output += IntToString(MarginV) + _T(","); output += _T("0,"); - output += wxString::Format(_T("%i"),encoding); + output += IntToString(encoding); return output; } diff --git a/core/ass_style.h b/core/ass_style.h index 143109436..221549846 100644 --- a/core/ass_style.h +++ b/core/ass_style.h @@ -69,7 +69,7 @@ class AssStyle : public AssEntry { public: wxString name; wxString font; - int fontsize; + double fontsize; AssColor primary; AssColor secondary; @@ -81,8 +81,8 @@ public: bool underline; bool strikeout; - int scalex; - int scaley; + double scalex; + double scaley; double spacing; double angle; int borderstyle; diff --git a/core/dialog_style_editor.cpp b/core/dialog_style_editor.cpp index 6cad4cceb..d81260105 100644 --- a/core/dialog_style_editor.cpp +++ b/core/dialog_style_editor.cpp @@ -36,13 +36,14 @@ //////////// // Includes +#include +#include #include "dialog_style_editor.h" #include "ass_style.h" #include "ass_file.h" #include "validators.h" #include "subs_grid.h" -#include -#include +#include "utils.h" #include "dialog_colorpicker.h" @@ -64,8 +65,8 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit // Font FontName = new wxTextCtrl(this,-1,style->font,wxDefaultPosition,wxSize(150,20)); - FontSizeValue = wxString::Format(_T("%i"),style->fontsize); - FontSize = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(30,20),0,NumValidator(&FontSizeValue)); + FontSizeValue = FloatToString(style->fontsize); + FontSize = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(30,20),0,wxTextValidator(wxFILTER_NUMERIC,&FontSizeValue)); FontName->SetToolTip(_("Font face")); FontSize->SetToolTip(_("Font size")); wxButton *FontButton = new wxButton(this,BUTTON_STYLE_FONT,_("Choose")); @@ -187,8 +188,8 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit // Outline wxSizer *OutlineBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Outline")); OutlineType = new wxCheckBox(this,-1,_("Opaque box")); - OutlineValue = wxString::Format(_T("%.1f"),style->outline_w); - ShadowValue = wxString::Format(_T("%.1f"),style->shadow_w); + OutlineValue = FloatToString(style->outline_w); + ShadowValue = FloatToString(style->shadow_w); Outline = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&OutlineValue)); Shadow = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&ShadowValue)); OutlineType->SetToolTip(_("Checking this will display an opaque box instead of outline")); @@ -207,13 +208,13 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit wxSizer *MiscBox = new wxStaticBoxSizer(wxVERTICAL,this,_("Miscelaneous")); wxSizer *MiscBoxTop = new wxBoxSizer(wxHORIZONTAL); wxSizer *MiscBoxBottom = new wxBoxSizer(wxHORIZONTAL); - ScaleXValue = wxString::Format(_T("%i"),style->scalex); - ScaleYValue = wxString::Format(_T("%i"),style->scaley); - AngleValue = wxString::Format(_T("%.1f"),style->angle); - EncodingValue = wxString::Format(_T("%i"),style->encoding); - SpacingValue = wxString::Format(_T("%.1f"),style->spacing); - ScaleX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(40,20),0,NumValidator(&ScaleXValue)); - ScaleY = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(40,20),0,NumValidator(&ScaleYValue)); + ScaleXValue = FloatToString(style->scalex); + ScaleYValue = FloatToString(style->scaley); + AngleValue = FloatToString(style->angle); + EncodingValue = IntToString(style->encoding); + SpacingValue = FloatToString(style->spacing); + ScaleX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(70,20),0,wxTextValidator(wxFILTER_NUMERIC,&ScaleXValue)); + ScaleY = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(70,20),0,wxTextValidator(wxFILTER_NUMERIC,&ScaleYValue)); Angle = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&AngleValue)); Encoding = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(40,20),0,NumValidator(&EncodingValue)); Spacing = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&SpacingValue)); @@ -324,10 +325,8 @@ void DialogStyleEditor::Apply (bool apply,bool close) { if (apply) { // Update long templ; - ScaleX->GetValue().ToLong(&templ); - work->scalex = templ; - ScaleY->GetValue().ToLong(&templ); - work->scaley = templ; + ScaleX->GetValue().ToDouble(&(work->scalex)); + ScaleY->GetValue().ToDouble(&(work->scaley)); Encoding->GetValue().ToLong(&templ); work->encoding = templ; Angle->GetValue().ToDouble(&(work->angle)); @@ -353,7 +352,7 @@ void DialogStyleEditor::Apply (bool apply,bool close) { work->underline = BoxUnderline->IsChecked(); work->strikeout = BoxStrikeout->IsChecked(); work->font = FontName->GetValue(); - FontSize->GetValue().ToLong(&templ); + FontSize->GetValue().ToDouble(&(work->fontsize)); work->fontsize = templ; work->name = StyleName->GetValue(); diff --git a/core/utils.cpp b/core/utils.cpp index b5f3227ae..6bda5e6e0 100644 --- a/core/utils.cpp +++ b/core/utils.cpp @@ -130,3 +130,17 @@ wxString PrettyFloat(wxString src) { } return src; } + + +/////////////////// +// Float to string +wxString FloatToString(double value) { + return PrettyFloat(wxString::Format(_T("%f"),value)); +} + + +///////////////// +// Int to string +wxString IntToString(int value) { + return wxString::Format(_T("%i"),value); +} diff --git a/core/utils.h b/core/utils.h index aedd45fb2..e0f2791f5 100644 --- a/core/utils.h +++ b/core/utils.h @@ -45,6 +45,8 @@ bool Backup(wxString src,wxString dst); wxString MakeRelativePath(wxString path,wxString reference); wxString DecodeRelativePath(wxString path,wxString reference); wxString PrettyFloat(wxString src); +wxString FloatToString(double value); +wxString IntToString(int value); //////////