From: <sag...@us...> - 2014-11-01 20:16:25
|
Revision: 4530 http://sourceforge.net/p/modplug/code/4530 Author: saga-games Date: 2014-11-01 20:16:14 +0000 (Sat, 01 Nov 2014) Log Message: ----------- [Fix] MIDI Mapping Editor: Up/Down spin button was not updating instantly anymore in some cases. [Imp] MIDI Mapping Editor: Combined some columns where it makes sense to save space. [Ref] Remove now unneeded CMIDIMappingDirective::ToString Modified Paths: -------------- trunk/OpenMPT/mptrack/MIDIMapping.cpp trunk/OpenMPT/mptrack/MIDIMapping.h trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/MIDIMappingDialog.h Modified: trunk/OpenMPT/mptrack/MIDIMapping.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.cpp 2014-11-01 17:36:25 UTC (rev 4529) +++ trunk/OpenMPT/mptrack/MIDIMapping.cpp 2014-11-01 20:16:14 UTC (rev 4530) @@ -18,17 +18,6 @@ OPENMPT_NAMESPACE_BEGIN -std::string CMIDIMappingDirective::ToString() const -//------------------------------------------------- -{ - char flags[4] = "000"; - if(m_Active) flags[0] = '1'; - if(m_CaptureMIDI) flags[1] = '1'; - if(m_AllowPatternEdit) flags[2] = '1'; - return mpt::String::Print("%1:%2:%3:%4:%5:%6", flags, (int)GetChannel(), mpt::fmt::hex((int)GetEvent()), (int)GetController(), (int)m_PluginIndex, m_Parameter); -} - - size_t CMIDIMapper::GetSerializationSize() const //---------------------------------------------- { Modified: trunk/OpenMPT/mptrack/MIDIMapping.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.h 2014-11-01 17:36:25 UTC (rev 4529) +++ trunk/OpenMPT/mptrack/MIDIMapping.h 2014-11-01 20:16:14 UTC (rev 4530) @@ -57,22 +57,20 @@ bool IsDefault() const {return *this == CMIDIMappingDirective();} - bool operator==(const CMIDIMappingDirective &other) const { return memcmp(this, &other, sizeof(CMIDIMappingDirective)) == 0; } + bool operator==(const CMIDIMappingDirective &other) const { return memcmp(this, &other, sizeof(*this)) == 0; } bool operator<(const CMIDIMappingDirective &other) const { return GetController() < other.GetController(); } - std::string ToString() const; - BYTE GetChnEvent() const {return m_ChnEvent;} private: - bool m_Active; - bool m_CaptureMIDI; //When true, MIDI data should not be processed beyond this directive - bool m_AllowPatternEdit; //When true, the mapping can be used for modifying pattern. - bool m_AnyChannel; + uint32 m_Parameter; + PLUGINDEX m_PluginIndex; + BYTE m_MIDIByte1; uint8 m_ChnEvent; //0-3 channel, 4-7 event - BYTE m_MIDIByte1; - PLUGINDEX m_PluginIndex; - uint32 m_Parameter; + bool m_Active : 1; + bool m_CaptureMIDI : 1; //When true, MIDI data should not be processed beyond this directive + bool m_AllowPatternEdit : 1; //When true, the mapping can be used for modifying pattern. + bool m_AnyChannel : 1; }; class CSoundFile; Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2014-11-01 17:36:25 UTC (rev 4529) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2014-11-01 20:16:14 UTC (rev 4530) @@ -108,14 +108,14 @@ CDialog::OnInitDialog(); // Add events - m_EventCBox.SetItemData(m_EventCBox.AddString("Controller Change (0xB)"), MIDIEvents::evControllerChange); - m_EventCBox.SetItemData(m_EventCBox.AddString("Polyphonic Aftertouch (0xA)"), MIDIEvents::evPolyAftertouch); - m_EventCBox.SetItemData(m_EventCBox.AddString("Channel Aftertouch (0xD)"), MIDIEvents::evChannelAftertouch); + m_EventCBox.SetItemData(m_EventCBox.AddString(_T("Controller Change")), MIDIEvents::evControllerChange); + m_EventCBox.SetItemData(m_EventCBox.AddString(_T("Polyphonic Aftertouch")), MIDIEvents::evPolyAftertouch); + m_EventCBox.SetItemData(m_EventCBox.AddString(_T("Channel Aftertouch")), MIDIEvents::evChannelAftertouch); // Add controller names + CString temp; for(size_t i = MIDIEvents::MIDICC_start; i <= MIDIEvents::MIDICC_end; i++) { - CString temp; temp.Format("%3u %s", i, MIDIEvents::MidiCCNames[i]); m_ControllerCBox.AddString(temp); } @@ -123,21 +123,19 @@ // Add plugin names AddPluginNamesToCombobox(m_PluginCBox, m_rSndFile.m_MixPlugins); - // Initialize mapping list + // Initialize mapping table const struct { const TCHAR *text; int width; } labels[] = { - { _T("Active"), 20 }, - { _T("Channel"), 48 }, - { _T("Event"), 56 }, - { _T("Controller"), 120 }, - { _T("Plugin"), 120 }, - { _T("Parameter"), 120 }, - { _T("Capture"), 36 }, - { _T("Pattern Record"), 36 } + { _T("Channel"), 58 }, + { _T("Event / Controller"), 176 }, + { _T("Plugin"), 120 }, + { _T("Parameter"), 120 }, + { _T("Capture"), 40 }, + { _T("Pattern Record"), 40 } }; for(int i = 0; i < CountOf(labels); i++) { @@ -174,50 +172,44 @@ int CMIDIMappingDialog::InsertItem(const CMIDIMappingDirective& m, int insertAt) //------------------------------------------------------------------------------ { - insertAt = m_List.InsertItem(insertAt, _T("")); - if(insertAt == -1) - return -1; - CString s; - m_List.SetCheck(insertAt, m.IsActive() ? TRUE : FALSE); if(m.GetAnyChannel()) s = _T("Any"); else s.Format(_T("Ch %u"), m.GetChannel()); - m_List.SetItemText(insertAt, 1, s); + insertAt = m_List.InsertItem(insertAt, s); + if(insertAt == -1) + return -1; + m_List.SetCheck(insertAt, m.IsActive() ? TRUE : FALSE); + switch(m.GetEvent()) { case MIDIEvents::evControllerChange: - s = _T("CC"); break; + s.Format(_T("CC %u: "), m.GetController()); + if(m.GetController() <= MIDIEvents::MIDICC_end) s += MIDIEvents::MidiCCNames[m.GetController()]; + break; case MIDIEvents::evPolyAftertouch: - s = _T("PolyAT"); break; + s = _T("Polyphonic Aftertouch"); break; case MIDIEvents::evChannelAftertouch: - s = _T("ChanAT"); break; + s = _T("Channel Aftertouch"); break; default: s.Format(_T("0x%02X"), m.GetEvent()); break; } - m_List.SetItemText(insertAt, 2, s); + m_List.SetItemText(insertAt, 1, s); - if(m.GetController() <= MIDIEvents::MIDICC_end && m.GetEvent() == MIDIEvents::evControllerChange) - { - s.Format(_T("%u "), m.GetController()); - s += MIDIEvents::MidiCCNames[m.GetController()]; - m_List.SetItemText(insertAt, 3, s); - } - const PLUGINDEX plugindex = m.GetPlugIndex(); if(plugindex > 0 && plugindex < MAX_MIXPLUGINS) { s.Format(_T("FX%u: "), plugindex); s += m_rSndFile.m_MixPlugins[plugindex - 1].GetName(); - m_List.SetItemText(insertAt, 4, s); + m_List.SetItemText(insertAt, 2, s); s.Format(_T("%02u: "), m.GetParamIndex()); s += m_rSndFile.m_MixPlugins[plugindex - 1].GetParamName(m.GetParamIndex()).c_str(); - m_List.SetItemText(insertAt, 5, s); + m_List.SetItemText(insertAt, 3, s); } - m_List.SetItemText(insertAt, 6, m.GetCaptureMIDI() ? _T("Cap") : _T("")); - m_List.SetItemText(insertAt, 7, m.GetAllowPatternEdit() ? _T("PR") : _T("")); + m_List.SetItemText(insertAt, 4, m.GetCaptureMIDI() ? _T("Capt") : _T("")); + m_List.SetItemText(insertAt, 5, m.GetAllowPatternEdit() ? _T("Rec") : _T("")); return insertAt; } @@ -231,8 +223,8 @@ } -void CMIDIMappingDialog::UpdateDialog() -//------------------------------------- +void CMIDIMappingDialog::UpdateDialog(int selItem) +//------------------------------------------------ { CheckDlgButton(IDC_CHECKACTIVE, m_Setting.IsActive() ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CHECKCAPTURE, m_Setting.GetCaptureMIDI() ? BST_CHECKED : BST_UNCHECKED); @@ -257,8 +249,9 @@ UpdateEvent(); UpdateParameters(); - const int i = m_List.GetSelectionMark(); - const bool enableMover = i >= 0 && ( (i > 0 && m_rMIDIMapper.AreOrderEqual(i - 1, i)) || (i + 1 < m_List.GetItemCount() && m_rMIDIMapper.AreOrderEqual(i, i + 1))); + const bool enableMover = selItem >= 0 && ( + (selItem > 0 && m_rMIDIMapper.AreOrderEqual(selItem - 1, selItem)) || + (selItem + 1 < m_List.GetItemCount() && m_rMIDIMapper.AreOrderEqual(selItem, selItem + 1))); m_SpinMoveMapping.EnableWindow(enableMover); } Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.h 2014-11-01 17:36:25 UTC (rev 4529) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.h 2014-11-01 20:16:14 UTC (rev 4530) @@ -46,7 +46,7 @@ ~CMIDIMappingDialog(); protected: - void UpdateDialog(); + void UpdateDialog(int selItem = -1); void UpdateEvent(); void UpdateParameters(); int InsertItem(const CMIDIMappingDirective& m, int insertAt); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |