Fixed and completed the implementation of DirectSound audio player, and made some changes for future ASS2 support.

Originally committed to SVN as r716.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-05 18:27:15 +00:00
parent 4384dbe2c4
commit b3f2f069d3
16 changed files with 172 additions and 109 deletions

View file

@ -64,7 +64,7 @@ AssDialogue::AssDialogue() {
End.SetMS(5000); End.SetMS(5000);
StartMS = 0; StartMS = 0;
Layer = 0; Layer = 0;
MarginR = MarginL = MarginV = 0; for (int i=0;i<4;i++) Margin[i] = 0;
Text = _T(""); Text = _T("");
Style = _T("Default"); Style = _T("Default");
Actor = _T(""); Actor = _T("");
@ -178,15 +178,15 @@ bool AssDialogue::Parse(wxString rawData, bool IsSSA) {
// Get left margin // Get left margin
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),1); SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),0);
// Get right margin // Get right margin
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),2); SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),1);
// Get vertical margin // Get vertical margin
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),3); SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),2);
// Get effect // Get effect
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
@ -234,12 +234,12 @@ wxString AssDialogue::MakeData() {
final += Style + _T(","); final += Style + _T(",");
final += Actor + _T(","); final += Actor + _T(",");
final += GetMarginString(0);
final += _T(",");
final += GetMarginString(1); final += GetMarginString(1);
final += _T(","); final += _T(",");
final += GetMarginString(2); final += GetMarginString(2);
final += _T(","); final += _T(",");
final += GetMarginString(3);
final += _T(",");
Effect.Replace(_T(","),_T(";")); Effect.Replace(_T(","),_T(";"));
final += Effect + _T(","); final += Effect + _T(",");
@ -287,12 +287,12 @@ wxString AssDialogue::GetSSAText () {
work += Style + _T(","); work += Style + _T(",");
work += Actor + _T(","); work += Actor + _T(",");
work += GetMarginString(0);
work += _T(",");
work += GetMarginString(1); work += GetMarginString(1);
work += _T(","); work += _T(",");
work += GetMarginString(2); work += GetMarginString(2);
work += _T(","); work += _T(",");
work += GetMarginString(3);
work += _T(",");
Effect.Replace(_T(","),_T(";")); Effect.Replace(_T(","),_T(";"));
work += Effect + _T(","); work += Effect + _T(",");
@ -678,25 +678,16 @@ void AssDialogue::SetMarginString(const wxString origvalue,int which) {
if (value > 9999) value = 9999; if (value > 9999) value = 9999;
// Assign // Assign
switch (which) { if (which < 0 || which >= 4) throw _T("Invalid Margin");
case 1: MarginL = value; break; Margin[which] = value;
case 2: MarginR = value; break;
case 3: MarginV = value; break;
default: throw _T("Invalid margin");
}
} }
////////////////////////// //////////////////////////
// Gets string for margin // Gets string for margin
wxString AssDialogue::GetMarginString(int which,bool pad) { wxString AssDialogue::GetMarginString(int which,bool pad) {
int value; if (which < 0 || which >= 4) throw _T("Invalid margin");
switch (which) { int value = Margin[which];
case 1: value = MarginL; break;
case 2: value = MarginR; break;
case 3: value = MarginV; break;
default: throw _T("Invalid margin");
}
if (pad) return wxString::Format(_T("%04i"),value); if (pad) return wxString::Format(_T("%04i"),value);
else return wxString::Format(_T("%i"),value); else return wxString::Format(_T("%i"),value);
} }
@ -745,9 +736,7 @@ AssEntry *AssDialogue::Clone() {
final->Effect = Effect; final->Effect = Effect;
final->End = End; final->End = End;
final->Layer = Layer; final->Layer = Layer;
final->MarginL = MarginL; for (int i=0;i<4;i++) final->Margin[i] = Margin[i];
final->MarginR = MarginR;
final->MarginV = MarginV;
final->Start = Start; final->Start = Start;
final->StartMS = final->StartMS; final->StartMS = final->StartMS;
final->Style = Style; final->Style = Style;

View file

@ -164,9 +164,7 @@ public:
bool Comment; // Is this a comment line? bool Comment; // Is this a comment line?
int Layer; // Layer number int Layer; // Layer number
int MarginR; // Right margin int Margin[4]; // Margins: 0 = Left, 1 = Right, 2 = Top (Vertical), 3 = Bottom
int MarginL; // Left margin
int MarginV; // Vertical margin
AssTime Start; // Starting time AssTime Start; // Starting time
AssTime End; // Ending time AssTime End; // Ending time
wxString Style; // Style name wxString Style; // Style name
@ -192,8 +190,8 @@ public:
void ConvertTagsToSRT(); // Converts tags to SRT format void ConvertTagsToSRT(); // Converts tags to SRT format
void StripTags(); // Strips all tags from the text void StripTags(); // Strips all tags from the text
void Clear(); // Wipes all data void Clear(); // Wipes all data
void SetMarginString(const wxString value,int which); // Set string to a margin value (1 = left, 2 = right, 3 = vertical) void SetMarginString(const wxString value,int which); // Set string to a margin value (0 = left, 1 = right, 2 = vertical/top, 3 = bottom)
wxString GetMarginString(int which,bool pad=true); // Returns the string of a margin value (1 = left, 2 = right, 3 = vertical) wxString GetMarginString(int which,bool pad=true); // Returns the string of a margin value (0 = left, 1 = right, 2 = vertical/top, 3 = bottom)
void ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter*,void *userData),void *userData=NULL); // Callback to process parameters void ProcessParameters(void (*callback)(wxString,int,AssOverrideParameter*,void *userData),void *userData=NULL); // Callback to process parameters
wxString GetSSAText(); wxString GetSSAText();
bool CollidesWith(AssDialogue *target); // Checks if two lines collide bool CollidesWith(AssDialogue *target); // Checks if two lines collide

