mirror of https://github.com/odrling/Aegisub
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:
parent
4384dbe2c4
commit
b3f2f069d3
|
@ -64,7 +64,7 @@ AssDialogue::AssDialogue() {
|
|||
End.SetMS(5000);
|
||||
StartMS = 0;
|
||||
Layer = 0;
|
||||
MarginR = MarginL = MarginV = 0;
|
||||
for (int i=0;i<4;i++) Margin[i] = 0;
|
||||
Text = _T("");
|
||||
Style = _T("Default");
|
||||
Actor = _T("");
|
||||
|
@ -178,15 +178,15 @@ bool AssDialogue::Parse(wxString rawData, bool IsSSA) {
|
|||
|
||||
// Get left margin
|
||||
if (!tkn.HasMoreTokens()) return false;
|
||||
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),1);
|
||||
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),0);
|
||||
|
||||
// Get right margin
|
||||
if (!tkn.HasMoreTokens()) return false;
|
||||
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),2);
|
||||
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),1);
|
||||
|
||||
// Get vertical margin
|
||||
if (!tkn.HasMoreTokens()) return false;
|
||||
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),3);
|
||||
SetMarginString(tkn.GetNextToken().Trim(false).Trim(true),2);
|
||||
|
||||
// Get effect
|
||||
if (!tkn.HasMoreTokens()) return false;
|
||||
|
@ -234,12 +234,12 @@ wxString AssDialogue::MakeData() {
|
|||
final += Style + _T(",");
|
||||
final += Actor + _T(",");
|
||||
|
||||
final += GetMarginString(0);
|
||||
final += _T(",");
|
||||
final += GetMarginString(1);
|
||||
final += _T(",");
|
||||
final += GetMarginString(2);
|
||||
final += _T(",");
|
||||
final += GetMarginString(3);
|
||||
final += _T(",");
|
||||
|
||||
Effect.Replace(_T(","),_T(";"));
|
||||
final += Effect + _T(",");
|
||||
|
@ -287,12 +287,12 @@ wxString AssDialogue::GetSSAText () {
|
|||
work += Style + _T(",");
|
||||
work += Actor + _T(",");
|
||||
|
||||
work += GetMarginString(0);
|
||||
work += _T(",");
|
||||
work += GetMarginString(1);
|
||||
work += _T(",");
|
||||
work += GetMarginString(2);
|
||||
work += _T(",");
|
||||
work += GetMarginString(3);
|
||||
work += _T(",");
|
||||
|
||||
Effect.Replace(_T(","),_T(";"));
|
||||
work += Effect + _T(",");
|
||||
|
@ -678,25 +678,16 @@ void AssDialogue::SetMarginString(const wxString origvalue,int which) {
|
|||
if (value > 9999) value = 9999;
|
||||
|
||||
// Assign
|
||||
switch (which) {
|
||||
case 1: MarginL = value; break;
|
||||
case 2: MarginR = value; break;
|
||||
case 3: MarginV = value; break;
|
||||
default: throw _T("Invalid margin");
|
||||
}
|
||||
if (which < 0 || which >= 4) throw _T("Invalid Margin");
|
||||
Margin[which] = value;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
// Gets string for margin
|
||||
wxString AssDialogue::GetMarginString(int which,bool pad) {
|
||||
int value;
|
||||
switch (which) {
|
||||
case 1: value = MarginL; break;
|
||||
case 2: value = MarginR; break;
|
||||
case 3: value = MarginV; break;
|
||||
default: throw _T("Invalid margin");
|
||||
}
|
||||
if (which < 0 || which >= 4) throw _T("Invalid margin");
|
||||
int value = Margin[which];
|
||||
if (pad) return wxString::Format(_T("%04i"),value);
|
||||
else return wxString::Format(_T("%i"),value);
|
||||
}
|
||||
|
@ -745,9 +736,7 @@ AssEntry *AssDialogue::Clone() {
|
|||
final->Effect = Effect;
|
||||
final->End = End;
|
||||
final->Layer = Layer;
|
||||
final->MarginL = MarginL;
|
||||
final->MarginR = MarginR;
|
||||
final->MarginV = MarginV;
|
||||
for (int i=0;i<4;i++) final->Margin[i] = Margin[i];
|
||||
final->Start = Start;
|
||||
final->StartMS = final->StartMS;
|
||||
final->Style = Style;
|
||||
|
|
|
@ -164,9 +164,7 @@ public:
|
|||
|
||||
bool Comment; // Is this a comment line?
|
||||
int Layer; // Layer number
|
||||
int MarginR; // Right margin
|
||||
int MarginL; // Left margin
|
||||
int MarginV; // Vertical margin
|
||||
int Margin[4]; // Margins: 0 = Left, 1 = Right, 2 = Top (Vertical), 3 = Bottom
|
||||
AssTime Start; // Starting time
|
||||
AssTime End; // Ending time
|
||||
wxString Style; // Style name
|
||||
|
@ -192,8 +190,8 @@ public:
|
|||
void ConvertTagsToSRT(); // Converts tags to SRT format
|
||||
void StripTags(); // Strips all tags from the text
|
||||
void Clear(); // Wipes all data
|
||||
void SetMarginString(const wxString value,int which); // Set string to a margin value (1 = left, 2 = right, 3 = vertical)
|
||||
wxString GetMarginString(int which,bool pad=true); // Returns the string of 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 (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
|
||||
wxString GetSSAText();
|
||||
bool CollidesWith(AssDialogue *target); // Checks if two lines collide
|
||||
|
|
|
@ -374,15 +374,15 @@ bool AssStyle::Parse(wxString rawData,bool IsSSA) {
|
|||
|
||||
// Read left margin
|
||||
if (!tkn.HasMoreTokens()) return false;
|
||||
SetMarginString(tkn.GetNextToken(),1);
|
||||
SetMarginString(tkn.GetNextToken(),0);
|
||||
|
||||
// Read right margin
|
||||
if (!tkn.HasMoreTokens()) return false;
|
||||
SetMarginString(tkn.GetNextToken(),2);
|
||||
SetMarginString(tkn.GetNextToken(),1);
|
||||
|
||||
// Read vertical margin
|
||||
if (!tkn.HasMoreTokens()) return false;
|
||||
SetMarginString(tkn.GetNextToken(),3);
|
||||
SetMarginString(tkn.GetNextToken(),2);
|
||||
|
||||
if (IsSSA) {
|
||||
// Read alpha level
|
||||
|
@ -455,9 +455,9 @@ void AssStyle::SetMarginString(const wxString str,int which) {
|
|||
if (value < 0) value = 0;
|
||||
if (value > 9999) value = 9999;
|
||||
switch (which) {
|
||||
case 1: MarginL = value; break;
|
||||
case 2: MarginR = value; break;
|
||||
case 3: MarginV = value; break;
|
||||
case 0: MarginL = value; break;
|
||||
case 1: MarginR = value; break;
|
||||
case 2: MarginV = value; break;
|
||||
default: throw _T("Invalid margin");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,8 +99,8 @@ public:
|
|||
bool Parse(wxString data,bool IsSSA=false); // Parses raw ASS/SSA data into everything else
|
||||
void UpdateData(); // Updates raw data
|
||||
wxString GetSSAText(); // Retrieves SSA-formatted style
|
||||
wxString GetMarginString(int which); // Returns the margin value as a string (1 = left, 2 = right, 3 = vertical)
|
||||
void SetMarginString(const wxString value,int which); // Sets margin value from 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 (0 = left, 1 = right, 2 = vertical/top, 3 = bottom)
|
||||
|
||||
AssEntry *Clone();
|
||||
|
||||
|
|
|
@ -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->PushEventHandler(new FocusEvent());
|
||||
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->SetToolTip(_("Link vertical zoom and volume sliders"));
|
||||
VerticalLink->SetValue(Options.AsBool(_T("Audio Link")));
|
||||
VerticalLink->SetValue(link);
|
||||
|
||||
// Display sizer
|
||||
DisplaySizer = new wxBoxSizer(wxVERTICAL);
|
||||
|
|
|
@ -61,6 +61,8 @@ DirectSoundPlayer::DirectSoundPlayer() {
|
|||
|
||||
buffer = NULL;
|
||||
directSound = NULL;
|
||||
thread = NULL;
|
||||
threadRunning = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -197,8 +199,8 @@ void DirectSoundPlayer::FillBuffer(bool fill) {
|
|||
}
|
||||
|
||||
// Get source wave
|
||||
if (count1) provider->GetAudio(ptr1,playPos,count1);
|
||||
if (count2) provider->GetAudio(ptr2,playPos+count1,count2);
|
||||
if (count1) provider->GetAudioWithVolume(ptr1,playPos,count1,volume);
|
||||
if (count2) provider->GetAudioWithVolume(ptr2,playPos+count1,count2,volume);
|
||||
playPos += totalCount;
|
||||
|
||||
// Unlock
|
||||
|
@ -215,21 +217,17 @@ void DirectSoundPlayer::Play(__int64 start,__int64 count) {
|
|||
// Lock
|
||||
wxMutexLocker locker(DSMutex);
|
||||
|
||||
// Set variables
|
||||
HRESULT res;
|
||||
startPos = start;
|
||||
endPos = start+count;
|
||||
playPos = start;
|
||||
offset = 0;
|
||||
|
||||
// Check if buffer is loaded
|
||||
if (!buffer) return;
|
||||
buffer->Stop();
|
||||
|
||||
// Create notification event
|
||||
CloseHandle(notificationEvent);
|
||||
notificationEvent = CreateEvent(NULL,false,false,NULL);
|
||||
|
||||
// Create notification interface
|
||||
IDirectSoundNotify8 *notify;
|
||||
HRESULT res;
|
||||
res = buffer->QueryInterface(IID_IDirectSoundNotify8,(LPVOID*)¬ify);
|
||||
if (!SUCCEEDED(res)) return;
|
||||
|
||||
|
@ -246,6 +244,12 @@ void DirectSoundPlayer::Play(__int64 start,__int64 count) {
|
|||
res = notify->SetNotificationPositions(4,positionNotify);
|
||||
notify->Release();
|
||||
|
||||
// Set variables
|
||||
startPos = start;
|
||||
endPos = start+count;
|
||||
playPos = start;
|
||||
offset = 0;
|
||||
|
||||
// Fill buffer
|
||||
FillBuffer(false);
|
||||
|
||||
|
@ -255,9 +259,11 @@ void DirectSoundPlayer::Play(__int64 start,__int64 count) {
|
|||
if (SUCCEEDED(res)) playing = true;
|
||||
|
||||
// Start thread
|
||||
thread = new DirectSoundPlayerThread(this);
|
||||
thread->Create();
|
||||
thread->Run();
|
||||
if (!thread) {
|
||||
thread = new DirectSoundPlayerThread(this);
|
||||
thread->Create();
|
||||
thread->Run();
|
||||
}
|
||||
|
||||
// Update timer
|
||||
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
|
||||
|
@ -270,23 +276,29 @@ void DirectSoundPlayer::Stop(bool timerToo) {
|
|||
// Lock
|
||||
wxMutexLocker locker(DSMutex);
|
||||
|
||||
// Check if buffer is loaded and playing
|
||||
if (!buffer || !playing) return;
|
||||
// Stop the thread
|
||||
if (thread) {
|
||||
thread->alive = false;
|
||||
thread = NULL;
|
||||
}
|
||||
|
||||
// Stop
|
||||
buffer->Stop();
|
||||
if (buffer) buffer->Stop();
|
||||
|
||||
// Stop the thread
|
||||
thread = NULL;
|
||||
// Reset variables
|
||||
playing = false;
|
||||
playPos = 0;
|
||||
startPos = 0;
|
||||
endPos = 0;
|
||||
offset = 0;
|
||||
|
||||
// Close event handle
|
||||
CloseHandle(notificationEvent);
|
||||
|
||||
|
||||
// Stop timer
|
||||
if (timerToo && displayTimer) {
|
||||
displayTimer->Stop();
|
||||
}
|
||||
playing = false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,8 +339,10 @@ __int64 DirectSoundPlayer::GetCurrentPosition() {
|
|||
|
||||
//////////////////////
|
||||
// Thread constructor
|
||||
DirectSoundPlayerThread::DirectSoundPlayerThread(DirectSoundPlayer *par) : wxThread(wxTHREAD_DETACHED) {
|
||||
DirectSoundPlayerThread::DirectSoundPlayerThread(DirectSoundPlayer *par) : wxThread(wxTHREAD_JOINABLE) {
|
||||
parent = par;
|
||||
alive = true;
|
||||
parent->threadRunning = true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -343,34 +357,54 @@ DirectSoundPlayerThread::~DirectSoundPlayerThread() {
|
|||
wxThread::ExitCode DirectSoundPlayerThread::Entry() {
|
||||
// Variables
|
||||
unsigned long int playPos,endPos,bufSize;
|
||||
bool playing;
|
||||
|
||||
// Wait for notification
|
||||
while (parent->playing) {
|
||||
while (alive) {
|
||||
// Get variables
|
||||
parent->DSMutex.Lock();
|
||||
playPos = parent->GetCurrentPosition();
|
||||
endPos = parent->endPos;
|
||||
bufSize = parent->bufSize;
|
||||
parent->DSMutex.Unlock();
|
||||
bool booga = true;
|
||||
if (booga) {
|
||||
if (!alive) break;
|
||||
wxMutexLocker locker(parent->DSMutex);
|
||||
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?
|
||||
if (playPos < endPos + bufSize/8) {
|
||||
// Wait for signal
|
||||
if (!alive) break;
|
||||
WaitForSingleObject(parent->notificationEvent,1000);
|
||||
if (!alive) break;
|
||||
|
||||
// Fill buffer
|
||||
//parent->DSMutex.Lock();
|
||||
wxMutexLocker locker(parent->DSMutex);
|
||||
if (!alive) break;
|
||||
parent->FillBuffer(false);
|
||||
//parent->DSMutex.Unlock();
|
||||
if (!alive) break;
|
||||
}
|
||||
|
||||
// Over, stop it
|
||||
else {
|
||||
parent->buffer->Stop();
|
||||
if (alive) parent->Stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//wxMutexLocker locker(parent->DSMutex);
|
||||
parent->threadRunning = false;
|
||||
Delete();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ private:
|
|||
DirectSoundPlayer *parent;
|
||||
|
||||
public:
|
||||
bool alive;
|
||||
DirectSoundPlayerThread(DirectSoundPlayer *parent);
|
||||
~DirectSoundPlayerThread();
|
||||
|
||||
|
@ -88,6 +89,7 @@ private:
|
|||
void FillBuffer(bool fill);
|
||||
|
||||
DirectSoundPlayerThread *thread;
|
||||
bool threadRunning;
|
||||
|
||||
public:
|
||||
DirectSoundPlayer();
|
||||
|
|
|
@ -201,3 +201,25 @@ AudioProvider *AudioProvider::GetAudioProvider(wxString filename, AudioDisplay *
|
|||
// Return
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public:
|
|||
|
||||
virtual wxString GetFilename();
|
||||
virtual void GetAudio(void *buf, __int64 start, __int64 count)=0;
|
||||
void GetAudioWithVolume(void *buf, __int64 start, __int64 count, double volume);
|
||||
|
||||
int GetChannels();
|
||||
__int64 GetNumSamples();
|
||||
|
|
|
@ -121,13 +121,13 @@ namespace Automation4 {
|
|||
lua_pushstring(L, dia->Actor.mb_str(wxConvUTF8));
|
||||
lua_setfield(L, -2, "actor");
|
||||
|
||||
lua_pushnumber(L, dia->MarginL);
|
||||
lua_pushnumber(L, dia->Margin[0]);
|
||||
lua_setfield(L, -2, "margin_l");
|
||||
lua_pushnumber(L, dia->MarginR);
|
||||
lua_pushnumber(L, dia->Margin[1]);
|
||||
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_pushnumber(L, dia->MarginV);
|
||||
lua_pushnumber(L, dia->Margin[3]);
|
||||
lua_setfield(L, -2, "margin_b");
|
||||
|
||||
lua_pushstring(L, dia->Effect.mb_str(wxConvUTF8));
|
||||
|
@ -329,7 +329,7 @@ namespace Automation4 {
|
|||
GETINT(margin_l, "margin_l", "style")
|
||||
GETINT(margin_r, "margin_r", "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")
|
||||
// leaving out relative_to and vertical
|
||||
|
||||
|
@ -376,7 +376,7 @@ namespace Automation4 {
|
|||
GETINT(margin_l, "margin_l", "dialogue")
|
||||
GETINT(margin_r, "margin_r", "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(userdata, "userdata", "dialogue")
|
||||
GETSTRING(text, "text", "dialogue")
|
||||
|
@ -388,9 +388,10 @@ namespace Automation4 {
|
|||
dia->End.SetMS(end_time);
|
||||
dia->Style = style;
|
||||
dia->Actor = actor;
|
||||
dia->MarginL = margin_l;
|
||||
dia->MarginR = margin_r;
|
||||
dia->MarginV = margin_t;
|
||||
dia->Margin[0] = margin_l;
|
||||
dia->Margin[1] = margin_r;
|
||||
dia->Margin[2] = margin_t;
|
||||
dia->Margin[3] = margin_b;
|
||||
dia->Effect = effect;
|
||||
dia->Text = text;
|
||||
dia->UpdateData();
|
||||
|
|
|
@ -437,9 +437,9 @@ void BaseGrid::DrawImage(wxDC &dc) {
|
|||
strings.Add(curDiag->Style);
|
||||
strings.Add(curDiag->Actor);
|
||||
strings.Add(curDiag->Effect);
|
||||
strings.Add(curDiag->GetMarginString(0));
|
||||
strings.Add(curDiag->GetMarginString(1));
|
||||
strings.Add(curDiag->GetMarginString(2));
|
||||
strings.Add(curDiag->GetMarginString(3));
|
||||
|
||||
// Set text
|
||||
int mode = Options.AsInt(_T("Grid Hide Overrides"));
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
DialogPasteOver::DialogPasteOver (wxWindow *parent)
|
||||
: wxDialog (parent,-1,_("Select Fields to Paste Over"),wxDefaultPosition,wxDefaultSize)
|
||||
{
|
||||
// Script mode
|
||||
int mode = 1; // ASS
|
||||
|
||||
// List box
|
||||
wxArrayString choices;
|
||||
choices.Add(_T("Layer"));
|
||||
|
@ -55,13 +58,19 @@ DialogPasteOver::DialogPasteOver (wxWindow *parent)
|
|||
choices.Add(_T("Actor"));
|
||||
choices.Add(_T("Margin Left"));
|
||||
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("Text"));
|
||||
ListBox = new wxCheckListBox(this,-1,wxDefaultPosition,wxSize(250,170), choices);
|
||||
|
||||
// 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
|
||||
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
|
||||
void DialogPasteOver::OnOK(wxCommandEvent &event) {
|
||||
// Set options
|
||||
options.SetCount(10);
|
||||
for (int i=0;i<10;i++) {
|
||||
options.SetCount(11);
|
||||
for (int i=0;i<11;i++) {
|
||||
options[i] = ListBox->IsChecked(i) ? 1 : 0;
|
||||
Options.SetBool(wxString::Format(_T("Paste Over #%i"),i),options[i]==1);
|
||||
}
|
||||
|
@ -137,15 +146,15 @@ void DialogPasteOver::OnCancel(wxCommandEvent &event) {
|
|||
///////////////
|
||||
// Select Text
|
||||
void DialogPasteOver::OnText(wxCommandEvent &event) {
|
||||
for (int i=0;i<9;i++) ListBox->Check(i,false);
|
||||
ListBox->Check(9,true);
|
||||
for (int i=0;i<10;i++) ListBox->Check(i,false);
|
||||
ListBox->Check(10,true);
|
||||
}
|
||||
|
||||
|
||||
////////////////
|
||||
// Select Times
|
||||
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(2,true);
|
||||
}
|
||||
|
@ -154,14 +163,14 @@ void DialogPasteOver::OnTimes(wxCommandEvent &event) {
|
|||
//////////////
|
||||
// Select All
|
||||
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
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -197,9 +197,10 @@ void DialogResample::OnResample (wxCommandEvent &event) {
|
|||
}
|
||||
|
||||
// Margins
|
||||
curDiag->MarginL = int(curDiag->MarginL * rx + 0.5);
|
||||
curDiag->MarginR = int(curDiag->MarginR * rx + 0.5);
|
||||
curDiag->MarginV = int(curDiag->MarginV * ry + 0.5);
|
||||
for (int i=0;i<2;i++) {
|
||||
curDiag->Margin[i] = int(curDiag->Margin[i] * rx + 0.5);
|
||||
curDiag->Margin[i+2] = int(curDiag->Margin[i+2] * ry + 0.5);
|
||||
}
|
||||
|
||||
// Update
|
||||
curDiag->UpdateText();
|
||||
|
|
|
@ -146,11 +146,11 @@ DialogStyleEditor::DialogStyleEditor (wxWindow *parent, AssStyle *_style, Subtit
|
|||
wxSizer *MarginSizerL = new wxBoxSizer(wxVERTICAL);
|
||||
wxSizer *MarginSizerR = 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));
|
||||
MarginRValue = style->GetMarginString(2);
|
||||
MarginRValue = style->GetMarginString(1);
|
||||
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));
|
||||
MarginL->SetToolTip(_("Distance from left 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());
|
||||
|
||||
// Margins
|
||||
work->SetMarginString(MarginL->GetValue(),1);
|
||||
work->SetMarginString(MarginR->GetValue(),2);
|
||||
work->SetMarginString(MarginV->GetValue(),3);
|
||||
work->SetMarginString(MarginL->GetValue(),0);
|
||||
work->SetMarginString(MarginR->GetValue(),1);
|
||||
work->SetMarginString(MarginV->GetValue(),2);
|
||||
|
||||
// Color alphas
|
||||
ColorAlpha1->GetValue().ToLong(&templ);
|
||||
|
|
|
@ -249,9 +249,9 @@ void SubsEditBox::Update (bool timeOnly) {
|
|||
if (!timeOnly) {
|
||||
TextEdit->SetTextTo(curdiag->Text);
|
||||
Layer->SetValue(wxString::Format(_T("%i"),curdiag->Layer));
|
||||
MarginL->SetValue(curdiag->GetMarginString(1,false));
|
||||
MarginR->SetValue(curdiag->GetMarginString(2,false));
|
||||
MarginV->SetValue(curdiag->GetMarginString(3,false));
|
||||
MarginL->SetValue(curdiag->GetMarginString(0,false));
|
||||
MarginR->SetValue(curdiag->GetMarginString(1,false));
|
||||
MarginV->SetValue(curdiag->GetMarginString(2,false));
|
||||
Effect->SetValue(curdiag->Effect);
|
||||
CommentBox->SetValue(curdiag->Comment);
|
||||
StyleBox->Select(StyleBox->FindString(curdiag->Style));
|
||||
|
@ -699,11 +699,11 @@ void SubsEditBox::OnMarginLChange(wxCommandEvent &event) {
|
|||
for (int i=0;i<n;i++) {
|
||||
cur = grid->GetDialogue(sel[i]);
|
||||
if (cur) {
|
||||
cur->SetMarginString(MarginL->GetValue(),1);
|
||||
cur->SetMarginString(MarginL->GetValue(),0);
|
||||
cur->UpdateData();
|
||||
}
|
||||
}
|
||||
MarginL->SetValue(cur->GetMarginString(1,false));
|
||||
MarginL->SetValue(cur->GetMarginString(0,false));
|
||||
grid->ass->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
grid->EndBatch();
|
||||
|
@ -721,11 +721,11 @@ void SubsEditBox::OnMarginRChange(wxCommandEvent &event) {
|
|||
for (int i=0;i<n;i++) {
|
||||
cur = grid->GetDialogue(sel[i]);
|
||||
if (cur) {
|
||||
cur->SetMarginString(MarginR->GetValue(),2);
|
||||
cur->SetMarginString(MarginR->GetValue(),1);
|
||||
cur->UpdateData();
|
||||
}
|
||||
}
|
||||
MarginR->SetValue(cur->GetMarginString(2,false));
|
||||
MarginR->SetValue(cur->GetMarginString(1,false));
|
||||
grid->ass->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
grid->EndBatch();
|
||||
|
@ -743,11 +743,11 @@ void SubsEditBox::OnMarginVChange(wxCommandEvent &event) {
|
|||
for (int i=0;i<n;i++) {
|
||||
cur = grid->GetDialogue(sel[i]);
|
||||
if (cur) {
|
||||
cur->SetMarginString(MarginV->GetValue(),3);
|
||||
cur->SetMarginString(MarginV->GetValue(),2);
|
||||
cur->UpdateData();
|
||||
}
|
||||
}
|
||||
MarginV->SetValue(cur->GetMarginString(3,false));
|
||||
MarginV->SetValue(cur->GetMarginString(2,false));
|
||||
grid->ass->FlagAsModified();
|
||||
grid->CommitChanges();
|
||||
grid->EndBatch();
|
||||
|
|
|
@ -863,11 +863,12 @@ void SubtitlesGrid::PasteLines(int n,bool pasteOver) {
|
|||
if (pasteOverOptions[2]) target->End = curdiag->End;
|
||||
if (pasteOverOptions[3]) target->Style = curdiag->Style;
|
||||
if (pasteOverOptions[4]) target->Actor = curdiag->Actor;
|
||||
if (pasteOverOptions[5]) target->MarginL = curdiag->MarginL;
|
||||
if (pasteOverOptions[6]) target->MarginR = curdiag->MarginR;
|
||||
if (pasteOverOptions[7]) target->MarginV = curdiag->MarginV;
|
||||
if (pasteOverOptions[8]) target->Effect = curdiag->Effect;
|
||||
if (pasteOverOptions[9]) target->Text = curdiag->Text;
|
||||
if (pasteOverOptions[5]) target->Margin[0] = curdiag->Margin[0];
|
||||
if (pasteOverOptions[6]) target->Margin[1] = curdiag->Margin[1];
|
||||
if (pasteOverOptions[7]) target->Margin[2] = curdiag->Margin[2];
|
||||
if (pasteOverOptions[8]) target->Margin[3] = curdiag->Margin[3];
|
||||
if (pasteOverOptions[9]) target->Effect = curdiag->Effect;
|
||||
if (pasteOverOptions[10]) target->Text = curdiag->Text;
|
||||
}
|
||||
delete curdiag;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue