From: <sag...@us...> - 2014-08-16 14:48:34
|
Revision: 4205 http://sourceforge.net/p/modplug/code/4205 Author: saga-games Date: 2014-08-16 14:48:20 +0000 (Sat, 16 Aug 2014) Log Message: ----------- [New] Plugin editor positions are now stored in module files [Mod] OpenMPT: Version is now 1.23.04.07 Modified Paths: -------------- trunk/OpenMPT/common/versionNumber.h trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/AbstractVstEditor.h trunk/OpenMPT/mptrack/DefaultVstEditor.cpp trunk/OpenMPT/mptrack/VSTEditor.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h trunk/OpenMPT/soundlib/Load_it.cpp trunk/OpenMPT/soundlib/plugins/PlugInterface.h Modified: trunk/OpenMPT/common/versionNumber.h =================================================================== --- trunk/OpenMPT/common/versionNumber.h 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/common/versionNumber.h 2014-08-16 14:48:20 UTC (rev 4205) @@ -19,7 +19,7 @@ #define VER_MAJORMAJOR 1 #define VER_MAJOR 23 #define VER_MINOR 04 -#define VER_MINORMINOR 06 +#define VER_MINORMINOR 07 //Version string. For example "1.17.02.28" #define MPT_VERSION_STR VER_STRINGIZE(VER_MAJORMAJOR) "." VER_STRINGIZE(VER_MAJOR) "." VER_STRINGIZE(VER_MINOR) "." VER_STRINGIZE(VER_MINORMINOR) Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-08-16 14:48:20 UTC (rev 4205) @@ -41,6 +41,7 @@ ON_WM_MENUSELECT() ON_WM_ACTIVATE() ON_WM_DROPFILES() + ON_WM_MOVE() ON_COMMAND(ID_EDIT_COPY, OnCopyParameters) ON_COMMAND(ID_EDIT_PASTE, OnPasteParameters) ON_COMMAND(ID_PRESET_LOAD, OnLoadPreset) @@ -950,6 +951,57 @@ return m_nLearnMacro; } + +void CAbstractVstEditor::OnMove(int, int) +//--------------------------------------- +{ + if(IsWindowVisible()) + { + StoreWindowPos(); + } +} + + +void CAbstractVstEditor::StoreWindowPos() +//--------------------------------------- +{ + if(m_hWnd) + { + // Translate screen position into percentage (to make it independent of the actual screen resolution) + CRect rect; + GetWindowRect(&rect); + const int cxScreen = GetSystemMetrics(SM_CXSCREEN), cyScreen = GetSystemMetrics(SM_CYSCREEN); + int32 editorX = Util::muldivr(rect.left, 1 << 30, cxScreen); + int32 editorY = Util::muldivr(rect.top, 1 << 30, cyScreen); + m_VstPlugin.SetEditorPos(editorX, editorY); + } +} + + +void CAbstractVstEditor::RestoreWindowPos() +//----------------------------------------- +{ + // Restore previous editor position + int32 editorX, editorY; + m_VstPlugin.GetEditorPos(editorX, editorY); + + if((editorX >= 0) && (editorY >= 0)) + { + // Translate percentage into screen position (to make it independent of the actual screen resolution) + const int cxScreen = GetSystemMetrics(SM_CXSCREEN), cyScreen = GetSystemMetrics(SM_CYSCREEN); + editorX = Util::muldivr(editorX, cxScreen, 1 << 30); + editorY = Util::muldivr(editorY, cyScreen, 1 << 30); + + if((editorX + 8 < cxScreen) && (editorY + 8 < cyScreen)) + { + SetWindowPos(NULL, editorX, editorY, 0, 0, + SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); + } + } + +} + + #endif // NO_VST Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2014-08-16 14:48:20 UTC (rev 4205) @@ -67,6 +67,7 @@ afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM); //rewbs.customKeys afx_msg LRESULT OnMidiMsg(WPARAM, LPARAM); afx_msg void OnDropFiles(HDROP hDropInfo); + afx_msg void OnMove(int x, int y); //Overridden methods: virtual void OnOK() = 0; @@ -103,6 +104,9 @@ afx_msg void OnInitMenu(CMenu* pMenu); void PrepareToLearnMacro(UINT nID); + void StoreWindowPos(); + void RestoreWindowPos(); + }; //end rewbs.defaultPlugGUI Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2014-08-16 14:48:20 UTC (rev 4205) @@ -409,21 +409,8 @@ CreateControls(); - // Restore previous editor position - int editorX, editorY; - m_VstPlugin.GetEditorPos(editorX, editorY); - - if((editorX >= 0) && (editorY >= 0)) - { - int cxScreen = GetSystemMetrics(SM_CXSCREEN); - int cyScreen = GetSystemMetrics(SM_CYSCREEN); - if((editorX + 8 < cxScreen) && (editorY + 8 < cyScreen)) - { - SetWindowPos(NULL, editorX, editorY, 0,0, - SWP_NOZORDER|SWP_NOSIZE|SWP_NOACTIVATE); - } - } - + RestoreWindowPos(); + ShowWindow(SW_SHOW); return true; @@ -454,13 +441,7 @@ void CDefaultVstEditor::DoClose() //------------------------------- { - if(m_hWnd) - { - CRect rect; - GetWindowRect(&rect); - m_VstPlugin.SetEditorPos(rect.left, rect.top); - } - + StoreWindowPos(); m_VstPlugin.Dispatch(effEditClose, 0, 0, NULL, 0); DestroyWindow(); Modified: trunk/OpenMPT/mptrack/VSTEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.cpp 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/mptrack/VSTEditor.cpp 2014-08-16 14:48:20 UTC (rev 4205) @@ -84,20 +84,7 @@ SetSize(rect.right - rect.left, rect.bottom - rect.top); } - // Restore previous editor position - int editorX, editorY; - m_VstPlugin.GetEditorPos(editorX, editorY); - - if((editorX >= 0) && (editorY >= 0)) - { - int cxScreen = GetSystemMetrics(SM_CXSCREEN); - int cyScreen = GetSystemMetrics(SM_CYSCREEN); - if((editorX + 8 < cxScreen) && (editorY + 8 < cyScreen)) - { - SetWindowPos(NULL, editorX, editorY, 0, 0, - SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); - } - } + RestoreWindowPos(); SetTitle(); m_VstPlugin.Dispatch(effEditTop, 0,0, NULL, 0); @@ -135,12 +122,7 @@ void COwnerVstEditor::DoClose() //----------------------------- { - if(m_hWnd) - { - CRect rect; - GetWindowRect(&rect); - m_VstPlugin.SetEditorPos(rect.left, rect.top); - } + StoreWindowPos(); m_VstPlugin.Dispatch(effEditClose, 0, 0, NULL, 0); if(m_hWnd) { Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-08-16 14:48:20 UTC (rev 4205) @@ -666,7 +666,6 @@ m_pNext = nullptr; m_pMixStruct = &mixStruct; m_pEditor = nullptr; - m_nEditorX = m_nEditorY = -1; m_pProcessFP = nullptr; m_MixState.dwFlags = 0; @@ -976,7 +975,6 @@ if (minParam == 0 && maxParam == 0) { maxParam = m_Effect.numParams; - } LimitMax(maxParam, PlugParamIndex(m_Effect.numParams)); Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/mptrack/Vstplug.h 2014-08-16 14:48:20 UTC (rev 4205) @@ -171,7 +171,6 @@ size_t m_nRefCount; uint32 m_nSampleRate; SNDMIXPLUGINSTATE m_MixState; - int32 m_nEditorX, m_nEditorY; double lastBarStartPos; float m_fGain; @@ -227,8 +226,8 @@ PLUGINDEX GetSlot(); void UpdateMixStructPtr(SNDMIXPLUGIN *); - void SetEditorPos(int x, int y) { m_nEditorX = x; m_nEditorY = y; } - void GetEditorPos(int &x, int &y) const { x = m_nEditorX; y = m_nEditorY; } + void SetEditorPos(int32 x, int32 y) { m_pMixStruct->editorX= x; m_pMixStruct->editorY = y; } + void GetEditorPos(int32 &x, int32 &y) const { x = m_pMixStruct->editorX; y = m_pMixStruct->editorY; } void SetCurrentProgram(VstInt32 nIndex); PlugParamValue GetParameter(PlugParamIndex nIndex); @@ -345,6 +344,9 @@ bool IsBypassed() const { return false; } bool IsSongPlaying() const { return false; } + void SetEditorPos(int32, int32) { } + void GetEditorPos(int32 &x, int32 &y) const { x = y = int32_min; } + #endif // NO_VST }; Modified: trunk/OpenMPT/soundlib/Load_it.cpp =================================================================== --- trunk/OpenMPT/soundlib/Load_it.cpp 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/soundlib/Load_it.cpp 2014-08-16 14:48:20 UTC (rev 4205) @@ -1708,8 +1708,9 @@ } // rewbs.modularPlugData - DWORD MPTxPlugDataSize = 4 + (sizeof(m_MixPlugins[i].fDryRatio)) + //4 for ID and size of dryRatio - 4 + (sizeof(m_MixPlugins[i].defaultProgram)); //rewbs.plugDefaultProgram + DWORD MPTxPlugDataSize = 4 + (sizeof(m_MixPlugins[i].fDryRatio)) + // 4 for ID and size of dryRatio + 4 + (sizeof(m_MixPlugins[i].defaultProgram)) + // rewbs.plugDefaultProgram + 4 + 3 * sizeof(int32); // Editor data // for each extra entity, add 4 for ID, plus size of entity, plus optionally 4 for size of entity. nPluginSize += MPTxPlugDataSize + 4; //+4 is for size itself: sizeof(DWORD) is 4 @@ -1734,19 +1735,34 @@ fwrite(&MPTxPlugDataSize, 1, 4, f); - //write ID for this xPlugData chunk: + // Dry/Wet ratio memcpy(id, "DWRT", 4); fwrite(id, 1, 4, f); - // DWRT chunk does not include a size, so better make sure we always write 4 bytes here. - STATIC_ASSERT(sizeof(float) == 4); - fwrite(&(m_MixPlugins[i].fDryRatio), 1, sizeof(float), f); + uint32 ratio = IEEE754binary32LE(m_MixPlugins[i].fDryRatio).GetInt32(); + fwrite(&ratio, 1, sizeof(uint32), f); + // Default program memcpy(id, "PROG", 4); fwrite(id, 1, 4, f); // PROG chunk does not include a size, so better make sure we always write 4 bytes here. STATIC_ASSERT(sizeof(m_MixPlugins[i].defaultProgram) == sizeof(int32)); - fwrite(&(m_MixPlugins[i].defaultProgram), 1, sizeof(int32), f); + int32 prog = m_MixPlugins[i].defaultProgram; + SwapBytesLE(prog); + fwrite(&prog, 1, sizeof(int32), f); + // Editor window parameters + memcpy(id, "EWND", 4); + fwrite(id, 1, 4, f); + uint32 size = 2 * sizeof(int32); + SwapBytesLE(size); + fwrite(&size, sizeof(uint32), 1, f); + int32 x = m_MixPlugins[i].editorX, y = m_MixPlugins[i].editorY; + SwapBytesLE(x); + SwapBytesLE(y); + fwrite(&x, sizeof(int32), 1, f); + fwrite(&y, sizeof(int32), 1, f); + + // Please, if you add any more chunks here, don't repeat history (see above) and *do* add a size field for your chunk, mmmkay? } nTotalSize += nPluginSize + 8; } @@ -1816,6 +1832,7 @@ chunk.ReadConvertEndianness(m_MixPlugins[plug].Info); mpt::String::SetNullTerminator(m_MixPlugins[plug].Info.szName); mpt::String::SetNullTerminator(m_MixPlugins[plug].Info.szLibraryName); + m_MixPlugins[plug].editorX = m_MixPlugins[plug].editorY = int32_min; //data for VST setchunk? size lies just after standard plugin data. const uint32 pluginDataChunkSize = chunk.ReadUint32LE(); @@ -1842,19 +1859,26 @@ { // do we recognize this chunk? modularData.ReadArray(code); - //rewbs.dryRatio //TODO: turn this into a switch statement like for modular instrument data if(!memcmp(code, "DWRT", 4)) { m_MixPlugins[plug].fDryRatio = modularData.ReadFloatLE(); } - //end rewbs.dryRatio - //rewbs.plugDefaultProgram else if(!memcmp(code, "PROG", 4)) { m_MixPlugins[plug].defaultProgram = modularData.ReadUint32LE(); } - //end rewbs.plugDefaultProgram + else if(!memcmp(code, "MCRO", 4)) + { + // Read plugin-specific macros + //modularData.ReadStructPartial(m_MixPlugins[plug].macros, modularData.ReadUint32LE()); + } + else if(!memcmp(code, "EWND", 4)) + { + FileReader editorChunk = modularData.ReadChunk(modularData.ReadUint32LE()); + m_MixPlugins[plug].editorX = editorChunk.ReadInt32LE(); + m_MixPlugins[plug].editorY = editorChunk.ReadInt32LE(); + } //else if.. (add extra attempts to recognize chunks here) else // otherwise move forward a byte. { @@ -1950,7 +1974,7 @@ void CSoundFile::WriteInstrumentPropertyForAllInstruments(uint32 code, int16 size, FILE* f, UINT nInstruments) const //------------------------------------------------------------------------------------------------------------------ { - fwrite(&code, 1, sizeof(uint32), f); //write code + fwrite(&code, 1, sizeof(uint32), f); //write code fwrite(&size, 1, sizeof(int16), f); //write size for(UINT nins=1; nins<=nInstruments; nins++) //for all instruments... { Modified: trunk/OpenMPT/soundlib/plugins/PlugInterface.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2014-08-10 07:44:19 UTC (rev 4204) +++ trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2014-08-16 14:48:20 UTC (rev 4205) @@ -71,6 +71,8 @@ virtual bool isInstrument() = 0; virtual bool CanRecieveMidiEvents() = 0; virtual void SetDryRatio(UINT param) = 0; + virtual void SetEditorPos(int32 x, int32 y) = 0; + virtual void GetEditorPos(int32 &x, int32 &y) const = 0; }; @@ -159,6 +161,7 @@ SNDMIXPLUGININFO Info; float fDryRatio; VstInt32 defaultProgram; + int32 editorX, editorY; const char *GetName() const { return Info.szName; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |