Fix #441 (Join/Split karaoke buttons now become Cancel/Accept Split buttons when in karaoke split mode)

Originally committed to SVN as r1288.
This commit is contained in:
Niels Martin Hansen 2007-06-22 23:28:28 +00:00
parent cee5c46ab7
commit 3818649af7
5 changed files with 40 additions and 27 deletions

View File

@ -200,20 +200,16 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE
KaraokeButton->SetToolTip(_("Toggle karaoke mode"));
karaokeSizer->Add(KaraokeButton,0,wxRIGHT|wxEXPAND,0);
#ifndef __WXMAC__
JoinButton = new wxButton(this,Audio_Button_Join,_("Join"),wxDefaultPosition,wxSize(-1,10));
JoinButton = new wxButton(this,Audio_Button_Join,_T(""),wxDefaultPosition,wxSize(-1,10));
#else
// we use this custom class to match the button style of toggle buttons in wxMac
JoinButton = new wxBevelButton(this,Audio_Button_Join,_("Join"),wxDefaultPosition,wxSize(-1,-1));
JoinButton = new wxBevelButton(this,Audio_Button_Join,_T(""),wxDefaultPosition,wxSize(-1,-1));
#endif
JoinButton->SetToolTip(_("Join selected syllables"));
JoinButton->Enable(false);
karaokeSizer->Add(JoinButton,0,wxRIGHT|wxEXPAND,0);
SplitButton = new wxToggleButton(this,Audio_Button_Split,_("Split"),wxDefaultPosition,wxSize(-1,-1));
SplitButton->SetToolTip(_("Toggle splitting-mode"));
SplitButton->Enable(false);
SplitButton->SetValue(false);
SplitButton = new wxButton(this,Audio_Button_Split,_T(""),wxDefaultPosition,wxSize(-1,-1));
karaokeSizer->Add(SplitButton,0,wxRIGHT|wxEXPAND,5);
karaokeSizer->Add(audioKaraoke,1,wxEXPAND,0);
SetKaraokeButtons(); // labels, hints and enabled-ness for join/split buttons set here
// Main sizer
MainSizer = new wxBoxSizer(wxVERTICAL);
@ -278,13 +274,13 @@ BEGIN_EVENT_TABLE(AudioBox,wxPanel)
EVT_BUTTON(Audio_Button_Commit, AudioBox::OnCommit)
EVT_BUTTON(Audio_Button_Goto, AudioBox::OnGoto)
EVT_BUTTON(Audio_Button_Join,AudioBox::OnJoin)
EVT_BUTTON(Audio_Button_Split,AudioBox::OnSplit)
EVT_BUTTON(Audio_Button_Leadin,AudioBox::OnLeadIn)
EVT_BUTTON(Audio_Button_Leadout,AudioBox::OnLeadOut)
EVT_TOGGLEBUTTON(Audio_Vertical_Link, AudioBox::OnVerticalLink)
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_Medusa,AudioBox::OnMedusaMode)
EVT_TOGGLEBUTTON(Audio_Check_Spectrum,AudioBox::OnSpectrumMode)
EVT_TOGGLEBUTTON(Audio_Check_AutoCommit,AudioBox::OnAutoCommit)
@ -523,7 +519,7 @@ void AudioBox::OnKaraoke(wxCommandEvent &event) {
}
karaokeMode = false;
audioKaraoke->enabled = false;
SetKaraokeButtons(false,false);
SetKaraokeButtons();
audioDisplay->SetDialogue();
audioKaraoke->Refresh(false);
}
@ -532,7 +528,7 @@ void AudioBox::OnKaraoke(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnKaraoke: karaoke disabled, enabling"));
karaokeMode = true;
audioKaraoke->enabled = true;
SetKaraokeButtons(true,true);
SetKaraokeButtons();
audioDisplay->SetDialogue();
}
@ -542,15 +538,25 @@ void AudioBox::OnKaraoke(wxCommandEvent &event) {
////////////////////////
// Sets karaoke buttons
void AudioBox::SetKaraokeButtons(bool join,bool split) {
void AudioBox::SetKaraokeButtons() {
// What to enable
bool join,split;
join = audioKaraoke->enabled && (audioKaraoke->splitting || audioKaraoke->selectionCount>=2);
split = audioKaraoke->enabled;
audioDisplay->SetFocus();
JoinButton->Enable(join && !audioKaraoke->splitting);
JoinButton->Enable(join);
SplitButton->Enable(split);
SplitButton->SetValue(audioKaraoke->splitting);
if (audioKaraoke->splitting) {
SplitButton->SetLabel(_("Cancel Split"));
JoinButton->SetLabel(_("Cancel Split"));
JoinButton->SetToolTip(_("Discard all splits and leave split-mode"));
SplitButton->SetLabel(_("Accept Split"));
SplitButton->SetToolTip(_("Commit splits and leave split-mode"));
} else {
JoinButton->SetLabel(_("Join"));
JoinButton->SetToolTip(_("Join selected syllables"));
SplitButton->SetLabel(_("Split"));
SplitButton->SetToolTip(_("Enter split-mode"));
}
}
@ -560,7 +566,11 @@ void AudioBox::SetKaraokeButtons(bool join,bool split) {
void AudioBox::OnJoin(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnJoin"));
audioDisplay->SetFocus();
audioKaraoke->Join();
if (!audioKaraoke->splitting) {
audioKaraoke->Join();
} else {
audioKaraoke->EndSplit(false);
}
}
@ -572,7 +582,7 @@ void AudioBox::OnSplit(wxCommandEvent &event) {
if (!audioKaraoke->splitting) {
audioKaraoke->BeginSplit();
} else {
audioKaraoke->EndSplit(false);
audioKaraoke->EndSplit(true);
}
}

View File

@ -70,7 +70,7 @@ private:
wxSashWindow *Sash;
ToggleBitmap *VerticalLink;
wxToggleButton *SplitButton;
wxButton *SplitButton;
wxButton *JoinButton;
ToggleBitmap *AutoScroll;
ToggleBitmap *NextCommit;
@ -122,7 +122,7 @@ public:
~AudioBox();
void SetFile(wxString file,bool FromVideo);
void SetKaraokeButtons(bool join,bool split);
void SetKaraokeButtons();
DECLARE_EVENT_TABLE()
};

View File

@ -1107,7 +1107,6 @@ void AudioDisplay::CommitChanges (bool nextLine) {
bool wasKaraSplitting = false;
bool validCommit = true;
if (!karaoke->enabled && !karaoke->splitting) {
wxLogDebug(_T("AudioDisplay::CommitChanges: was not splitting karaoke"));
if (!NeedCommit || curEndMS < curStartMS) validCommit = false;
}

View File

@ -88,10 +88,9 @@ bool AudioKaraoke::LoadFromDialogue(AssDialogue *_diag) {
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue(diag=%p)"), _diag);
// Make sure we're not in splitting-mode
if (splitting) {
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue: is splitting, so going to commit"));
// Commit by default, discarding the splits requires explicitly cancelling
// This doesn't seem to work when changing line in the grid, WHY?
Commit();
wxLogDebug(_T("AudioKaraoke::LoadFromDialogue: is splitting, discarding splits"));
// Discard any splits and leave split-mode
EndSplit(false);
}
// Set dialogue
@ -596,6 +595,7 @@ void AudioKaraoke::SetSelection(int start,int end) {
max = min;
min = temp;
}
wxLogDebug(_T("AudioKaraoke::SetSelection: min=%d, max=%d"), min, max);
// Set values
bool state;
@ -607,9 +607,11 @@ void AudioKaraoke::SetSelection(int start,int end) {
if (state) sels++;
}
curSyllable = min;
selectionCount = max-min+1;
wxLogDebug(_T("AudioKaraoke::SetSelection: new curSyllable=%d, selectionCount=%d"), curSyllable, selectionCount);
// Set box buttons
box->SetKaraokeButtons(sels > 1,sels > 0);
box->SetKaraokeButtons();
}
@ -642,7 +644,7 @@ void AudioKaraoke::Join() {
}
// Set selection
curSyllable = first;
SetSelection(first);
// Update
must_rebuild = true;
@ -659,7 +661,7 @@ void AudioKaraoke::BeginSplit() {
splitting = true;
split_cursor_syl = -1;
split_cursor_x = -1;
box->SetKaraokeButtons(false, true);
box->SetKaraokeButtons();
Refresh(false);
}
@ -689,6 +691,7 @@ void AudioKaraoke::EndSplit(bool commit) {
display->Update();
}
// Always redraw, since the display is different in splitting mode
box->SetKaraokeButtons();
Refresh(false);
wxLogDebug(_T("AudioKaraoke::EndSplit: returning"));

View File

@ -110,6 +110,7 @@ public:
AudioBox *box;
int curSyllable;
int selectionCount;
bool enabled;
bool splitting;
SylVector syllables;