From: <pst...@us...> - 2009-02-19 15:06:51
|
Revision: 717 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=717&view=rev Author: pstieber Date: 2009-02-19 15:06:48 +0000 (Thu, 19 Feb 2009) Log Message: ----------- 1. Replaced the old piano window snap dialog with a new version. 2. Replaced the global limit steps vector with a map and updated the tNamedValueChoice class. The global limit steps map really shouldn't be global and the tNamedValueChoice class may eventually be removed. 3. Updated the interface to the piano window snap command. 4. Changed gQntSteps to gQuantizationSteps. 5. Changed a loop in the quantization dialog. Modified Paths: -------------- trunk/jazz/src/Dialogs/QuantizeDialog.cpp trunk/jazz/src/Dialogs.cpp trunk/jazz/src/Dialogs.h trunk/jazz/src/Globals.cpp trunk/jazz/src/Globals.h trunk/jazz/src/Makefile.am trunk/jazz/src/NamedValueChoice.cpp trunk/jazz/src/NamedValueChoice.h trunk/jazz/src/PianoWindow.cpp trunk/jazz/src/Project.cpp trunk/jazz/vc8/JazzPlusPlus-VC8.vcproj trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj Added Paths: ----------- trunk/jazz/src/Dialogs/SnapDialog.cpp trunk/jazz/src/Dialogs/SnapDialog.h Modified: trunk/jazz/src/Dialogs/QuantizeDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/QuantizeDialog.cpp 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/Dialogs/QuantizeDialog.cpp 2009-02-19 15:06:48 UTC (rev 717) @@ -79,8 +79,8 @@ mpStepSizeComboBox = new wxComboBox(this, wxID_ANY); for ( - map<int, string>::const_iterator iPair = gQntSteps.begin(); - iPair != gQntSteps.end(); + map<int, string>::const_iterator iPair = gQuantizationSteps.begin(); + iPair != gQuantizationSteps.end(); ++iPair) { const string& String = iPair->second; @@ -151,16 +151,15 @@ { int Selection = 0; for ( - map<int, string>::const_iterator iPair = gQntSteps.begin(); - iPair != gQntSteps.end(); - ++iPair) + map<int, string>::const_iterator iPair = gQuantizationSteps.begin(); + iPair != gQuantizationSteps.end(); + ++iPair, ++Selection) { const int& Value = iPair->first; if (Value <= mQuantizationStep) { break; } - ++Selection; } mpStepSizeComboBox->SetSelection(Selection); @@ -188,8 +187,8 @@ wxString SelectedValue = mpStepSizeComboBox->GetValue(); string SelectedString = SelectedValue.c_str(); for ( - map<int, string>::const_iterator iPair = gQntSteps.begin(); - iPair != gQntSteps.end(); + map<int, string>::const_iterator iPair = gQuantizationSteps.begin(); + iPair != gQuantizationSteps.end(); ++iPair) { const string& String = iPair->second; Added: trunk/jazz/src/Dialogs/SnapDialog.cpp =================================================================== --- trunk/jazz/src/Dialogs/SnapDialog.cpp (rev 0) +++ trunk/jazz/src/Dialogs/SnapDialog.cpp 2009-02-19 15:06:48 UTC (rev 717) @@ -0,0 +1,136 @@ +//***************************************************************************** +// The JAZZ++ Midi Sequencer +// +// Copyright (C) 2009 Peter J. Stieber, all rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//***************************************************************************** + +#include "SnapDialog.h" + +#include "../Globals.h" +#include "../Help.h" + +#include <wx/choice.h> +#include <wx/button.h> +#include <wx/sizer.h> +#include <wx/stattext.h> + +using namespace std; + +//***************************************************************************** +//***************************************************************************** +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +BEGIN_EVENT_TABLE(JZSnapDialog, wxDialog) + + EVT_BUTTON(wxID_HELP, JZSnapDialog::OnHelp) + +END_EVENT_TABLE() + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +JZSnapDialog::JZSnapDialog(int& SnapDenominator, wxWindow* pParent) + : wxDialog(pParent, wxID_ANY, wxString("Snap")), + mSnapDenominator(SnapDenominator), + mpSnapValueChoice(0) +{ + mpSnapValueChoice = new wxChoice(this, wxID_ANY); + for ( + map<int, string>::const_iterator iLimitSteps = gLimitSteps.begin(); + iLimitSteps != gLimitSteps.end(); + ++iLimitSteps) + { + mpSnapValueChoice->Append(iLimitSteps->second); + } + + wxButton* pOkButton = new wxButton(this, wxID_OK, "&OK"); + wxButton* pCancelButton = new wxButton(this, wxID_CANCEL, "Cancel"); + wxButton* pHelpButton = new wxButton(this, wxID_HELP, "Help"); + pOkButton->SetDefault(); + + wxBoxSizer* pTopSizer = new wxBoxSizer(wxVERTICAL); + + pTopSizer->Add( + new wxStaticText(this, wxID_ANY, "Quantize Cut & Paste Events"), + 0, + wxALIGN_CENTER | wxALL, + 5); + + pTopSizer->Add(mpSnapValueChoice, 0, wxALIGN_CENTER | wxALL, 5); + + wxBoxSizer* pButtonSizer = new wxBoxSizer(wxHORIZONTAL); + pButtonSizer->Add(pOkButton, 0, wxALL, 5); + pButtonSizer->Add(pCancelButton, 0, wxALL, 5); + pButtonSizer->Add(pHelpButton, 0, wxALL, 5); + + pTopSizer->Add(pButtonSizer, 0, wxALIGN_CENTER | wxBOTTOM, 6); + + SetAutoLayout(true); + SetSizer(pTopSizer); + + pTopSizer->SetSizeHints(this); + pTopSizer->Fit(this); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZSnapDialog::TransferDataToWindow() +{ + int Selection = 0; + for ( + map<int, string>::const_iterator iLimitSteps = gLimitSteps.begin(); + iLimitSteps != gLimitSteps.end(); + ++iLimitSteps, ++Selection) + { + const int& Value = iLimitSteps->first; + if (Value >= mSnapDenominator) + { + break; + } + } + mpSnapValueChoice->SetSelection(Selection); + + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +bool JZSnapDialog::TransferDataFromWindow() +{ + wxString SelectedValue = mpSnapValueChoice->GetStringSelection(); + string SelectedString = SelectedValue.c_str(); + for ( + map<int, string>::const_iterator iLimitSteps = gLimitSteps.begin(); + iLimitSteps != gLimitSteps.end(); + ++iLimitSteps) + { + const string& String = iLimitSteps->second; + if (SelectedString == String) + { + mSnapDenominator = iLimitSteps->first; + break; + } + } + + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +void JZSnapDialog::OnHelp(wxCommandEvent& Event) +{ + gpHelpInstance->ShowTopic("Snap"); +} Property changes on: trunk/jazz/src/Dialogs/SnapDialog.cpp ___________________________________________________________________ Added: svn:eol-style + native Added: trunk/jazz/src/Dialogs/SnapDialog.h =================================================================== --- trunk/jazz/src/Dialogs/SnapDialog.h (rev 0) +++ trunk/jazz/src/Dialogs/SnapDialog.h 2009-02-19 15:06:48 UTC (rev 717) @@ -0,0 +1,53 @@ +//***************************************************************************** +// The JAZZ++ Midi Sequencer +// +// Copyright (C) 2009 Peter J. Stieber, all rights reserved. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +//***************************************************************************** + +#ifndef JZ_SNAPDIALOG_H +#define JZ_SNAPDIALOG_H + +#include <wx/dialog.h> + +class wxChoice; + +//***************************************************************************** +//***************************************************************************** +class JZSnapDialog : public wxDialog +{ + public: + + JZSnapDialog(int& SnapDenominator, wxWindow* pParent); + + private: + + bool TransferDataToWindow(); + + bool TransferDataFromWindow(); + + void OnHelp(wxCommandEvent& Event); + + private: + + int& mSnapDenominator; + + wxChoice* mpSnapValueChoice; + + DECLARE_EVENT_TABLE(); +}; + +#endif // !defined(JZ_SNAPDIALOG_H) Property changes on: trunk/jazz/src/Dialogs/SnapDialog.h ___________________________________________________________________ Added: svn:eol-style + native Modified: trunk/jazz/src/Dialogs.cpp =================================================================== --- trunk/jazz/src/Dialogs.cpp 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/Dialogs.cpp 2009-02-19 15:06:48 UTC (rev 717) @@ -163,17 +163,17 @@ // How it really ought to work (except the validator might ask the "value" // for the list of allowed values). // http://sourceforge.net/tracker/?group_id=9863&atid=109863 wx bugracker - tNamedValueListValue val1 = tNamedValueListValue( - &lowLimit, - gLimitSteps); +// tNamedValueListValue val1 = tNamedValueListValue( +// &lowLimit, +// gLimitSteps); - wxPropertyValue& val = val1; - cout << "little test:" << val.GetStringRepresentation() << endl; - sheet->AddProperty(new wxProperty( - "Delete shorther than", - (tNamedValueListValue&)val1, - "props", - new tNamedValueListValidator(gLimitSteps))); +// wxPropertyValue& val = val1; +// cout << "little test:" << val.GetStringRepresentation() << endl; +// sheet->AddProperty(new wxProperty( +// "Delete shorther than", +// (tNamedValueListValue&)val1, +// "props", +// new tNamedValueListValidator(gLimitSteps))); sheet->AddProperty(new wxProperty( "Shorten overlapping", @@ -394,53 +394,6 @@ //***************************************************************************** -// Snap -//***************************************************************************** - -tSnapDlg::tSnapDlg(JZPianoWindow* pPianoWindow, int* snapptr) - : tPropertyListDlg("Snap:quantize cut/paste events"), - mpPianoWindow(pPianoWindow) -{ -//, Steps("Snap value", limitSteps, snapptr) - //limitSteps lives in util.cpp - ptr = snapptr; -} - - - -bool tSnapDlg::OnClose() -{ - //Steps.GetValue(); - // toggle the tool buttons - mpPianoWindow->SetSnapDenom(*ptr); - //tPropertyListDlg::OnClose(); - return false; -} - -void tSnapDlg::OnHelp() -{ - gpHelpInstance->ShowTopic("Snap"); -} - -void tSnapDlg::AddProperties() -{ -// panel->SetLabelPosition(wxVERTICAL); -// Add(wxMakeFormMessage("quantize cut/paste events")); -// Add(wxMakeFormNewLine()); -// Add(Steps.mkFormItem(100)); -// Add(wxMakeFormNewLine()); -// AssociatePanel(panel); - - sheet->AddProperty(new wxProperty( - "Steps", - tNamedValueListValue(ptr, gLimitSteps), - "props", - new tNamedValueListValidator(gLimitSteps))); -} - - - -//***************************************************************************** // Event-Dialogue //***************************************************************************** Modified: trunk/jazz/src/Dialogs.h =================================================================== --- trunk/jazz/src/Dialogs.h 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/Dialogs.h 2009-02-19 15:06:48 UTC (rev 717) @@ -139,27 +139,6 @@ void OnHelp(); }; -class tSnapDlg : public tPropertyListDlg -{ - public: - - tSnapDlg(JZPianoWindow* pPianoWindow, int* snapptr); - - void AddProperties(); - - //tNamedChoice Steps; - - bool OnClose(); - - void OnHelp(); - - private: - - JZPianoWindow* mpPianoWindow; - - int* ptr; -}; - void EventDialog( JZEvent*, JZPianoWindow*, Modified: trunk/jazz/src/Globals.cpp =================================================================== --- trunk/jazz/src/Globals.cpp 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/Globals.cpp 2009-02-19 15:06:48 UTC (rev 717) @@ -41,7 +41,7 @@ JZHelp* gpHelpInstance = 0; -vector<pair<string, int> > gLimitSteps; +map<int, string> gLimitSteps; vector<pair<string, int> > gModes; @@ -51,7 +51,7 @@ vector<pair<string, int> > gScaleNames; -map<int, string> gQntSteps; +map<int, string> gQuantizationSteps; vector<pair<string, int> > gSynthesizerTypes; Modified: trunk/jazz/src/Globals.h =================================================================== --- trunk/jazz/src/Globals.h 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/Globals.h 2009-02-19 15:06:48 UTC (rev 717) @@ -51,12 +51,12 @@ extern JZSynth* gpSynth; extern JZPlayer* gpMidiPlayer; extern JZHelp* gpHelpInstance; -extern std::vector<std::pair<std::string, int> > gLimitSteps; +extern std::map<int, std::string> gLimitSteps; extern std::vector<std::pair<std::string, int> > gModes; extern const int gScaleChromatic; extern const int gScaleSelected; extern std::vector<std::pair<std::string, int> > gScaleNames; -extern std::map<int, std::string> gQntSteps; +extern std::map<int, std::string> gQuantizationSteps; extern std::vector<std::pair<std::string, int> > gSynthesizerTypes; extern std::vector<std::pair<std::string, int> > gSynthesierTypeFiles; extern JZProject* gpProject; Modified: trunk/jazz/src/Makefile.am =================================================================== --- trunk/jazz/src/Makefile.am 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/Makefile.am 2009-02-19 15:06:48 UTC (rev 717) @@ -31,6 +31,7 @@ Dialogs/MidiChannelDialog.cpp \ Dialogs/QuantizeDialog.cpp \ Dialogs/ShiftDialog.cpp \ +Dialogs/SnapDialog.cpp \ Dialogs/SynthesizerSettingsDialog.cpp \ Dialogs/TrackDialog.cpp \ Dialogs/VelocityDialog.cpp \ @@ -115,6 +116,7 @@ Dialogs/MidiChannelDialog.cpp \ Dialogs/QuantizeDialog.cpp \ Dialogs/ShiftDialog.cpp \ +Dialogs/SnapDialog.cpp \ Dialogs/SynthesizerSettingsDialog.cpp \ Dialogs/TrackDialog.cpp \ Dialogs/VelocityDialog.cpp \ @@ -204,6 +206,7 @@ Dialogs/MidiChannelDialog.h \ Dialogs/QuantizeDialog.h \ Dialogs/ShiftDialog.h \ +Dialogs/SnapDialog.h \ Dialogs/SynthesizerSettingsDialog.h \ Dialogs/TrackDialog.h \ Dialogs/VelocityDialog.h \ Modified: trunk/jazz/src/NamedValueChoice.cpp =================================================================== --- trunk/jazz/src/NamedValueChoice.cpp 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/NamedValueChoice.cpp 2009-02-19 15:06:48 UTC (rev 717) @@ -30,16 +30,16 @@ //----------------------------------------------------------------------------- tNamedValueChoice::tNamedValueChoice( wxWindow* pParent, - const vector<pair<string, int> >& Pairs) + const map<int, string>& Map) : wxChoice(pParent, wxID_ANY), - mPairs(Pairs) + mMap(Map) { for ( - vector<pair<string, int> >::const_iterator iPair = mPairs.begin(); - iPair != mPairs.end(); - ++iPair) + map<int, string>::const_iterator iMap = mMap.begin(); + iMap != mMap.end(); + ++iMap) { - Append(iPair->first); + Append(iMap->second); } } @@ -47,10 +47,20 @@ //----------------------------------------------------------------------------- int tNamedValueChoice::GetValue() { - int i = GetSelection(); - if (i >= 0) + int Selection = GetSelection(); + if (Selection >= 0) { - return mPairs[i].second; + int i = 0; + for ( + map<int, string>::const_iterator iMap = mMap.begin(); + iMap != mMap.end(); + ++iMap, ++i) + { + if (i == Selection) + { + return iMap->first; + } + } } return 16; } @@ -61,14 +71,14 @@ { int i = 0; for ( - vector<pair<string, int> >::const_iterator iPair = mPairs.begin(); - iPair != mPairs.end(); - ++iPair) + map<int, string>::const_iterator iMap = mMap.begin(); + iMap != mMap.end(); + ++iMap, ++i) { - if (iPair->second == Measure) + if (iMap->first == Measure) { SetSelection(i); + break; } - ++i; } } Modified: trunk/jazz/src/NamedValueChoice.h =================================================================== --- trunk/jazz/src/NamedValueChoice.h 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/NamedValueChoice.h 2009-02-19 15:06:48 UTC (rev 717) @@ -25,7 +25,7 @@ #include <wx/choice.h> -#include <vector> +#include <map> #include <string> //***************************************************************************** @@ -36,7 +36,7 @@ tNamedValueChoice( wxWindow* pParent, - const std::vector<std::pair<std::string, int> >& Pairs); + const std::map<int, std::string>& Map); int GetValue(); @@ -44,7 +44,7 @@ private: - const std::vector<std::pair<std::string, int> >& mPairs; + const std::map<int, std::string>& mMap; }; #endif // !defined(JZ_NAMEDVALUECHOICE_H) Modified: trunk/jazz/src/PianoWindow.cpp =================================================================== --- trunk/jazz/src/PianoWindow.cpp 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/PianoWindow.cpp 2009-02-19 15:06:48 UTC (rev 717) @@ -25,6 +25,7 @@ #include "Command.h" #include "ControlEdit.h" #include "Dialogs.h" +#include "Dialogs/SnapDialog.h" #include "Filter.h" #include "GuitarFrame.h" #include "Harmony.h" @@ -3114,8 +3115,8 @@ //----------------------------------------------------------------------------- void JZPianoWindow::SnapDialog() { - tSnapDlg* pSnapDialog = new tSnapDlg(this, &mSnapDenomiator); - pSnapDialog->Create(); + JZSnapDialog SnapDialog(mSnapDenomiator, this); + SnapDialog.ShowModal(); } //----------------------------------------------------------------------------- Modified: trunk/jazz/src/Project.cpp =================================================================== --- trunk/jazz/src/Project.cpp 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/src/Project.cpp 2009-02-19 15:06:48 UTC (rev 717) @@ -78,14 +78,14 @@ { if (gLimitSteps.empty()) { - gLimitSteps.push_back(make_pair( "1/8", 8)); - gLimitSteps.push_back(make_pair( "1/12", 12)); - gLimitSteps.push_back(make_pair( "1/16", 16)); - gLimitSteps.push_back(make_pair( "1/24", 24)); - gLimitSteps.push_back(make_pair( "1/32", 32)); - gLimitSteps.push_back(make_pair( "1/48", 48)); - gLimitSteps.push_back(make_pair( "1/96", 96)); - gLimitSteps.push_back(make_pair("1/192", 192)); + gLimitSteps.insert(make_pair( 8, "1/8")); + gLimitSteps.insert(make_pair( 12, "1/12")); + gLimitSteps.insert(make_pair( 16, "1/16")); + gLimitSteps.insert(make_pair( 24, "1/24")); + gLimitSteps.insert(make_pair( 32, "1/32")); + gLimitSteps.insert(make_pair( 48, "1/48")); + gLimitSteps.insert(make_pair( 96, "1/96")); + gLimitSteps.insert(make_pair(192, "1/192")); } if (gModes.empty()) @@ -113,15 +113,15 @@ gScaleNames.push_back(make_pair("Selected", gScaleSelected)); } - if (gQntSteps.empty()) + if (gQuantizationSteps.empty()) { - gQntSteps.insert(make_pair(8, "1/8")); - gQntSteps.insert(make_pair(12, "1/12")); - gQntSteps.insert(make_pair(16, "1/16")); - gQntSteps.insert(make_pair(24, "1/24")); - gQntSteps.insert(make_pair(32, "1/32")); - gQntSteps.insert(make_pair(48, "1/48")); - gQntSteps.insert(make_pair(96, "1/96")); + gQuantizationSteps.insert(make_pair(8, "1/8")); + gQuantizationSteps.insert(make_pair(12, "1/12")); + gQuantizationSteps.insert(make_pair(16, "1/16")); + gQuantizationSteps.insert(make_pair(24, "1/24")); + gQuantizationSteps.insert(make_pair(32, "1/32")); + gQuantizationSteps.insert(make_pair(48, "1/48")); + gQuantizationSteps.insert(make_pair(96, "1/96")); } if (gSynthesizerTypes.empty()) Modified: trunk/jazz/vc8/JazzPlusPlus-VC8.vcproj =================================================================== --- trunk/jazz/vc8/JazzPlusPlus-VC8.vcproj 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/vc8/JazzPlusPlus-VC8.vcproj 2009-02-19 15:06:48 UTC (rev 717) @@ -899,6 +899,14 @@ > </File> <File + RelativePath="..\src\Dialogs\SnapDialog.cpp" + > + </File> + <File + RelativePath="..\src\Dialogs\SnapDialog.h" + > + </File> + <File RelativePath="..\src\Dialogs\SynthesizerSettingsDialog.cpp" > </File> Modified: trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj =================================================================== --- trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj 2009-02-17 17:36:54 UTC (rev 716) +++ trunk/jazz/vc9/JazzPlusPlus-VC9.vcproj 2009-02-19 15:06:48 UTC (rev 717) @@ -917,6 +917,14 @@ > </File> <File + RelativePath="..\src\Dialogs\SnapDialog.cpp" + > + </File> + <File + RelativePath="..\src\Dialogs\SnapDialog.h" + > + </File> + <File RelativePath="..\src\Dialogs\SynthesizerSettingsDialog.cpp" > </File> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |