From: <pst...@us...> - 2013-04-07 16:08:54
|
Revision: 1008 http://sourceforge.net/p/jazzplusplus/code/1008 Author: pstieber Date: 2013-04-07 16:08:51 +0000 (Sun, 07 Apr 2013) Log Message: ----------- Added the ability to delete instruments from the rhythm window. Modified Paths: -------------- trunk/jazz/src/Rhythm.cpp trunk/jazz/src/Rhythm.h Modified: trunk/jazz/src/Rhythm.cpp =================================================================== --- trunk/jazz/src/Rhythm.cpp 2013-04-07 08:08:41 UTC (rev 1007) +++ trunk/jazz/src/Rhythm.cpp 2013-04-07 16:08:51 UTC (rev 1008) @@ -1380,6 +1380,8 @@ //----------------------------------------------------------------------------- BEGIN_EVENT_TABLE(JZRhythmGeneratorWindow, wxPanel) + EVT_LISTBOX(IDC_LB_RHYTHM_INSTRUMENTS, JZRhythmGeneratorWindow::OnListBox) + END_EVENT_TABLE() //----------------------------------------------------------------------------- @@ -1689,6 +1691,36 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void JZRhythmGeneratorWindow::DeleteInstrument() +{ + if (mActiveInstrumentIndex >= 0) + { + vector<JZRhythm*> InstrumentsCopy(mInstruments); + + int i = mActiveInstrumentIndex; + delete InstrumentsCopy[i]; + + size_t k; + for (k = i; k < InstrumentsCopy.size() - 1; ++k) + { + InstrumentsCopy[k] = InstrumentsCopy[k + 1]; + } + + mInstruments.clear(); + for (k = 0; k < InstrumentsCopy.size() - 1; ++k) + { + mInstruments.push_back(InstrumentsCopy[k]); + } + + mpInstrumentListBox->Delete(i); + mActiveInstrumentIndex = mpInstrumentListBox->GetSelection(); + Instrument2Win(); + Refresh(); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZRhythmGeneratorWindow::Instrument2Win() { if ( @@ -1765,6 +1797,16 @@ mpGroupListenSlider->Enable(mRhythm.mRandomizeFlag); } +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZRhythmGeneratorWindow::OnListBox(wxCommandEvent&) +{ + Win2Instrument(); + mActiveInstrumentIndex = mpInstrumentListBox->GetSelection(); + Instrument2Win(); + Refresh(); +} + //***************************************************************************** //***************************************************************************** //----------------------------------------------------------------------------- @@ -1773,6 +1815,8 @@ EVT_MENU(ID_INSTRUMENT_ADD, JZRhythmGeneratorFrame::OnAddInstrument) + EVT_MENU(ID_INSTRUMENT_DELETE, JZRhythmGeneratorFrame::OnDeleteInstrument) + EVT_MENU(wxID_HELP, JZRhythmGeneratorFrame::OnHelp) EVT_MENU(wxID_HELP_CONTENTS, JZRhythmGeneratorFrame::OnHelpContents) @@ -1864,6 +1908,13 @@ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +void JZRhythmGeneratorFrame::OnDeleteInstrument(wxCommandEvent&) +{ + mpRhythmGeneratorWindow->DeleteInstrument(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- void JZRhythmGeneratorFrame::OnHelp(wxCommandEvent&) { JZHelp::Instance().ShowTopic("Random rhythm generator"); Modified: trunk/jazz/src/Rhythm.h =================================================================== --- trunk/jazz/src/Rhythm.h 2013-04-07 08:08:41 UTC (rev 1007) +++ trunk/jazz/src/Rhythm.h 2013-04-07 16:08:51 UTC (rev 1008) @@ -267,6 +267,8 @@ void AddInstrument(); + void DeleteInstrument(); + private: void AddInstrument(JZRhythm* pRhythm); @@ -277,6 +279,8 @@ void RandomEnable(); + void OnListBox(wxCommandEvent&); + private: JZRhythm mRhythm; @@ -320,6 +324,8 @@ void OnAddInstrument(wxCommandEvent& Event); + void OnDeleteInstrument(wxCommandEvent& Event); + void OnHelp(wxCommandEvent& Event); void OnHelpContents(wxCommandEvent& Event); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |