More preparations for ASS2

Originally committed to SVN as r740.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-08 01:08:50 +00:00
parent b96c7932b9
commit a477f58582
4 changed files with 26 additions and 39 deletions

View file

@ -184,9 +184,10 @@ AssStyle::AssStyle() {
outline_w = 2.0;
shadow_w = 2.0;
alignment = 2;
MarginL = 10;
MarginR = 10;
MarginV = 10;
Margin[0] = 10;
Margin[1] = 10;
Margin[2] = 10;
Margin[3] = 10;
encoding = 0;
UpdateData();
@ -435,9 +436,9 @@ void AssStyle::UpdateData() {
final += FloatToString(shadow_w) + _T(",");
final += IntegerToString(alignment) + _T(",");
final += IntegerToString(MarginL) + _T(",");
final += IntegerToString(MarginR) + _T(",");
final += IntegerToString(MarginV) + _T(",");
final += IntegerToString(Margin[0]) + _T(",");
final += IntegerToString(Margin[1]) + _T(",");
final += IntegerToString(Margin[2]) + _T(",");
final += IntegerToString(encoding);
SetEntryData(final);
}
@ -454,13 +455,8 @@ void AssStyle::SetMarginString(const wxString str,int which) {
work.ToLong(&value);
if (value < 0) value = 0;
if (value > 9999) value = 9999;
switch (which) {
case 0: MarginL = value; break;
case 1: MarginR = value; break;
case 2: MarginV = value; break;
case 3: MarginV = value; break;
default: throw _T("Invalid margin");
}
if (which < 0 || which >= 4) throw _T("Invalid margin");
Margin[which] = value;
}
@ -468,13 +464,8 @@ void AssStyle::SetMarginString(const wxString str,int which) {
// Gets string for margin
wxString AssStyle::GetMarginString(int which) {
int value;
switch (which) {
case 0: value = MarginL; break;
case 1: value = MarginR; break;
case 2: value = MarginV; break;
case 3: value = MarginV; break;
default: throw _T("Invalid margin");
}
if (which < 0 || which >= 4) throw _T("Invalid margin");
value = Margin[which];
wxString result = wxString::Format(_T("%04i"),value);
return result;
}
@ -519,9 +510,9 @@ wxString AssStyle::GetSSAText() {
}
output += IntegerToString(align) + _T(",");
output += IntegerToString(MarginL) + _T(",");
output += IntegerToString(MarginR) + _T(",");
output += IntegerToString(MarginV) + _T(",");
output += IntegerToString(Margin[0]) + _T(",");
output += IntegerToString(Margin[1]) + _T(",");
output += IntegerToString(Margin[2]) + _T(",");
output += _T("0,");
output += IntegerToString(encoding);
@ -547,9 +538,7 @@ AssEntry *AssStyle::Clone() {
final->font = font;
final->fontsize = fontsize;
final->italic = italic;
final->MarginL = MarginL;
final->MarginR = MarginR;
final->MarginV = MarginV;
for (int i=0;i<4;i++) final->Margin[i] = Margin[i];
final->name = name;
final->outline = outline;
final->outline_w = outline_w;

View file

@ -89,9 +89,7 @@ public:
double outline_w;
double shadow_w;
int alignment;
int MarginL;
int MarginR;
int MarginV;
int Margin[4];
int encoding;
ASS_EntryType GetType() { return ENTRY_STYLE; }

View file

@ -191,13 +191,13 @@ namespace Automation4 {
lua_pushnumber(L, sty->alignment);
lua_setfield(L, -2, "align");
lua_pushnumber(L, sty->MarginL);
lua_pushnumber(L, sty->Margin[0]);
lua_setfield(L, -2, "margin_l");
lua_pushnumber(L, sty->MarginR);
lua_pushnumber(L, sty->Margin[1]);
lua_setfield(L, -2, "margin_r");
lua_pushnumber(L, sty->MarginV); // duplicating MarginV to margin_t and margin_b here
lua_pushnumber(L, sty->Margin[2]);
lua_setfield(L, -2, "margin_t");
lua_pushnumber(L, sty->MarginV);
lua_pushnumber(L, sty->Margin[3]);
lua_setfield(L, -2, "margin_b");
lua_pushnumber(L, sty->encoding);
@ -353,9 +353,10 @@ namespace Automation4 {
sty->outline_w = outline;
sty->shadow_w = shadow;
sty->alignment = align;
sty->MarginL = margin_l;
sty->MarginR = margin_r;
sty->MarginV = margin_t;
sty->Margin[0] = margin_l;
sty->Margin[1] = margin_r;
sty->Margin[2] = margin_t;
sty->Margin[3] = margin_b;
sty->encoding = encoding;
sty->UpdateData();

View file

@ -224,9 +224,8 @@ void DialogResample::OnResample (wxCommandEvent &event) {
//curStyle->shadow_w *= r;
curStyle->spacing *= rx;
curStyle->scalex *= ar;
curStyle->MarginL = int(curStyle->MarginL * rx + 0.5);
curStyle->MarginR = int(curStyle->MarginR * rx + 0.5);
curStyle->MarginV = int(curStyle->MarginV * ry + 0.5);
for (int i=0;i<2;i++) curStyle->Margin[i] = int(curStyle->Margin[i] * rx + 0.5);
for (int i=2;i<4;i++) curStyle->Margin[i] = int(curStyle->Margin[i] * ry + 0.5);
curStyle->UpdateData();
}
}