View file

@ -374,15 +374,15 @@ bool AssStyle::Parse(wxString rawData,bool IsSSA) {
// Read left margin // Read left margin
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
SetMarginString(tkn.GetNextToken(),1); SetMarginString(tkn.GetNextToken(),0);
// Read right margin // Read right margin
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
SetMarginString(tkn.GetNextToken(),2); SetMarginString(tkn.GetNextToken(),1);
// Read vertical margin // Read vertical margin
if (!tkn.HasMoreTokens()) return false; if (!tkn.HasMoreTokens()) return false;
SetMarginString(tkn.GetNextToken(),3); SetMarginString(tkn.GetNextToken(),2);
if (IsSSA) { if (IsSSA) {
// Read alpha level // Read alpha level
@ -455,9 +455,9 @@ void AssStyle::SetMarginString(const wxString str,int which) {
if (value < 0) value = 0; if (value < 0) value = 0;
if (value > 9999) value = 9999; if (value > 9999) value = 9999;
switch (which) { switch (which) {
case 1: MarginL = value; break; case 0: MarginL = value; break;
case 2: MarginR = value; break; case 1: MarginR = value; break;
case 3: MarginV = value; break; case 2: MarginV = value; break;
default: throw _T("Invalid margin"); default: throw _T("Invalid margin");
} }
} }

View file

@ -99,8 +99,8 @@ public:
bool Parse(wxString data,bool IsSSA=false); // Parses raw ASS/SSA data into everything else bool Parse(wxString data,bool IsSSA=false); // Parses raw ASS/SSA data into everything else
void UpdateData(); // Updates raw data void UpdateData(); // Updates raw data
wxString GetSSAText(); // Retrieves SSA-formatted style wxString GetSSAText(); // Retrieves SSA-formatted style
wxString GetMarginString(int which); // Returns the margin value as a string (1 = left, 2 = right, 3 = vertical) wxString GetMarginString(int which); // Returns the margin value as a string (0 = left, 1 = right, 2 = vertical/top, 3 = bottom)
void SetMarginString(const wxString value,int which); // Sets margin value from a string (1 = left, 2 = right, 3 = vertical) void SetMarginString(const wxString value,int which); // Sets margin value from a string (0 = left, 1 = right, 2 = vertical/top, 3 = bottom)
AssEntry *Clone(); AssEntry *Clone();

View file

@ -85,9 +85,14 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE
VolumeBar = new wxSlider(this,Audio_Volume,50,0,100,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL|wxSL_INVERSE); VolumeBar = new wxSlider(this,Audio_Volume,50,0,100,wxDefaultPosition,wxSize(-1,20),wxSL_VERTICAL|wxSL_INVERSE);
VolumeBar->PushEventHandler(new FocusEvent()); VolumeBar->PushEventHandler(new FocusEvent());
VolumeBar->SetToolTip(_("Audio Volume")); VolumeBar->SetToolTip(_("Audio Volume"));
bool link = Options.AsBool(_T("Audio Link"));
if (link) {
VolumeBar->SetValue(VerticalZoom->GetValue());
VolumeBar->Enable(false);
}
VerticalLink = new ToggleBitmap(this,Audio_Vertical_Link,wxBITMAP(toggle_audio_link)); VerticalLink = new ToggleBitmap(this,Audio_Vertical_Link,wxBITMAP(toggle_audio_link));
VerticalLink->SetToolTip(_("Link vertical zoom and volume sliders")); VerticalLink->SetToolTip(_("Link vertical zoom and volume sliders"));
VerticalLink->SetValue(Options.AsBool(_T("Audio Link"))); VerticalLink->SetValue(link);
// Display sizer // Display sizer
DisplaySizer = new wxBoxSizer(wxVERTICAL); DisplaySizer = new wxBoxSizer(wxVERTICAL);

View file

@ -61,6 +61,8 @@ DirectSoundPlayer::DirectSoundPlayer() {
buffer = NULL; buffer = NULL;
directSound = NULL; directSound = NULL;
thread = NULL;
threadRunning = false;
} }
@ -197,8 +199,8 @@ void DirectSoundPlayer::FillBuffer(bool fill) {
} }
// Get source wave // Get source wave
if (count1) provider->GetAudio(ptr1,playPos,count1); if (count1) provider->GetAudioWithVolume(ptr1,playPos,count1,volume);
if (count2) provider->GetAudio(ptr2,playPos+count1,count2); if (count2) provider->GetAudioWithVolume(ptr2,playPos+count1,count2,volume);
playPos += totalCount; playPos += totalCount;
// Unlock // Unlock
@ -215,21 +217,17 @@ void DirectSoundPlayer::Play(__int64 start,__int64 count) {
// Lock // Lock
wxMutexLocker locker(DSMutex); wxMutexLocker locker(DSMutex);
// Set variables
HRESULT res;
startPos = start;
endPos = start+count;
playPos = start;
offset = 0;
// Check if buffer is loaded // Check if buffer is loaded
if (!buffer) return; if (!buffer) return;
buffer->Stop();
// Create notification event // Create notification event
CloseHandle(notificationEvent);
notificationEvent = CreateEvent(NULL,false,false,NULL); notificationEvent = CreateEvent(NULL,false,false,NULL);
// Create notification interface // Create notification interface
IDirectSoundNotify8 *notify; IDirectSoundNotify8 *notify;
HRESULT res;
res = buffer->QueryInterface(IID_IDirectSoundNotify8,(LPVOID*)&notify); res = buffer->QueryInterface(IID_IDirectSoundNotify8,(LPVOID*)&notify);
if (!SUCCEEDED(res)) return; if (!SUCCEEDED(res)) return;
@ -246,6 +244,12 @@ void DirectSoundPlayer::Play(__int64 start,__int64 count) {
res = notify->SetNotificationPositions(4,positionNotify); res = notify->SetNotificationPositions(4,positionNotify);
notify->Release(); notify->Release();
// Set variables
startPos = start;
endPos = start+count;
playPos = start;
offset = 0;
// Fill buffer // Fill buffer
FillBuffer(false); FillBuffer(false);
@ -255,9 +259,11 @@ void DirectSoundPlayer::Play(__int64 start,__int64 count) {
if (SUCCEEDED(res)) playing = true; if (SUCCEEDED(res)) playing = true;
// Start thread // Start thread
thread = new DirectSoundPlayerThread(this); if (!thread) {
thread->Create(); thread = new DirectSoundPlayerThread(this);
thread->Run(); thread->Create();
thread->Run();
}
// Update timer // Update timer
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15); if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
@ -270,14 +276,21 @@ void DirectSoundPlayer::Stop(bool timerToo) {
// Lock // Lock
wxMutexLocker locker(DSMutex); wxMutexLocker locker(DSMutex);
// Check if buffer is loaded and playing // Stop the thread
if (!buffer || !playing) return; if (thread) {
thread->alive = false;
thread = NULL;
}
// Stop // Stop
buffer->Stop(); if (buffer) buffer->Stop();
// Stop the thread // Reset variables
thread = NULL; playing = false;
playPos = 0;
startPos = 0;
endPos = 0;
offset = 0;
// Close event handle // Close event handle
CloseHandle(notificationEvent); CloseHandle(notificationEvent);
@ -286,7 +299,6 @@ void DirectSoundPlayer::Stop(bool timerToo) {
if (timerToo && displayTimer) { if (timerToo && displayTimer) {
displayTimer->Stop(); displayTimer->Stop();
} }
playing = false;
} }
@ -327,8 +339,10 @@ __int64 DirectSoundPlayer::GetCurrentPosition() {
////////////////////// //////////////////////
// Thread constructor // Thread constructor
DirectSoundPlayerThread::DirectSoundPlayerThread(DirectSoundPlayer *par) : wxThread(wxTHREAD_DETACHED) { DirectSoundPlayerThread::DirectSoundPlayerThread(DirectSoundPlayer *par) : wxThread(wxTHREAD_JOINABLE) {
parent = par; parent = par;
alive = true;
parent->threadRunning = true;
} }
@ -343,34 +357,54 @@ DirectSoundPlayerThread::~DirectSoundPlayerThread() {
wxThread::ExitCode DirectSoundPlayerThread::Entry() { wxThread::ExitCode DirectSoundPlayerThread::Entry() {
// Variables // Variables
unsigned long int playPos,endPos,bufSize; unsigned long int playPos,endPos,bufSize;
bool playing;
// Wait for notification // Wait for notification
while (parent->playing) { while (alive) {
// Get variables // Get variables
parent->DSMutex.Lock(); bool booga = true;
playPos = parent->GetCurrentPosition(); if (booga) {
endPos = parent->endPos; if (!alive) break;
bufSize = parent->bufSize; wxMutexLocker locker(parent->DSMutex);
parent->DSMutex.Unlock(); if (!alive) break;
playPos = parent->GetCurrentPosition();
endPos = parent->endPos;
bufSize = parent->bufSize;
playing = parent->playing;
if (!alive) break;
}
// Flag as stopped playing, but don't actually stop yet
if (playPos > endPos) {
if (!alive) break;
wxMutexLocker locker(parent->DSMutex);
if (!alive) break;
parent->playing = false;
}
// Still playing? // Still playing?
if (playPos < endPos + bufSize/8) { if (playPos < endPos + bufSize/8) {
// Wait for signal // Wait for signal
if (!alive) break;
WaitForSingleObject(parent->notificationEvent,1000); WaitForSingleObject(parent->notificationEvent,1000);
if (!alive) break;
// Fill buffer // Fill buffer
//parent->DSMutex.Lock(); wxMutexLocker locker(parent->DSMutex);
if (!alive) break;
parent->FillBuffer(false); parent->FillBuffer(false);
//parent->DSMutex.Unlock(); if (!alive) break;
} }
// Over, stop it // Over, stop it
else { else {
parent->buffer->Stop(); if (alive) parent->Stop();
break; break;
} }
} }
//wxMutexLocker locker(parent->DSMutex);
parent->threadRunning = false;
Delete(); Delete();
return 0; return 0;
} }

View file

@ -57,6 +57,7 @@ private:
DirectSoundPlayer *parent; DirectSoundPlayer *parent;
public: public:
bool alive;
DirectSoundPlayerThread(DirectSoundPlayer *parent); DirectSoundPlayerThread(DirectSoundPlayer *parent);
~DirectSoundPlayerThread(); ~DirectSoundPlayerThread();
@ -88,6 +89,7 @@ private:
void FillBuffer(bool fill); void FillBuffer(bool fill);
DirectSoundPlayerThread *thread; DirectSoundPlayerThread *thread;
bool threadRunning;
public: public:
DirectSoundPlayer(); DirectSoundPlayer();

View file

@ -201,3 +201,25 @@ AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *
// Return // Return
return provider; return provider;
} }
/////////////////////////
// Get audio with volume
void AudioProvider::GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume) {
GetAudio(buf,start,count);
if (volume == 1.0) return;
if (bytes_per_sample == 2) {
// Read raw samples
short *buffer = (short*) buf;
int value;
// Modify
for (__int64 i=0;i<count;i++) {
value = (int)(buffer[i]*volume+0.5);
if (value < -0x8000) value = -0x8000;
if (value > 0x7FFF) value = 0x7FFF;
buffer[i] = value;
}
}
}

View file

@ -69,6 +69,7 @@ public:
virtual wxString GetFilename(); virtual wxString GetFilename();
virtual void GetAudio(void *buf, __int64 start, __int64 count)=0; virtual void GetAudio(void *buf, __int64 start, __int64 count)=0;
void GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume);
int GetChannels(); int GetChannels();
__int64 GetNumSamples(); __int64 GetNumSamples();

