Made style's font size, scale x and scale y floats. Also made \fs take float as parameter.

Originally committed to SVN as r304.
This commit is contained in:
Rodrigo Braz Monteiro 2006-04-04 20:41:09 +00:00
parent 4ade87ba5a
commit 5e9c0aad16
6 changed files with 71 additions and 55 deletions

View File

@ -390,7 +390,7 @@ void AssOverrideTagProto::LoadProtos () {
// \fs<size> // \fs<size>
proto.push_back(AssOverrideTagProto()); proto.push_back(AssOverrideTagProto());
proto.back().name = _T("\\fs"); 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<alignment> // \an<alignment>
proto.push_back(AssOverrideTagProto()); proto.push_back(AssOverrideTagProto());

View File

@ -36,8 +36,9 @@
//////////// ////////////
// Includes // Includes
#include "ass_style.h"
#include <wx/tokenzr.h> #include <wx/tokenzr.h>
#include "ass_style.h"
#include "utils.h"
///////////////////////// AssColor ////////////////////////// ///////////////////////// AssColor //////////////////////////
@ -302,14 +303,14 @@ bool AssStyle::Parse(wxString rawData,bool IsSSA) {
// Read scale x // Read scale x
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
temp = tkn.GetNextToken(); temp = tkn.GetNextToken();
temp.ToLong(&templ); temp.ToDouble(&scalex);
scalex = templ; //scalex = templ;
// Read scale y // Read scale y
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
temp = tkn.GetNextToken(); temp = tkn.GetNextToken();
temp.ToLong(&templ); temp.ToDouble(&scaley);
scaley = templ; //scaley = templ;
// Read spacing // Read spacing
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
@ -412,32 +413,32 @@ void AssStyle::UpdateData() {
font.Replace(_T(","),_T(";")); font.Replace(_T(","),_T(";"));
final += name + _T(","); final += name + _T(",");
final += font + _T(","); final += font + _T(",");
final += wxString::Format(_T("%i"),fontsize) + _T(","); final += FloatToString(fontsize) + _T(",");
final += primary.GetASSFormatted(true,false,true) + _T(","); final += primary.GetASSFormatted(true,false,true) + _T(",");
final += secondary.GetASSFormatted(true,false,true) + _T(","); final += secondary.GetASSFormatted(true,false,true) + _T(",");
final += outline.GetASSFormatted(true,false,true) + _T(","); final += outline.GetASSFormatted(true,false,true) + _T(",");
final += shadow.GetASSFormatted(true,false,true) + _T(","); final += shadow.GetASSFormatted(true,false,true) + _T(",");
final += wxString::Format(_T("%i"),bold?-1:0) + _T(","); final += IntToString(bold?-1:0) + _T(",");
final += wxString::Format(_T("%i"),italic?-1:0) + _T(","); final += IntToString(italic?-1:0) + _T(",");
final += wxString::Format(_T("%i"),underline?-1:0) + _T(","); final += IntToString(underline?-1:0) + _T(",");
final += wxString::Format(_T("%i"),strikeout?-1:0) + _T(","); final += IntToString(strikeout?-1:0) + _T(",");
final += wxString::Format(_T("%i"),scalex) + _T(","); final += FloatToString(scalex) + _T(",");
final += wxString::Format(_T("%i"),scaley) + _T(","); final += FloatToString(scaley) + _T(",");
final += wxString::Format(_T("%.2f"),spacing) + _T(","); final += FloatToString(spacing) + _T(",");
final += wxString::Format(_T("%.2f"),angle) + _T(","); final += FloatToString(angle) + _T(",");
final += wxString::Format(_T("%i"),borderstyle) + _T(","); final += IntToString(borderstyle) + _T(",");
final += wxString::Format(_T("%.2f"),outline_w) + _T(","); final += FloatToString(outline_w) + _T(",");
final += wxString::Format(_T("%.2f"),shadow_w) + _T(","); final += FloatToString(shadow_w) + _T(",");
final += wxString::Format(_T("%i"),alignment) + _T(","); final += IntToString(alignment) + _T(",");
final += wxString::Format(_T("%i"),MarginL) + _T(","); final += IntToString(MarginL) + _T(",");
final += wxString::Format(_T("%i"),MarginR) + _T(","); final += IntToString(MarginR) + _T(",");
final += wxString::Format(_T("%i"),MarginV) + _T(","); final += IntToString(MarginV) + _T(",");
final += wxString::Format(_T("%i"),encoding); final += IntToString(encoding);
SetEntryData(final); SetEntryData(final);
} }
@ -488,19 +489,19 @@ wxString AssStyle::GetSSAText() {
font.Replace(_T(","),_T(";")); font.Replace(_T(","),_T(";"));
output += name + _T(","); output += name + _T(",");
output += font + _T(","); output += font + _T(",");
output += wxString::Format(_T("%i"),fontsize) + _T(","); output += FloatToString(fontsize) + _T(",");
output += primary.GetSSAFormatted() + _T(","); output += primary.GetSSAFormatted() + _T(",");
output += secondary.GetSSAFormatted() + _T(","); output += secondary.GetSSAFormatted() + _T(",");
output += _T("0,"); output += _T("0,");
output += shadow.GetSSAFormatted() + _T(","); output += shadow.GetSSAFormatted() + _T(",");
output += wxString::Format(_T("%i"),bold?-1:0) + _T(","); output += IntToString(bold?-1:0) + _T(",");
output += wxString::Format(_T("%i"),italic?-1:0) + _T(","); output += IntToString(italic?-1:0) + _T(",");
output += wxString::Format(_T("%i"),borderstyle) + _T(","); output += IntToString(borderstyle) + _T(",");
output += wxString::Format(_T("%.2f"),outline_w) + _T(","); output += FloatToString(outline_w) + _T(",");
output += wxString::Format(_T("%.2f"),shadow_w) + _T(","); output += FloatToString(shadow_w) + _T(",");
int align = 0; int align = 0;
switch (alignment) { switch (alignment) {
@ -514,13 +515,13 @@ wxString AssStyle::GetSSAText() {
case 8: align = 6; break; case 8: align = 6; break;
case 9: align = 7; 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 += IntToString(MarginL) + _T(",");
output += wxString::Format(_T("%i"),MarginR) + _T(","); output += IntToString(MarginR) + _T(",");
output += wxString::Format(_T("%i"),MarginV) + _T(","); output += IntToString(MarginV) + _T(",");
output += _T("0,"); output += _T("0,");
output += wxString::Format(_T("%i"),encoding); output += IntToString(encoding);
return output; return output;
} }

View File

@ -69,7 +69,7 @@ class AssStyle : public AssEntry {
public: public:
wxString name; wxString name;
wxString font; wxString font;
int fontsize; double fontsize;
AssColor primary; AssColor primary;
AssColor secondary; AssColor secondary;
@ -81,8 +81,8 @@ public:
bool underline; bool underline;
bool strikeout; bool strikeout;
int scalex; double scalex;
int scaley; double scaley;
double spacing; double spacing;
double angle; double angle;
int borderstyle; int borderstyle;

View File

@ -36,13 +36,14 @@
//////////// ////////////
// Includes // Includes
#include <wx/fontdlg.h>
#include <wx/colordlg.h>
#include "dialog_style_editor.h" #include "dialog_style_editor.h"
#include "ass_style.h" #include "ass_style.h"
#include "ass_file.h" #include "ass_file.h"
#include "validators.h" #include "validators.h"
#include "subs_grid.h" #include "subs_grid.h"
#include <wx/fontdlg.h> #include "utils.h"
#include <wx/colordlg.h>
#include "dialog_colorpicker.h" #include "dialog_colorpicker.h"
@ -64,8 +65,8 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
// Font // Font
FontName = new wxTextCtrl(this,-1,style->font,wxDefaultPosition,wxSize(150,20)); FontName = new wxTextCtrl(this,-1,style->font,wxDefaultPosition,wxSize(150,20));
FontSizeValue = wxString::Format(_T("%i"),style->fontsize); FontSizeValue = FloatToString(style->fontsize);
FontSize = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(30,20),0,NumValidator(&FontSizeValue)); FontSize = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(30,20),0,wxTextValidator(wxFILTER_NUMERIC,&FontSizeValue));
FontName->SetToolTip(_("Font face")); FontName->SetToolTip(_("Font face"));
FontSize->SetToolTip(_("Font size")); FontSize->SetToolTip(_("Font size"));
wxButton *FontButton = new wxButton(this,BUTTON_STYLE_FONT,_("Choose")); wxButton *FontButton = new wxButton(this,BUTTON_STYLE_FONT,_("Choose"));
@ -187,8 +188,8 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
// Outline // Outline
wxSizer *OutlineBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Outline")); wxSizer *OutlineBox = new wxStaticBoxSizer(wxHORIZONTAL,this,_("Outline"));
OutlineType = new wxCheckBox(this,-1,_("Opaque box")); OutlineType = new wxCheckBox(this,-1,_("Opaque box"));
OutlineValue = wxString::Format(_T("%.1f"),style->outline_w); OutlineValue = FloatToString(style->outline_w);
ShadowValue = wxString::Format(_T("%.1f"),style->shadow_w); ShadowValue = FloatToString(style->shadow_w);
Outline = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,wxTextValidator(wxFILTER_NUMERIC,&OutlineValue)); 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)); 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")); 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 *MiscBox = new wxStaticBoxSizer(wxVERTICAL,this,_("Miscelaneous"));
wxSizer *MiscBoxTop = new wxBoxSizer(wxHORIZONTAL); wxSizer *MiscBoxTop = new wxBoxSizer(wxHORIZONTAL);
wxSizer *MiscBoxBottom = new wxBoxSizer(wxHORIZONTAL); wxSizer *MiscBoxBottom = new wxBoxSizer(wxHORIZONTAL);
ScaleXValue = wxString::Format(_T("%i"),style->scalex); ScaleXValue = FloatToString(style->scalex);
ScaleYValue = wxString::Format(_T("%i"),style->scaley); ScaleYValue = FloatToString(style->scaley);
AngleValue = wxString::Format(_T("%.1f"),style->angle); AngleValue = FloatToString(style->angle);
EncodingValue = wxString::Format(_T("%i"),style->encoding); EncodingValue = IntToString(style->encoding);
SpacingValue = wxString::Format(_T("%.1f"),style->spacing); SpacingValue = FloatToString(style->spacing);
ScaleX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(40,20),0,NumValidator(&ScaleXValue)); ScaleX = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(70,20),0,wxTextValidator(wxFILTER_NUMERIC,&ScaleXValue));
ScaleY = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition, wxSize(40,20),0,NumValidator(&ScaleYValue)); 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)); 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)); 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)); 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) { if (apply) {
// Update // Update
long templ; long templ;
ScaleX->GetValue().ToLong(&templ); ScaleX->GetValue().ToDouble(&(work->scalex));
work->scalex = templ; ScaleY->GetValue().ToDouble(&(work->scaley));
ScaleY->GetValue().ToLong(&templ);
work->scaley = templ;
Encoding->GetValue().ToLong(&templ); Encoding->GetValue().ToLong(&templ);
work->encoding = templ; work->encoding = templ;
Angle->GetValue().ToDouble(&(work->angle)); Angle->GetValue().ToDouble(&(work->angle));
@ -353,7 +352,7 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
work->underline = BoxUnderline->IsChecked(); work->underline = BoxUnderline->IsChecked();
work->strikeout = BoxStrikeout->IsChecked(); work->strikeout = BoxStrikeout->IsChecked();
work->font = FontName->GetValue(); work->font = FontName->GetValue();
FontSize->GetValue().ToLong(&templ); FontSize->GetValue().ToDouble(&(work->fontsize));
work->fontsize = templ; work->fontsize = templ;
work->name = StyleName->GetValue(); work->name = StyleName->GetValue();

View File

@ -130,3 +130,17 @@ wxString PrettyFloat(wxString src) {
} }
return 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);
}

View File

@ -45,6 +45,8 @@ bool Backup(wxString src,wxString dst);
wxString MakeRelativePath(wxString path,wxString reference); wxString MakeRelativePath(wxString path,wxString reference);
wxString DecodeRelativePath(wxString path,wxString reference); wxString DecodeRelativePath(wxString path,wxString reference);
wxString PrettyFloat(wxString src); wxString PrettyFloat(wxString src);
wxString FloatToString(double value);
wxString IntToString(int value);
////////// //////////