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,47 +1518,19 @@ 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;
// 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
// Timing
if (hasSel) {
bool updated = false;
// Grab start/end
if (hold == 0) {
bool gotGrab = false;
@ -1572,7 +1541,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
defCursor = false;
if (event.LeftIsDown()) {
if (buttonIsDown) {
hold = 1;
gotGrab = true;
}
@ -1583,7 +1552,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
defCursor = false;
if (event.LeftIsDown()) {
if (buttonIsDown) {
hold = 2;
gotGrab = true;
}
@ -1618,7 +1587,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
// Dragging nothing, time from scratch
if (!gotGrab) {
if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
if (buttonIsDown) {
hold = 3;
lastX = x;
gotGrab = true;
@ -1629,24 +1598,26 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
// Drag start/end
if (hold != 0) {
// Dragging
if (event.ButtonIsDown(wxMOUSE_BTN_LEFT)) {
bool updated = false;
if (buttonIsDown) {
// Drag from nothing
if (hold == 3) {
if (hold == 3 && buttonIsDown) {
if (!karMode) {
if (leftIsDown) curStartMS = GetMSAtX(x);
else curEndMS = GetMSAtX(x);
updated = true;
if (x != lastX) {
selStart = x;
selEnd = x;
curEndMS = GetMSAtX(selEnd);
curStartMS = GetMSAtX(selStart);
curStartMS = GetMSAtX(x);
curEndMS = GetMSAtX(x);
hold = 2;
}
}
}
// Drag start
if (hold == 1) {
if (hold == 1 && buttonIsDown) {
// Set new value
if (x != selStart) {
selStart = x;
@ -1664,7 +1635,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
}
// Drag end
if (hold == 2) {
if (hold == 2 && buttonIsDown) {
// Set new value
if (x != selEnd) {
selEnd = x;
@ -1682,7 +1653,7 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
}
// Drag karaoke
if (hold == 4) {
if (hold == 4 && leftIsDown) {
// Set new value
int curpos,len,pos,nkar;
KaraokeSyllable *curSyl=NULL,*nextSyl=NULL;
@ -1709,14 +1680,6 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
}
}
}
// Update stuff
if (updated) {
player->SetEndPosition(GetSampleAtX(selEnd));
wxCursor cursor(wxCURSOR_SIZEWE);
SetCursor(cursor);
UpdateImage(true);
}
}
// Release
@ -1725,10 +1688,8 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
if (diagUpdated) {
diagUpdated = false;
NeedCommit = true;
if (Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS)
CommitChanges();
else
UpdateImage(true);
if (Options.AsBool(_T("Audio Autocommit")) && curStartMS <= curEndMS) CommitChanges();
else UpdateImage(true);
}
// Single click on nothing
@ -1748,11 +1709,20 @@ void AudioDisplay::OnMouseEvent(wxMouseEvent& event) {
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
if (defCursor) SetCursor(wxNullCursor);
@ -1890,13 +1860,10 @@ 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);
}
}
// Increase length
if (Hotkeys.IsPressed(_T("Audio Karaoke Increase Len"))) {
@ -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);
}
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);