Change how the Split/Join mode buttons work. Previously there was a weird hack used to change the text of the buttons when the various modes were used. When switching to icons this was no longer possible -- Well you could switch the bitmap dynamically but that's really gross. Instead the two pairs of buttons are put into their own BoxSizers which are Shown and Hidden when each mode is used.

Originally committed to SVN as r3404.
This commit is contained in:
Amar Takhar 2009-08-14 03:11:34 +00:00
parent d67176de9b
commit bebc71ef53
2 changed files with 81 additions and 47 deletions

View File

@ -195,20 +195,37 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE
ButtonSizer->AddStretchSpacer(1); ButtonSizer->AddStretchSpacer(1);
// Karaoke sizer // Karaoke sizer
wxSizer *karaokeSizer = new wxBoxSizer(wxHORIZONTAL); karaokeSizer = new wxBoxSizer(wxHORIZONTAL);
KaraokeButton = new wxBitmapToggleButton(this,Audio_Button_Karaoke,GETIMAGE(kara_mode_24),wxDefaultPosition,wxSize(33,30));
KaraokeButton->SetToolTip(_("Toggle karaoke mode"));
karaokeSizer->Add(KaraokeButton,0,wxRIGHT|wxEXPAND,0);
JoinSplitSizer = new wxBoxSizer(wxHORIZONTAL);
JoinButton = new wxBitmapButton(this,Audio_Button_Join,GETIMAGE(kara_join_24),wxDefaultPosition,wxSize(33,30));
JoinButton->SetToolTip(_("Join selected syllables"));
SplitButton = new wxBitmapButton(this,Audio_Button_Split,GETIMAGE(kara_split_24),wxDefaultPosition,wxSize(33,30));
SplitButton->SetToolTip(_("Enter split-mode"));
JoinSplitSizer->Add(JoinButton,0,wxRIGHT|wxEXPAND,0);
JoinSplitSizer->Add(SplitButton,0,wxRIGHT|wxEXPAND,0);
CancelAcceptSizer = new wxBoxSizer(wxHORIZONTAL);
CancelButton = new wxBitmapButton(this,Audio_Button_Cancel,GETIMAGE(kara_split_accept_24),wxDefaultPosition,wxSize(33,30));
CancelButton->SetToolTip(_("Discard all splits and leave split-mode"));
AcceptButton = new wxBitmapButton(this,Audio_Button_Accept,GETIMAGE(kara_split_cancel_24),wxDefaultPosition,wxSize(33,30));
AcceptButton->SetToolTip(_("Commit splits and leave split-mode"));
CancelAcceptSizer->Add(CancelButton,0,wxRIGHT|wxEXPAND,0);
CancelAcceptSizer->Add(AcceptButton,0,wxRIGHT|wxEXPAND,0);
karaokeSizer->Add(JoinSplitSizer,0,wxRIGHT|wxEXPAND,0);
karaokeSizer->Add(CancelAcceptSizer,0,wxRIGHT|wxEXPAND,0);
audioKaraoke = new AudioKaraoke(this); audioKaraoke = new AudioKaraoke(this);
audioKaraoke->box = this; audioKaraoke->box = this;
audioKaraoke->display = audioDisplay; audioKaraoke->display = audioDisplay;
audioDisplay->karaoke = audioKaraoke; audioDisplay->karaoke = audioKaraoke;
KaraokeButton = new wxBitmapToggleButton(this,Audio_Button_Karaoke,GETIMAGE(kara_mode_24),wxDefaultPosition,wxSize(33,30));
KaraokeButton->SetToolTip(_("Toggle karaoke mode"));
karaokeSizer->Add(KaraokeButton,0,wxRIGHT|wxEXPAND,0);
JoinButton = new wxBitmapButton(this,Audio_Button_Join,GETIMAGE(kara_join_24),wxDefaultPosition,wxSize(33,30));
karaokeSizer->Add(JoinButton,0,wxRIGHT|wxEXPAND,0);
SplitButton = new wxBitmapButton(this,Audio_Button_Split,GETIMAGE(kara_split_24),wxDefaultPosition,wxSize(33,30));
karaokeSizer->Add(SplitButton,0,wxRIGHT|wxEXPAND,5);
karaokeSizer->Add(audioKaraoke,1,wxEXPAND,0); karaokeSizer->Add(audioKaraoke,1,wxEXPAND,0);
SetKaraokeButtons(); // labels, hints and enabled-ness for join/split buttons set here
SetKaraokeButtons(); // Decide which one to show or hide.
// Main sizer // Main sizer
MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer = new wxBoxSizer(wxVERTICAL);
@ -218,6 +235,7 @@ wxPanel(parent,-1,wxDefaultPosition,wxDefaultSize,wxTAB_TRAVERSAL|wxBORDER_RAISE
MainSizer->Add(karaokeSizer,0,wxEXPAND,0); MainSizer->Add(karaokeSizer,0,wxEXPAND,0);
//MainSizer->SetSizeHints(this); //MainSizer->SetSizeHints(this);
SetSizer(MainSizer); SetSizer(MainSizer);
} }
@ -283,6 +301,8 @@ BEGIN_EVENT_TABLE(AudioBox,wxPanel)
EVT_BUTTON(Audio_Button_Goto, AudioBox::OnGoto) EVT_BUTTON(Audio_Button_Goto, AudioBox::OnGoto)
EVT_BUTTON(Audio_Button_Join,AudioBox::OnJoin) EVT_BUTTON(Audio_Button_Join,AudioBox::OnJoin)
EVT_BUTTON(Audio_Button_Split,AudioBox::OnSplit) EVT_BUTTON(Audio_Button_Split,AudioBox::OnSplit)
EVT_BUTTON(Audio_Button_Cancel,AudioBox::OnCancel)
EVT_BUTTON(Audio_Button_Accept,AudioBox::OnAccept)
EVT_BUTTON(Audio_Button_Leadin,AudioBox::OnLeadIn) EVT_BUTTON(Audio_Button_Leadin,AudioBox::OnLeadIn)
EVT_BUTTON(Audio_Button_Leadout,AudioBox::OnLeadOut) EVT_BUTTON(Audio_Button_Leadout,AudioBox::OnLeadOut)
@ -575,6 +595,7 @@ void AudioBox::OnKaraoke(wxCommandEvent &event) {
audioKaraoke->enabled = true; audioKaraoke->enabled = true;
audioDisplay->SetDialogue(); audioDisplay->SetDialogue();
} }
SetKaraokeButtons(); SetKaraokeButtons();
wxLogDebug(_T("AudioBox::OnKaraoke: returning")); wxLogDebug(_T("AudioBox::OnKaraoke: returning"));
@ -597,48 +618,51 @@ void AudioBox::SetKaraokeButtons() {
JoinButton->Enable(join); JoinButton->Enable(join);
SplitButton->Enable(split); SplitButton->Enable(split);
if (audioKaraoke->splitting) { if (audioKaraoke->splitting) {
JoinButton->SetLabel(_("Cancel Split")); karaokeSizer->Show(CancelAcceptSizer);
JoinButton->SetToolTip(_("Discard all splits and leave split-mode")); karaokeSizer->Hide(JoinSplitSizer);
SplitButton->SetLabel(_("Accept Split")); karaokeSizer->Layout();
SplitButton->SetToolTip(_("Commit splits and leave split-mode"));
} else { } else {
JoinButton->SetLabel(_("Join")); karaokeSizer->Hide(CancelAcceptSizer);
JoinButton->SetToolTip(_("Join selected syllables")); karaokeSizer->Show(JoinSplitSizer);
SplitButton->SetLabel(_("Split")); karaokeSizer->Layout();
SplitButton->SetToolTip(_("Enter split-mode"));
} }
} }
/// @brief Join button in karaoke mode
/// @param event wxEvent
/// @brief Join button
/// @param event
/// ///
void AudioBox::OnJoin(wxCommandEvent &event) { void AudioBox::OnJoin(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnJoin")); wxLogDebug(_T("AudioBox::OnJoin"));
audioDisplay->SetFocus(); audioDisplay->SetFocus();
if (!audioKaraoke->splitting) {
audioKaraoke->Join(); audioKaraoke->Join();
} else {
audioKaraoke->EndSplit(false);
}
} }
/// @brief Split button in karaoke mode
/// @param event wxEvent
/// @brief Split button
/// @param event
/// ///
void AudioBox::OnSplit(wxCommandEvent &event) { void AudioBox::OnSplit(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnSplit")); wxLogDebug(_T("AudioBox::OnSplit"));
audioDisplay->SetFocus(); audioDisplay->SetFocus();
if (!audioKaraoke->splitting) {
audioKaraoke->BeginSplit(); audioKaraoke->BeginSplit();
} else {
audioKaraoke->EndSplit(true);
}
} }
/// @brief Cancel join/split in karaoke mode.
/// @param event wxEvent
///
void AudioBox::OnCancel(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnCancel"));
audioDisplay->SetFocus();
audioKaraoke->EndSplit(true);
}
/// @brief Accept join/split button in karaoke mode.
/// @param event wxEvent
///
void AudioBox::OnAccept(wxCommandEvent &event) {
wxLogDebug(_T("AudioBox::OnAccept"));
audioDisplay->SetFocus();
audioKaraoke->EndSplit(false);
}
/// @brief Goto button /// @brief Goto button
@ -741,7 +765,3 @@ void FocusEvent::OnSetFocus(wxFocusEvent &event) {
wxWindow *previous = event.GetWindow(); wxWindow *previous = event.GetWindow();
if (previous) previous->SetFocus(); if (previous) previous->SetFocus();
} }

View File

@ -106,12 +106,26 @@ private:
/// DOCME /// DOCME
ToggleBitmap *VerticalLink; ToggleBitmap *VerticalLink;
/// Karaoke box sizer
wxSizer *karaokeSizer;
/// DOCME /// Karaoke mode join syllabel button.
wxButton *JoinButton;
/// Karaoke mode split word button.
wxButton *SplitButton; wxButton *SplitButton;
/// DOCME /// Karaoke mode split/join cancel button.
wxButton *JoinButton; wxButton *CancelButton;
/// Karaoke mode split/join accept button.
wxButton *AcceptButton;
/// Join/Split button sizer.
wxSizer *JoinSplitSizer;
/// Cancel/Accept sizer.
wxSizer *CancelAcceptSizer;
/// DOCME /// DOCME
ToggleBitmap *AutoScroll; ToggleBitmap *AutoScroll;
@ -149,6 +163,8 @@ private:
void OnKaraoke(wxCommandEvent &event); void OnKaraoke(wxCommandEvent &event);
void OnJoin(wxCommandEvent &event); void OnJoin(wxCommandEvent &event);
void OnSplit(wxCommandEvent &event); void OnSplit(wxCommandEvent &event);
void OnCancel(wxCommandEvent &event);
void OnAccept(wxCommandEvent &event);
void OnGoto(wxCommandEvent &event); void OnGoto(wxCommandEvent &event);
void OnLeadIn(wxCommandEvent &event); void OnLeadIn(wxCommandEvent &event);
void OnLeadOut(wxCommandEvent &event); void OnLeadOut(wxCommandEvent &event);
@ -228,7 +244,6 @@ enum {
/// DOCME /// DOCME
Audio_Vertical_Link, Audio_Vertical_Link,
/// DOCME /// DOCME
Audio_Button_Play, Audio_Button_Play,
@ -268,11 +283,10 @@ enum {
/// DOCME /// DOCME
Audio_Button_Goto, Audio_Button_Goto,
/// DOCME Audio_Button_Join, /// Karaoke -> Enter join mode.
Audio_Button_Join, Audio_Button_Split, /// Karaoke -> Enter split mode.
Audio_Button_Accept, /// Karaoke -> Split/Join mode -> Accept.
/// DOCME Audio_Button_Cancel, /// KAraoke -> Split/Join mode -> Cancel.
Audio_Button_Split,
/// DOCME /// DOCME
Audio_Button_Leadin, Audio_Button_Leadin,