Merged SSA mode & normal mode

Originally committed to SVN as r719.
This commit is contained in:
Rodrigo Braz Monteiro 2007-01-05 23:43:24 +00:00
parent 1d87fd3934
commit b3ddefa5ee
6 changed files with 198 additions and 254 deletions

View file

@ -171,10 +171,6 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE
AutoScroll->SetToolTip(_("Auto scrolls audio display to selected line")); AutoScroll->SetToolTip(_("Auto scrolls audio display to selected line"));
AutoScroll->SetValue(Options.AsBool(_T("Audio Autoscroll"))); AutoScroll->SetValue(Options.AsBool(_T("Audio Autoscroll")));
ButtonSizer->Add(AutoScroll,0,wxRIGHT | wxALIGN_CENTER | wxEXPAND,0); ButtonSizer->Add(AutoScroll,0,wxRIGHT | wxALIGN_CENTER | wxEXPAND,0);
SSAMode = new ToggleBitmap(this,Audio_Check_SSA,wxBITMAP(toggle_audio_ssa),wxSize(30,-1));
SSAMode->SetToolTip(_("Substation Alpha Mode - Left click sets start and right click sets end"));
SSAMode->SetValue(Options.AsBool(_T("Audio SSA Mode")));
ButtonSizer->Add(SSAMode,0,wxRIGHT | wxALIGN_CENTER | wxEXPAND,0);
MedusaMode = new ToggleBitmap(this,Audio_Check_Medusa,wxBITMAP(toggle_audio_medusa),wxSize(30,-1)); MedusaMode = new ToggleBitmap(this,Audio_Check_Medusa,wxBITMAP(toggle_audio_medusa),wxSize(30,-1));
MedusaMode->SetToolTip(_("Enable Medusa-Style Timing Shortcuts")); MedusaMode->SetToolTip(_("Enable Medusa-Style Timing Shortcuts"));
MedusaMode->SetValue(Options.AsBool(_T("Audio Medusa Timing Hotkeys"))); MedusaMode->SetValue(Options.AsBool(_T("Audio Medusa Timing Hotkeys")));
@ -277,7 +273,6 @@ BEGIN_EVENT_TABLE(AudioBox,wxPanel)
EVT_TOGGLEBUTTON(Audio_Button_Karaoke, AudioBox::OnKaraoke) EVT_TOGGLEBUTTON(Audio_Button_Karaoke, AudioBox::OnKaraoke)
EVT_TOGGLEBUTTON(Audio_Check_AutoGoto,AudioBox::OnAutoGoto) EVT_TOGGLEBUTTON(Audio_Check_AutoGoto,AudioBox::OnAutoGoto)
EVT_TOGGLEBUTTON(Audio_Button_Split,AudioBox::OnSplit) EVT_TOGGLEBUTTON(Audio_Button_Split,AudioBox::OnSplit)
EVT_TOGGLEBUTTON(Audio_Check_SSA,AudioBox::OnSSAMode)
EVT_TOGGLEBUTTON(Audio_Check_Medusa,AudioBox::OnMedusaMode) EVT_TOGGLEBUTTON(Audio_Check_Medusa,AudioBox::OnMedusaMode)
EVT_TOGGLEBUTTON(Audio_Check_Spectrum,AudioBox::OnSpectrumMode) EVT_TOGGLEBUTTON(Audio_Check_Spectrum,AudioBox::OnSpectrumMode)
EVT_TOGGLEBUTTON(Audio_Check_AutoCommit,AudioBox::OnAutoCommit) EVT_TOGGLEBUTTON(Audio_Check_AutoCommit,AudioBox::OnAutoCommit)
@ -589,15 +584,6 @@ void AudioBox::OnAutoCommit(wxCommandEvent &event) {
} }
////////////
// SSA Mode
void AudioBox::OnSSAMode(wxCommandEvent &event) {
audioDisplay->SetFocus();
Options.SetBool(_T("Audio SSA Mode"),SSAMode->GetValue());
Options.Save();
}
/////////////// ///////////////
// Medusa Mode // Medusa Mode
void AudioBox::OnMedusaMode(wxCommandEvent &event) { void AudioBox::OnMedusaMode(wxCommandEvent &event) {

View file

@ -74,7 +74,6 @@ private:
wxToggleButton *SplitButton; wxToggleButton *SplitButton;
wxButton *JoinButton; wxButton *JoinButton;
ToggleBitmap *AutoScroll; ToggleBitmap *AutoScroll;
ToggleBitmap *SSAMode;
ToggleBitmap *MedusaMode; ToggleBitmap *MedusaMode;
ToggleBitmap *AutoCommit; ToggleBitmap *AutoCommit;
ToggleBitmap *SpectrumMode; ToggleBitmap *SpectrumMode;
@ -106,7 +105,6 @@ private:
void OnAutoGoto(wxCommandEvent &event); void OnAutoGoto(wxCommandEvent &event);
void OnAutoCommit(wxCommandEvent &event); void OnAutoCommit(wxCommandEvent &event);
void OnSSAMode(wxCommandEvent &event);
void OnMedusaMode(wxCommandEvent &event); void OnMedusaMode(wxCommandEvent &event);
void OnSpectrumMode(wxCommandEvent &event); void OnSpectrumMode(wxCommandEvent &event);
@ -167,7 +165,6 @@ enum {
Audio_Check_AutoCommit, Audio_Check_AutoCommit,
Audio_Check_AutoGoto, Audio_Check_AutoGoto,
Audio_Check_SSA,
Audio_Check_Medusa, Audio_Check_Medusa,
Audio_Check_Spectrum Audio_Check_Spectrum
}; };

View file

@ -1146,19 +1146,16 @@ void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
////////////////// //////////////////
// Commit changes // Commit changes
void AudioDisplay::CommitChanges () { void AudioDisplay::CommitChanges (bool nextLine) {
// Loaded? // Loaded?
if (!loaded) return; if (!loaded) return;
if (!Options.AsBool(_T("Audio SSA Mode")) && !box->audioKaraoke->splitting) { if (!box->audioKaraoke->splitting) {
// Check if there's any need to commit // Check if there's any need to commit
if (!NeedCommit) return; if (!NeedCommit) return;
// Check if selection is valid // Check if selection is valid
if (curEndMS < curStartMS) { if (curEndMS < curStartMS) return;
wxMessageBox(_T("Start time must be before end time!"),_T("Error commiting"),wxICON_ERROR);
return;
}
} }
// Reset flags // Reset flags
@ -1198,8 +1195,8 @@ void AudioDisplay::CommitChanges () {
karaoke->curSyllable = karSyl; karaoke->curSyllable = karSyl;
blockUpdate = false; blockUpdate = false;
// If in SSA mode, select next line and "move timing forward" (unless the user was splitting karaoke) // Next line
if (Options.AsBool(_T("Audio SSA Mode")) && Options.AsBool(_T("Audio SSA Next Line on Commit")) && !wasKaraSplitting) { if (nextLine && Options.AsBool(_T("Audio Next Line on Commit")) && !wasKaraSplitting) {
// Insert a line if it doesn't exist // Insert a line if it doesn't exist
int nrows = grid->GetRows(); int nrows = grid->GetRows();
if (nrows == line_n + 1) { if (nrows == line_n + 1) {
@ -1521,237 +1518,210 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
} }
} }
// Buttons
bool leftIsDown = event.ButtonIsDown(wxMOUSE_BTN_LEFT);
bool rightIsDown = event.ButtonIsDown(wxMOUSE_BTN_RIGHT);
bool buttonIsDown = leftIsDown || rightIsDown;
bool leftClick = event.ButtonDown(wxMOUSE_BTN_LEFT);
bool rightClick = event.ButtonDown(wxMOUSE_BTN_RIGHT);
bool buttonClick = leftClick || rightClick;
bool defCursor = true; bool defCursor = true;
// Substation alpha mode // Timing
if (Options.AsBool(_T("Audio SSA Mode")) && !karaoke->enabled && dialogue) { if (hasSel) {
bool mod = false; bool updated = false;
// Grab start/end
if (hold == 0) {
bool gotGrab = false;
// Set start // Grab start
if (event.ButtonDown(wxMOUSE_BTN_LEFT)) { if (!karMode) {
curStartMS = GetMSAtX(x); if (abs64 (x - selStart) < 6) {
mod = true; wxCursor cursor(wxCURSOR_SIZEWE);
} SetCursor(cursor);
defCursor = false;
// Set end if (buttonIsDown) {
if (event.ButtonDown(wxMOUSE_BTN_RIGHT)) { hold = 1;
curEndMS = GetMSAtX(x); gotGrab = true;
mod = true;
player->SetEndPosition(GetSampleAtX(x));
}
// Modified, commit changes
if (mod) {
// Swap if needed
if (false && curStartMS > curEndMS) {
int aux = curStartMS;
curStartMS = curEndMS;
curEndMS = aux;
}
// Commit
NeedCommit = true;
if (Options.AsBool(_T("Audio SSA Allow Autocommit")) && Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS)
CommitChanges();
else
UpdateImage(true);
}
}
// Standard mode
else {
// Moving around
if (hasSel) {
// Grab start/end
if (hold == 0) {
bool gotGrab = false;
// Grab start
if (!karMode) {
if (abs64 (x - selStart) < 6) {
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
defCursor = false;
if (event.LeftIsDown()) {
hold = 1;
gotGrab = true;
}
}
// Grab end
else if (abs64 (x - selEnd) < 6) {
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
defCursor = false;
if (event.LeftIsDown()) {
hold = 2;
gotGrab = true;
}
} }
} }
// Grabbing a syllable // Grab end
if (!gotGrab && karMode) { else if (abs64 (x - selEnd) < 6) {
__int64 pos,len,curpos; wxCursor cursor(wxCURSOR_SIZEWE);
KaraokeSyllable *curSyl; SetCursor(cursor);
size_t karn = karaoke->syllables.size(); defCursor = false;
for (size_t i=0;i<karn;i++) { if (buttonIsDown) {
curSyl = &karaoke->syllables.at(i); hold = 2;
len = curSyl->length*10;
curpos = curSyl->position*10;
if (len != -1) {
pos = GetXAtMS(curStartMS+len+curpos);
if (abs64 (x - pos) < 4) {
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
defCursor = false;
if (event.LeftIsDown()) {
hold = 4;
holdSyl = (int)i;
gotGrab = true;
}
break;
}
}
}
}
// Dragging nothing, time from scratch
if (!gotGrab) {
if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
hold = 3;
lastX = x;
gotGrab = true; gotGrab = true;
} }
} }
} }
// Drag start/end // Grabbing a syllable
if (hold != 0) { if (!gotGrab && karMode) {
// Dragging __int64 pos,len,curpos;
if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) { KaraokeSyllable *curSyl;
bool updated = false; size_t karn = karaoke->syllables.size();
for (size_t i=0;i<karn;i++) {
// Drag from nothing curSyl = &karaoke->syllables.at(i);
if (hold == 3) { len = curSyl->length*10;
if (!karMode) { curpos = curSyl->position*10;
if (x != lastX) { if (len != -1) {
selStart = x; pos = GetXAtMS(curStartMS+len+curpos);
selEnd = x; if (abs64 (x - pos) < 4) {
curEndMS = GetMSAtX(selEnd); wxCursor cursor(wxCURSOR_SIZEWE);
curStartMS = GetMSAtX(selStart); SetCursor(cursor);
hold = 2; defCursor = false;
if (event.LeftIsDown()) {
hold = 4;
holdSyl = (int)i;
gotGrab = true;
} }
break;
} }
} }
// Drag start
if (hold == 1) {
// Set new value
if (x != selStart) {
selStart = x;
if (selStart > selEnd) {
int temp = selStart;
selStart = selEnd;
selEnd = temp;
hold = 2;
curEndMS = GetMSAtX(selEnd);
}
curStartMS = GetMSAtX(selStart);
updated = true;
diagUpdated = true;
}
}
// Drag end
if (hold == 2) {
// Set new value
if (x != selEnd) {
selEnd = x;
if (selStart > selEnd) {
int temp = selStart;
selStart = selEnd;
selEnd = temp;
hold = 1;
curStartMS = GetMSAtX(selStart);
}
curEndMS = GetMSAtX(selEnd);
updated = true;
diagUpdated = true;
}
}
// Drag karaoke
if (hold == 4) {
// Set new value
int curpos,len,pos,nkar;
KaraokeSyllable *curSyl=NULL,*nextSyl=NULL;
curSyl = &karaoke->syllables.at(holdSyl);
nkar = (int)karaoke->syllables.size();
if (holdSyl < nkar-1) {
nextSyl = &karaoke->syllables.at(holdSyl+1);
}
curpos = curSyl->position;
len = curSyl->length;
pos = GetXAtMS(curStartMS+(len+curpos)*10);
if (x != pos) {
// Calculate delta in centiseconds
int delta = ((__int64)(x-pos)*samples*100)/provider->GetSampleRate();
// Apply delta
int deltaMode = 0;
if (shiftDown) deltaMode = 1;
// else if (ctrlDown) deltaMode = 2;
bool result = karaoke->SyllableDelta(holdSyl,delta,deltaMode);
if (result) {
updated = true;
diagUpdated = true;
}
}
}
// Update stuff
if (updated) {
player->SetEndPosition(GetSampleAtX(selEnd));
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
UpdateImage(true);
}
} }
}
// Release // Dragging nothing, time from scratch
else { if (!gotGrab) {
// Commit changes if (buttonIsDown) {
if (diagUpdated) { hold = 3;
diagUpdated = false; lastX = x;
NeedCommit = true; gotGrab = true;
if (Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS)
CommitChanges();
else
UpdateImage(true);
}
// Single click on nothing
else if (hold == 3) {
// Select syllable
if (karaoke->enabled) {
int syl = GetSyllableAtX(x);
if (syl != -1) {
karaoke->SetSyllable(syl);
UpdateImage(true);
}
}
}
// Update stuff
SetCursor(wxNullCursor);
hold = 0;
} }
} }
} }
else {
hold = 0; // Drag start/end
if (hold != 0) {
// Dragging
if (buttonIsDown) {
// Drag from nothing
if (hold == 3 && buttonIsDown) {
if (!karMode) {
if (leftIsDown) curStartMS = GetMSAtX(x);
else curEndMS = GetMSAtX(x);
updated = true;
if (x != lastX) {
selStart = x;
selEnd = x;
curStartMS = GetMSAtX(x);
curEndMS = GetMSAtX(x);
hold = 2;
}
}
}
// Drag start
if (hold == 1 && buttonIsDown) {
// Set new value
if (x != selStart) {
selStart = x;
if (selStart > selEnd) {
int temp = selStart;
selStart = selEnd;
selEnd = temp;
hold = 2;
curEndMS = GetMSAtX(selEnd);
}
curStartMS = GetMSAtX(selStart);
updated = true;
diagUpdated = true;
}
}
// Drag end
if (hold == 2 && buttonIsDown) {
// Set new value
if (x != selEnd) {
selEnd = x;
if (selStart > selEnd) {
int temp = selStart;
selStart = selEnd;
selEnd = temp;
hold = 1;
curStartMS = GetMSAtX(selStart);
}
curEndMS = GetMSAtX(selEnd);
updated = true;
diagUpdated = true;
}
}
// Drag karaoke
if (hold == 4 && leftIsDown) {
// Set new value
int curpos,len,pos,nkar;
KaraokeSyllable *curSyl=NULL,*nextSyl=NULL;
curSyl = &karaoke->syllables.at(holdSyl);
nkar = (int)karaoke->syllables.size();
if (holdSyl < nkar-1) {
nextSyl = &karaoke->syllables.at(holdSyl+1);
}
curpos = curSyl->position;
len = curSyl->length;
pos = GetXAtMS(curStartMS+(len+curpos)*10);
if (x != pos) {
// Calculate delta in centiseconds
int delta = ((__int64)(x-pos)*samples*100)/provider->GetSampleRate();
// Apply delta
int deltaMode = 0;
if (shiftDown) deltaMode = 1;
// else if (ctrlDown) deltaMode = 2;
bool result = karaoke->SyllableDelta(holdSyl,delta,deltaMode);
if (result) {
updated = true;
diagUpdated = true;
}
}
}
}
// Release
else {
// Commit changes
if (diagUpdated) {
diagUpdated = false;
NeedCommit = true;
if (Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS) CommitChanges();
else UpdateImage(true);
}
// Single click on nothing
else if (hold == 3) {
// Select syllable
if (karaoke->enabled) {
int syl = GetSyllableAtX(x);
if (syl != -1) {
karaoke->SetSyllable(syl);
UpdateImage(true);
}
}
}
// Update stuff
SetCursor(wxNullCursor);
hold = 0;
}
} }
// Update stuff
if (updated) {
player->SetEndPosition(GetSampleAtX(selEnd));
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
UpdateImage(true);
}
}
// Not holding
else {
hold = 0;
} }
// Restore cursor // Restore cursor
@ -1890,12 +1860,9 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
// Play // Play
if (Hotkeys.IsPressed(_T("Audio Play")) || Hotkeys.IsPressed(_T("Audio Play Alt"))) { if (Hotkeys.IsPressed(_T("Audio Play")) || Hotkeys.IsPressed(_T("Audio Play Alt"))) {
if (player->IsPlaying()) Stop(); int start=0,end=0;
else { GetTimesSelection(start,end);
int start=0,end=0; Play(start,end);
GetTimesSelection(start,end);
Play(start,end);
}
} }
// Increase length // Increase length
@ -1985,9 +1952,7 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
if (Hotkeys.IsPressed(_T("Audio Play Original Line"))) { if (Hotkeys.IsPressed(_T("Audio Play Original Line"))) {
int start=0,end=0; int start=0,end=0;
GetTimesDialogue(start,end); GetTimesDialogue(start,end);
if (Options.AsBool(_T("Audio SSA Mode"))) { SetSelection(start, end);
SetSelection(start, end);
}
Play(start,end); Play(start,end);
} }
@ -2005,10 +1970,8 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
if (diagUpdated) { if (diagUpdated) {
diagUpdated = false; diagUpdated = false;
NeedCommit = true; NeedCommit = true;
if ((Options.AsBool(_T("Audio SSA Allow Autocommit")) || Options.AsBool(_T("Audio SSA Mode")) == false) && Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS) if (Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS) CommitChanges();
CommitChanges(); else UpdateImage(true);
else
UpdateImage(true);
} }
} }

View file

@ -158,7 +158,7 @@ public:
int GetSyllableAtX(int x); int GetSyllableAtX(int x);
void MakeDialogueVisible(bool force=false); void MakeDialogueVisible(bool force=false);
void CommitChanges(); void CommitChanges(bool nextLine=false);
void ChangeLine(int delta); void ChangeLine(int delta);
void Next(); void Next();
void Prev(); void Prev();

View file

@ -386,7 +386,7 @@ DialogOptions::DialogOptions(wxWindow *parent)
// First sizer // First sizer
control = new wxCheckBox(audioPage,-1,_("Next line on commit")); control = new wxCheckBox(audioPage,-1,_("Next line on commit"));
Bind(control,_T("Audio SSA Next Line on Commit")); Bind(control,_T("Audio Next Line on Commit"));
audioSizer3->Add(control,1,wxEXPAND,0); audioSizer3->Add(control,1,wxEXPAND,0);
control = new wxCheckBox(audioPage,-1,_("Auto-focus on mouse over")); control = new wxCheckBox(audioPage,-1,_("Auto-focus on mouse over"));
Bind(control,_T("Audio Autofocus")); Bind(control,_T("Audio Autofocus"));

View file

@ -140,8 +140,7 @@ void OptionsManager::LoadDefaults() {
SetText(_T("Video resizer"),_T("BilinearResize")); SetText(_T("Video resizer"),_T("BilinearResize"));
// Audio Options // Audio Options
SetBool(_T("Audio SSA Next Line on Commit"),true); SetBool(_T("Audio Next Line on Commit"),true);
SetBool(_T("Audio SSA Allow Autocommit"),false);
SetBool(_T("Audio Autofocus"),false); SetBool(_T("Audio Autofocus"),false);
SetBool(_T("Audio Wheel Default To Zoom"),false); SetBool(_T("Audio Wheel Default To Zoom"),false);
SetBool(_T("Audio lock scroll on cursor"),false); SetBool(_T("Audio lock scroll on cursor"),false);
@ -247,7 +246,6 @@ void OptionsManager::LoadDefaults() {
SetBool(_T("Audio Link"),true); SetBool(_T("Audio Link"),true);
SetBool(_T("Audio Autocommit"),false); SetBool(_T("Audio Autocommit"),false);
SetBool(_T("Audio Autoscroll"),true); SetBool(_T("Audio Autoscroll"),true);
SetBool(_T("Audio SSA Mode"),false);
SetBool(_T("Audio Medusa Timing Hotkeys"),false); SetBool(_T("Audio Medusa Timing Hotkeys"),false);
SetBool(_T("Shift Times ByTime"),true); SetBool(_T("Shift Times ByTime"),true);