View file

@ -121,13 +121,13 @@ namespace Automation4 {
lua_pushstring(L, dia->Actor.mb_str(wxConvUTF8)); lua_pushstring(L, dia->Actor.mb_str(wxConvUTF8));
lua_setfield(L, -2, "actor"); lua_setfield(L, -2, "actor");
lua_pushnumber(L, dia->MarginL); lua_pushnumber(L, dia->Margin[0]);
lua_setfield(L, -2, "margin_l"); lua_setfield(L, -2, "margin_l");
lua_pushnumber(L, dia->MarginR); lua_pushnumber(L, dia->Margin[1]);
lua_setfield(L, -2, "margin_r"); lua_setfield(L, -2, "margin_r");
lua_pushnumber(L, dia->MarginV); // duplicating MarginV to margin_t and margin_b here lua_pushnumber(L, dia->Margin[2]);
lua_setfield(L, -2, "margin_t"); lua_setfield(L, -2, "margin_t");
lua_pushnumber(L, dia->MarginV); lua_pushnumber(L, dia->Margin[3]);
lua_setfield(L, -2, "margin_b"); lua_setfield(L, -2, "margin_b");
lua_pushstring(L, dia->Effect.mb_str(wxConvUTF8)); lua_pushstring(L, dia->Effect.mb_str(wxConvUTF8));
@ -329,7 +329,7 @@ namespace Automation4 {
GETINT(margin_l, "margin_l", "style") GETINT(margin_l, "margin_l", "style")
GETINT(margin_r, "margin_r", "style") GETINT(margin_r, "margin_r", "style")
GETINT(margin_t, "margin_t", "style") GETINT(margin_t, "margin_t", "style")
//GETINT(margin_b, "margin_b", "style") // skipping for now, since it's not used anyway GETINT(margin_b, "margin_b", "style")
GETINT(encoding, "encoding", "style") GETINT(encoding, "encoding", "style")
// leaving out relative_to and vertical // leaving out relative_to and vertical
@ -376,7 +376,7 @@ namespace Automation4 {
GETINT(margin_l, "margin_l", "dialogue") GETINT(margin_l, "margin_l", "dialogue")
GETINT(margin_r, "margin_r", "dialogue") GETINT(margin_r, "margin_r", "dialogue")
GETINT(margin_t, "margin_t", "dialogue") GETINT(margin_t, "margin_t", "dialogue")
//GETINT(margin_b, "margin_b", "dialogue") // skipping for now, since it's not used anyway GETINT(margin_b, "margin_b", "dialogue")
GETSTRING(effect, "effect", "dialogue") GETSTRING(effect, "effect", "dialogue")
//GETSTRING(userdata, "userdata", "dialogue") //GETSTRING(userdata, "userdata", "dialogue")
GETSTRING(text, "text", "dialogue") GETSTRING(text, "text", "dialogue")
@ -388,9 +388,10 @@ namespace Automation4 {
dia->End.SetMS(end_time); dia->End.SetMS(end_time);
dia->Style = style; dia->Style = style;
dia->Actor = actor; dia->Actor = actor;
dia->MarginL = margin_l; dia->Margin[0] = margin_l;
dia->MarginR = margin_r; dia->Margin[1] = margin_r;
dia->MarginV = margin_t; dia->Margin[2] = margin_t;
dia->Margin[3] = margin_b;
dia->Effect = effect; dia->Effect = effect;
dia->Text = text; dia->Text = text;
dia->UpdateData(); dia->UpdateData();

View file

@ -437,9 +437,9 @@ void BaseGrid::DrawImage(wxDC &dc) {
strings.Add(curDiag->Style); strings.Add(curDiag->Style);
strings.Add(curDiag->Actor); strings.Add(curDiag->Actor);
strings.Add(curDiag->Effect); strings.Add(curDiag->Effect);
strings.Add(curDiag->GetMarginString(0));
strings.Add(curDiag->GetMarginString(1)); strings.Add(curDiag->GetMarginString(1));
strings.Add(curDiag->GetMarginString(2)); strings.Add(curDiag->GetMarginString(2));
strings.Add(curDiag->GetMarginString(3));
// Set text // Set text
int mode = Options.AsInt(_T("Grid Hide Overrides")); int mode = Options.AsInt(_T("Grid Hide Overrides"));

View file

@ -46,6 +46,9 @@
DialogPasteOver::DialogPasteOver (wxWindow *parent) DialogPasteOver::DialogPasteOver (wxWindow *parent)
: wxDialog (parent,-1,_("Select Fields to Paste Over"),wxDefaultPosition,wxDefaultSize) : wxDialog (parent,-1,_("Select Fields to Paste Over"),wxDefaultPosition,wxDefaultSize)
{ {
// Script mode
int mode = 1; // ASS
// List box // List box
wxArrayString choices; wxArrayString choices;
choices.Add(_T("Layer")); choices.Add(_T("Layer"));
@ -55,13 +58,19 @@ DialogPasteOver::DialogPasteOver (wxWindow *parent)
choices.Add(_T("Actor")); choices.Add(_T("Actor"));
choices.Add(_T("Margin Left")); choices.Add(_T("Margin Left"));
choices.Add(_T("Margin Right")); choices.Add(_T("Margin Right"));
choices.Add(_T("Margin Vertical")); if (mode == 1) {
choices.Add(_T("Margin Vertical"));
}
else {
choices.Add(_T("Margin Top"));
choices.Add(_T("Margin Bottom"));
}
choices.Add(_T("Effect")); choices.Add(_T("Effect"));
choices.Add(_T("Text")); choices.Add(_T("Text"));
ListBox = new wxCheckListBox(this,-1,wxDefaultPosition,wxSize(250,170), choices); ListBox = new wxCheckListBox(this,-1,wxDefaultPosition,wxSize(250,170), choices);
// Load checked items // Load checked items
for (int i=0;i<10;i++) ListBox->Check(i,Options.AsBool(wxString::Format(_T("Paste Over #%i"),i))); for (unsigned int i=0;i<choices.Count();i++) ListBox->Check(i,Options.AsBool(wxString::Format(_T("Paste Over #%i"),i)));
// Label and list sizer // Label and list sizer
wxStaticText *label = new wxStaticText(this,-1,_("Please select the fields that you want to paste over::"),wxDefaultPosition,wxDefaultSize); wxStaticText *label = new wxStaticText(this,-1,_("Please select the fields that you want to paste over::"),wxDefaultPosition,wxDefaultSize);
@ -115,8 +124,8 @@ END_EVENT_TABLE()
// OK pressed // OK pressed
void DialogPasteOver::OnOK(wxCommandEvent &event) { void DialogPasteOver::OnOK(wxCommandEvent &event) {
// Set options // Set options
options.SetCount(10); options.SetCount(11);
for (int i=0;i<10;i++) { for (int i=0;i<11;i++) {
options[i] = ListBox->IsChecked(i) ? 1 : 0; options[i] = ListBox->IsChecked(i) ? 1 : 0;
Options.SetBool(wxString::Format(_T("Paste Over #%i"),i),options[i]==1); Options.SetBool(wxString::Format(_T("Paste Over #%i"),i),options[i]==1);
} }
@ -137,15 +146,15 @@ void DialogPasteOver::OnCancel(wxCommandEvent &event) {
/////////////// ///////////////
// Select Text // Select Text
void DialogPasteOver::OnText(wxCommandEvent &event) { void DialogPasteOver::OnText(wxCommandEvent &event) {
for (int i=0;i<9;i++) ListBox->Check(i,false); for (int i=0;i<10;i++) ListBox->Check(i,false);
ListBox->Check(9,true); ListBox->Check(10,true);
} }
//////////////// ////////////////
// Select Times // Select Times
void DialogPasteOver::OnTimes(wxCommandEvent &event) { void DialogPasteOver::OnTimes(wxCommandEvent &event) {
for (int i=0;i<10;i++) ListBox->Check(i,false); for (int i=0;i<11;i++) ListBox->Check(i,false);
ListBox->Check(1,true); ListBox->Check(1,true);
ListBox->Check(2,true); ListBox->Check(2,true);
} }
@ -154,14 +163,14 @@ void DialogPasteOver::OnTimes(wxCommandEvent &event) {
////////////// //////////////
// Select All // Select All
void DialogPasteOver::OnAll(wxCommandEvent &event) { void DialogPasteOver::OnAll(wxCommandEvent &event) {
for (int i=0;i<10;i++) ListBox->Check(i,true); for (int i=0;i<11;i++) ListBox->Check(i,true);
} }
/////////////// ///////////////
// Select None // Select None
void DialogPasteOver::OnNone(wxCommandEvent &event) { void DialogPasteOver::OnNone(wxCommandEvent &event) {
for (int i=0;i<10;i++) ListBox->Check(i,false); for (int i=0;i<11;i++) ListBox->Check(i,false);
} }

View file

@ -197,9 +197,10 @@ void DialogResample::OnResample (wxCommandEvent &event) {
} }
// Margins // Margins
curDiag->MarginL = int(curDiag->MarginL * rx + 0.5); for (int i=0;i<2;i++) {
curDiag->MarginR = int(curDiag->MarginR * rx + 0.5); curDiag->Margin[i] = int(curDiag->Margin[i] * rx + 0.5);
curDiag->MarginV = int(curDiag->MarginV * ry + 0.5); curDiag->Margin[i+2] = int(curDiag->Margin[i+2] * ry + 0.5);
}
// Update // Update
curDiag->UpdateText(); curDiag->UpdateText();

View file

@ -146,11 +146,11 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
wxSizer *MarginSizerL = new wxBoxSizer(wxVERTICAL); wxSizer *MarginSizerL = new wxBoxSizer(wxVERTICAL);
wxSizer *MarginSizerR = new wxBoxSizer(wxVERTICAL); wxSizer *MarginSizerR = new wxBoxSizer(wxVERTICAL);
wxSizer *MarginSizerV = new wxBoxSizer(wxVERTICAL); wxSizer *MarginSizerV = new wxBoxSizer(wxVERTICAL);
MarginLValue = style->GetMarginString(1); MarginLValue = style->GetMarginString(0);
MarginL = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&MarginLValue)); MarginL = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&MarginLValue));
MarginRValue = style->GetMarginString(2); MarginRValue = style->GetMarginString(1);
MarginR = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&MarginRValue)); MarginR = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&MarginRValue));
MarginVValue = style->GetMarginString(3); MarginVValue = style->GetMarginString(2);
MarginV = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&MarginVValue)); MarginV = new wxTextCtrl(this,-1,_T(""),wxDefaultPosition,wxSize(40,20),0,NumValidator(&MarginVValue));
MarginL->SetToolTip(_("Distance from left edge, in pixels")); MarginL->SetToolTip(_("Distance from left edge, in pixels"));
MarginR->SetToolTip(_("Distance from right edge, in pixels")); MarginR->SetToolTip(_("Distance from right edge, in pixels"));
@ -422,9 +422,9 @@ void DialogStyleEditor::Apply (bool apply,bool close) {
work->alignment = ControlToAlign(Alignment->GetSelection()); work->alignment = ControlToAlign(Alignment->GetSelection());
// Margins // Margins
work->SetMarginString(MarginL->GetValue(),1); work->SetMarginString(MarginL->GetValue(),0);
work->SetMarginString(MarginR->GetValue(),2); work->SetMarginString(MarginR->GetValue(),1);
work->SetMarginString(MarginV->GetValue(),3); work->SetMarginString(MarginV->GetValue(),2);
// Color alphas // Color alphas
ColorAlpha1->GetValue().ToLong(&templ); ColorAlpha1->GetValue().ToLong(&templ);

View file

@ -249,9 +249,9 @@ void SubsEditBox::Update (bool timeOnly) {
if (!timeOnly) { if (!timeOnly) {
TextEdit->SetTextTo(curdiag->Text); TextEdit->SetTextTo(curdiag->Text);
Layer->SetValue(wxString::Format(_T("%i"),curdiag->Layer)); Layer->SetValue(wxString::Format(_T("%i"),curdiag->Layer));
MarginL->SetValue(curdiag->GetMarginString(1,false)); MarginL->SetValue(curdiag->GetMarginString(0,false));
MarginR->SetValue(curdiag->GetMarginString(2,false)); MarginR->SetValue(curdiag->GetMarginString(1,false));
MarginV->SetValue(curdiag->GetMarginString(3,false)); MarginV->SetValue(curdiag->GetMarginString(2,false));
Effect->SetValue(curdiag->Effect); Effect->SetValue(curdiag->Effect);
CommentBox->SetValue(curdiag->Comment); CommentBox->SetValue(curdiag->Comment);
StyleBox->Select(StyleBox->FindString(curdiag->Style)); StyleBox->Select(StyleBox->FindString(curdiag->Style));
@ -699,11 +699,11 @@ void SubsEditBox::OnMarginLChange(wxCommandEvent &event) {
for (int i=0;i<n;i++) { for (int i=0;i<n;i++) {
cur = grid->GetDialogue(sel[i]); cur = grid->GetDialogue(sel[i]);
if (cur) { if (cur) {
cur->SetMarginString(MarginL->GetValue(),1); cur->SetMarginString(MarginL->GetValue(),0);
cur->UpdateData(); cur->UpdateData();
} }
} }
MarginL->SetValue(cur->GetMarginString(1,false)); MarginL->SetValue(cur->GetMarginString(0,false));
grid->ass->FlagAsModified(); grid->ass->FlagAsModified();
grid->CommitChanges(); grid->CommitChanges();
grid->EndBatch(); grid->EndBatch();
@ -721,11 +721,11 @@ void SubsEditBox::OnMarginRChange(wxCommandEvent &event) {
for (int i=0;i<n;i++) { for (int i=0;i<n;i++) {
cur = grid->GetDialogue(sel[i]); cur = grid->GetDialogue(sel[i]);
if (cur) { if (cur) {
cur->SetMarginString(MarginR->GetValue(),2); cur->SetMarginString(MarginR->GetValue(),1);
cur->UpdateData(); cur->UpdateData();
} }
} }
MarginR->SetValue(cur->GetMarginString(2,false)); MarginR->SetValue(cur->GetMarginString(1,false));
grid->ass->FlagAsModified(); grid->ass->FlagAsModified();
grid->CommitChanges(); grid->CommitChanges();
grid->EndBatch(); grid->EndBatch();
@ -743,11 +743,11 @@ void SubsEditBox::OnMarginVChange(wxCommandEvent &event) {
for (int i=0;i<n;i++) { for (int i=0;i<n;i++) {
cur = grid->GetDialogue(sel[i]); cur = grid->GetDialogue(sel[i]);
if (cur) { if (cur) {
cur->SetMarginString(MarginV->GetValue(),3); cur->SetMarginString(MarginV->GetValue(),2);
cur->UpdateData(); cur->UpdateData();
} }
} }
MarginV->SetValue(cur->GetMarginString(3,false)); MarginV->SetValue(cur->GetMarginString(2,false));
grid->ass->FlagAsModified(); grid->ass->FlagAsModified();
grid->CommitChanges(); grid->CommitChanges();
grid->EndBatch(); grid->EndBatch();

View file

@ -863,11 +863,12 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
if (pasteOverOptions[2]) target->End = curdiag->End; if (pasteOverOptions[2]) target->End = curdiag->End;
if (pasteOverOptions[3]) target->Style = curdiag->Style; if (pasteOverOptions[3]) target->Style = curdiag->Style;
if (pasteOverOptions[4]) target->Actor = curdiag->Actor; if (pasteOverOptions[4]) target->Actor = curdiag->Actor;
if (pasteOverOptions[5]) target->MarginL = curdiag->MarginL; if (pasteOverOptions[5]) target->Margin[0] = curdiag->Margin[0];
if (pasteOverOptions[6]) target->MarginR = curdiag->MarginR; if (pasteOverOptions[6]) target->Margin[1] = curdiag->Margin[1];
if (pasteOverOptions[7]) target->MarginV = curdiag->MarginV; if (pasteOverOptions[7]) target->Margin[2] = curdiag->Margin[2];
if (pasteOverOptions[8]) target->Effect = curdiag->Effect; if (pasteOverOptions[8]) target->Margin[3] = curdiag->Margin[3];
if (pasteOverOptions[9]) target->Text = curdiag->Text; if (pasteOverOptions[9]) target->Effect = curdiag->Effect;
if (pasteOverOptions[10]) target->Text = curdiag->Text;
} }
delete curdiag; delete curdiag;
} }