From: <sag...@us...> - 2014-06-19 12:53:16
|
Revision: 4139 http://sourceforge.net/p/modplug/code/4139 Author: saga-games Date: 2014-06-19 12:53:01 +0000 (Thu, 19 Jun 2014) Log Message: ----------- [Imp] VST: Allow drag&drop actions on plugin editors to drop preset files. Modified Paths: -------------- 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/plugins/PlugInterface.h Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-06-19 10:07:57 UTC (rev 4138) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-06-19 12:53:01 UTC (rev 4139) @@ -40,6 +40,7 @@ ON_WM_INITMENU() ON_WM_MENUSELECT() ON_WM_ACTIVATE() + ON_WM_DROPFILES() ON_COMMAND(ID_EDIT_COPY, OnCopyParameters) ON_COMMAND(ID_EDIT_PASTE, OnPasteParameters) ON_COMMAND(ID_PRESET_LOAD, OnLoadPreset) @@ -122,6 +123,24 @@ } +// Drop files from Windows +void CAbstractVstEditor::OnDropFiles(HDROP hDropInfo) +//--------------------------------------------------- +{ + const UINT nFiles = ::DragQueryFileW(hDropInfo, (UINT)-1, NULL, 0); + CMainFrame::GetMainFrame()->SetForegroundWindow(); + for(UINT f = 0; f < nFiles; f++) + { + WCHAR fileName[MAX_PATH]; + if(::DragQueryFileW(hDropInfo, f, fileName, CountOf(fileName))) + { + m_VstPlugin.LoadProgram(mpt::PathString::FromNative(fileName)); + } + } + ::DragFinish(hDropInfo); +} + + void CAbstractVstEditor::OnLoadPreset() //------------------------------------- { Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.h =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.h 2014-06-19 10:07:57 UTC (rev 4138) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.h 2014-06-19 12:53:01 UTC (rev 4139) @@ -66,6 +66,7 @@ afx_msg void OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hMenu); afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM); //rewbs.customKeys afx_msg LRESULT OnMidiMsg(WPARAM, LPARAM); + afx_msg void OnDropFiles(HDROP hDropInfo); //Overridden methods: virtual void OnOK() = 0; Modified: trunk/OpenMPT/mptrack/DefaultVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2014-06-19 10:07:57 UTC (rev 4138) +++ trunk/OpenMPT/mptrack/DefaultVstEditor.cpp 2014-06-19 12:53:01 UTC (rev 4139) @@ -402,6 +402,8 @@ //---------------------------------------------- { Create(IDD_DEFAULTPLUGINEDITOR, parent); + ModifyStyleEx(0, WS_EX_ACCEPTFILES); + SetTitle(); SetupMenu(); Modified: trunk/OpenMPT/mptrack/VSTEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/VSTEditor.cpp 2014-06-19 10:07:57 UTC (rev 4138) +++ trunk/OpenMPT/mptrack/VSTEditor.cpp 2014-06-19 12:53:01 UTC (rev 4139) @@ -62,6 +62,7 @@ //-------------------------------------------- { Create(IDD_PLUGINEDITOR, parent); + ModifyStyleEx(0, WS_EX_ACCEPTFILES); // Some plugins (e.g. ProteusVX) need to be planted into another control or else they will break our window proc, making the window unusable. plugWindow.Create(nullptr, WS_CHILD | WS_VISIBLE, CRect(0, 0, 100, 100), this); Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-06-19 10:07:57 UTC (rev 4138) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-06-19 12:53:01 UTC (rev 4139) @@ -1032,8 +1032,8 @@ } -bool CVstPlugin::LoadProgram() -//---------------------------- +bool CVstPlugin::LoadProgram(mpt::PathString fileName) +//---------------------------------------------------- { mpt::PathString defaultDir = TrackerDirectories::Instance().GetWorkingDirectory(DIR_PLUGINPRESETS); bool useDefaultDir = !defaultDir.empty(); @@ -1042,23 +1042,27 @@ defaultDir = m_Factory.dllPath.GetPath(); } - FileDialog dlg = OpenFileDialog() - .DefaultExtension("fxp") - .ExtensionFilter("VST Plugin Programs and Banks (*.fxp,*.fxb)|*.fxp;*.fxb|" - "VST Plugin Programs (*.fxp)|*.fxp|" - "VST Plugin Banks (*.fxb)|*.fxb|" - "All Files|*.*||") - .WorkingDirectory(defaultDir); - if(!dlg.Show(m_pEditor)) return false; + if(fileName.empty()) + { + FileDialog dlg = OpenFileDialog() + .DefaultExtension("fxp") + .ExtensionFilter("VST Plugin Programs and Banks (*.fxp,*.fxb)|*.fxp;*.fxb|" + "VST Plugin Programs (*.fxp)|*.fxp|" + "VST Plugin Banks (*.fxb)|*.fxb|" + "All Files|*.*||") + .WorkingDirectory(defaultDir); + if(!dlg.Show(m_pEditor)) return false; - if(useDefaultDir) - { - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINPRESETS); + if(useDefaultDir) + { + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINPRESETS); + } + fileName = dlg.GetFirstFile(); } CMappedFile f; const char *errorStr = nullptr; - if(f.Open(dlg.GetFirstFile())) + if(f.Open(fileName)) { FileReader file = f.GetFile(); errorStr = VSTPresets::GetErrorMessage(VSTPresets::LoadFile(file, *this)); @@ -1981,22 +1985,6 @@ } -bool CVstPlugin::MoveNote(UINT note, UINT midiChn, UINT sourceTrackerChn, UINT destTrackerChn) -//--------------------------------------------------------------------------------------------- -{ - note -= NOTE_MIN; - VSTInstrChannel &chn = m_MidiCh[midiChn & 0x0f]; - - if(!chn.noteOnMap[note][sourceTrackerChn]) - return false; - - chn.noteOnMap[note][sourceTrackerChn]--; - chn.noteOnMap[note][destTrackerChn]++; - return true; -} -//end rewbs.introVST - - void CVstPlugin::SetZxxParameter(UINT nParam, UINT nValue) //-------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2014-06-19 10:07:57 UTC (rev 4138) +++ trunk/OpenMPT/mptrack/Vstplug.h 2014-06-19 12:53:01 UTC (rev 4139) @@ -208,7 +208,7 @@ VstInt32 GetCurrentProgram(); VstInt32 GetNumProgramCategories(); CString GetFormattedProgramName(VstInt32 index); - bool LoadProgram(); + bool LoadProgram(mpt::PathString fileName = mpt::PathString()); bool SaveProgram(); VstInt32 GetUID() const; VstInt32 GetVersion() const; @@ -274,7 +274,6 @@ void MidiCommand(uint8 nMidiCh, uint8 nMidiProg, uint16 wMidiBank, uint16 note, uint16 vol, CHANNELINDEX trackChannel); void HardAllNotesOff(); bool isPlaying(UINT note, UINT midiChn, UINT trackerChn); - bool MoveNote(UINT note, UINT midiChn, UINT sourceTrackerChn, UINT destTrackerChn); void NotifySongPlaying(bool playing); bool IsSongPlaying() const { return m_bSongPlaying; } bool IsResumed() {return m_bPlugResumed;} @@ -337,7 +336,7 @@ CString GetParamDisplay(PlugParamIndex) { return ""; }; PlugParamValue GetParameter(PlugParamIndex) { return 0; } - bool LoadProgram() { return false; } + bool LoadProgram(mpt::PathString = mpt::PathString()) { return false; } bool SaveProgram() { return false; } void SetCurrentProgram(VstInt32) {} void SetSlot(PLUGINDEX) {} Modified: trunk/OpenMPT/soundlib/plugins/PlugInterface.h =================================================================== --- trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2014-06-19 10:07:57 UTC (rev 4138) +++ trunk/OpenMPT/soundlib/plugins/PlugInterface.h 2014-06-19 12:53:01 UTC (rev 4139) @@ -53,7 +53,6 @@ virtual void HardAllNotesOff() = 0; //rewbs.VSTCompliance virtual void RecalculateGain() = 0; virtual bool isPlaying(UINT note, UINT midiChn, UINT trackerChn) = 0; //rewbs.VSTiNNA - virtual bool MoveNote(UINT note, UINT midiChn, UINT sourceTrackerChn, UINT destTrackerChn) = 0; //rewbs.VSTiNNA virtual void SetParameter(PlugParamIndex paramindex, PlugParamValue paramvalue) = 0; virtual void SetZxxParameter(UINT nParam, UINT nValue) = 0; virtual PlugParamValue GetParameter(PlugParamIndex nIndex) = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |