From: <sag...@us...> - 2011-10-20 21:47:01
|
Revision: 1111 http://modplug.svn.sourceforge.net/modplug/?rev=1111&view=rev Author: saga-games Date: 2011-10-20 21:46:54 +0000 (Thu, 20 Oct 2011) Log Message: ----------- [Fix] Custom plugin editors should now finally always have the correct size (quite a dirty hack). [Fix] Plugin preset menu is correct again for plugins with 128*n presets. [Ref] Added HasValidMIDIChannel() function to instrument struct. Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/VSTEditor.cpp trunk/OpenMPT/soundlib/Snd_fx.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-10-20 21:20:23 UTC (rev 1110) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2011-10-20 21:46:54 UTC (rev 1111) @@ -411,7 +411,7 @@ m_pPresetMenu->CreatePopupMenu(); } - const int numSubMenus = (numProgs / PRESETS_PER_GROUP) + 1; + const int numSubMenus = ((numProgs - 1) / PRESETS_PER_GROUP) + 1; if(numSubMenus > 1) { // Create sub menus if necessary Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2011-10-20 21:20:23 UTC (rev 1110) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2011-10-20 21:46:54 UTC (rev 1111) @@ -1014,8 +1014,8 @@ //rewbs.vstiLive if (nins <= m_SndFile.m_nInstruments) { - MODINSTRUMENT *pIns = m_SndFile.Instruments[nins]; - if (pIns && pIns->nMidiChannel > 0 && pIns->nMidiChannel < 17) // instro sends to a midi chan + const MODINSTRUMENT *pIns = m_SndFile.Instruments[nins]; + if (pIns && pIns->HasValidMIDIChannel()) // instro sends to a midi chan { // UINT nPlugin = m_SndFile.GetBestPlugin(nChn, PRIORITISE_INSTRUMENT, EVEN_IF_MUTED); @@ -1055,7 +1055,7 @@ { MODINSTRUMENT *pIns = m_SndFile.Instruments[nins]; - if (pIns && pIns->nMidiChannel > 0 && pIns->nMidiChannel < 17) // instro sends to a midi chan + if (pIns && pIns->HasValidMIDIChannel()) // instro sends to a midi chan { UINT nPlugin = pIns->nMixPlug; // First try intrument VST Modified: trunk/OpenMPT/mptrack/VSTEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.cpp 2011-10-20 21:20:23 UTC (rev 1110) +++ trunk/OpenMPT/mptrack/VSTEditor.cpp 2011-10-20 21:46:54 UTC (rev 1111) @@ -28,11 +28,23 @@ //-------------------------------------------- { Create(IDD_PLUGINEDITOR, parent); + SetupMenu(); + + CRect rcWnd, rcClient; + // First, get window size without menu + GetWindowRect(&rcWnd); + GetClientRect(&rcClient); + + MENUBARINFO mbi; + MemsetZero(mbi); + mbi.cbSize = sizeof(mbi); + GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi); + rcWnd.bottom -= mbi.rcBar.bottom - mbi.rcBar.top; + if(m_pVstPlugin) { // Set editor window size - CRect rcWnd, rcClient; ERect *pRect; pRect = NULL; @@ -41,13 +53,27 @@ m_pVstPlugin->Dispatch(effEditGetRect, 0, 0, (LPRECT)&pRect, 0); if((pRect) && (pRect->right > pRect->left) && (pRect->bottom > pRect->top)) { + // Plugin provided valid window size + CRect rcContent; + rcContent.right = pRect->right - pRect->left; + rcContent.bottom = pRect->bottom - pRect->top; + + // Preliminary setup, without taking menu bar size into account, just to find out the height of the menu bar. + // With small (narrow) plugin GUIs, the menu might be two lines high... + SetWindowPos(NULL, 0, 0, + rcWnd.Width() - rcClient.Width() + rcContent.Width(), + rcWnd.Height() - rcClient.Height() + rcContent.Height(), + SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); + + GetMenuBarInfo(m_hWnd, OBJID_MENU, 0, &mbi); + GetWindowRect(&rcWnd); - GetClientRect(&rcClient); - SetWindowPos(NULL, 0,0, - (rcWnd.Width()) - (rcClient.Width()) + (pRect->right - pRect->left), - (rcWnd.Height()) - (rcClient.Height()) + (pRect->bottom - pRect->top), - SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE); - + rcWnd.bottom += mbi.rcBar.bottom - mbi.rcBar.top; + + // Now we have the real size. + SetWindowPos(NULL, 0, 0, + rcWnd.Width(), rcWnd.Height(), + SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); } // Restore previous editor position @@ -61,11 +87,10 @@ if((editorX + 8 < cxScreen) && (editorY + 8 < cyScreen)) { SetWindowPos(NULL, editorX, editorY, 0, 0, - SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE); + SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); } } SetTitle(); - m_pVstPlugin->Dispatch(effEditTop, 0,0, NULL, 0); m_pVstPlugin->Dispatch(effEditIdle, 0,0, NULL, 0); Modified: trunk/OpenMPT/soundlib/Snd_fx.cpp =================================================================== --- trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-10-20 21:20:23 UTC (rev 1110) +++ trunk/OpenMPT/soundlib/Snd_fx.cpp 2011-10-20 21:46:54 UTC (rev 1111) @@ -1205,7 +1205,7 @@ // Do we need to apply New/Duplicate Note Action to a VSTi? bool applyNNAtoPlug = false; IMixPlugin *pPlugin = NULL; - if (pChn->pModInstrument && pChn->pModInstrument->nMidiChannel > 0 && pChn->pModInstrument->nMidiChannel < 17 && pChn->nNote>0 && pChn->nNote<128) // instro sends to a midi chan + if (pChn->pModInstrument && pChn->pModInstrument->HasValidMIDIChannel() && pChn->nNote > 0 && pChn->nNote < 128) // instro sends to a midi chan { PLUGINDEX nPlugin = GetBestPlugin(nChn, PrioritiseInstrument, RespectMutes); /* @@ -2349,13 +2349,17 @@ //---------------------------------------------------------- { //Send midi pitch bend event if there's a plugin: - MODINSTRUMENT *pHeader = pChn->pModInstrument; - if (pHeader && pHeader->nMidiChannel>0 && pHeader->nMidiChannel<17) { // instro sends to a midi chan - UINT nPlug = pHeader->nMixPlug; - if ((nPlug) && (nPlug <= MAX_MIXPLUGINS)) { + const MODINSTRUMENT *pIns = pChn->pModInstrument; + if (pIns && pIns->HasValidMIDIChannel()) + { + // instro sends to a midi chan + UINT nPlug = pIns->nMixPlug; + if ((nPlug) && (nPlug <= MAX_MIXPLUGINS)) + { IMixPlugin *pPlug = (IMixPlugin*)m_MixPlugins[nPlug-1].pMixPlugin; - if (pPlug) { - pPlug->MidiPitchBend(pHeader->nMidiChannel, param, 0); + if (pPlug) + { + pPlug->MidiPitchBend(pIns->nMidiChannel, param, 0); } } } @@ -3742,7 +3746,7 @@ const MODINSTRUMENT *pIns = pChn->pModInstrument; // instro sends to a midi chan - if (pIns && pIns->nMidiChannel > 0 && pIns->nMidiChannel < 17) + if (pIns && pIns->HasValidMIDIChannel()) { UINT nPlug = pIns->nMixPlug; if ((nPlug) && (nPlug <= MAX_MIXPLUGINS)) @@ -4219,7 +4223,7 @@ UINT CSoundFile::GetBestMidiChan(const MODCHANNEL *pChn) const //------------------------------------------------------------ { - if (pChn && pChn->pModInstrument && pChn->pModInstrument->nMidiChannel) + if (pChn && pChn->pModInstrument && pChn->pModInstrument->HasValidMIDIChannel()) { return (pChn->pModInstrument->nMidiChannel - 1) & 0x0F; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2011-10-20 21:20:23 UTC (rev 1110) +++ trunk/OpenMPT/soundlib/Sndfile.h 2011-10-20 21:46:54 UTC (rev 1111) @@ -123,9 +123,9 @@ BYTE nIFC; // Default filter cutoff (0...127). Used if the high bit is set BYTE nIFR; // Default filter resonance (0...127). Used if the high bit is set - WORD wMidiBank; // MIDI bank - BYTE nMidiProgram; // MIDI program - BYTE nMidiChannel; // MIDI channel + WORD wMidiBank; // MIDI Bank (1...16384). 0 = Don't send. + BYTE nMidiProgram; // MIDI Program (1...128). 0 = Don't send. + BYTE nMidiChannel; // MIDI Channel (1...16). 0 = Don't send. BYTE nMidiDrumKey; // Drum set note mapping (currently only used by the .MID loader) signed char nPPS; //Pitch/Pan separation (i.e. how wide the panning spreads) @@ -208,6 +208,8 @@ MemsetZero(filename); } + bool HasValidMIDIChannel() const { return (nMidiChannel >= 1 && nMidiChannel <= 16); } + }; //MODINSTRUMENT; Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2011-10-20 21:20:23 UTC (rev 1110) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2011-10-20 21:46:54 UTC (rev 1111) @@ -958,7 +958,7 @@ if (vol > 0 || IsCompatibleMode(TRK_IMPULSETRACKER)) { // IT compatibility: We don't need a different attenuation here because of the different tables we're going to use - const int tremattn = (m_nType & MOD_TYPE_XM || IsCompatibleMode(TRK_IMPULSETRACKER)) ? 5 : 6; + const int tremattn = ((GetType() & MOD_TYPE_XM) || IsCompatibleMode(TRK_IMPULSETRACKER)) ? 5 : 6; switch (pChn->nTremoloType & 0x03) { case 1: @@ -981,7 +981,7 @@ vol += ((IsCompatibleMode(TRK_IMPULSETRACKER) ? ITSinusTable[trempos] : ModSinusTable[trempos]) * (int)pChn->nTremoloDepth) >> tremattn; } } - if ((m_nTickCount) || ((m_nType & (MOD_TYPE_STM|MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) && (!(m_dwSongFlags & SONG_ITOLDEFFECTS)))) + if (!(m_dwSongFlags & SONG_FIRSTTICK) || ((GetType() & (MOD_TYPE_STM|MOD_TYPE_S3M|MOD_TYPE_IT|MOD_TYPE_MPT)) && (!(m_dwSongFlags & SONG_ITOLDEFFECTS)))) { // IT compatibility: IT has its own, more precise tables if(IsCompatibleMode(TRK_IMPULSETRACKER)) @@ -1619,7 +1619,7 @@ // Sample Auto-Vibrato if ((pChn->pModSample) && (pChn->pModSample->nVibDepth)) { - MODSAMPLE *pSmp = pChn->pModSample; + const MODSAMPLE *pSmp = pChn->pModSample; const bool alternativeTuning = pChn->pModInstrument && pChn->pModInstrument->pTuning; // IT compatibility: Autovibrato is so much different in IT that I just put this in a separate code block, to get rid of a dozen IsCompatibilityMode() calls. @@ -1735,19 +1735,19 @@ if(alternativeTuning) { //Vib sweep is not taken into account here. - vibratoFactor += 0.05F * pSmp->nVibDepth * vdelta / 4096.0F; //4096 == 64^2 + vibratoFactor += 0.05F * pSmp->nVibDepth * vdelta / 4096.0f; //4096 == 64^2 //See vibrato for explanation. pChn->m_CalculateFreq = true; /* Finestep vibrato: - const float autoVibDepth = pSmp->nVibDepth * val / 4096.0F; //4096 == 64^2 + const float autoVibDepth = pSmp->nVibDepth * val / 4096.0f; //4096 == 64^2 vibratoFineSteps += static_cast<CTuning::FINESTEPTYPE>(pChn->pModInstrument->pTuning->GetFineStepCount() * autoVibDepth); pChn->m_CalculateFreq = true; */ } else //Original behavior { - if (m_nType & (MOD_TYPE_IT | MOD_TYPE_MPT)) + if (GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT)) { int df1, df2; if (n < 0) @@ -2413,7 +2413,7 @@ if (pIns) { // Check instrument plugins - if ((pIns->nMidiChannel >= 1) && (pIns->nMidiChannel <= 16)) + if (pIns->HasValidMIDIChannel()) { nPlugin = GetBestPlugin(nChn, PrioritiseInstrument, RespectMutes); if ((nPlugin) && (nPlugin <= MAX_MIXPLUGINS)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |