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->SetValue(Options.AsBool(_T("Audio Autoscroll")));
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->SetToolTip(_("Enable Medusa-Style Timing Shortcuts"));
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_Check_AutoGoto,AudioBox::OnAutoGoto)
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_Spectrum,AudioBox::OnSpectrumMode)
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
void AudioBox::OnMedusaMode(wxCommandEvent &event) {

View file

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

View file

@ -1146,19 +1146,16 @@ void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
//////////////////
// Commit changes
void AudioDisplay::CommitChanges () {
void AudioDisplay::CommitChanges (bool nextLine) {
// Loaded?
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
if (!NeedCommit) return;
// Check if selection is valid
if (curEndMS < curStartMS) {
wxMessageBox(_T("Start time must be before end time!"),_T("Error commiting"),wxICON_ERROR);
return;
}
if (curEndMS < curStartMS) return;
}
// Reset flags
@ -1198,8 +1195,8 @@ void AudioDisplay::CommitChanges () {
karaoke->curSyllable = karSyl;
blockUpdate = false;
// If in SSA mode, select next line and "move timing forward" (unless the user was splitting karaoke)
if (Options.AsBool(_T("Audio SSA Mode")) && Options.AsBool(_T("Audio SSA Next Line on Commit")) && !wasKaraSplitting) {
// Next line
if (nextLine && Options.AsBool(_T("Audio Next Line on Commit")) && !wasKaraSplitting) {
// Insert a line if it doesn't exist
int nrows = grid->GetRows();
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;
// Substation alpha mode
if (Options.AsBool(_T("Audio SSA Mode")) && !karaoke->enabled && dialogue) {
bool mod = false;
// Timing
if (hasSel) {
bool updated = false;
// Grab start/end
if (hold == 0) {
bool gotGrab = false;
// Set start
if (event.ButtonDown(wxMOUSE_BTN_LEFT)) {
curStartMS = GetMSAtX(x);
mod = true;
}
// Set end
if (event.ButtonDown(wxMOUSE_BTN_RIGHT)) {
curEndMS = GetMSAtX(x);
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;
}
// Grab start
if (!karMode) {
if (abs64 (x - selStart) < 6) {
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
defCursor = false;
if (buttonIsDown) {
hold = 1;
gotGrab = true;
}
}
// Grabbing a syllable
if (!gotGrab && karMode) {
__int64 pos,len,curpos;
KaraokeSyllable *curSyl;
size_t karn = karaoke->syllables.size();
for (size_t i=0;i<karn;i++) {
curSyl = &karaoke->syllables.at(i);
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;
// Grab end
else if (abs64 (x - selEnd) < 6) {
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
defCursor = false;
if (buttonIsDown) {
hold = 2;
gotGrab = true;
}
}
}
// Drag start/end
if (hold != 0) {
// Dragging
if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
bool updated = false;
// Drag from nothing
if (hold == 3) {
if (!karMode) {
if (x != lastX) {
selStart = x;
selEnd = x;
curEndMS = GetMSAtX(selEnd);
curStartMS = GetMSAtX(selStart);
hold = 2;
// Grabbing a syllable
if (!gotGrab && karMode) {
__int64 pos,len,curpos;
KaraokeSyllable *curSyl;
size_t karn = karaoke->syllables.size();
for (size_t i=0;i<karn;i++) {
curSyl = &karaoke->syllables.at(i);
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;
}
}
// 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
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;
// Dragging nothing, time from scratch
if (!gotGrab) {
if (buttonIsDown) {
hold = 3;
lastX = x;
gotGrab = true;
}
}
}
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
@ -1890,12 +1860,9 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
// Play
if (Hotkeys.IsPressed(_T("Audio Play")) || Hotkeys.IsPressed(_T("Audio Play Alt"))) {
if (player->IsPlaying()) Stop();
else {
int start=0,end=0;
GetTimesSelection(start,end);
Play(start,end);
}
int start=0,end=0;
GetTimesSelection(start,end);
Play(start,end);
}
// Increase length
@ -1985,9 +1952,7 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
if (Hotkeys.IsPressed(_T("Audio Play Original Line"))) {
int start=0,end=0;
GetTimesDialogue(start,end);
if (Options.AsBool(_T("Audio SSA Mode"))) {
SetSelection(start, end);
}
SetSelection(start, end);
Play(start,end);
}
@ -2005,10 +1970,8 @@ void AudioDisplay::OnKeyDown(wxKeyEvent &event) {
if (diagUpdated) {
diagUpdated = false;
NeedCommit = true;
if ((Options.AsBool(_T("Audio SSA Allow Autocommit")) || Options.AsBool(_T("Audio SSA Mode")) == false) && Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS)
CommitChanges();
else
UpdateImage(true);
if (Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS) CommitChanges();
else UpdateImage(true);
}
}

View file

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

View file

@ -386,7 +386,7 @@ DialogOptions::DialogOptions(wxWindow *parent)
// First sizer
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);
control = new wxCheckBox(audioPage,-1,_("Auto-focus on mouse over"));
Bind(control,_T("Audio Autofocus"));

View file

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