From: <sag...@us...> - 2013-12-14 16:01:07
|
Revision: 3470 http://sourceforge.net/p/modplug/code/3470 Author: saga-games Date: 2013-12-14 16:01:01 +0000 (Sat, 14 Dec 2013) Log Message: ----------- [New] VST Manager: Added option to scan a folder for plugins. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.h trunk/OpenMPT/mptrack/TuningDialog.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-12-14 16:00:14 UTC (rev 3469) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2013-12-14 16:01:01 UTC (rev 3470) @@ -1693,7 +1693,7 @@ .FilterIndex(&nLastIndex); if(!dlg.Show(this)) return; - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_INSTRUMENTS, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_INSTRUMENTS); const FileDialog::PathList &files = dlg.GetFilenames(); for(size_t counter = 0; counter < files.size(); counter++) Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-12-14 16:00:14 UTC (rev 3469) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2013-12-14 16:01:01 UTC (rev 3470) @@ -964,7 +964,7 @@ .FilterIndex(&nLastIndex); if(!dlg.Show(this)) return; - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_SAMPLES, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_SAMPLES); const FileDialog::PathList &files = dlg.GetFilenames(); for(size_t counter = 0; counter < files.size(); counter++) @@ -1084,7 +1084,7 @@ ErrorBox(IDS_ERR_SAVESMP, this); } else { - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_SAMPLES, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_SAMPLES); } SwitchToView(); } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-14 16:00:14 UTC (rev 3469) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-14 16:01:01 UTC (rev 3470) @@ -1107,7 +1107,7 @@ .FilterIndex(&nFilterIndex); if(!dlg.Show()) return; - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_MODS, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_MODS); const FileDialog::PathList &files = dlg.GetFilenames(); for(size_t counter = 0; counter < files.size(); counter++) Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-12-14 16:00:14 UTC (rev 3469) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2013-12-14 16:01:01 UTC (rev 3470) @@ -25,11 +25,12 @@ BEGIN_MESSAGE_MAP(CSelectPluginDlg, CDialog) - ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelChanged) - ON_NOTIFY(NM_DBLCLK, IDC_TREE1, OnSelDblClk) - ON_COMMAND(IDC_BUTTON1, OnAddPlugin) - ON_COMMAND(IDC_BUTTON2, OnRemovePlugin) - ON_EN_CHANGE(IDC_NAMEFILTER, OnNameFilterChanged) + ON_NOTIFY(TVN_SELCHANGED, IDC_TREE1, OnSelChanged) + ON_NOTIFY(NM_DBLCLK, IDC_TREE1, OnSelDblClk) + ON_COMMAND(IDC_BUTTON1, OnAddPlugin) + ON_COMMAND(IDC_BUTTON3, OnScanFolder) + ON_COMMAND(IDC_BUTTON2, OnRemovePlugin) + ON_EN_CHANGE(IDC_NAMEFILTER, OnNameFilterChanged) ON_WM_SIZE() ON_WM_GETMINMAXINFO() END_MESSAGE_MAP() @@ -471,11 +472,11 @@ for(size_t p = 0; p < CountOf(problemPlugs); p++) { - if(problemPlugs[p].id2 == plug->pluginId2 /*&& gProblemPlugs[p].id1 == plug->dwPluginId1*/) + if(problemPlugs[p].id2 == plug->pluginId2 && problemPlugs[p].id1 == plug->pluginId1) { CString s; s.Format("WARNING: This plugin has been identified as %s,\nwhich is known to have the following problem with OpenMPT:\n\n%s\n\nWould you still like to add this plugin to the library?", problemPlugs[p].name, problemPlugs[p].problem); - return (Reporting::Confirm(s) == cnfYes); + return (Reporting::Confirm(s, false, false, this) == cnfYes); } } @@ -493,29 +494,33 @@ .WorkingDirectory(TrackerDirectories::Instance().GetWorkingDirectory(DIR_PLUGINS)); if(!dlg.Show(this)) return; - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINS, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINS); CVstPluginManager *pManager = theApp.GetPluginManager(); - bool bOk = false; VSTPluginLib *plugLib = nullptr; + bool update = false; + const FileDialog::PathList &files = dlg.GetFilenames(); for(size_t counter = 0; counter < files.size(); counter++) { if (pManager) { - plugLib = pManager->AddPlugin(files[counter], false); - if (plugLib) + VSTPluginLib *lib = pManager->AddPlugin(files[counter], false); + if(lib != nullptr) { - bOk = true; - if(!VerifyPlug(plugLib)) + update = true; + if(!VerifyPlug(lib)) { - pManager->RemovePlugin(plugLib); + pManager->RemovePlugin(lib); + } else + { + plugLib = lib; } } } } - if (bOk) + if(update) { // Force selection to last added plug. UpdatePluginsList(plugLib ? plugLib->pluginId2 : 0); @@ -526,6 +531,76 @@ } +void CSelectPluginDlg::OnScanFolder() +//----------------------------------- +{ + BrowseForFolder dlg(TrackerDirectories::Instance().GetWorkingDirectory(DIR_PLUGINS), "Select a folder that should be scanned for VST plugins (including sub-folders)"); + if(!dlg.Show(this)) return; + + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetDirectory(), DIR_PLUGINS); + + CVstPluginManager *pManager = theApp.GetPluginManager(); + VSTPluginLib *plugLib = nullptr; + bool update = false; + + std::vector<mpt::PathString> paths(1, dlg.GetDirectory()); + int files = 0; + while(!paths.empty()) + { + HANDLE hFind; + WIN32_FIND_DATAW wfd; + MemsetZero(wfd); + + mpt::PathString path = paths.back(); + paths.pop_back(); + if(!path.HasTrailingSlash()) path += MPT_PATHSTRING("\\"); + if((hFind = FindFirstFileW((path + MPT_PATHSTRING("*.*")).AsNative().c_str(), &wfd)) != INVALID_HANDLE_VALUE) + { + do + { + mpt::PathString fileName = path + mpt::PathString::FromNative(wfd.cFileName); + if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + if(wcscmp(wfd.cFileName, L"..") + && wcscmp(wfd.cFileName, L".")) + { + paths.push_back(fileName); + } + continue; + } else if(!mpt::PathString::CompareNoCase(fileName.GetFileExt(), MPT_PATHSTRING(".dll"))) + { + CMainFrame::GetMainFrame()->SetHelpText(mpt::ToLocale(wfd.cFileName).c_str()); + VSTPluginLib *lib = pManager->AddPlugin(fileName, false); + if(lib) + { + update = true; + if(!VerifyPlug(lib)) + { + pManager->RemovePlugin(lib); + } else + { + plugLib = lib; + files++; + } + } + } + } while (FindNextFileW(hFind, &wfd)); + FindClose(hFind); + } + } + + if(update) + { + // Force selection to last added plug. + Reporting::Information(mpt::String::Print("Found %1 plugins.", files).c_str(), this); + UpdatePluginsList(plugLib ? plugLib->pluginId2 : 0); + } else + { + Reporting::Error("Could not find any valid VST plugins."); + } +} + + void CSelectPluginDlg::OnRemovePlugin() //------------------------------------- { @@ -552,14 +627,15 @@ { m_treePlugins.MoveWindow(8, 36, cx - 104, cy - 63, FALSE); - ::MoveWindow(GetDlgItem(IDC_STATIC_VSTNAMEFILTER)->m_hWnd, 8, 11, 40, 21, FALSE); - ::MoveWindow(GetDlgItem(IDC_NAMEFILTER)->m_hWnd, 40, 8, cx - 136, 21, FALSE); - - ::MoveWindow(GetDlgItem(IDC_TEXT_CURRENT_VSTPLUG)->m_hWnd, 8, cy - 20, cx - 22, 25, FALSE); - ::MoveWindow(GetDlgItem(IDOK)->m_hWnd, cx-85, 8, 75, 23, FALSE); - ::MoveWindow(GetDlgItem(IDCANCEL)->m_hWnd, cx-85, 39, 75, 23, FALSE); - ::MoveWindow(GetDlgItem(IDC_BUTTON1)->m_hWnd , cx-85, cy-80, 75, 23, FALSE); - ::MoveWindow(GetDlgItem(IDC_BUTTON2)->m_hWnd, cx-85, cy-52, 75, 23, FALSE); + GetDlgItem(IDC_STATIC_VSTNAMEFILTER)->MoveWindow(8, 11, 40, 21, FALSE); + GetDlgItem(IDC_NAMEFILTER)->MoveWindow(40, 8, cx - 136, 21, FALSE); + GetDlgItem(IDC_TEXT_CURRENT_VSTPLUG)->MoveWindow(8, cy - 20, cx - 22, 25, FALSE); + const int rightOff = cx - 85; // Offset of right button column + GetDlgItem(IDOK)->MoveWindow( rightOff, 8, 75, 23, FALSE); + GetDlgItem(IDCANCEL)->MoveWindow( rightOff, 39, 75, 23, FALSE); + GetDlgItem(IDC_BUTTON1)->MoveWindow(rightOff, cy - 108, 75, 23, FALSE); + GetDlgItem(IDC_BUTTON3)->MoveWindow(rightOff, cy - 80, 75, 23, FALSE); + GetDlgItem(IDC_BUTTON2)->MoveWindow(rightOff, cy - 52, 75, 23, FALSE); Invalidate(); } } Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.h =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.h 2013-12-14 16:00:14 UTC (rev 3469) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.h 2013-12-14 16:01:01 UTC (rev 3470) @@ -40,7 +40,9 @@ virtual void OnOK(); virtual void OnCancel(); virtual BOOL PreTranslateMessage(MSG *pMsg); + afx_msg void OnAddPlugin(); + afx_msg void OnScanFolder(); afx_msg void OnRemovePlugin(); afx_msg void OnNameFilterChanged(); afx_msg void OnSelChanged(NMHDR *pNotifyStruct, LRESULT *result); Modified: trunk/OpenMPT/mptrack/TuningDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-12-14 16:00:14 UTC (rev 3469) +++ trunk/OpenMPT/mptrack/TuningDialog.cpp 2013-12-14 16:01:01 UTC (rev 3470) @@ -680,7 +680,7 @@ if(!dlg.Show(this)) return; - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_TUNING, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_TUNING); std::wstring sLoadReport; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-12-14 16:00:14 UTC (rev 3469) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-12-14 16:01:01 UTC (rev 3470) @@ -988,7 +988,7 @@ if(useDefaultDir) { - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINPRESETS, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINPRESETS); } bool bank = (dlg.GetExtension() == MPT_PATHSTRING("fxb")); @@ -1027,7 +1027,7 @@ if(useDefaultDir) { - TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINPRESETS, true); + TrackerDirectories::Instance().SetWorkingDirectory(dlg.GetWorkingDirectory(), DIR_PLUGINPRESETS); } CMappedFile f; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2013-12-14 16:00:14 UTC (rev 3469) +++ trunk/OpenMPT/mptrack/mptrack.rc 2013-12-14 16:01:01 UTC (rev 3470) @@ -1464,10 +1464,11 @@ EDITTEXT IDC_NAMEFILTER,30,6,150,14,ES_AUTOHSCROLL CONTROL "Tree1",IDC_TREE1,"SysTreeView32",TVS_DISABLEDRAGDROP | TVS_SHOWSELALWAYS | WS_HSCROLL | WS_TABSTOP,6,24,174,180,WS_EX_CLIENTEDGE DEFPUSHBUTTON "Add to Song",IDOK,187,6,53,14 - PUSHBUTTON "&New plugin...",IDC_BUTTON1,188,23,52,14,BS_MULTILINE - PUSHBUTTON "&Remove",IDC_BUTTON2,188,40,52,14 - PUSHBUTTON "&Cancel",IDCANCEL,186,189,54,14 + PUSHBUTTON "&New plugin...",IDC_BUTTON1,186,150,52,14,BS_MULTILINE + PUSHBUTTON "&Remove",IDC_BUTTON2,186,186,52,14 + PUSHBUTTON "&Cancel",IDCANCEL,186,24,54,14 LTEXT "IDC_TEXT_CURRENT_VSTPLUG",IDC_TEXT_CURRENT_VSTPLUG,6,208,234,8 + PUSHBUTTON "&Scan folder...",IDC_BUTTON3,186,168,52,14,BS_MULTILINE END IDD_PLUGINEDITOR DIALOGEX 0, 0, 485, 153 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-12-18 18:28:31
|
Revision: 3493 http://sourceforge.net/p/modplug/code/3493 Author: manxorist Date: 2013-12-18 18:28:25 +0000 (Wed, 18 Dec 2013) Log Message: ----------- [Imp] Mod Export: Also show lossy codecs in pattern render to wave dialog. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Moddoc.h Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-12-18 18:21:25 UTC (rev 3492) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2013-12-18 18:28:25 UTC (rev 3493) @@ -1185,7 +1185,7 @@ //------------------------------ { OrdSelection selection = GetCurSel(false); - m_pModDoc.OnFileWaveConvert(selection.firstOrd, selection.lastOrd); + m_pModDoc.OnFileMP3Convert(selection.firstOrd, selection.lastOrd); } Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2013-12-18 18:21:25 UTC (rev 3492) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2013-12-18 18:28:25 UTC (rev 3493) @@ -1858,6 +1858,12 @@ void CModDoc::OnFileMP3Convert() //------------------------------ { + OnFileMP3Convert(ORDERINDEX_INVALID, ORDERINDEX_INVALID, true); +} + +void CModDoc::OnFileMP3Convert(ORDERINDEX nMinOrder, ORDERINDEX nMaxOrder, bool showWarning) +//------------------------------------------------------------------------------------------ +{ WAVEncoder wavencoder; FLACEncoder flacencoder; OggOpusEncoder opusencoder; @@ -1873,7 +1879,7 @@ if(mp3lame.IsAvailable()) encoders.push_back(&mp3lame); if(mp3blade.IsAvailable()) encoders.push_back(&mp3blade); if(mp3acm.IsAvailable()) encoders.push_back(&mp3acm); - if(encoders.size() == 2) + if(showWarning && encoders.size() == 2) { Reporting::Warning( "No Opus/Vorbis/MP3 codec found.\n" @@ -1885,7 +1891,7 @@ "Alternatively, you can install a MP3 ACM codec.", "OpenMPT - Export"); } - OnFileWaveConvert(ORDERINDEX_INVALID, ORDERINDEX_INVALID, encoders); + OnFileWaveConvert(nMinOrder, nMaxOrder, encoders); } Modified: trunk/OpenMPT/mptrack/Moddoc.h =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.h 2013-12-18 18:21:25 UTC (rev 3492) +++ trunk/OpenMPT/mptrack/Moddoc.h 2013-12-18 18:28:25 UTC (rev 3493) @@ -358,6 +358,7 @@ CSize GetOldPatternScrollbarsPos() const { return m_szOldPatternScrollbarsPos; }; void SetOldPatternScrollbarsPos( CSize s ){ m_szOldPatternScrollbarsPos = s; }; + void OnFileMP3Convert(ORDERINDEX nMinOrder, ORDERINDEX nMaxOrder, bool showWarning = false); void OnFileWaveConvert(ORDERINDEX nMinOrder, ORDERINDEX nMaxOrder); void OnFileWaveConvert(ORDERINDEX nMinOrder, ORDERINDEX nMaxOrder, const std::vector<EncoderFactoryBase*> &encFactories); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2013-12-19 14:13:15
|
Revision: 3502 http://sourceforge.net/p/modplug/code/3502 Author: manxorist Date: 2013-12-19 14:13:04 +0000 (Thu, 19 Dec 2013) Log Message: ----------- [Fix] Build fix. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/ModConvert.cpp Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-19 14:12:26 UTC (rev 3501) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-19 14:13:04 UTC (rev 3502) @@ -2165,7 +2165,7 @@ if (bTemplateFile) { - pModDoc->GetFileHistory().clear(); // Reset edit history for template files + pModDoc->GetSoundFile()->GetFileHistory().clear(); // Reset edit history for template files pModDoc->GetSoundFile()->m_dwCreatedWithVersion = MptVersion::num; pModDoc->GetSoundFile()->m_dwLastSavedWithVersion = 0; } Modified: trunk/OpenMPT/mptrack/ModConvert.cpp =================================================================== --- trunk/OpenMPT/mptrack/ModConvert.cpp 2013-12-19 14:12:26 UTC (rev 3501) +++ trunk/OpenMPT/mptrack/ModConvert.cpp 2013-12-19 14:13:04 UTC (rev 3502) @@ -470,7 +470,7 @@ } // Check whether the new format supports embedding the edit history in the file. - if(oldTypeIsIT_MPT && !newTypeIsIT_MPT && GetFileHistory().size() > 0) + if(oldTypeIsIT_MPT && !newTypeIsIT_MPT && GetrSoundFile().GetFileHistory().size() > 0) { CHANGEMODTYPE_WARNING(wEditHistory); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-12-23 23:37:06
|
Revision: 3522 http://sourceforge.net/p/modplug/code/3522 Author: saga-games Date: 2013-12-23 23:36:57 +0000 (Mon, 23 Dec 2013) Log Message: ----------- [Fix] MRU implementation was incomplete Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-23 22:56:18 UTC (rev 3521) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-23 23:36:57 UTC (rev 3522) @@ -1725,7 +1725,7 @@ } } -//rewbs.xinfo + VOID CMainFrame::SetXInfoText(LPCSTR lpszText) //------------------------------------------- { @@ -1735,8 +1735,8 @@ OnUpdateInfo(NULL); } } -//end rewbs.xinfo + VOID CMainFrame::SetHelpText(LPCSTR lpszText) //------------------------------------------- { @@ -1747,8 +1747,8 @@ VOID CMainFrame::OnDocumentCreated(CModDoc *pModDoc) //-------------------------------------------------- { + m_wndTree.OnDocumentCreated(pModDoc); UpdateMRUList(); - m_wndTree.OnDocumentCreated(pModDoc); } Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-23 22:56:18 UTC (rev 3521) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-23 23:36:57 UTC (rev 3522) @@ -468,6 +468,7 @@ /// Opens either template or example menu item. void OpenMenuItemFile(const UINT nId, const bool bTemplateFile); +public: void UpdateMRUList(); // Implementation Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-23 22:56:18 UTC (rev 3521) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-23 23:36:57 UTC (rev 3522) @@ -70,14 +70,7 @@ // First, remove document from MRU list. if(addToMru) { - for(std::vector<mpt::PathString>::iterator i = TrackerSettings::Instance().mruFiles.begin(); i != TrackerSettings::Instance().mruFiles.end(); i++) - { - if(!mpt::PathString::CompareNoCase(*i, filename)) - { - TrackerSettings::Instance().mruFiles.erase(i); - break; - } - } + theApp.RemoveMruItem(filename); } #if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) @@ -87,14 +80,6 @@ #endif if(pDoc) { - if(addToMru) - { - TrackerSettings::Instance().mruFiles.insert(TrackerSettings::Instance().mruFiles.begin(), filename); - if(TrackerSettings::Instance().mruFiles.size() > TrackerSettings::Instance().mruListLength) - { - TrackerSettings::Instance().mruFiles.resize(TrackerSettings::Instance().mruListLength); - } - } CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if (pMainFrm) pMainFrm->OnDocumentCreated(static_cast<CModDoc *>(pDoc)); } else //Case: pDoc == 0, opening document failed. @@ -617,21 +602,22 @@ void CTrackApp::AddToRecentFileList(LPCTSTR lpszPathName) //------------------------------------------------------- { - mpt::PathString filename = mpt::PathString::TunnelOutofCString(lpszPathName); - #ifdef UNICODE - CWinApp::AddToRecentFileList(filename.AsNative().c_str()); - #else - if(filename.AsNative() != (mpt::PathString::FromCStringSilent(filename.ToCStringSilent())).AsNative()) - { - // MFC ANSI builds fire strict assertions if the file path is invalid. - // Only proceed for string representable in CP_ACP. - return; - } - CWinApp::AddToRecentFileList(filename.ToCStringSilent()); - #endif + AddToRecentFileList(mpt::PathString::TunnelOutofCString(lpszPathName)); } +void CTrackApp::AddToRecentFileList(const mpt::PathString &path) +//-------------------------------------------------------------- +{ + TrackerSettings::Instance().mruFiles.insert(TrackerSettings::Instance().mruFiles.begin(), path); + if(TrackerSettings::Instance().mruFiles.size() > TrackerSettings::Instance().mruListLength) + { + TrackerSettings::Instance().mruFiles.resize(TrackerSettings::Instance().mruListLength); + } + CMainFrame::GetMainFrame()->UpdateMRUList(); +} + + ///////////////////////////////////////////////////////////////////////////// // CTrackApp initialization @@ -2043,9 +2029,26 @@ } -void CTrackApp::RemoveMruItem(const int nItem) -//-------------------------------------------- +void CTrackApp::RemoveMruItem(const size_t item) +//---------------------------------------------- { - if (m_pRecentFileList && nItem >= 0 && nItem < m_pRecentFileList->GetSize()) - m_pRecentFileList->Remove(nItem); + if(item < TrackerSettings::Instance().mruFiles.size()) + { + TrackerSettings::Instance().mruFiles.erase(TrackerSettings::Instance().mruFiles.begin() + item); + CMainFrame::GetMainFrame()->UpdateMRUList(); + } } + + +void CTrackApp::RemoveMruItem(const mpt::PathString &path) +//-------------------------------------------------------- +{ + for(std::vector<mpt::PathString>::iterator i = TrackerSettings::Instance().mruFiles.begin(); i != TrackerSettings::Instance().mruFiles.end(); i++) + { + if(!mpt::PathString::CompareNoCase(*i, path)) + { + TrackerSettings::Instance().mruFiles.erase(i); + break; + } + } +} Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-12-23 22:56:18 UTC (rev 3521) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-12-23 23:36:57 UTC (rev 3522) @@ -178,6 +178,10 @@ #endif MPT_DEPRECATED_PATH virtual void AddToRecentFileList(LPCTSTR lpszPathName); + void AddToRecentFileList(const mpt::PathString &path); + /// Removes item from MRU-list; most recent item has index zero. + void RemoveMruItem(const size_t item); + void RemoveMruItem(const mpt::PathString &path); protected: @@ -273,9 +277,6 @@ mpt::PathString AbsolutePathToRelative(const mpt::PathString &path) { return path.AbsolutePathToRelative(GetAppDirPath()); } mpt::PathString RelativePathToAbsolute(const mpt::PathString &path) { return path.RelativePathToAbsolute(GetAppDirPath()); } - /// Removes item from MRU-list; most recent item has index zero. - void RemoveMruItem(const int nItem); - // Splash Screen protected: void StartSplashScreen(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-12-25 21:10:24
|
Revision: 3528 http://sourceforge.net/p/modplug/code/3528 Author: saga-games Date: 2013-12-25 21:10:15 +0000 (Wed, 25 Dec 2013) Log Message: ----------- [Fix] More MRU list fixing. [Fix] VST: When providing a file dialog for VST GUIs, set the VST GUI as a parent for the dialog. Modified Paths: -------------- trunk/OpenMPT/mptrack/FileDialog.cpp trunk/OpenMPT/mptrack/FileDialog.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h Modified: trunk/OpenMPT/mptrack/FileDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.cpp 2013-12-24 15:40:11 UTC (rev 3527) +++ trunk/OpenMPT/mptrack/FileDialog.cpp 2013-12-25 21:10:15 UTC (rev 3528) @@ -16,8 +16,8 @@ // Display the file dialog. -bool FileDialog::Show(CWnd *parent) -//--------------------------------- +bool FileDialog::Show(const CWnd *parent) +//--------------------------------------- { filenames.clear(); @@ -122,8 +122,8 @@ // Display the folder dialog. -bool BrowseForFolder::Show(CWnd *parent) -//-------------------------------------- +bool BrowseForFolder::Show(const CWnd *parent) +//-------------------------------------------- { WCHAR path[MAX_PATH]; Modified: trunk/OpenMPT/mptrack/FileDialog.h =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.h 2013-12-24 15:40:11 UTC (rev 3527) +++ trunk/OpenMPT/mptrack/FileDialog.h 2013-12-25 21:10:15 UTC (rev 3528) @@ -52,7 +52,7 @@ FileDialog &FilterIndex(int *index) { filterIndex = index; return *this; } // Show the file selection dialog. - bool Show(CWnd *parent = nullptr); + bool Show(const CWnd *parent = nullptr); // Get some selected file. Mostly useful when only one selected file is possible anyway. mpt::PathString GetFirstFile() const @@ -106,7 +106,7 @@ BrowseForFolder(const mpt::PathString &dir, const CString &caption) : workingDirectory(dir), caption(mpt::ToWide(caption)) { } // Show the folder selection dialog. - bool Show(CWnd *parent = nullptr); + bool Show(const CWnd *parent = nullptr); // Gets selected directory. mpt::PathString GetDirectory() const { return workingDirectory; } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-24 15:40:11 UTC (rev 3527) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-25 21:10:15 UTC (rev 3528) @@ -609,6 +609,7 @@ void CTrackApp::AddToRecentFileList(const mpt::PathString &path) //-------------------------------------------------------------- { + RemoveMruItem(path); TrackerSettings::Instance().mruFiles.insert(TrackerSettings::Instance().mruFiles.begin(), path); if(TrackerSettings::Instance().mruFiles.size() > TrackerSettings::Instance().mruListLength) { @@ -618,6 +619,31 @@ } +void CTrackApp::RemoveMruItem(const size_t item) +//---------------------------------------------- +{ + if(item < TrackerSettings::Instance().mruFiles.size()) + { + TrackerSettings::Instance().mruFiles.erase(TrackerSettings::Instance().mruFiles.begin() + item); + CMainFrame::GetMainFrame()->UpdateMRUList(); + } +} + + +void CTrackApp::RemoveMruItem(const mpt::PathString &path) +//-------------------------------------------------------- +{ + for(std::vector<mpt::PathString>::iterator i = TrackerSettings::Instance().mruFiles.begin(); i != TrackerSettings::Instance().mruFiles.end(); i++) + { + if(!mpt::PathString::CompareNoCase(*i, path)) + { + TrackerSettings::Instance().mruFiles.erase(i); + break; + } + } +} + + ///////////////////////////////////////////////////////////////////////////// // CTrackApp initialization @@ -2027,28 +2053,3 @@ } return false; } - - -void CTrackApp::RemoveMruItem(const size_t item) -//---------------------------------------------- -{ - if(item < TrackerSettings::Instance().mruFiles.size()) - { - TrackerSettings::Instance().mruFiles.erase(TrackerSettings::Instance().mruFiles.begin() + item); - CMainFrame::GetMainFrame()->UpdateMRUList(); - } -} - - -void CTrackApp::RemoveMruItem(const mpt::PathString &path) -//-------------------------------------------------------- -{ - for(std::vector<mpt::PathString>::iterator i = TrackerSettings::Instance().mruFiles.begin(); i != TrackerSettings::Instance().mruFiles.end(); i++) - { - if(!mpt::PathString::CompareNoCase(*i, path)) - { - TrackerSettings::Instance().mruFiles.erase(i); - break; - } - } -} Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-12-24 15:40:11 UTC (rev 3527) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-12-25 21:10:15 UTC (rev 3528) @@ -422,7 +422,10 @@ // close a fileselector operation with VstFileSelect* in <ptr>: Must be always called after an open ! case audioMasterCloseFileSelector: - return VstFileSelector(opcode == audioMasterCloseFileSelector, static_cast<VstFileSelect *>(ptr), effect); + if(pVstPlugin != nullptr) + { + return VstFileSelector(opcode == audioMasterCloseFileSelector, static_cast<VstFileSelect *>(ptr), pVstPlugin); + } // open an editor for audio (defined by XML text in ptr) - DEPRECATED in VST 2.4 case audioMasterEditFile: @@ -458,8 +461,8 @@ // Helper function for file selection dialog stuff. -VstIntPtr CVstPluginManager::VstFileSelector(bool destructor, VstFileSelect *fileSel, const AEffect *effect) -//---------------------------------------------------------------------------------------------------------- +VstIntPtr CVstPluginManager::VstFileSelector(bool destructor, VstFileSelect *fileSel, const CVstPlugin *plugin) +//------------------------------------------------------------------------------------------------------------- { if(fileSel == nullptr) { @@ -515,7 +518,7 @@ } dlg.ExtensionFilter(extensions) .WorkingDirectory(mpt::PathString::FromLocale(workingDir)); - if(!dlg.Show()) + if(!dlg.Show(plugin->GetEditor())) { return 0; } @@ -538,7 +541,7 @@ // Single path // VOPM doesn't initialize required information properly (it doesn't memset the struct to 0)... - if(CCONST('V', 'O', 'P', 'M') == effect->uniqueID) + if(CCONST('V', 'O', 'P', 'M') == plugin->GetUID()) { fileSel->sizeReturnPath = _MAX_PATH; } @@ -569,10 +572,10 @@ { // Plugin wants a directory BrowseForFolder dlg(mpt::PathString::FromLocale(fileSel->initialPath != nullptr ? fileSel->initialPath : ""), fileSel->title != nullptr ? fileSel->title : ""); - if(dlg.Show()) + if(dlg.Show(plugin->GetEditor())) { const std::string dir = dlg.GetDirectory().ToLocale(); - if(CCONST('V', 'S', 'T', 'r') == effect->uniqueID && fileSel->returnPath != nullptr && fileSel->sizeReturnPath == 0) + if(CCONST('V', 'S', 'T', 'r') == plugin->GetUID() && fileSel->returnPath != nullptr && fileSel->sizeReturnPath == 0) { // old versions of reViSiT (which still relied on the host's file selection code) seem to be dodgy. // They report a path size of 0, but when using an own buffer, they will crash. @@ -2180,13 +2183,6 @@ } -CAbstractVstEditor* CVstPlugin::GetEditor() -//----------------------------------------- -{ - return m_pEditor; -} - - void CVstPlugin::Bypass(bool bypass) //---------------------------------- { Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2013-12-24 15:40:11 UTC (rev 3527) +++ trunk/OpenMPT/mptrack/Vstplug.h 2013-12-25 21:10:15 UTC (rev 3528) @@ -207,7 +207,8 @@ void ToggleEditor(); void GetPluginType(LPSTR pszType); BOOL GetDefaultEffectName(LPSTR pszName); - CAbstractVstEditor* GetEditor(); //rewbs.defaultPlugGUI + CAbstractVstEditor *GetEditor() { return m_pEditor; } + const CAbstractVstEditor *GetEditor() const { return m_pEditor; } void Bypass(bool bypass = true); bool IsBypassed() const { return m_pMixStruct->IsBypassed(); }; @@ -345,7 +346,7 @@ protected: VstIntPtr VstCallback(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt); - VstIntPtr VstFileSelector(bool destructor, VstFileSelect *fileSel, const AEffect *effect); + VstIntPtr VstFileSelector(bool destructor, VstFileSelect *fileSel, const CVstPlugin *plugin); static VstIntPtr VSTCALLBACK MasterCallBack(AEffect *effect, VstInt32 opcode, VstInt32 index, VstIntPtr value, void *ptr, float opt); static bool CreateMixPluginProc(SNDMIXPLUGIN &, CSoundFile &); VstTimeInfo timeInfo; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2013-12-26 18:32:15
|
Revision: 3529 http://sourceforge.net/p/modplug/code/3529 Author: saga-games Date: 2013-12-26 18:32:07 +0000 (Thu, 26 Dec 2013) Log Message: ----------- [Fix] Now the MRU list should be finally working... I think. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/Mptrack.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-25 21:10:15 UTC (rev 3528) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2013-12-26 18:32:07 UTC (rev 3529) @@ -2621,19 +2621,32 @@ } +// Hack-ish way to get the file menu (this is necessary because the MDI document icon next to the File menu is a sub menu, too). +CMenu *CMainFrame::GetFileMenu() const +//------------------------------------ +{ + CMenu *mainMenu = GetMenu(); + CMenu *fileMenu = mainMenu ? mainMenu->GetSubMenu(0) : nullptr; + if(fileMenu) + { + if(fileMenu->GetMenuItemID(1) != ID_FILE_OPEN) + fileMenu = mainMenu->GetSubMenu(1); + ASSERT(fileMenu->GetMenuItemID(1) == ID_FILE_OPEN); + } + ASSERT(fileMenu); + return fileMenu; +} + + void CMainFrame::CreateTemplateModulesMenu() //------------------------------------------ { static_assert(nMaxItemsInTemplateModulesMenu == ID_FILE_OPENTEMPLATE_LASTINRANGE - ID_FILE_OPENTEMPLATE + 1, "Make sure that there's a proper range for menu commands in resources."); HMENU hMenu = CreateFileMenu(nMaxItemsInTemplateModulesMenu, s_TemplateModulePaths, MPT_PATHSTRING("TemplateModules\\"), ID_FILE_OPENTEMPLATE); - CMenu* const pMainMenu = GetMenu(); - CMenu* pFileMenu = (pMainMenu) ? pMainMenu->GetSubMenu(0) : nullptr; + CMenu *pFileMenu = GetFileMenu(); if (hMenu && pFileMenu && m_InputHandler) { - if (pFileMenu->GetMenuItemID(1) != ID_FILE_OPEN) - pFileMenu = pMainMenu->GetSubMenu(1); - ASSERT(pFileMenu->GetMenuItemID(1) == ID_FILE_OPEN); VERIFY(pFileMenu->RemoveMenu(2, MF_BYPOSITION)); VERIFY(pFileMenu->InsertMenu(2, MF_BYPOSITION | MF_POPUP, (UINT_PTR)hMenu, m_InputHandler->GetMenuText(ID_FILE_OPENTEMPLATE))); } @@ -2645,7 +2658,7 @@ void CMainFrame::UpdateMRUList() //------------------------------ { - CMenu *pMenu = (CMainFrame::GetMainFrame())->GetMenu()->GetSubMenu(0); + CMenu *pMenu = GetFileMenu(); static int firstMenu = -1; if(firstMenu == -1) { @@ -2697,10 +2710,10 @@ s += path; } else { - // Shorten path - size_t start = path.find_first_of(L"\\/"); + // Shorten path ("C:\Foo\VeryLongString...\Bar.it" => "C:\Foo\...\Bar.it") + size_t start = path.find_first_of(L"\\/", path.find_first_of(L"\\/") + 1); size_t end = path.find_last_of(L"\\/"); - if(start != end) + if(start < end) { s += path.substr(0, start + 1) + L"..." + path.substr(end); } else Modified: trunk/OpenMPT/mptrack/Mainfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-25 21:10:15 UTC (rev 3528) +++ trunk/OpenMPT/mptrack/Mainfrm.h 2013-12-26 18:32:07 UTC (rev 3529) @@ -396,6 +396,7 @@ void CreateExampleModulesMenu(); void CreateTemplateModulesMenu(); + CMenu *GetFileMenu() const; /// Creates submenu whose items are filenames of files in both /// AppDirectory\pszFolderName\ (usually C:\program files\OpenMPT\pszFolderName\) Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-25 21:10:15 UTC (rev 3528) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2013-12-26 18:32:07 UTC (rev 3529) @@ -86,6 +86,10 @@ { if(!filename.empty()) { + if(CMainFrame::GetMainFrame() && addToMru) + { + CMainFrame::GetMainFrame()->UpdateMRUList(); + } if(PathFileExistsW(filename.AsNative().c_str()) == FALSE) { Reporting::Error(L"Unable to open \"" + filename.ToWide() + L"\": file does not exist."); @@ -606,8 +610,8 @@ } -void CTrackApp::AddToRecentFileList(const mpt::PathString &path) -//-------------------------------------------------------------- +void CTrackApp::AddToRecentFileList(const mpt::PathString path) +//------------------------------------------------------------- { RemoveMruItem(path); TrackerSettings::Instance().mruFiles.insert(TrackerSettings::Instance().mruFiles.begin(), path); Modified: trunk/OpenMPT/mptrack/Mptrack.h =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.h 2013-12-25 21:10:15 UTC (rev 3528) +++ trunk/OpenMPT/mptrack/Mptrack.h 2013-12-26 18:32:07 UTC (rev 3529) @@ -178,7 +178,7 @@ #endif MPT_DEPRECATED_PATH virtual void AddToRecentFileList(LPCTSTR lpszPathName); - void AddToRecentFileList(const mpt::PathString &path); + void AddToRecentFileList(const mpt::PathString path); /// Removes item from MRU-list; most recent item has index zero. void RemoveMruItem(const size_t item); void RemoveMruItem(const mpt::PathString &path); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-01-01 19:01:49
|
Revision: 3539 http://sourceforge.net/p/modplug/code/3539 Author: saga-games Date: 2014-01-01 19:01:43 +0000 (Wed, 01 Jan 2014) Log Message: ----------- [Fix] VST: Plugin names in error messages are now displayed correctly [Fix] VST: Don't validate plugin version in preset files (old OpenMPT wrote other values there, so old presets are no longer readable for some plugins) [Fix] Pattern Editor: Copy Pattern didn't copy the last channel properly. [Mod] OpenMPT: Version is now 1.22.07.11 Modified Paths: -------------- trunk/OpenMPT/mptrack/ExceptionHandler.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/VstPresets.cpp trunk/OpenMPT/mptrack/VstPresets.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/Vstplug.h Modified: trunk/OpenMPT/mptrack/ExceptionHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2014-01-01 03:20:51 UTC (rev 3538) +++ trunk/OpenMPT/mptrack/ExceptionHandler.cpp 2014-01-01 19:01:43 UTC (rev 3539) @@ -151,7 +151,7 @@ } -// Try to close the audio device and rescue unsaved work if an unhandled exception occurrs... +// Try to close the audio device and rescue unsaved work if an unhandled exception occurs... LONG ExceptionHandler::UnhandledExceptionFilter(_EXCEPTION_POINTERS *pExceptionInfo) //---------------------------------------------------------------------------------- { @@ -168,7 +168,7 @@ if(pMainFrame->m_NotifyTimer) { pMainFrame->KillTimer(pMainFrame->m_NotifyTimer); - pMainFrame->m_NotifyTimer = 0; + pMainFrame->m_NotifyTimer = 0; } } catch(...) { Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2014-01-01 03:20:51 UTC (rev 3538) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2014-01-01 19:01:43 UTC (rev 3539) @@ -4079,7 +4079,7 @@ const CSoundFile *pSndFile = GetSoundFile(); if(pSndFile != nullptr) { - CopyPattern(m_nPattern, PatternRect(PatternCursor(0, 0), PatternCursor(pSndFile->Patterns[m_nPattern].GetNumRows() - 1, pSndFile->GetNumChannels() - 1))); + CopyPattern(m_nPattern, PatternRect(PatternCursor(0, 0), PatternCursor(pSndFile->Patterns[m_nPattern].GetNumRows() - 1, pSndFile->GetNumChannels() - 1, PatternCursor::lastColumn))); } } break; Modified: trunk/OpenMPT/mptrack/VstPresets.cpp =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.cpp 2014-01-01 03:20:51 UTC (rev 3538) +++ trunk/OpenMPT/mptrack/VstPresets.cpp 2014-01-01 19:01:43 UTC (rev 3539) @@ -55,10 +55,6 @@ { return wrongPlugin; } - if(header.fxVersion > plugin.GetVersion()) - { - return outdatedPlugin; - } if(header.fxMagic == fMagic || header.fxMagic == chunkPresetMagic) { @@ -259,8 +255,6 @@ return "This does not appear to be a valid preset file."; case VSTPresets::wrongPlugin: return "This file appears to be for a different plugin."; - case VSTPresets::outdatedPlugin: - return "This file is for a newer version of this plugin."; case VSTPresets::wrongParameters: return "The number of parameters in this file is incompatible with the current plugin."; } Modified: trunk/OpenMPT/mptrack/VstPresets.h =================================================================== --- trunk/OpenMPT/mptrack/VstPresets.h 2014-01-01 03:20:51 UTC (rev 3538) +++ trunk/OpenMPT/mptrack/VstPresets.h 2014-01-01 19:01:43 UTC (rev 3539) @@ -20,7 +20,6 @@ noError, invalidFile, wrongPlugin, - outdatedPlugin, wrongParameters, }; Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2014-01-01 03:20:51 UTC (rev 3538) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2014-01-01 19:01:43 UTC (rev 3539) @@ -863,7 +863,7 @@ delete this; } catch (...) { - CVstPluginManager::ReportPlugException("Exception while destroying plugin!\n"); + ReportPlugException(L"Exception while destroying plugin!"); } return 0; @@ -1077,7 +1077,7 @@ } } catch (...) { - CVstPluginManager::ReportPlugException("Exception in Dispatch(%d) (Plugin=\"%s\")!\n", opCode, m_Factory.libraryName); + CVstPluginManager::ReportPlugException(mpt::String::PrintW(L"Exception in Dispatch(%1)!", opCode)); } return result; @@ -1196,7 +1196,7 @@ } } catch (...) { - CVstPluginManager::ReportPlugException("Exception in SetParameter(%d, 0.%03d) (Plugin=%s)\n", nIndex, (int)(fValue*1000), m_Factory.libraryName); + ReportPlugException(mpt::String::PrintW(L"Exception in SetParameter(%1, %2)!", nIndex, fValue)); } } @@ -1300,7 +1300,7 @@ m_bPlugResumed = true; } catch (...) { - CVstPluginManager::ReportPlugException("Exception in Resume() (Plugin=%s)\n", m_Factory.libraryName); + ReportPlugException(L"Exception in Resume()!"); } } @@ -1317,7 +1317,7 @@ m_bPlugResumed = false; } catch (...) { - CVstPluginManager::ReportPlugException("Exception in Suspend() (Plugin=%s)\n", m_Factory.libraryName); + ReportPlugException(L"Exception in Suspend()!"); } } } @@ -1335,8 +1335,8 @@ m_Effect.dispatcher(&m_Effect, effProcessEvents, 0, 0, &vstEvents, 0); } catch (...) { - CVstPluginManager::ReportPlugException("Exception in ProcessVSTEvents() (Plugin=%s, numEvents:%d)\n", - m_Factory.libraryName, vstEvents.GetNumEvents()); + ReportPlugException(mpt::String::PrintW(L"Exception in ProcessVSTEvents(numEvents:%1)!", + vstEvents.GetNumEvents())); } } } @@ -1480,8 +1480,8 @@ } catch (...) { Bypass(); - CString processMethod = (m_Effect.flags & effFlagsCanReplacing) ? "processReplacing" : "process"; - CVstPluginManager::ReportPlugException("The plugin %s threw an exception in %s. It has automatically been set to \"Bypass\".", m_pMixStruct->GetName(), processMethod); + const wchar_t *processMethod = (m_Effect.flags & effFlagsCanReplacing) ? L"processReplacing" : L"process"; + ReportPlugException(mpt::String::PrintW(L"The plugin threw an exception in %1. It has automatically been set to \"Bypass\".", processMethod)); } ASSERT(outputBuffers != nullptr); @@ -2178,7 +2178,7 @@ } } catch (...) { - CVstPluginManager::ReportPlugException("Exception in ToggleEditor() (Plugin=%s)\n", m_Factory.libraryName); + ReportPlugException(L"Exception in ToggleEditor()"); } } @@ -2341,6 +2341,15 @@ } + +void CVstPlugin::ReportPlugException(std::wstring text) const +//----------------------------------------------------------- +{ + text += L" (Plugin=" + m_Factory.libraryName.ToWide() + L")"; + CVstPluginManager::ReportPlugException(text); +} + + #endif // NO_VST Modified: trunk/OpenMPT/mptrack/Vstplug.h =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.h 2014-01-01 03:20:51 UTC (rev 3538) +++ trunk/OpenMPT/mptrack/Vstplug.h 2014-01-01 19:01:43 UTC (rev 3539) @@ -252,7 +252,7 @@ void SetZxxParameter(UINT nParam, UINT nValue); UINT GetZxxParameter(UINT nParam); //rewbs.smoothVST -private: +protected: void MidiPitchBend(uint8 nMidiCh, int32 pitchBendPos); // Converts a 14-bit MIDI pitch bend position to a 16.11 fixed point pitch bend position static int32 EncodePitchBendParam(int32 position) { return (position << vstPitchBendShift); } @@ -275,6 +275,8 @@ void ProcessMixOps(float *pOutL, float *pOutR, size_t nSamples); + void ReportPlugException(std::wstring text) const; + #else // case: NO_VST public: PlugParamIndex GetNumParameters() { return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-01-05 17:11:58
|
Revision: 3563 http://sourceforge.net/p/modplug/code/3563 Author: saga-games Date: 2014-01-05 17:11:53 +0000 (Sun, 05 Jan 2014) Log Message: ----------- [Fix] Plugin selection dialog: Forced plugin highlighting (e.g. after adding new plugin) was broken. [Fix] Sample editor: With sample lengths > 1 second, fractional second part was not displayed correctly. Modified Paths: -------------- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/View_smp.cpp Modified: trunk/OpenMPT/mptrack/SelectPluginDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2014-01-05 17:10:19 UTC (rev 3562) +++ trunk/OpenMPT/mptrack/SelectPluginDialog.cpp 2014-01-05 17:11:53 UTC (rev 3563) @@ -350,16 +350,18 @@ } } + if(forceSelect != 0 && plug.pluginId2 == forceSelect) + { + // Forced selection (e.g. just after add plugin) + currentPlug = h; + foundCurrentPlug = true; + } + if(m_pPlugin && !foundCurrentPlug) { //Which plugin should be selected? - - if(forceSelect != 0 && plug.pluginId2 == forceSelect) + if(m_pPlugin->pMixPlugin) { - //forced selection (e.g. just after add plugin) - currentPlug = h; - } else if(m_pPlugin->pMixPlugin) - { //Current slot's plugin CVstPlugin *pVstPlug = (CVstPlugin *)m_pPlugin->pMixPlugin; if (&pVstPlug->GetPluginFactory() == &plug) Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2014-01-05 17:10:19 UTC (rev 3562) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-01-05 17:11:53 UTC (rev 3563) @@ -326,12 +326,12 @@ CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); if(pMainFrm) { - CHAR s[64]; - s[0] = 0; + std::string s; if(m_dwEndSel > m_dwBeginSel) { const SmpLength selLength = m_dwEndSel - m_dwBeginSel; - wsprintf(s, "[%u,%u] (%u sample%s, ", m_dwBeginSel, m_dwEndSel, selLength, (selLength == 1) ? "" : "s"); + s = mpt::String::Print("[%1,%2] (%3 sample%4, ", m_dwBeginSel, m_dwEndSel, selLength, (selLength == 1) ? "" : "s"); + uint32 lSampleRate = pSndFile->GetSample(m_nSample).nC5Speed; if(pSndFile->GetType() & (MOD_TYPE_MOD|MOD_TYPE_XM)) { @@ -340,11 +340,11 @@ if (!lSampleRate) lSampleRate = 8363; uint64 msec = (uint64(selLength) * 1000) / lSampleRate; if(msec < 1000) - wsprintf(s + strlen(s), "%lums)", msec); + s += mpt::String::Print("%1ms)", msec); else - wsprintf(s + strlen(s), "%lu.%lus)", msec / 1000, (msec / 100) % 10); + s += mpt::String::Print("%1.%2s)", msec / 1000, mpt::fmt::dec0<2>((msec / 10) % 100)); } - pMainFrm->SetInfoText(s); + pMainFrm->SetInfoText(s.c_str()); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-01-15 15:40:09
|
Revision: 3574 http://sourceforge.net/p/modplug/code/3574 Author: saga-games Date: 2014-01-15 15:39:59 +0000 (Wed, 15 Jan 2014) Log Message: ----------- [Imp/Ref] Replace (mostly empty, yet 5 MB large) key combination array by a hash map. Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/InputHandler.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2014-01-14 15:27:27 UTC (rev 3573) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2014-01-15 15:39:59 UTC (rev 3574) @@ -1401,7 +1401,7 @@ CArray<InputTargetContext, InputTargetContext> contexts; //Clear map - memset(km, kcNull, sizeof(KeyMap)); + km.clear(); //Copy commandlist content into map: for(UINT cmd=0; cmd<kcNumCommands; cmd++) @@ -1432,22 +1432,19 @@ contexts.Add(kCtxViewPatternsVol); contexts.Add(kCtxViewPatternsFX); contexts.Add(kCtxViewPatternsFXparam); - } - else if(curKc.ctx == kCtxCtrlPatterns) + } else if(curKc.ctx == kCtxCtrlPatterns) { contexts.Add(kCtxCtrlOrderlist); - } - else + } else { contexts.Add(curKc.ctx); } - //long label = 0; for (int cx=0; cx<contexts.GetSize(); cx++) { for (int ke=0; ke<eventTypes.GetSize(); ke++) { - km[contexts[cx]][curKc.mod][curKc.code][eventTypes[ke]] = (CommandID)cmd; + km[KeyMapID(contexts[cx], curKc.mod, curKc.code, eventTypes[ke])] = (CommandID)cmd; } } } Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2014-01-14 15:27:27 UTC (rev 3573) +++ trunk/OpenMPT/mptrack/CommandSet.h 2014-01-15 15:39:59 UTC (rev 3574) @@ -1132,14 +1132,50 @@ RAlt = 1<<5, MaxMod = 1<<6, */ - MaxMod = HOTKEYF_ALT | HOTKEYF_CONTROL | HOTKEYF_EXT | HOTKEYF_SHIFT | HOTKEYF_MIDI, + MaxMod = (HOTKEYF_ALT | HOTKEYF_CONTROL | HOTKEYF_EXT | HOTKEYF_SHIFT | HOTKEYF_MIDI) + 1, }; #define MAINKEYS 256 -typedef CommandID KeyMap[kCtxMaxInputContexts][MaxMod][MAINKEYS][kNumKeyEvents]; -//typedef CMap<long, long, CommandID, CommandID> KeyMap; +struct KeyMapID +{ + uint8 context; + uint8 modifier; + uint8 key; + uint8 type; + + KeyMapID(InputTargetContext context, UINT modifier, UINT key, KeyEventType type) + : context(static_cast<uint8>(context)) + , modifier(static_cast<uint8>(modifier)) + , key(static_cast<uint8>(key)) + , type(static_cast<uint8>(type)) + { } + + bool operator== (const KeyMapID &other) const + { + return context == other.context && modifier == other.modifier && key == other.key && type == other.type; + } + + // Hash + operator size_t() const + { + return *reinterpret_cast<const uint32 *>(this); + } + + STATIC_ASSERT(static_cast<uint8>(kCtxMaxInputContexts - 1) == kCtxMaxInputContexts - 1); + STATIC_ASSERT(static_cast<uint8>(MaxMod - 1) == MaxMod - 1); + STATIC_ASSERT(static_cast<uint8>(MAINKEYS - 1) == MAINKEYS - 1); + STATIC_ASSERT(static_cast<uint8>(kNumKeyEvents - 1) == kNumKeyEvents - 1); +}; + +#include <unordered_map> +#if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) +typedef std::tr1::unordered_map<KeyMapID, CommandID> KeyMap; +#else +typedef std::unordered_map<KeyMapID, CommandID> KeyMap; +#endif + //KeyMap struct KeyCombination @@ -1174,12 +1210,6 @@ }; -struct Rule -{ - UINT ID; - CString desc; - bool enforce; -}; enum RuleID { Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2014-01-14 15:27:27 UTC (rev 3573) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2014-01-15 15:39:59 UTC (rev 3574) @@ -90,7 +90,7 @@ CommandID CInputHandler::GeneralKeyEvent(InputTargetContext context, int code, WPARAM wParam , LPARAM lParam) //----------------------------------------------------------------------------------------------------------- { - CommandID executeCommand = kcNull; + KeyMap::const_iterator cmd = keyMap.end(); KeyEventType keyEventType; if(code == HC_ACTION) @@ -120,16 +120,18 @@ { // only execute command when the input handler is not locked // and the input is not a consequence of special key interception. - executeCommand = keyMap[context][modifierMask][wParam][keyEventType]; + cmd = keyMap.find(KeyMapID(context, modifierMask, wParam, keyEventType)); } } if(code == HC_MIDI) { - executeCommand = keyMap[context][HOTKEYF_MIDI][wParam][kKeyEventDown]; + cmd = keyMap.find(KeyMapID(context, HOTKEYF_MIDI, wParam, kKeyEventDown)); } - if(m_pMainFrm && executeCommand != kcNull) + CommandID executeCommand = kcNull; + if(m_pMainFrm && cmd != keyMap.end()) { + executeCommand = cmd->second; if(!m_pMainFrm->SendMessage(WM_MOD_KEYCOMMAND, executeCommand, wParam)) { // Command was not handled, so let Windows process it. @@ -144,13 +146,15 @@ CommandID CInputHandler::KeyEvent(InputTargetContext context, UINT &nChar, UINT &/*nRepCnt*/, UINT &/*nFlags*/, KeyEventType keyEventType, CWnd* pSourceWnd) //---------------------------------------------------------------------------------------------------------------------------------------------------------- { - CommandID executeCommand = keyMap[context][modifierMask][nChar][keyEventType]; + KeyMap::const_iterator cmd = keyMap.find(KeyMapID(context, modifierMask, nChar, keyEventType)); + CommandID executeCommand = kcNull; if(pSourceWnd == nullptr) pSourceWnd = m_pMainFrm; //by default, send command message to main frame. - if(pSourceWnd && (executeCommand != kcNull)) + if(pSourceWnd && cmd != keyMap.end()) { + executeCommand = cmd->second; if(!pSourceWnd->SendMessage(WM_MOD_KEYCOMMAND, executeCommand, nChar)) { // Command was not handled, so let Windows process it. @@ -212,16 +216,14 @@ //----------------------------------------------- { m_bInterceptWindowsKeys = m_bInterceptNumLock = m_bInterceptCapsLock = m_bInterceptScrollLock = false; - for( int context=0; context < CountOf(keyMap); context++ ) - for( int mod=0; mod < CountOf(keyMap[0]); mod++ ) - for( int key=0; key < CountOf(keyMap[0][0]); key++ ) - for( int kevent=0; kevent < CountOf(keyMap[0][0][0]); kevent++ ) { - if( keyMap[context][mod][key][kevent] == kcNull ) continue; - if( mod == HOTKEYF_EXT ) m_bInterceptWindowsKeys = true; - if( key == VK_NUMLOCK ) m_bInterceptNumLock = true; - if( key == VK_CAPITAL ) m_bInterceptCapsLock = true; - if( key == VK_SCROLL ) m_bInterceptScrollLock = true; - }; + for(KeyMap::const_iterator i = keyMap.begin(); i != keyMap.end(); i++) + { + ASSERT(i->second != kcNull); + if(i->first.modifier == HOTKEYF_EXT) m_bInterceptWindowsKeys = true; + if(i->first.key == VK_NUMLOCK) m_bInterceptNumLock = true; + if(i->first.key == VK_CAPITAL) m_bInterceptCapsLock = true; + if(i->first.key == VK_SCROLL) m_bInterceptScrollLock = true; + } }; Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2014-01-14 15:27:27 UTC (rev 3573) +++ trunk/OpenMPT/mptrack/InputHandler.h 2014-01-15 15:39:59 UTC (rev 3574) @@ -61,7 +61,7 @@ CWnd *m_pMainFrm; int AsciiToScancode(char ch); KeyMap keyMap; - void LogModifiers(UINT mask); + void LogModifiers(UINT mask); UINT modifierMask; bool m_bBypass; bool m_bNoAltMenu; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-01-15 17:46:57
|
Revision: 3575 http://sourceforge.net/p/modplug/code/3575 Author: saga-games Date: 2014-01-15 17:46:44 +0000 (Wed, 15 Jan 2014) Log Message: ----------- [Ref] Unify KeyMapID and KeyCommand structs [Ref] Don't include InputHandler.h from Mainfrm.h, this isn't really needed in quite a few files that include Mainfrm.h [Ref] Remove unused input handler crap Modified Paths: -------------- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp trunk/OpenMPT/mptrack/CloseMainDialog.cpp trunk/OpenMPT/mptrack/CloseMainDialog.h trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/Ctrl_com.cpp trunk/OpenMPT/mptrack/Ctrl_com.h trunk/OpenMPT/mptrack/Ctrl_ins.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Ctrl_pat.h trunk/OpenMPT/mptrack/Ctrl_seq.cpp trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/FileDialog.cpp trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/InputHandler.h trunk/OpenMPT/mptrack/KeyConfigDlg.cpp trunk/OpenMPT/mptrack/KeyConfigDlg.h trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/ModConvert.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/Mpt_midi.cpp trunk/OpenMPT/mptrack/Mptrack.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/Reporting.cpp trunk/OpenMPT/mptrack/SelectPluginDialog.cpp trunk/OpenMPT/mptrack/View_gen.cpp trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_tre.cpp trunk/OpenMPT/mptrack/VstPresets.h trunk/OpenMPT/mptrack/Vstplug.cpp trunk/OpenMPT/mptrack/view_com.cpp Modified: trunk/OpenMPT/mptrack/AbstractVstEditor.cpp =================================================================== --- trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/AbstractVstEditor.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -20,6 +20,7 @@ #include "MIDIMacros.h" #include "VstPresets.h" #include "../soundlib/FileReader.h" +#include "InputHandler.h" #include <sstream> Modified: trunk/OpenMPT/mptrack/CloseMainDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/CloseMainDialog.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -11,6 +11,7 @@ #include "stdafx.h" #include "Mptrack.h" #include "Mainfrm.h" +#include "InputHandler.h" #include "Moddoc.h" #include "CloseMainDialog.h" @@ -32,6 +33,20 @@ } +CloseMainDialog::CloseMainDialog() : CDialog(IDD_CLOSEDOCUMENTS) +//-------------------------------------------------------------- +{ + CMainFrame::GetInputHandler()->Bypass(true); +}; + + +CloseMainDialog::~CloseMainDialog() +//--------------------------------- +{ + CMainFrame::GetInputHandler()->Bypass(false); +}; + + // Format a list entry string - apparently list boxes in ANSI windows are ANSI too, so inserted unicode // strings are converted to ANSI. Thus, we will keep using CStrings here for ANSI builds. CString CloseMainDialog::FormatTitle(const CModDoc *pModDoc, bool fullPath) Modified: trunk/OpenMPT/mptrack/CloseMainDialog.h =================================================================== --- trunk/OpenMPT/mptrack/CloseMainDialog.h 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/CloseMainDialog.h 2014-01-15 17:46:44 UTC (rev 3575) @@ -21,8 +21,8 @@ CString FormatTitle(const CModDoc *pModDoc, bool fullPath); public: - CloseMainDialog() : CDialog(IDD_CLOSEDOCUMENTS) { CMainFrame::GetInputHandler()->Bypass(true); }; - ~CloseMainDialog() { CMainFrame::GetInputHandler()->Bypass(false); }; + CloseMainDialog(); + ~CloseMainDialog(); protected: virtual void DoDataExchange(CDataExchange* pDX); Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -729,12 +729,12 @@ { if (crossContext) { - report += "Warning! the following commands may conflict:\r\n >" + GetCommandText((CommandID)curCmd) + " in " + GetContextText(curKc.ctx) + "\r\n >" + GetCommandText((CommandID)cmd) + " in " + GetContextText(kc.ctx) + "\r\n\r\n"; + report += "Warning! the following commands may conflict:\r\n >" + GetCommandText((CommandID)curCmd) + " in " + curKc.GetContextText() + "\r\n >" + GetCommandText((CommandID)cmd) + " in " + kc.GetContextText() + "\r\n\r\n"; Log("%s", report); } else { Remove(curKc, (CommandID)curCmd); - report += "Removed due to conflict in same context:\r\n >" + GetCommandText((CommandID)curCmd) + " in " + GetContextText(curKc.ctx) + "\r\n\r\n"; + report += "Removed due to conflict in same context:\r\n >" + GetCommandText((CommandID)curCmd) + " in " + curKc.GetContextText() + "\r\n\r\n"; Log("%s", report); } } @@ -820,14 +820,14 @@ {//for all selection modifiers curKc=commands[kcSelect].kcList[kSel]; newKc=inKc; - newKc.mod|=curKc.mod; //Add selection modifier's modifiers to this command + newKc.Modifier(curKc); //Add selection modifier's modifiers to this command if(adding) { - Log("Enforcing rule krAllowNavigationWithSelection - adding key:%d with modifier:%d to command: %d\n", kSel, newKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - adding key:%d with modifier:%d to command: %d\n", kSel, newKc.Modifier(), cmdNavSelection); Add(newKc, cmdNavSelection, false); } else { - Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", kSel, newKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", kSel, newKc.Modifier(), cmdNavSelection); Remove(newKc, cmdNavSelection); } } @@ -840,14 +840,14 @@ {//for all selection modifiers curKc=commands[kcSelect].kcList[kSel]; newKc=inKc; - newKc.mod|=curKc.mod; //Add selection modifier's modifiers to this command + newKc.AddModifier(curKc); //Add selection modifier's modifiers to this command if(adding) { - Log("Enforcing rule krAllowNavigationWithSelection - adding key:%d with modifier:%d to command: %d\n", kSel, newKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - adding key:%d with modifier:%d to command: %d\n", kSel, newKc.Modifier(), cmdNavSelection); Add(newKc, cmdNavSelection, false); } else { - Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", kSel, newKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", kSel, newKc.Modifier(), cmdNavSelection); Remove(newKc, cmdNavSelection); } } @@ -864,15 +864,15 @@ { // for all keys for this command CommandID cmdNavSelection = (CommandID)(kcStartPatNavigationSelect + (curCmd-kcStartPatNavigation)); - newKc=commands[curCmd].kcList[k]; // get all properties from the current nav cmd key - newKc.mod|=inKc.mod; // and the new selection modifier + newKc=commands[curCmd].kcList[k]; // get all properties from the current nav cmd key + newKc.AddModifier(inKc); // and the new selection modifier if(adding) { - Log("Enforcing rule krAllowNavigationWithSelection - adding key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - adding key:%d with modifier:%d to command: %d\n", curCmd, inKc.Modifier(), cmdNavSelection); Add(newKc, cmdNavSelection, false); } else { - Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.Modifier(), cmdNavSelection); Remove(newKc, cmdNavSelection); } } @@ -882,15 +882,15 @@ for(int k = 0; k < commands[curCmd].kcList.GetSize(); k++) {// for all keys for this command CommandID cmdNavSelection = (CommandID)(kcStartOrderlistNavigationSelect+ (curCmd-kcStartOrderlistNavigation)); - newKc=commands[curCmd].kcList[k]; // get all properties from the current nav cmd key - newKc.mod|=inKc.mod; // and the new selection modifier + newKc=commands[curCmd].kcList[k]; // get all properties from the current nav cmd key + newKc.AddModifier(inKc); // and the new selection modifier if(adding) { - Log("Enforcing rule krAllowNavigationWithSelection - adding key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - adding key:%d with modifier:%d to command: %d\n", curCmd, inKc.Modifier(), cmdNavSelection); Add(newKc, cmdNavSelection, false); } else { - Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, cmdNavSelection); + Log("Enforcing rule krAllowNavigationWithSelection - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.Modifier(), cmdNavSelection); Remove(newKc, cmdNavSelection); } } @@ -909,7 +909,7 @@ for(int kSel = 0; kSel < commands[kcSelect].kcList.GetSize(); kSel++) {//for all deselection modifiers newKcSel = commands[kcSelect].kcList[kSel]; // get all properties from the selection key - newKcSel.mod |= inKc.mod; // add modifiers from the new nav command + newKcSel.AddModifier(inKc); // add modifiers from the new nav command if(adding) { Log("Enforcing rule krAllowSelectionWithNavigation: adding removing kcSelectWithNav and kcSelectOffWithNav\n"); @@ -927,7 +927,7 @@ for(int kSel = 0; kSel < commands[kcSelect].kcList.GetSize(); kSel++) {//for all deselection modifiers newKcSel=commands[kcSelect].kcList[kSel]; // get all properties from the selection key - newKcSel.mod|=inKc.mod; // add modifiers from the new nav command + newKcSel.AddModifier(inKc); // add modifiers from the new nav command if(adding) { Log("Enforcing rule krAllowSelectionWithNavigation: adding removing kcSelectWithNav and kcSelectOffWithNav\n"); @@ -948,14 +948,14 @@ for(int k = 0; k < commands[curCmd].kcList.GetSize(); k++) {// for all keys for this command newKcSel=inKc; // get all properties from the selection key - newKcSel.mod|=commands[curCmd].kcList[k].mod; //add the nav keys' modifiers + newKcSel.AddModifier(commands[curCmd].kcList[k]); //add the nav keys' modifiers if(adding) { - Log("Enforcing rule krAllowSelectionWithNavigation - adding key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, kcSelectWithNav); + Log("Enforcing rule krAllowSelectionWithNavigation - adding key:%d with modifier:%d to command: %d\n", curCmd, inKc.Modifier(), kcSelectWithNav); Add(newKcSel, kcSelectWithNav, false); } else { - Log("Enforcing rule krAllowSelectionWithNavigation - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, kcSelectWithNav); + Log("Enforcing rule krAllowSelectionWithNavigation - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.Modifier(), kcSelectWithNav); Remove(newKcSel, kcSelectWithNav); } } @@ -966,14 +966,14 @@ for(int k = 0; k <commands[curCmd].kcList.GetSize(); k++) {// for all keys for this command newKcSel=inKc; // get all properties from the selection key - newKcSel.mod |= commands[curCmd].kcList[k].mod; //add the nav keys' modifiers + newKcSel.AddModifier(commands[curCmd].kcList[k]); //add the nav keys' modifiers if(adding) { - Log("Enforcing rule krAllowSelectionWithNavigation - adding key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, kcSelectWithNav); + Log("Enforcing rule krAllowSelectionWithNavigation - adding key:%d with modifier:%d to command: %d\n", curCmd, inKc.Modifier(), kcSelectWithNav); Add(newKcSel, kcSelectWithNav, false); } else { - Log("Enforcing rule krAllowSelectionWithNavigation - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.mod, kcSelectWithNav); + Log("Enforcing rule krAllowSelectionWithNavigation - removing key:%d with modifier:%d to command: %d\n", curCmd, inKc.Modifier(), kcSelectWithNav); Remove(newKcSel, kcSelectWithNav); } } @@ -1004,13 +1004,14 @@ if(ruleApplies) { newKcDeSel = inKc; - newKcDeSel.event = kKeyEventUp; + newKcDeSel.EventType(kKeyEventUp); // Register key-up when releasing any of the modifiers. // Otherwise, select key combos might get stuck. Example: // [Ctrl Down] [Alt Down] [Alt Up] [Ctrl Up] After this action, copy select (Ctrl+Drag) would still be activated without. - for(newKcDeSel.mod = 0; newKcDeSel.mod <= (HOTKEYF_ALT | HOTKEYF_CONTROL | HOTKEYF_SHIFT); newKcDeSel.mod++) + for(UINT i = 0; i <= (HOTKEYF_ALT | HOTKEYF_CONTROL | HOTKEYF_SHIFT); i++) { + newKcDeSel.Modifier(i); //newKcDeSel.mod&=~CodeToModifier(inKc.code); //<-- Need to get rid of right modifier!! if (adding) @@ -1032,9 +1033,9 @@ for (int k=0; k<commands[kcCopySelect].kcList.GetSize(); k++) { newKcSel=inKc; - newKcSel.mod|=commands[kcCopySelect].kcList[k].mod; + newKcSel.AddModifier(commands[kcCopySelect].kcList[k]); newKcCopySel=commands[kcCopySelect].kcList[k]; - newKcCopySel.mod|=inKc.mod; + newKcCopySel.AddModifier(inKc); Log("Enforcing rule krAllowSelectCopySelectCombos\n"); if(adding) { @@ -1054,9 +1055,9 @@ for(int k = 0; k < commands[kcSelect].kcList.GetSize(); k++) { newKcSel=commands[kcSelect].kcList[k]; - newKcSel.mod |= inKc.mod; + newKcSel.AddModifier(inKc); newKcCopySel=inKc; - newKcCopySel.mod|=commands[kcSelect].kcList[k].mod; + newKcCopySel.AddModifier(commands[kcSelect].kcList[k]); Log("Enforcing rule krAllowSelectCopySelectCombos\n"); if(adding) { @@ -1081,7 +1082,7 @@ for (int k=0; k<commands[kcChordModifier].kcList.GetSize(); k++) {//for all chord modifier keys newKc=inKc; - newKc.mod|=commands[kcChordModifier].kcList[k].mod; + newKc.AddModifier(commands[kcChordModifier].kcList[k]); if (adding) { Log("Enforcing rule krLockNotesToChords: auto adding in a chord command\n"); @@ -1103,7 +1104,7 @@ {//for all keys for this note noteOffset = curCmd - kcVPStartNotes; newKc=commands[curCmd].kcList[k]; - newKc.mod|=inKc.mod; + newKc.AddModifier(inKc); if (adding) { Log("Enforcing rule krLockNotesToChords: auto adding in a chord command\n"); @@ -1127,7 +1128,7 @@ { int noteOffset = inCmd - kcVPStartNotes; newKc=inKc; - newKc.event=kKeyEventUp; + newKc.EventType(kKeyEventUp); if (adding) { Log("Enforcing rule krNoteOffOnKeyRelease: adding note off command\n"); @@ -1143,7 +1144,7 @@ { int noteOffset = inCmd - kcVPStartChords; newKc=inKc; - newKc.event=kKeyEventUp; + newKc.EventType(kKeyEventUp); if (adding) { Log("Enforcing rule krNoteOffOnKeyRelease: adding Chord off command\n"); @@ -1159,7 +1160,7 @@ { int noteOffset = inCmd - kcSetOctave0; newKc=inKc; - newKc.event=kKeyEventUp; + newKc.EventType(kKeyEventUp); if (adding) { Log("Enforcing rule krNoteOffOnKeyRelease: adding Chord off command\n"); @@ -1176,50 +1177,41 @@ //# Reassign freed number keys to octaves if (enforceRule[krReassignDigitsToOctaves] && !adding) { - if ( (inKc.mod == 0) && //no modifier - ( (inKc.ctx == kCtxViewPatternsNote) || (inKc.ctx == kCtxViewPatterns) ) && //note scope or pattern scope - ( ('0'<=inKc.code && inKc.code<='9') || (VK_NUMPAD0<=inKc.code && inKc.code<=VK_NUMPAD9) ) ) { //is number key - newKc.ctx=kCtxViewPatternsNote; - newKc.mod=0; - newKc.event= kKeyEventDown; - newKc.code=inKc.code; - int offset = ('0'<=inKc.code && inKc.code<='9') ? newKc.code-'0' : newKc.code-VK_NUMPAD0; - Add(newKc, (CommandID)(kcSetOctave0 + (newKc.code-offset)), false); - } + if ( (inKc.Modifier() == 0) && //no modifier + ( (inKc.Context() == kCtxViewPatternsNote) || (inKc.Context() == kCtxViewPatterns) ) && //note scope or pattern scope + ( ('0'<=inKc.KeyCode() && inKc.KeyCode()<='9') || (VK_NUMPAD0<=inKc.KeyCode() && inKc.KeyCode()<=VK_NUMPAD9) ) ) //is number key + { + KeyCombination newKc(kCtxViewPatternsNote, 0, inKc.KeyCode(), kKeyEventDown); + int offset = ('0'<=inKc.KeyCode() && inKc.KeyCode()<='9') ? newKc.KeyCode()-'0' : newKc.KeyCode()-VK_NUMPAD0; + Add(newKc, (CommandID)(kcSetOctave0 + (newKc.KeyCode()-offset)), false); + } } // Add spacing if (enforceRule[krAutoSpacing]) { if (inCmd==kcSetSpacing && adding) { - newKc.ctx=kCtxViewPatterns; - newKc.mod=inKc.mod; - newKc.event= kKeyEventDown; - for (newKc.code='0'; newKc.code<='9'; newKc.code++) + KeyCombination newKc(kCtxViewPatterns, inKc.Modifier(), 0, kKeyEventDown); + for (char i = 0; i <= 9; i++) { - Add(newKc, (CommandID)(kcSetSpacing0 + (newKc.code-'0')), false); + newKc.KeyCode('0' + i); + Add(newKc, (CommandID)(kcSetSpacing0 + i), false); + newKc.KeyCode(VK_NUMPAD0 + i); + Add(newKc, (CommandID)(kcSetSpacing0 + i), false); } - for (newKc.code=VK_NUMPAD0; newKc.code<=VK_NUMPAD9; newKc.code++) - { - Add(newKc, (CommandID)(kcSetSpacing0 + (newKc.code-VK_NUMPAD0)), false); - } } else if (!adding && (inCmd<kcSetSpacing && kcSetSpacing9<inCmd)) { - KeyCombination spacing; for (int k=0; k<commands[kcSetSpacing].kcList.GetSize(); k++) { - spacing = commands[kcSetSpacing].kcList[k]; - if ((('0'<=inKc.code && inKc.code<='9')||(VK_NUMPAD0<=inKc.code && inKc.code<=VK_NUMPAD9)) && !adding) + KeyCombination spacing = commands[kcSetSpacing].kcList[k]; + if ((('0'<=inKc.KeyCode() && inKc.KeyCode()<='9')||(VK_NUMPAD0<=inKc.KeyCode() && inKc.KeyCode()<=VK_NUMPAD9)) && !adding) { - newKc.ctx= kCtxViewPatterns; - newKc.mod= spacing.mod; - newKc.event= spacing.event; - newKc.code=inKc.code; - if ('0'<=inKc.code && inKc.code<='9') - Add(newKc, (CommandID)(kcSetSpacing0 + inKc.code - '0'), false); - else if (VK_NUMPAD0<=inKc.code && inKc.code<=VK_NUMPAD9) - Add(newKc, (CommandID)(kcSetSpacing0 + inKc.code - VK_NUMPAD0), false); + KeyCombination newKc(kCtxViewPatterns, spacing.Modifier(), inKc.KeyCode(), spacing.EventType()); + if ('0'<=inKc.KeyCode() && inKc.KeyCode()<='9') + Add(newKc, (CommandID)(kcSetSpacing0 + inKc.KeyCode() - '0'), false); + else if (VK_NUMPAD0<=inKc.KeyCode() && inKc.KeyCode()<=VK_NUMPAD9) + Add(newKc, (CommandID)(kcSetSpacing0 + inKc.KeyCode() - VK_NUMPAD0), false); } } @@ -1238,11 +1230,11 @@ KeyCombination newKcInsNoteMap = inKc; KeyCombination newKcVSTGUI = inKc; - newKcSamp.ctx=kCtxViewSamples; - newKcIns.ctx=kCtxViewInstruments; - newKcTree.ctx=kCtxViewTree; - newKcInsNoteMap.ctx=kCtxInsNoteMap; - newKcVSTGUI.ctx=kCtxVSTGUI; + newKcSamp.Context(kCtxViewSamples); + newKcIns.Context(kCtxViewInstruments); + newKcTree.Context(kCtxViewTree); + newKcInsNoteMap.Context(kCtxInsNoteMap); + newKcVSTGUI.Context(kCtxVSTGUI); noteOffset = inCmd - kcVPStartNotes; if (adding) @@ -1272,11 +1264,11 @@ KeyCombination newKcInsNoteMap = inKc; KeyCombination newKcVSTGUI = inKc; - newKcSamp.ctx=kCtxViewSamples; - newKcIns.ctx=kCtxViewInstruments; - newKcTree.ctx=kCtxViewTree; - newKcInsNoteMap.ctx=kCtxInsNoteMap; - newKcVSTGUI.ctx=kCtxVSTGUI; + newKcSamp.Context(kCtxViewSamples); + newKcIns.Context(kCtxViewInstruments); + newKcTree.Context(kCtxViewTree); + newKcInsNoteMap.Context(kCtxInsNoteMap); + newKcVSTGUI.Context(kCtxVSTGUI); noteOffset = inCmd - kcVPStartNoteStops; if (adding) @@ -1313,14 +1305,14 @@ for (int k=0; k<commands[curCmd].kcList.GetSize(); k++) { curKc = commands[curCmd].kcList[k]; - if ((!curKc.mod) || (curKc.code!=VK_SHIFT && curKc.code!=VK_CONTROL && curKc.code!=VK_MENU && curKc.code!=0 && - curKc.code!=VK_LWIN && curKc.code!=VK_RWIN )) // Feature: use Windows keys as modifier keys + if ((!curKc.Modifier()) || (curKc.KeyCode()!=VK_SHIFT && curKc.KeyCode()!=VK_CONTROL && curKc.KeyCode()!=VK_MENU && curKc.KeyCode()!=0 && + curKc.KeyCode()!=VK_LWIN && curKc.KeyCode()!=VK_RWIN )) // Feature: use Windows keys as modifier keys { - report += ("Error! " + GetCommandText((CommandID)curCmd) + " must be a modifier (shift/ctrl/alt), but is currently " + GetKeyText(inKc.mod, inKc.code) + "\r\n"); + report += ("Error! " + GetCommandText((CommandID)curCmd) + " must be a modifier (shift/ctrl/alt), but is currently " + inKc.GetKeyText() + "\r\n"); //replace with dummy - commands[curCmd].kcList[k].mod=1; - commands[curCmd].kcList[k].code=0; - commands[curCmd].kcList[k].event=(KeyEventType)0; + commands[curCmd].kcList[k].Modifier(HOTKEYF_SHIFT); + commands[curCmd].kcList[k].KeyCode(0); + commands[curCmd].kcList[k].EventType(kKeyEventNone); //commands[curCmd].kcList[k].ctx; } } @@ -1339,10 +1331,8 @@ commands[newCmd].kcList.SetSize(commands[inCmd].kcList.GetSize()); for (int k=0; k<commands[inCmd].kcList.GetSize(); k++) { - commands[newCmd].kcList[k].mod = commands[inCmd].kcList[k].mod; - commands[newCmd].kcList[k].code = commands[inCmd].kcList[k].code; - commands[newCmd].kcList[k].event = commands[inCmd].kcList[k].event; - commands[newCmd].kcList[k].ctx = kCtxViewInstruments; + commands[newCmd].kcList[k] = commands[inCmd].kcList[k]; + commands[newCmd].kcList[k].Context(kCtxViewInstruments); } } @@ -1374,21 +1364,6 @@ } -UINT CCommandSet::CodeToModifier(UINT code) -//----------------------------------------- -{ - switch(code) - { - case VK_SHIFT: return HOTKEYF_SHIFT; - case VK_MENU: return HOTKEYF_ALT; - case VK_CONTROL: return HOTKEYF_CONTROL; - case VK_LWIN: case VK_RWIN: return HOTKEYF_EXT; // Feature: use Windows keys as modifier keys - default: /*DEBUG: ASSERT(false);*/ return 0; //can only get modifier for modifier key - } - -} - - //------------------------------------------------------- // Export //------------------------------------------------------- @@ -1416,35 +1391,35 @@ curKc = commands[cmd].kcList[k]; //Handle keyEventType mask. - if (curKc.event & kKeyEventDown) + if (curKc.EventType() & kKeyEventDown) eventTypes.Add(kKeyEventDown); - if (curKc.event & kKeyEventUp) + if (curKc.EventType() & kKeyEventUp) eventTypes.Add(kKeyEventUp); - if (curKc.event & kKeyEventRepeat) + if (curKc.EventType() & kKeyEventRepeat) eventTypes.Add(kKeyEventRepeat); //ASSERT(eventTypes.GetSize()>0); //Handle super-contexts (contexts that represent a set of sub contexts) - if (curKc.ctx == kCtxViewPatterns) + if (curKc.Context() == kCtxViewPatterns) { contexts.Add(kCtxViewPatternsNote); contexts.Add(kCtxViewPatternsIns); contexts.Add(kCtxViewPatternsVol); contexts.Add(kCtxViewPatternsFX); contexts.Add(kCtxViewPatternsFXparam); - } else if(curKc.ctx == kCtxCtrlPatterns) + } else if(curKc.Context() == kCtxCtrlPatterns) { contexts.Add(kCtxCtrlOrderlist); } else { - contexts.Add(curKc.ctx); + contexts.Add(curKc.Context()); } for (int cx=0; cx<contexts.GetSize(); cx++) { for (int ke=0; ke<eventTypes.GetSize(); ke++) { - km[KeyMapID(contexts[cx], curKc.mod, curKc.code, eventTypes[ke])] = (CommandID)cmd; + km[KeyCombination(contexts[cx], curKc.Modifier(), curKc.KeyCode(), eventTypes[ke])] = (CommandID)cmd; } } } @@ -1512,7 +1487,7 @@ for (int ctx=0; ctx<kCtxMaxInputContexts; ctx++) { - fprintf(outStream, "\n//----( %s (%d) )------------\n", GetContextText((InputTargetContext)ctx), ctx); + fprintf(outStream, "\n//----( %s (%d) )------------\n", KeyCombination::GetContextText((InputTargetContext)ctx), ctx); for (int cmd=0; cmd<kcNumCommands; cmd++) { @@ -1520,14 +1495,14 @@ { kc = GetKey((CommandID)cmd, k); - if (kc.ctx != ctx) + if (kc.Context() != ctx) continue; //sort by context if (!commands[cmd].isHidden) { fprintf(outStream, "%d:%d:%d:%d:%d\t\t//%s: %s (%s)\n", - ctx, commands[cmd].UID, kc.mod, kc.code, kc.event, - GetCommandText((CommandID)cmd), GetKeyText(kc.mod,kc.code), GetKeyEventText(kc.event)); + ctx, commands[cmd].UID, kc.Modifier(), kc.KeyCode(), kc.EventType(), + GetCommandText((CommandID)cmd), kc.GetKeyText(), kc.GetKeyEventText()); } } @@ -1577,7 +1552,7 @@ //context token=curLine.Tokenize(":",spos); - kc.ctx = (InputTargetContext) atoi(token); + kc.Context((InputTargetContext) atoi(token)); // this line indicates the version of this keymap file instead. (e.g. "version:1") if((token.Trim().CompareNoCase("version") == 0) && (spos != -1)) @@ -1598,28 +1573,28 @@ if (spos != -1) { token=curLine.Tokenize(":",spos); - cmd= (CommandID) FindCmd(atoi(token)); + cmd= (CommandID)FindCmd(atoi(token)); } //modifier if (spos != -1) { token=curLine.Tokenize(":",spos); - kc.mod = atoi(token); + kc.Modifier(atoi(token)); } //scancode if (spos != -1) { token=curLine.Tokenize(":",spos); - kc.code = atoi(token); + kc.KeyCode(atoi(token)); } //event if (spos != -1) { token=curLine.Tokenize(":",spos); - kc.event = (KeyEventType) atoi(token); + kc.EventType((KeyEventType)atoi(token)); } if(!ignoreLine) @@ -1708,74 +1683,70 @@ void CCommandSet::UpgradeKeymap(CCommandSet *pCommands, int oldVersion) //--------------------------------------------------------------------- { - KeyCombination kc; - // no orderlist context if(oldVersion == 0) { - kc.ctx = kCtxCtrlOrderlist; - kc.event = (KeyEventType) (kKeyEventDown | kKeyEventRepeat); - kc.mod = 0; + KeyCombination kc(kCtxCtrlOrderlist, 0, 0, kKeyEventDown | kKeyEventRepeat); - kc.code = VK_DELETE; + kc.KeyCode(VK_DELETE); pCommands->Add(kc, kcOrderlistEditDelete, false); - kc.code = VK_INSERT; + kc.KeyCode(VK_INSERT); pCommands->Add(kc, kcOrderlistEditInsert, false); - kc.code = VK_RETURN; + kc.KeyCode(VK_RETURN); pCommands->Add(kc, kcOrderlistEditPattern, false); - kc.code = VK_TAB; + kc.KeyCode(VK_TAB); pCommands->Add(kc, kcOrderlistSwitchToPatternView, false); - kc.code = VK_LEFT; + kc.KeyCode(VK_LEFT); pCommands->Add(kc, kcOrderlistNavigateLeft, false); - kc.code = VK_UP; + kc.KeyCode(VK_UP); pCommands->Add(kc, kcOrderlistNavigateLeft, false); - kc.code = VK_RIGHT; + kc.KeyCode(VK_RIGHT); pCommands->Add(kc, kcOrderlistNavigateRight, false); - kc.code = VK_DOWN; + kc.KeyCode(VK_DOWN); pCommands->Add(kc, kcOrderlistNavigateRight, false); - kc.code = VK_HOME; + kc.KeyCode(VK_HOME); pCommands->Add(kc, kcOrderlistNavigateFirst, false); - kc.code = VK_END; + kc.KeyCode(VK_END); pCommands->Add(kc, kcOrderlistNavigateLast, false); - kc.code = VK_ADD; + kc.KeyCode(VK_ADD); pCommands->Add(kc, kcOrderlistPatPlus, false); - kc.code = VK_OEM_PLUS; + kc.KeyCode(VK_OEM_PLUS); pCommands->Add(kc, kcOrderlistPatPlus, false); - kc.code = VK_SUBTRACT; + kc.KeyCode(VK_SUBTRACT); pCommands->Add(kc, kcOrderlistPatMinus, false); - kc.code = VK_OEM_MINUS; + kc.KeyCode(VK_OEM_MINUS); pCommands->Add(kc, kcOrderlistPatMinus, false); STATIC_ASSERT(VK_NUMPAD0 + 9 == VK_NUMPAD9); STATIC_ASSERT(kcOrderlistPat0 + 9 == kcOrderlistPat9); for(int i = 0; i <= 9; i++) { - kc.code = '0' + i; + kc.KeyCode('0' + i); pCommands->Add(kc, static_cast<CommandID>(kcOrderlistPat0 + i), false); - kc.code = VK_NUMPAD0 + i; + kc.KeyCode(VK_NUMPAD0 + i); pCommands->Add(kc, static_cast<CommandID>(kcOrderlistPat0 + i), false); } - kc.code = 'I'; + kc.KeyCode('I'); pCommands->Add(kc, kcOrderlistPatIgnore, false); - kc.code = VK_SPACE; + kc.KeyCode(VK_SPACE); pCommands->Add(kc, kcOrderlistPatInvalid, false); - kc.code = 'L'; - kc.mod = HOTKEYF_CONTROL; + kc.KeyCode('L'); + kc.Modifier(HOTKEYF_CONTROL); pCommands->Add(kc, kcOrderlistLockPlayback, false); - kc.code = 'U'; + kc.KeyCode('U'); pCommands->Add(kc, kcOrderlistUnlockPlayback, false); } } @@ -1795,8 +1766,8 @@ } -CString CCommandSet::GetContextText(InputTargetContext ctx) -//--------------------------------------------------------- +CString KeyCombination::GetContextText(InputTargetContext ctx) +//------------------------------------------------------------ { switch(ctx) { @@ -1826,24 +1797,24 @@ }; -CString CCommandSet::GetKeyEventText(KeyEventType ke) -//--------------------------------------------------- +CString KeyCombination::GetKeyEventText(KeyEventType event) +//--------------------------------------------------------- { CString text=""; bool first = true; - if (ke & kKeyEventDown) + if (event & kKeyEventDown) { first=false; text.Append("KeyDown"); } - if (ke & kKeyEventRepeat) + if (event & kKeyEventRepeat) { if (!first) text.Append("|"); text.Append("KeyHold"); first=false; } - if (ke & kKeyEventUp) + if (event & kKeyEventUp) { if (!first) text.Append("|"); text.Append("KeyUp"); @@ -1853,8 +1824,8 @@ } -CString CCommandSet::GetModifierText(UINT mod) -//-------------------------------------------- +CString KeyCombination::GetModifierText(UINT mod) +//----------------------------------------------- { CString text = ""; if (mod & HOTKEYF_SHIFT) text.Append("Shift+"); @@ -1866,8 +1837,8 @@ } -CString CCommandSet::GetKeyText(UINT mod, UINT code) -//-------------------------------------------------- +CString KeyCombination::GetKeyText(UINT mod, UINT code) +//----------------------------------------------------- { CString keyText; keyText=GetModifierText(mod); @@ -1888,7 +1859,7 @@ //--------------------------------------------------------------- { if ( static_cast<INT_PTR>(key) < commands[c].kcList.GetSize()) - return GetKeyText(commands[c].kcList[0].mod, commands[c].kcList[0].code); + return commands[c].kcList[0].GetKeyText(); else return ""; } @@ -1917,7 +1888,7 @@ for (int p=0; p<choices; p++) //for all choices { kc = GetKey(cmd, p); - kc.event = (KeyEventType)((UINT)kc.event | (UINT)kKeyEventRepeat); + kc.EventType(kc.EventType() | kKeyEventRepeat); //Remove(p, cmd); //out with the old Add(kc, cmd, true, p); //in with the new } @@ -1937,7 +1908,7 @@ for (int p=0; p<choices; p++) //for all choices { kc = GetKey(cmd, p); - kc.event = (KeyEventType)((UINT)kc.event & ~(UINT)kKeyEventRepeat); + kc.EventType(kc.EventType() & ~kKeyEventRepeat); //Remove(p, cmd); //out with the old Add(kc, cmd, true, p); //in with the new } @@ -1950,10 +1921,8 @@ //-------------------------------------------------------------------------- { int choices=0; - KeyCombination kc; - kc.ctx = kCtxViewPatternsFX; - kc.event = kKeyEventDown; - + KeyCombination kc(kCtxViewPatternsFX, 0, 0, kKeyEventDown); + for(CommandID cmd = kcFixedFXStart; cmd <= kcFixedFXend; cmd = static_cast<CommandID>(cmd + 1)) { //Remove all old choices @@ -1977,13 +1946,13 @@ if(effect != '?') { SHORT codeNmod = VkKeyScanEx(effect, GetKeyboardLayout(0)); - kc.code = LOBYTE(codeNmod); - kc.mod = HIBYTE(codeNmod) & 0x07; //We're only interest in the bottom 3 bits. + kc.KeyCode(LOBYTE(codeNmod)); + kc.Modifier(HIBYTE(codeNmod) & 0x07); //We're only interest in the bottom 3 bits. Add(kc, cmd, true); - if (kc.code >= '0' && kc.code <= '9') //for numbers, ensure numpad works too + if (kc.KeyCode() >= '0' && kc.KeyCode() <= '9') //for numbers, ensure numpad works too { - kc.code = VK_NUMPAD0 + (kc.code-'0'); + kc.KeyCode(VK_NUMPAD0 + (kc.KeyCode() - '0')); Add(kc, cmd, true); } } @@ -1994,7 +1963,8 @@ // Stupid MFC crap: for some reason VK code isn't enough to get correct string with GetKeyName. // We also need to figure out the correct "extended" bit. -bool CCommandSet::IsExtended(UINT code) +bool KeyCombination::IsExtended(UINT code) +//---------------------------------------- { if (code==VK_SNAPSHOT) //print screen return true; @@ -2060,17 +2030,17 @@ bool CCommandSet::KeyCombinationConflict(KeyCombination kc1, KeyCombination kc2, bool &crossCxtConflict) { - bool modConflict = (kc1.mod==kc2.mod); - bool codeConflict = (kc1.code==kc2.code); - bool eventConflict = ((kc1.event&kc2.event)!=0); - bool ctxConflict = (kc1.ctx == kc2.ctx); - crossCxtConflict = m_isParentContext[kc1.ctx][kc2.ctx] || m_isParentContext[kc2.ctx][kc1.ctx]; + bool modConflict = (kc1.Modifier()==kc2.Modifier()); + bool codeConflict = (kc1.KeyCode()==kc2.KeyCode()); + bool eventConflict = ((kc1.EventType()&kc2.EventType())!=0); + bool ctxConflict = (kc1.Context() == kc2.Context()); + crossCxtConflict = m_isParentContext[kc1.Context()][kc2.Context()] || m_isParentContext[kc2.Context()][kc1.Context()]; bool conflict = modConflict && codeConflict && eventConflict && (ctxConflict || crossCxtConflict); - return conflict; + return conflict; } //end rewbs.customKeys \ No newline at end of file Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/CommandSet.h 2014-01-15 17:46:44 UTC (rev 3575) @@ -11,6 +11,7 @@ #pragma once #include "afxtempl.h" #include <string> +#include "../common/FlagSet.h" struct CModSpecifications; //#define VK_ALT 0x12 @@ -50,12 +51,15 @@ enum KeyEventType { + kKeyEventNone = 0, kKeyEventDown = 1 << 0, kKeyEventUp = 1 << 1, kKeyEventRepeat = 1 << 2, kNumKeyEvents = 1 << 3 }; +DECLARE_FLAGSET(KeyEventType) + enum CommandID { kcNull = -1, @@ -79,7 +83,7 @@ kcFileImportMidiLib, kcFileAddSoundBank, kcEndFile=kcFileAddSoundBank, - + kcStartPlayCommands, kcPlayPauseSong=kcStartPlayCommands, kcPauseSong, @@ -465,7 +469,7 @@ kcVPChordStopGS2, kcVPChordStopA_3, kcVPEndChordStops=kcVPChordStopA_3, - + //Set octave from note column kcSetOctave0, kcSetOctave1, @@ -477,7 +481,7 @@ kcSetOctave7, kcSetOctave8, kcSetOctave9, - + // Release set octave key kcSetOctaveStop0, kcSetOctaveStop1, @@ -543,7 +547,7 @@ kcSetVolumeITPortaDown, //e kcSetVolumeITUnused, //: kcSetVolumeITOffset, //o - kcSetVolumeEnd=kcSetVolumeITOffset, + kcSetVolumeEnd=kcSetVolumeITOffset, //Effect params kcSetFXParam0, @@ -1132,62 +1136,84 @@ RAlt = 1<<5, MaxMod = 1<<6, */ - MaxMod = (HOTKEYF_ALT | HOTKEYF_CONTROL | HOTKEYF_EXT | HOTKEYF_SHIFT | HOTKEYF_MIDI) + 1, + MaxMod = HOTKEYF_ALT | HOTKEYF_CONTROL | HOTKEYF_EXT | HOTKEYF_SHIFT | HOTKEYF_MIDI, }; #define MAINKEYS 256 -struct KeyMapID +struct KeyCombination { - uint8 context; - uint8 modifier; - uint8 key; - uint8 type; +protected: + uint8 ctx; + uint8 mod; + uint8 code; + uint8 event; - KeyMapID(InputTargetContext context, UINT modifier, UINT key, KeyEventType type) - : context(static_cast<uint8>(context)) - , modifier(static_cast<uint8>(modifier)) - , key(static_cast<uint8>(key)) - , type(static_cast<uint8>(type)) + STATIC_ASSERT(static_cast<uint8>(kCtxMaxInputContexts - 1) == kCtxMaxInputContexts - 1); + STATIC_ASSERT(static_cast<uint8>(MaxMod) == MaxMod); + STATIC_ASSERT(static_cast<uint8>(MAINKEYS - 1) == MAINKEYS - 1); + STATIC_ASSERT(static_cast<uint8>(kNumKeyEvents - 1) == kNumKeyEvents - 1); + +public: + KeyCombination(InputTargetContext context = kCtxAllContexts, UINT modifier = 0, UINT key = 0, KeyEventType type = kKeyEventNone) + : ctx(static_cast<uint8>(context)) + , mod(static_cast<uint8>(modifier)) + , code(static_cast<uint8>(key)) + , event(static_cast<uint8>(type)) { } - bool operator== (const KeyMapID &other) const + bool operator== (const KeyCombination &other) const { - return context == other.context && modifier == other.modifier && key == other.key && type == other.type; + return ctx == other.ctx && mod == other.mod && code == other.code && event == other.event; } - // Hash + // For hash operator size_t() const { return *reinterpret_cast<const uint32 *>(this); } - STATIC_ASSERT(static_cast<uint8>(kCtxMaxInputContexts - 1) == kCtxMaxInputContexts - 1); - STATIC_ASSERT(static_cast<uint8>(MaxMod - 1) == MaxMod - 1); - STATIC_ASSERT(static_cast<uint8>(MAINKEYS - 1) == MAINKEYS - 1); - STATIC_ASSERT(static_cast<uint8>(kNumKeyEvents - 1) == kNumKeyEvents - 1); + // Getters / Setters + void Context(InputTargetContext context) { ctx = static_cast<uint8>(context); } + InputTargetContext Context() const { return static_cast<InputTargetContext>(ctx); } + + void Modifier(UINT modifier) { mod = static_cast<uint8>(modifier); } + UINT Modifier() const { return static_cast<UINT>(mod); } + void AddModifier(UINT modifier) { mod |= static_cast<uint8>(modifier); } + void AddModifier(const KeyCombination &other) { mod |= other.mod; } + + void KeyCode(UINT key) { code = static_cast<uint8>(key); } + UINT KeyCode() const { return static_cast<UINT>(code); } + + void EventType(KeyEventType type) { event = static_cast<uint8>(type); } + KeyEventType EventType() const { return static_cast<KeyEventType>(event); } + + // Key combination to string + static CString GetContextText(InputTargetContext ctx); + CString GetContextText() const { return GetContextText(Context()); } + + static CString GetModifierText(UINT mod); + CString GetModifierText() const { return GetModifierText(Modifier()); } + + static CString GetKeyText(UINT mod, UINT code); + CString GetKeyText() const { return GetKeyText(Modifier(), KeyCode()); } + + static CString GetKeyEventText(KeyEventType event); + CString GetKeyEventText() const { return GetKeyEventText(EventType()); } + + static bool IsExtended(UINT code); }; #include <unordered_map> #if MPT_COMPILER_MSVC && MPT_MSVC_BEFORE(2010,0) -typedef std::tr1::unordered_map<KeyMapID, CommandID> KeyMap; +typedef std::tr1::unordered_map<KeyCombination, CommandID> KeyMap; #else -typedef std::unordered_map<KeyMapID, CommandID> KeyMap; +typedef std::unordered_map<KeyCombination, CommandID> KeyMap; #endif //KeyMap -struct KeyCombination -{ - UINT mod; - UINT code; - InputTargetContext ctx; - KeyEventType event; - bool operator==(const KeyCombination &other) - {return (mod==other.mod && code==other.code && ctx==other.ctx && event==other.event);} -}; - struct CommandStruct { //public: @@ -1197,7 +1223,7 @@ CString Message; CArray <KeyCombination, KeyCombination> kcList; //KeyCombination kcList[10]; - + bool operator = (const CommandStruct &other) { UID = other.UID; @@ -1210,6 +1236,12 @@ }; +struct Rule +{ + UINT ID; + CString desc; + bool enforce; +}; enum RuleID { @@ -1251,10 +1283,8 @@ void SetupCommands(); void SetupContextHierarchy(); bool IsDummyCommand(CommandID cmd); - UINT CodeToModifier(UINT code); CString EnforceAll(KeyCombination kc, CommandID cmd, bool adding); - bool IsExtended(UINT code); int FindCmd(int uid); bool KeyCombinationConflict(KeyCombination kc1, KeyCombination kc2, bool &crossCxtConflict); @@ -1268,7 +1298,7 @@ CCommandSet(void); ~CCommandSet(void); - + //Population CString Add(KeyCombination kc, CommandID cmd, bool overwrite, int pos = -1); CString Remove(KeyCombination kc, CommandID cmd); @@ -1284,11 +1314,7 @@ bool isHidden(UINT c); int GetKeyListSize(CommandID cmd); CString GetCommandText(CommandID cmd); - CString GetKeyText(UINT mod, UINT code); CString GetKeyTextFromCommand(CommandID c, UINT key); - CString GetContextText(InputTargetContext ctx); - CString GetKeyEventText(KeyEventType ke); - CString GetModifierText(UINT mod); //Pululation ;) void Copy(CCommandSet *source); // copy the contents of a commandset into this command set @@ -1298,6 +1324,6 @@ bool LoadFile(std::istream& iStrm, const std::wstring &filenameDescription); bool LoadDefaultKeymap(); void UpgradeKeymap(CCommandSet *pCommands, int oldVersion); - + }; -//end rewbs.customKeys +//end rewbs.customKeys \ No newline at end of file Modified: trunk/OpenMPT/mptrack/Ctrl_com.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_com.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/Ctrl_com.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -16,10 +16,10 @@ #include "globals.h" #include "ctrl_com.h" #include "view_com.h" +#include "InputHandler.h" BEGIN_MESSAGE_MAP(CCtrlComments, CModControlDlg) //{{AFX_MSG_MAP(CCtrlComments) - ON_MESSAGE(WM_MOD_KEYCOMMAND, OnCustomKeyMsg) //rewbs.customKeys ON_EN_CHANGE(IDC_EDIT_COMMENTS, OnCommentsChanged) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -213,13 +213,3 @@ delete[] p; } } - -//rewbs.customKeys -LRESULT CCtrlComments::OnCustomKeyMsg(WPARAM wParam, LPARAM /*lParam*/) -{ - if (wParam == kcNull) - return NULL; - //currently no specific custom keys for this context - return wParam; -} -//end rewbs.customKeys \ No newline at end of file Modified: trunk/OpenMPT/mptrack/Ctrl_com.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_com.h 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/Ctrl_com.h 2014-01-15 17:46:44 UTC (rev 3575) @@ -38,7 +38,6 @@ //}}AFX_VIRTUAL protected: //{{AFX_MSG(CCtrlComments) - afx_msg LRESULT OnCustomKeyMsg(WPARAM, LPARAM); //rewbs.customKeys afx_msg void OnCommentsChanged(); //}}AFX_MSG DECLARE_MESSAGE_MAP() Modified: trunk/OpenMPT/mptrack/Ctrl_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/Ctrl_ins.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -12,6 +12,7 @@ #include "stdafx.h" #include "mptrack.h" #include "mainfrm.h" +#include "InputHandler.h" #include "childfrm.h" #include "moddoc.h" #include "globals.h" Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -12,6 +12,7 @@ #include "stdafx.h" #include "mptrack.h" #include "mainfrm.h" +#include "InputHandler.h" #include "childfrm.h" #include "moddoc.h" #include "globals.h" Modified: trunk/OpenMPT/mptrack/Ctrl_pat.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.h 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/Ctrl_pat.h 2014-01-15 17:46:44 UTC (rev 3575) @@ -104,10 +104,6 @@ // Set given sqeuence and update orderlist display. void SelectSequence(const SEQUENCEINDEX nSeq); - // Little helper function to avoid copypasta - bool IsSelectionKeyPressed() const { return CMainFrame::GetInputHandler()->SelectionPressed(); } - bool IsCtrlKeyPressed() const { return CMainFrame::GetInputHandler()->CtrlPressed(); } - // Clipboard. void OnEditCopy(); void OnEditCut(); Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -12,11 +12,18 @@ #include "stdafx.h" #include "mptrack.h" #include "mainfrm.h" +#include "InputHandler.h" #include "moddoc.h" #include "globals.h" #include "ctrl_pat.h" #include "PatternClipboard.h" + +// Little helper function to avoid copypasta +static bool IsSelectionKeyPressed() { return CMainFrame::GetInputHandler()->SelectionPressed(); } +static bool IsCtrlKeyPressed() { return CMainFrame::GetInputHandler()->CtrlPressed(); } + + ////////////////////////////////////////////////////////////// // CPatEdit Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -12,6 +12,7 @@ #include "stdafx.h" #include "mptrack.h" #include "mainfrm.h" +#include "InputHandler.h" #include "childfrm.h" #include "moddoc.h" #include "globals.h" Modified: trunk/OpenMPT/mptrack/FileDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/FileDialog.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -12,6 +12,7 @@ #include "FileDialog.h" #include "Mptrack.h" #include "Mainfrm.h" +#include "InputHandler.h" #include "../common/StringFixer.h" Modified: trunk/OpenMPT/mptrack/InputHandler.cpp =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/InputHandler.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -26,10 +26,10 @@ //------------------------------------------- { m_pMainFrm = mainframe; - + //Init CommandSet and Load defaults activeCommandSet = new CCommandSet(); - + mpt::PathString sDefaultPath = theApp.GetConfigPath() + MPT_PATHSTRING("Keybindings.mkb"); if(sDefaultPath.AsNative().length() > MAX_PATH - 1) sDefaultPath = mpt::PathString(); @@ -65,14 +65,11 @@ // We will only overwrite the default Keybindings.mkb file from now on. TrackerSettings::Instance().m_szKbdFile = sDefaultPath; - //Get Keymap + //Get Keymap activeCommandSet->GenKeyMap(keyMap); SetupSpecialKeyInterception(); // Feature: use Windows keys as modifier keys, intercept special keys m_nSkipGeneratedKeypresses = 0; - - m_bDistinguishControls = false; - m_bDistinguishShifts = false; - m_bDistinguishAlts = false; + m_bBypass = false; modifierMask=0; m_bNoAltMenu = true; @@ -120,12 +117,12 @@ { // only execute command when the input handler is not locked // and the input is not a consequence of special key interception. - cmd = keyMap.find(KeyMapID(context, modifierMask, wParam, keyEventType)); + cmd = keyMap.find(KeyCombination(context, modifierMask, wParam, keyEventType)); } } if(code == HC_MIDI) { - cmd = keyMap.find(KeyMapID(context, HOTKEYF_MIDI, wParam, kKeyEventDown)); + cmd = keyMap.find(KeyCombination(context, HOTKEYF_MIDI, wParam, kKeyEventDown)); } CommandID executeCommand = kcNull; @@ -146,7 +143,7 @@ CommandID CInputHandler::KeyEvent(InputTargetContext context, UINT &nChar, UINT &/*nRepCnt*/, UINT &/*nFlags*/, KeyEventType keyEventType, CWnd* pSourceWnd) //---------------------------------------------------------------------------------------------------------------------------------------------------------- { - KeyMap::const_iterator cmd = keyMap.find(KeyMapID(context, modifierMask, nChar, keyEventType)); + KeyMap::const_iterator cmd = keyMap.find(KeyCombination(context, modifierMask, nChar, keyEventType)); CommandID executeCommand = kcNull; if(pSourceWnd == nullptr) @@ -172,11 +169,14 @@ { KeyEventType keyEventType = GetKeyEventType( HIWORD(nFlags) ); enum { VK_NonExistentKey = VK_F24+1 }; - - if( nChar == VK_NonExistentKey ) { + + if( nChar == VK_NonExistentKey ) + { return true; - } else if( m_bInterceptWindowsKeys && ( nChar == VK_LWIN || nChar == VK_RWIN ) ) { - if( keyEventType == kKeyEventDown ) { + } else if( m_bInterceptWindowsKeys && ( nChar == VK_LWIN || nChar == VK_RWIN ) ) + { + if( keyEventType == kKeyEventDown ) + { INPUT inp[2]; inp[0].type = inp[1].type = INPUT_KEYBOARD; inp[0].ki.time = inp[1].ki.time = 0; @@ -188,14 +188,17 @@ SendInput( 2, inp, sizeof(INPUT) ); } } - - if( ( nChar == VK_NUMLOCK && m_bInterceptNumLock ) || - ( nChar == VK_CAPITAL && m_bInterceptCapsLock ) || - ( nChar == VK_SCROLL && m_bInterceptScrollLock ) ) { - if( m_nSkipGeneratedKeypresses > 0 ) { + + if( ( nChar == VK_NUMLOCK && m_bInterceptNumLock ) || + ( nChar == VK_CAPITAL && m_bInterceptCapsLock ) || + ( nChar == VK_SCROLL && m_bInterceptScrollLock ) ) + { + if( m_nSkipGeneratedKeypresses > 0 ) + { m_nSkipGeneratedKeypresses -- ; return true; - } else if( keyEventType == kKeyEventDown ) { + } else if( keyEventType == kKeyEventDown ) + { m_nSkipGeneratedKeypresses = 2; INPUT inp[2]; inp[0].type = inp[1].type = INPUT_KEYBOARD; @@ -219,10 +222,10 @@ for(KeyMap::const_iterator i = keyMap.begin(); i != keyMap.end(); i++) { ASSERT(i->second != kcNull); - if(i->first.modifier == HOTKEYF_EXT) m_bInterceptWindowsKeys = true; - if(i->first.key == VK_NUMLOCK) m_bInterceptNumLock = true; - if(i->first.key == VK_CAPITAL) m_bInterceptCapsLock = true; - if(i->first.key == VK_SCROLL) m_bInterceptScrollLock = true; + if(i->first.Modifier() == HOTKEYF_EXT) m_bInterceptWindowsKeys = true; + if(i->first.KeyCode() == VK_NUMLOCK) m_bInterceptNumLock = true; + if(i->first.KeyCode() == VK_CAPITAL) m_bInterceptCapsLock = true; + if(i->first.KeyCode() == VK_SCROLL) m_bInterceptScrollLock = true; } }; @@ -233,8 +236,8 @@ { UINT tempModifierMask = 0; switch(wParam) - { - case VK_CONTROL: + { + case VK_CONTROL: /* if (m_bDistinguishControls) { if (scancode == SC_LCONTROL) tempModifierMask |= LControl; @@ -243,8 +246,8 @@ } else { -*/ tempModifierMask |= HOTKEYF_CONTROL; - break; +*/ tempModifierMask |= HOTKEYF_CONTROL; + break; // } case VK_SHIFT: @@ -256,11 +259,11 @@ } else { -*/ tempModifierMask |= HOTKEYF_SHIFT; +*/ tempModifierMask |= HOTKEYF_SHIFT; break; // } - - case VK_MENU: + + case VK_MENU: /* if (m_bDistinguishAlts) { if (scancode == SC_LALT) {tempModifierMask |= LAlt; break;} @@ -268,11 +271,11 @@ } else { -*/ tempModifierMask |= HOTKEYF_ALT; +*/ tempModifierMask |= HOTKEYF_ALT; break; // } case VK_LWIN: case VK_RWIN: // Feature: use Windows keys as modifier keys - tempModifierMask |= HOTKEYF_EXT; + tempModifierMask |= HOTKEYF_EXT; break; } @@ -281,14 +284,16 @@ if (keyEventType == kKeyEventDown) { modifierMask |= tempModifierMask; +#ifdef _DEBUG LogModifiers(modifierMask); +#endif } if (keyEventType == kKeyEventUp) modifierMask &= ~tempModifierMask; return true; } - + return false; } @@ -306,42 +311,7 @@ return kcNull; } -//-------------------------------------------------------------- -DWORD CInputHandler::GetKey(CommandID /*c*/) -//------------------------------------------ -{ - return 0;// command[c].kc.code command[c].kc.mod; -} -//------------------------------------------------------------- -//----------------------- Command Access -//-------------------------------------------------------------- - - -int CInputHandler::SetCommand(InputTargetContext context, CommandID cmd, UINT modifierMask, UINT actionKey, UINT keyEventType) -//---------------------------------------------------------------------------------------------------------------------------- -{ - int deletedCommand = -1; - - KeyCombination curKc; - curKc.code=actionKey; - curKc.ctx=context; - curKc.event=(KeyEventType)keyEventType; - curKc.mod=modifierMask; - - activeCommandSet->Add(curKc, cmd, true); - - return deletedCommand; -} - - -KeyCombination CInputHandler::GetKey(CommandID cmd, UINT key) -//----------------------------------------------------------- -{ - return activeCommandSet->GetKey(cmd, key); -} - - int CInputHandler::GetKeyListSize(CommandID cmd) //---------------------------------------------- { @@ -349,13 +319,6 @@ } -CString CInputHandler::GetCommandText(CommandID cmd) -//-------------------------------------------------- -{ - return activeCommandSet->GetCommandText(cmd); -} - - //------------------------------------------------------------- //----------------------- Misc //-------------------------------------------------------------- @@ -382,7 +345,7 @@ KeyEventType CInputHandler::GetKeyEventType(UINT nFlags) //------------------------------------------------------ -{ +{ if (nFlags & TRANSITIONBIT) { // Key released @@ -410,9 +373,9 @@ KeyCombination key; for (int k=0; k<nSelectionKeys; k++) - { + { key = activeCommandSet->GetKey(kcSelect, k); - if (modifierMask & key.mod) + if (modifierMask & key.Modifier()) { result=true; break; @@ -471,13 +434,6 @@ } -CString CInputHandler::GetCurModifierText() -//----------------------------------------- -{ - return activeCommandSet->GetModifierText(modifierMask); -} - - CString CInputHandler::GetKeyTextFromCommand(CommandID c) //------------------------------------------------------- { @@ -563,7 +519,7 @@ void CInputHandler::UpdateMainMenu() //---------------------------------- -{ +{ CMenu *pMenu = (CMainFrame::GetMainFrame())->GetMenu(); if (!pMenu) return; @@ -601,7 +557,7 @@ pMenu->ModifyMenu(ID_EDIT_FINDNEXT, MF_BYCOMMAND | MF_STRING, ID_EDIT_FINDNEXT, GetMenuText(ID_EDIT_FINDNEXT)); pMenu->ModifyMenu(ID_EDIT_GOTO_MENU, MF_BYCOMMAND | MF_STRING, ID_EDIT_GOTO_MENU, GetMenuText(ID_EDIT_GOTO_MENU)); pMenu->ModifyMenu(ID_EDIT_SPLITKEYBOARDSETTINGS, MF_BYCOMMAND | MF_STRING, ID_EDIT_SPLITKEYBOARDSETTINGS, GetMenuText(ID_EDIT_SPLITKEYBOARDSETTINGS)); - + pMenu->ModifyMenu(ID_VIEW_GLOBALS, MF_BYCOMMAND | MF_STRING, ID_VIEW_GLOBALS, GetMenuText(ID_VIEW_GLOBALS)); pMenu->ModifyMenu(ID_VIEW_SAMPLES, MF_BYCOMMAND | MF_STRING, ID_VIEW_SAMPLES, GetMenuText(ID_VIEW_SAMPLES)); pMenu->ModifyMenu(ID_VIEW_PATTERNS, MF_BYCOMMAND | MF_STRING, ID_VIEW_PATTERNS, GetMenuText(ID_VIEW_PATTERNS)); @@ -639,26 +595,26 @@ } -bool CInputHandler::isKeyPressHandledByTextBox(DWORD key) +bool CInputHandler::isKeyPressHandledByTextBox(DWORD key) //------------------------------------------------------- { //Alpha-numerics (only shift or no modifier): if(!CtrlPressed() && !AltPressed() - && ((key>='A'&&key<='Z') || (key>='0'&&key<='9') || + && ((key>='A'&&key<='Z') || (key>='0'&&key<='9') || key==VK_DIVIDE || key==VK_MULTIPLY || key==VK_SPACE || key==VK_RETURN || key==VK_CAPITAL || (key>=VK_OEM_1 && key<=VK_OEM_3) || (key>=VK_OEM_4 && key<=VK_OEM_8))) return true; - + //navigation (any modifier): - if(key == VK_LEFT || key == VK_RIGHT || key == VK_UP || key == VK_DOWN || + if(key == VK_LEFT || key == VK_RIGHT || key == VK_UP || key == VK_DOWN || key == VK_HOME || key == VK_END || key == VK_DELETE || key == VK_INSERT || key == VK_BACK) return true; - + //Copy paste etc.. - if(CMainFrame::GetInputHandler()->GetModifierMask()==HOTKEYF_CONTROL && + if(CMainFrame::GetInputHandler()->GetModifierMask()==HOTKEYF_CONTROL && (key == 'Y' || key == 'Z' || key == 'X' || key == 'C' || key == 'V' || key == 'A')) return true; return false; -} +} \ No newline at end of file Modified: trunk/OpenMPT/mptrack/InputHandler.h =================================================================== --- trunk/OpenMPT/mptrack/InputHandler.h 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/InputHandler.h 2014-01-15 17:46:44 UTC (rev 3575) @@ -12,27 +12,6 @@ #include "CommandSet.h" -//not sure why I shoved message IDs here anymore. Might want to move em. -rewbs -enum -{ - WM_MOD_UPDATEPOSITION = (WM_USER+1973), - WM_MOD_INVALIDATEPATTERNS, - WM_MOD_ACTIVATEVIEW, - WM_MOD_CHANGEVIEWCLASS, - WM_MOD_UNLOCKCONTROLS, - WM_MOD_CTRLMSG, - WM_MOD_VIEWMSG, - WM_MOD_TREEMSG, - WM_MOD_MIDIMSG, - WM_MOD_GETTOOLTIPTEXT, - WM_MOD_DRAGONDROPPING, - WM_MOD_SPECIALKEY, - WM_MOD_KBDNOTIFY, - WM_MOD_INSTRSELECTED, - WM_MOD_KEYCOMMAND, - WM_MOD_RECORDPARAM, -}; - // Hook codes enum { @@ -47,25 +26,19 @@ ~CInputHandler(); CommandID GeneralKeyEvent(InputTargetContext context, int code, WPARAM wParam , LPARAM lParam); CommandID KeyEvent(InputTargetContext context, UINT &nChar, UINT &nRepCnt, UINT &nFlags, KeyEventType keyEventType, CWnd* pSourceWnd=NULL); - int SetCommand(InputTargetContext context, CommandID command, UINT modifierMask, UINT actionKey, UINT keyEventType); KeyEventType GetKeyEventType(UINT nFlags); - DWORD GetKey(CommandID); bool isKeyPressHandledByTextBox(DWORD wparam); CommandID CInputHandler::HandleMIDIMessage(InputTargetContext context, uint32 message); - KeyCombination GetKey(CommandID cmd, UINT key); int GetKeyListSize(CommandID cmd); - CString GetCommandText(CommandID cmd); protected: CWnd *m_pMainFrm; - int AsciiToScancode(char ch); KeyMap keyMap; void LogModifiers(UINT mask); UINT modifierMask; bool m_bBypass; bool m_bNoAltMenu; - bool m_bDistinguishControls, m_bDistinguishShifts, m_bDistinguishAlts; bool CatchModifierChange(WPARAM wParam, KeyEventType keyEventType, int scancode); bool m_bInterceptWindowsKeys, m_bInterceptNumLock, m_bInterceptCapsLock, m_bInterceptScrollLock; int m_nSkipGeneratedKeypresses; @@ -82,11 +55,10 @@ void Bypass(bool); WORD GetModifierMask(); void SetModifierMask(WORD mask); - CString GetCurModifierText(); CString GetKeyTextFromCommand(CommandID c); CString GetMenuText(UINT id); void UpdateMainMenu(); void SetNewCommandSet(CCommandSet * newSet); bool noAltMenu() { return m_bNoAltMenu; }; bool SetEffectLetters(const CModSpecifications &modSpecs); -}; +}; \ No newline at end of file Modified: trunk/OpenMPT/mptrack/KeyConfigDlg.cpp =================================================================== --- trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2014-01-15 15:39:59 UTC (rev 3574) +++ trunk/OpenMPT/mptrack/KeyConfigDlg.cpp 2014-01-15 17:46:44 UTC (rev 3575) @@ -30,7 +30,7 @@ if(MIDIEvents::GetTypeFromEvent(dwMidiDataParam) == MIDIEvents::evControllerChange && MIDIEvents::GetDataByte2FromEvent(dwMidiDataParam) != 0 && isFocussed) { SetKey(HOTKEYF_MIDI, MIDIEvents::GetDataByte1FromEvent(dwMidiDataParam)); - m_pOptKeyDlg->OnSetKeyChoice(); + m_pOptKeyDlg->OnSetKeyChoice(); } return 1; } @@ -65,7 +65,7 @@ mod = inMod; code = inCode; //Setup display - SetWindowText(CMainFrame::GetInputHandler()->activeCommandSet->GetKeyText(mod, code)); + SetWindowText(KeyCombination::GetKeyText(mod, code)); } @@ -131,7 +131,7 @@ { CPropertyPage::DoDataExchange(pDX); DDX_Control(pDX, IDC_KEYCATEGORY, m_cmbCategory); - DDX_Control(pDX, IDC_COMMAND_LIST, m_lbnCommandKeys); + DDX_Control(pDX, IDC_COMMAND_LIST, m_lbnCommandKeys); DDX_Control(pDX, IDC_CHOICECOMBO, m_cmbKeyChoice); DDX_Control(pDX, IDC_CHORDDETECTWAITTIME, m_eChordWaitTime);//rewbs.autochord DDX_Control(pDX, IDC_KEYREPORT, m_eReport); @@ -163,17 +163,17 @@ m_bModified = false; m_bChoiceModified = false; m_sFullPathName = TrackerSettings::Instance().m_szKbdFile; - + plocalCmdSet = new CCommandSet(); plocalCmdSet->Copy(CMainFrame::GetInputHandler()->activeCommandSet); - + //Fill category combo and automatically selects first category DefineCommandCategories(); for (int c=0; c<commandCategories.GetSize(); c++) { if (commandCategories[c].name && commandCategories[c].commands.GetCount()) m_cmbCategory.SetItemData(m_cmbCategory.AddString(commandCategories[c].name), c); - } + } m_cmbCategory.SetCurSel(0); UpdateDialog(); @@ -518,7 +518,7 @@ for(size_t choice = 0; choice < numChoices; choice++) { const KeyCombination &kc = plocalCmdSet->GetKey(com, choice); - if(kc.code == m_eFindHotKey.code && kc.mod == m_eFindHotKey.mod) + if(kc.KeyCode() == m_eFindHotKey.code && kc.Modifier() == m_eFindHotKey.mod) { addKey = true; break; @@ -595,17 +595,17 @@ else if ((nCmd >= 0) && (nCmd != m_nCurHotKey) || m_bForceUpdate) //have we changed command? { m_bForceUpdate = false; - + m_cmbKeyChoice.EnableWindow(TRUE); m_eCustHotKey.Enab... [truncated message content] |
From: <sag...@us...> - 2014-01-15 20:43:13
|
Revision: 3577 http://sourceforge.net/p/modplug/code/3577 Author: saga-games Date: 2014-01-15 20:43:07 +0000 (Wed, 15 Jan 2014) Log Message: ----------- [Imp] Default keybindings are now automatically added when loading existing, possibly incomplete keybindings (http://bugs.openmpt.org/view.php?id=4). Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2014-01-15 18:39:04 UTC (rev 3576) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2014-01-15 20:43:07 UTC (rev 3577) @@ -1506,24 +1506,24 @@ } -bool CCommandSet::LoadFile(std::istream& iStrm, const std::wstring &filenameDescription) -//-------------------------------------------------------------------------------------- +bool CCommandSet::LoadFile(std::istream& iStrm, const std::wstring &filenameDescription, CCommandSet *commandSet) +//--------------------------------------------------------------------------------------------------------------- { KeyCombination kc; CommandID cmd=kcNumCommands; char s[1024]; CString curLine, token; int commentStart; - CCommandSet *pTempCS; int l=0; int fileVersion = 0; - pTempCS = new CCommandSet(); + // If commandSet is valid, add new commands to it (this is used for adding the default shortcuts to existing keymaps) + CCommandSet *pTempCS = commandSet ? commandSet : new CCommandSet(); int errorCount=0; CString errText = ""; - while(iStrm.getline(s, sizeof(s))) + while(iStrm.getline(s, CountOf(s))) { curLine = s; @@ -1612,10 +1612,9 @@ errText += err + "\n"; Log(err); } - } - else + } else { - pTempCS->Add(kc, cmd, true); + pTempCS->Add(kc, cmd, commandSet == nullptr); } } @@ -1623,6 +1622,26 @@ l++; } + //if(fileVersion < KEYMAP_VERSION) UpgradeKeymap(pTempCS, fileVersion); + + if(commandSet == nullptr) + { + // Add the default command set to our freshly loaded command set. + const char *pData = nullptr; + HGLOBAL hglob = nullptr; + size_t nSize = 0; + if(LoadResource(MAKEINTRESOURCE(IDR_DEFAULT_KEYBINDINGS), TEXT("KEYBINDINGS"), pData, nSize, hglob) != nullptr) + { + std::istringstream iStrm(std::string(pData, nSize)); + LoadFile(iStrm, std::wstring(), pTempCS); + FreeResource(hglob); + } + } else + { + // We were just adding stuff to an existing command set - don't delete it! + return true; + } + if(!errText.IsEmpty()) { std::wstring err = L"The following problems have been encountered while trying to load the key binding file " + filenameDescription + L":\n"; @@ -1630,8 +1649,6 @@ Reporting::Warning(err); } - if(fileVersion < KEYMAP_VERSION) UpgradeKeymap(pTempCS, fileVersion); - Copy(pTempCS); delete pTempCS; @@ -1656,93 +1673,11 @@ bool CCommandSet::LoadDefaultKeymap() //----------------------------------- { - bool success = false; - const char* pData = nullptr; - HGLOBAL hglob = nullptr; - size_t nSize = 0; - if (LoadResource(MAKEINTRESOURCE(IDR_DEFAULT_KEYBINDINGS), TEXT("KEYBINDINGS"), pData, nSize, hglob) != nullptr) - { - std::istringstream iStrm(std::string(pData, nSize)); - success = LoadFile(iStrm, L"\"executable resource\""); - FreeResource(hglob); - } - return success; + std::istringstream s; + return LoadFile(s, L"\"executable resource\""); } -// Fix outdated keymap files -void CCommandSet::UpgradeKeymap(CCommandSet *pCommands, int oldVersion) -//--------------------------------------------------------------------- -{ - // no orderlist context - if(oldVersion == 0) - { - KeyCombination kc(kCtxCtrlOrderlist, 0, 0, kKeyEventDown | kKeyEventRepeat); - - kc.KeyCode(VK_DELETE); - pCommands->Add(kc, kcOrderlistEditDelete, false); - - kc.KeyCode(VK_INSERT); - pCommands->Add(kc, kcOrderlistEditInsert, false); - - kc.KeyCode(VK_RETURN); - pCommands->Add(kc, kcOrderlistEditPattern, false); - - kc.KeyCode(VK_TAB); - pCommands->Add(kc, kcOrderlistSwitchToPatternView, false); - - kc.KeyCode(VK_LEFT); - pCommands->Add(kc, kcOrderlistNavigateLeft, false); - kc.KeyCode(VK_UP); - pCommands->Add(kc, kcOrderlistNavigateLeft, false); - - kc.KeyCode(VK_RIGHT); - pCommands->Add(kc, kcOrderlistNavigateRight, false); - kc.KeyCode(VK_DOWN); - pCommands->Add(kc, kcOrderlistNavigateRight, false); - - kc.KeyCode(VK_HOME); - pCommands->Add(kc, kcOrderlistNavigateFirst, false); - - kc.KeyCode(VK_END); - pCommands->Add(kc, kcOrderlistNavigateLast, false); - - kc.KeyCode(VK_ADD); - pCommands->Add(kc, kcOrderlistPatPlus, false); - kc.KeyCode(VK_OEM_PLUS); - pCommands->Add(kc, kcOrderlistPatPlus, false); - - kc.KeyCode(VK_SUBTRACT); - pCommands->Add(kc, kcOrderlistPatMinus, false); - kc.KeyCode(VK_OEM_MINUS); - pCommands->Add(kc, kcOrderlistPatMinus, false); - - STATIC_ASSERT(VK_NUMPAD0 + 9 == VK_NUMPAD9); - STATIC_ASSERT(kcOrderlistPat0 + 9 == kcOrderlistPat9); - for(int i = 0; i <= 9; i++) - { - kc.KeyCode('0' + i); - pCommands->Add(kc, static_cast<CommandID>(kcOrderlistPat0 + i), false); - kc.KeyCode(VK_NUMPAD0 + i); - pCommands->Add(kc, static_cast<CommandID>(kcOrderlistPat0 + i), false); - } - - kc.KeyCode('I'); - pCommands->Add(kc, kcOrderlistPatIgnore, false); - - kc.KeyCode(VK_SPACE); - pCommands->Add(kc, kcOrderlistPatInvalid, false); - - kc.KeyCode('L'); - kc.Modifier(HOTKEYF_CONTROL); - pCommands->Add(kc, kcOrderlistLockPlayback, false); - - kc.KeyCode('U'); - pCommands->Add(kc, kcOrderlistUnlockPlayback, false); - } -} - - //Could do better search algo but this is not perf critical. int CCommandSet::FindCmd(int uid) //------------------------------- Modified: trunk/OpenMPT/mptrack/CommandSet.h =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h 2014-01-15 18:39:04 UTC (rev 3576) +++ trunk/OpenMPT/mptrack/CommandSet.h 2014-01-15 20:43:07 UTC (rev 3577) @@ -1233,12 +1233,6 @@ }; -struct Rule -{ - UINT ID; - CString desc; - bool enforce; -}; enum RuleID { @@ -1315,8 +1309,7 @@ void GenKeyMap(KeyMap &km); // Generate a keymap from this command set bool SaveFile(const mpt::PathString &filename); bool LoadFile(const mpt::PathString &filename); - bool LoadFile(std::istream& iStrm, const std::wstring &filenameDescription); + bool LoadFile(std::istream& iStrm, const std::wstring &filenameDescription, CCommandSet *commandSet = nullptr); bool LoadDefaultKeymap(); - void UpgradeKeymap(CCommandSet *pCommands, int oldVersion); }; Modified: trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb =================================================================== --- trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb 2014-01-15 18:39:04 UTC (rev 3576) +++ trunk/OpenMPT/mptrack/res/defaultKeybindings.mkb 2014-01-15 20:43:07 UTC (rev 3577) @@ -387,7 +387,7 @@ 19:1817:0:187:5 //Increase pattern index : = (KeyDown|KeyHold) 19:1818:0:109:5 //Decrease pattern index: NUM SUB (KeyDown|KeyHold) 19:1818:0:189:5 //Decrease pattern index: - (KeyDown|KeyHold) -19:1853:0:83:1 //Separator (+++) Index: S (KeyDown) +19:1853:0:73:1 //Separator (+++) Index: I (KeyDown) 19:1854:0:32:1 //Stop (---) Index: SPACE (KeyDown) 19:1875:2:76:1 //Lock Playback to Selection: Ctrl+L (KeyDown) 19:1876:2:85:1 //Unlock Playback: Ctrl+U (KeyDown) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-02-01 23:53:18
|
Revision: 3626 http://sourceforge.net/p/modplug/code/3626 Author: manxorist Date: 2014-02-01 23:53:08 +0000 (Sat, 01 Feb 2014) Log Message: ----------- [Imp] ASIO: Allow specifying a flexible channel mapping instead just the base channel offset in soundcard settings. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mpdlgs.cpp trunk/OpenMPT/mptrack/Mpdlgs.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/Mpdlgs.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-02-01 23:11:40 UTC (rev 3625) +++ trunk/OpenMPT/mptrack/Mpdlgs.cpp 2014-02-01 23:53:08 UTC (rev 3626) @@ -59,6 +59,7 @@ + BEGIN_MESSAGE_MAP(COptionsSoundcard, CPropertyPage) ON_WM_HSCROLL() ON_WM_VSCROLL() @@ -72,14 +73,17 @@ ON_CBN_SELCHANGE(IDC_COMBO_UPDATEINTERVAL, OnSettingsChanged) ON_CBN_SELCHANGE(IDC_COMBO3, OnSettingsChanged) ON_CBN_SELCHANGE(IDC_COMBO4, OnSettingsChanged) - ON_CBN_SELCHANGE(IDC_COMBO5, OnSettingsChanged) + ON_CBN_SELCHANGE(IDC_COMBO5, OnChannelsChanged) ON_CBN_SELCHANGE(IDC_COMBO6, OnSampleFormatChanged) ON_CBN_SELCHANGE(IDC_COMBO10, OnSettingsChanged) - ON_CBN_SELCHANGE(IDC_COMBO9, OnSettingsChanged) ON_CBN_EDITCHANGE(IDC_COMBO2, OnSettingsChanged) ON_CBN_EDITCHANGE(IDC_COMBO_UPDATEINTERVAL, OnSettingsChanged) ON_COMMAND(IDC_BUTTON1, OnSoundCardRescan) ON_COMMAND(IDC_BUTTON2, OnSoundCardDriverPanel) + ON_CBN_SELCHANGE(IDC_COMBO_CHANNEL_FRONTLEFT, OnChannel1Changed) + ON_CBN_SELCHANGE(IDC_COMBO_CHANNEL_FRONTRIGHT, OnChannel2Changed) + ON_CBN_SELCHANGE(IDC_COMBO_CHANNEL_REARLEFT, OnChannel3Changed) + ON_CBN_SELCHANGE(IDC_COMBO_CHANNEL_REARRIGHT, OnChannel4Changed) END_MESSAGE_MAP() @@ -103,8 +107,16 @@ DDX_Control(pDX, IDC_COMBO5, m_CbnChannels); DDX_Control(pDX, IDC_COMBO6, m_CbnSampleFormat); DDX_Control(pDX, IDC_COMBO10, m_CbnDither); - DDX_Control(pDX, IDC_COMBO9, m_CbnBaseChannel); DDX_Control(pDX, IDC_BUTTON2, m_BtnDriverPanel); + DDX_Control(pDX, IDC_COMBO6, m_CbnSampleFormat); + DDX_Control(pDX, IDC_STATIC_CHANNEL_FRONTLEFT , m_StaticChannelMapping[0]); + DDX_Control(pDX, IDC_STATIC_CHANNEL_FRONTRIGHT, m_StaticChannelMapping[1]); + DDX_Control(pDX, IDC_STATIC_CHANNEL_REARLEFT , m_StaticChannelMapping[2]); + DDX_Control(pDX, IDC_STATIC_CHANNEL_REARRIGHT , m_StaticChannelMapping[3]); + DDX_Control(pDX, IDC_COMBO_CHANNEL_FRONTLEFT , m_CbnChannelMapping[0]); + DDX_Control(pDX, IDC_COMBO_CHANNEL_FRONTRIGHT, m_CbnChannelMapping[1]); + DDX_Control(pDX, IDC_COMBO_CHANNEL_REARLEFT , m_CbnChannelMapping[2]); + DDX_Control(pDX, IDC_COMBO_CHANNEL_REARRIGHT , m_CbnChannelMapping[3]); DDX_Control(pDX, IDC_EDIT_STATISTICS, m_EditStatistics); //}}AFX_DATA_MAP } @@ -304,6 +316,7 @@ UpdateChannels(); UpdateSampleFormat(); UpdateDither(); + UpdateChannelMapping(); } @@ -330,24 +343,6 @@ } } m_CbnChannels.SetCurSel(sel); - - GetDlgItem(IDC_STATIC_BASECHANNEL)->EnableWindow(m_CurrentDeviceCaps.CanChannelMapping ? TRUE : FALSE); - m_CbnBaseChannel.EnableWindow(m_CurrentDeviceCaps.CanChannelMapping ? TRUE : FALSE); - m_CbnBaseChannel.ResetContent(); - if(m_CurrentDeviceCaps.CanChannelMapping) - { - int sel = 0; - for(std::size_t channel = 0; channel < m_CurrentDeviceCaps.channelNames.size(); ++channel) - { - int ndx = m_CbnBaseChannel.AddString(mpt::ToCString(m_CurrentDeviceCaps.channelNames[channel])); - m_CbnBaseChannel.SetItemData(ndx, channel); - if(channel == m_Settings.ChannelMapping.GetBaseChannel()) - { - sel = ndx; - } - } - m_CbnBaseChannel.SetCurSel(sel); - } } @@ -420,6 +415,38 @@ } +void COptionsSoundcard::UpdateChannelMapping() +//-------------------------------------------- +{ + int usedChannels = m_CbnChannels.GetItemData(m_CbnChannels.GetCurSel()); + for(int mch = 0; mch < NUM_CHANNELCOMBOBOXES; mch++) // Host channels + { + CStatic *statictext = &m_StaticChannelMapping[mch]; + CComboBox *combo = &m_CbnChannelMapping[mch]; + statictext->EnableWindow((m_CurrentDeviceCaps.CanChannelMapping && mch < usedChannels) ? TRUE : FALSE); + combo->EnableWindow((m_CurrentDeviceCaps.CanChannelMapping && mch < usedChannels) ? TRUE : FALSE); + combo->ResetContent(); + if(m_CurrentDeviceCaps.CanChannelMapping) + { + combo->SetItemData(combo->AddString("Unassigned"), (DWORD_PTR)-1); + combo->SetCurSel(0); + if(mch < usedChannels) + { + for(size_t dch = 0; dch < m_CurrentDeviceCaps.channelNames.size(); dch++) // Device channels + { + const int pos = (int)::SendMessageW(combo->m_hWnd, CB_ADDSTRING, 0, (LPARAM)m_CurrentDeviceCaps.channelNames[dch].c_str()); + combo->SetItemData(pos, (DWORD_PTR)dch); + if(dch == m_Settings.ChannelMapping.ToDevice(mch)) + { + combo->SetCurSel(pos); + } + } + } + } + } +} + + void COptionsSoundcard::OnDeviceChanged() //--------------------------------------- { @@ -433,6 +460,14 @@ } +void COptionsSoundcard::OnChannelsChanged() +//----------------------------------------- +{ + UpdateChannelMapping(); + OnSettingsChanged(); +} + + void COptionsSoundcard::OnSoundCardDriverPanel() //---------------------------------------------- { @@ -440,6 +475,58 @@ } +void COptionsSoundcard::OnChannelChanged(int channel) +//--------------------------------------------------- +{ + CComboBox *combo = &m_CbnChannelMapping[channel]; + const int newChn = combo->GetItemData(combo->GetCurSel()); + if(newChn == -1) + { + return; + } + // Ensure that no channel is used twice + for(int mch = 0; mch < NUM_CHANNELCOMBOBOXES; mch++) // Host channels + { + if(mch != channel) + { + combo = &m_CbnChannelMapping[mch]; + if((int)combo->GetItemData(combo->GetCurSel()) == newChn) + { + // find an unused channel + bool found = false; + std::size_t deviceChannel = 0; + for(; deviceChannel < m_CurrentDeviceCaps.channelNames.size(); ++deviceChannel) + { + bool used = false; + for(int hostChannel = 0; hostChannel < NUM_CHANNELCOMBOBOXES; ++hostChannel) + { + if((int)m_CbnChannelMapping[hostChannel].GetItemData(m_CbnChannelMapping[hostChannel].GetCurSel()) == (int)deviceChannel) + { + used = true; + break; + } + } + if(!used) + { + found = true; + break; + } + } + if(found) + { + combo->SetCurSel(deviceChannel+1); + } else + { + combo->SetCurSel(0); + } + break; + } + } + } + OnSettingsChanged(); +} + + // Fill the dropdown box with a list of valid sample rates, depending on the selected sound device. void COptionsSoundcard::UpdateSampleRates() //----------------------------------------- @@ -556,11 +643,21 @@ wsprintf(s, "%d ms", m_Settings.UpdateIntervalMS); m_CbnUpdateIntervalMS.SetWindowText(s); } - // Base Channel + // Channel Mapping { - if(m_CurrentDeviceInfo.id.GetType() == SNDDEV_ASIO) + if(m_CurrentDeviceCaps.CanChannelMapping) { - m_Settings.ChannelMapping = SoundChannelMapping::BaseChannel(m_Settings.Channels, m_CbnBaseChannel.GetItemData(m_CbnBaseChannel.GetCurSel())); + int numChannels = std::min<int>(m_Settings.Channels, NUM_CHANNELCOMBOBOXES); + std::vector<uint32> channels(numChannels); + for(int mch = 0; mch < numChannels; mch++) // Host channels + { + CComboBox *combo = &m_CbnChannelMapping[mch]; + channels[mch] = combo->GetItemData(combo->GetCurSel()); + } + m_Settings.ChannelMapping = SoundChannelMapping(channels); + } else + { + m_Settings.ChannelMapping = SoundChannelMapping(); } } CMainFrame::GetMainFrame()->SetupSoundCard(m_Settings, m_CurrentDeviceInfo.id); Modified: trunk/OpenMPT/mptrack/Mpdlgs.h =================================================================== --- trunk/OpenMPT/mptrack/Mpdlgs.h 2014-02-01 23:11:40 UTC (rev 3625) +++ trunk/OpenMPT/mptrack/Mpdlgs.h 2014-02-01 23:53:08 UTC (rev 3626) @@ -13,6 +13,8 @@ class CSoundFile; class CMainFrame; +#define NUM_CHANNELCOMBOBOXES 4 + //=========================================== class COptionsSoundcard: public CPropertyPage //=========================================== @@ -20,10 +22,12 @@ protected: CComboBoxEx m_CbnDevice; CComboBox m_CbnLatencyMS, m_CbnUpdateIntervalMS, m_CbnMixingFreq, m_CbnChannels, m_CbnSampleFormat, m_CbnDither; - CComboBox m_CbnBaseChannel; CEdit m_EditStatistics; CButton m_BtnDriverPanel; + CStatic m_StaticChannelMapping[NUM_CHANNELCOMBOBOXES]; + CComboBox m_CbnChannelMapping[NUM_CHANNELCOMBOBOXES]; + void SetDevice(SoundDeviceID dev, bool forceReload=false); SoundDeviceInfo m_CurrentDeviceInfo; SoundDeviceCaps m_CurrentDeviceCaps; @@ -43,6 +47,7 @@ void UpdateChannels(); void UpdateSampleFormat(); void UpdateDither(); + void UpdateChannelMapping(); void UpdateControls(); protected: @@ -51,11 +56,20 @@ virtual BOOL OnSetActive(); virtual void DoDataExchange(CDataExchange* pDX); void UpdateStereoSep(); + afx_msg void OnDeviceChanged(); afx_msg void OnSettingsChanged() { SetModified(TRUE); } + afx_msg void OnChannelsChanged(); afx_msg void OnSampleFormatChanged(); afx_msg void OnSoundCardRescan(); afx_msg void OnSoundCardDriverPanel(); + + void OnChannelChanged(int channel); + afx_msg void OnChannel1Changed() { OnChannelChanged(0); }; + afx_msg void OnChannel2Changed() { OnChannelChanged(1); }; + afx_msg void OnChannel3Changed() { OnChannelChanged(2); }; + afx_msg void OnChannel4Changed() { OnChannelChanged(3); }; + DECLARE_MESSAGE_MAP() }; Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-02-01 23:11:40 UTC (rev 3625) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-02-01 23:53:08 UTC (rev 3626) @@ -1290,7 +1290,7 @@ CAPTION "Sound Card" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - GROUPBOX "&Device",IDC_STATIC,6,6,264,120 + GROUPBOX "&Device",IDC_STATIC,6,6,264,174 CONTROL "",IDC_COMBO1,"ComboBoxEx32",CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP,12,18,252,96 PUSHBUTTON "&Setup device ...",IDC_BUTTON2,48,36,72,12 PUSHBUTTON "&Rescan device list",IDC_BUTTON1,198,36,66,12 @@ -1302,19 +1302,26 @@ COMBOBOX IDC_COMBO3,48,90,54,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO5,108,90,42,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_COMBO6,156,90,36,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + COMBOBOX IDC_COMBO10,198,90,66,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Use device exclusively",IDC_CHECK4,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,54,84,12 CONTROL "Keep running",IDC_CHECK8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,198,54,66,12 CONTROL "&Boost thread priority",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,72,84,12 CONTROL "Hardware timing",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,198,72,66,12 - LTEXT "Base &channel:",IDC_STATIC_BASECHANNEL,12,108,48,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO9,66,108,198,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "General",IDC_STATIC,6,132,264,48 + LTEXT "Channel &mapping:",IDC_STATIC,12,108,60,12,SS_CENTERIMAGE + CTEXT "Front Left",IDC_STATIC_CHANNEL_FRONTLEFT,78,108,48,12,SS_CENTERIMAGE,WS_EX_STATICEDGE + COMBOBOX IDC_COMBO_CHANNEL_FRONTLEFT,132,108,132,72,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CTEXT "Front Right",IDC_STATIC_CHANNEL_FRONTRIGHT,78,126,48,12,SS_CENTERIMAGE,WS_EX_STATICEDGE + COMBOBOX IDC_COMBO_CHANNEL_FRONTRIGHT,132,126,132,72,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CTEXT "Rear Left",IDC_STATIC_CHANNEL_REARLEFT,78,144,48,12,SS_CENTERIMAGE,WS_EX_STATICEDGE + COMBOBOX IDC_COMBO_CHANNEL_REARLEFT,132,144,132,72,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + CTEXT "Rear Right",IDC_STATIC_CHANNEL_REARRIGHT,78,162,48,12,SS_CENTERIMAGE,WS_EX_STATICEDGE + COMBOBOX IDC_COMBO_CHANNEL_REARRIGHT,132,162,132,72,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "General",IDC_STATIC,6,186,264,30 CONTROL "Keep device &open when playback is stopped",IDC_CHECK6, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,144,162,12 - CONTROL "Open device at &startup",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,24,162,162,12 - GROUPBOX "Stat&istics",IDC_STATIC,6,186,264,60 - EDITTEXT IDC_EDIT_STATISTICS,12,197,252,42,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP - COMBOBOX IDC_COMBO10,198,90,66,80,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,198,156,12 + CONTROL "Open device at &startup",IDC_CHECK7,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,174,198,90,12 + GROUPBOX "Stat&istics",IDC_STATIC,6,222,264,55 + EDITTEXT IDC_EDIT_STATISTICS,12,233,252,38,ES_MULTILINE | ES_AUTOHSCROLL | ES_READONLY | NOT WS_TABSTOP END IDD_MIDIMACRO DIALOGEX 0, 0, 358, 354 Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2014-02-01 23:11:40 UTC (rev 3625) +++ trunk/OpenMPT/mptrack/resource.h 2014-02-01 23:53:08 UTC (rev 3626) @@ -946,6 +946,14 @@ #define IDC_EDIT_VOLRAMP_SAMPLES_UP 2468 #define IDC_EDIT_VOLRAMP_SAMPLES_DOWN 2469 #define IDC_CHECK_KEEPDEVICEOPEN 2470 +#define IDC_STATIC_CHANNEL_FRONTLEFT 2471 +#define IDC_STATIC_CHANNEL_FRONTRIGHT 2472 +#define IDC_STATIC_CHANNEL_REARLEFT 2473 +#define IDC_STATIC_CHANNEL_REARRIGHT 2474 +#define IDC_COMBO_CHANNEL_FRONTLEFT 2475 +#define IDC_COMBO_CHANNEL_FRONTRIGHT 2476 +#define IDC_COMBO_CHANNEL_REARLEFT 2477 +#define IDC_COMBO_CHANNEL_REARRIGHT 2478 #define ID_FILE_NEWMOD 32771 #define ID_FILE_NEWXM 32772 #define ID_FILE_NEWS3M 32773 @@ -1227,7 +1235,7 @@ #define _APS_3D_CONTROLS 1 #define _APS_NEXT_RESOURCE_VALUE 541 #define _APS_NEXT_COMMAND_VALUE 44643 -#define _APS_NEXT_CONTROL_VALUE 2471 +#define _APS_NEXT_CONTROL_VALUE 2479 #define _APS_NEXT_SYMED_VALUE 901 #endif #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-02 16:25:34
|
Revision: 3630 http://sourceforge.net/p/modplug/code/3630 Author: saga-games Date: 2014-02-02 16:25:26 +0000 (Sun, 02 Feb 2014) Log Message: ----------- [Mod] Mostly cosmetic changes to mixer setup dialog. Removed unused IDD_SETUP_REVERB dialog resource which will never ever be needed again. Modified Paths: -------------- trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-02-02 14:35:50 UTC (rev 3629) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-02-02 16:25:26 UTC (rev 3630) @@ -1307,7 +1307,7 @@ CONTROL "Keep running",IDC_CHECK8,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,198,54,66,12 CONTROL "&Boost thread priority",IDC_CHECK5,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,108,72,84,12 CONTROL "Hardware timing",IDC_CHECK9,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,198,72,66,12 - LTEXT "Channel &mapping:",IDC_STATIC,12,108,60,12,SS_CENTERIMAGE + LTEXT "Channel &Mapping:",IDC_STATIC,12,108,60,12,SS_CENTERIMAGE CTEXT "Front Left",IDC_STATIC_CHANNEL_FRONTLEFT,78,108,48,12,SS_CENTERIMAGE,WS_EX_STATICEDGE COMBOBOX IDC_COMBO_CHANNEL_FRONTLEFT,132,108,132,72,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CTEXT "Front Right",IDC_STATIC_CHANNEL_FRONTRIGHT,78,126,48,12,SS_CENTERIMAGE,WS_EX_STATICEDGE @@ -1467,40 +1467,6 @@ BEGIN END -IDD_SETUP_REVERB DIALOG 0, 0, 240, 156 -STYLE DS_SETFONT | WS_CHILD | WS_CAPTION -CAPTION "Reverb" -FONT 8, "MS Shell Dlg" -BEGIN - GROUPBOX "",IDC_STATIC,4,3,232,59 - GROUPBOX "Early reflections",IDC_STATIC,4,68,78,71 - LTEXT "Master level:",IDC_STATIC,10,13,44,8 - CONTROL "Slider1",IDC_SLIDER1,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,10,23,70,11 - LTEXT "HF level:",IDC_STATIC,10,34,43,8 - CONTROL "Slider1",IDC_SLIDER2,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,10,45,70,11 - CTEXT "Diffusion",IDC_STATIC,91,13,53,8 - CONTROL "Slider1",IDC_SLIDER3,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,91,23,53,11 - CTEXT "Density",IDC_STATIC,91,34,53,8 - CONTROL "Slider1",IDC_SLIDER4,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,91,45,53,11 - GROUPBOX "Late reverberation",IDC_STATIC,86,68,150,71 - LTEXT "Level:",IDC_STATIC,9,81,67,8 - CONTROL "Slider1",IDC_SLIDER5,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,9,92,67,12 - LTEXT "Delay:",IDC_STATIC,9,111,67,8 - CONTROL "Slider1",IDC_SLIDER6,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,9,121,67,12 - LTEXT "Level:",IDC_STATIC,91,81,67,8 - CONTROL "Slider1",IDC_SLIDER7,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,91,92,67,12 - LTEXT "Delay:",IDC_STATIC,91,111,67,8 - CONTROL "Slider1",IDC_SLIDER8,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,91,121,67,12 - LTEXT "Decay time:",IDC_STATIC,165,81,67,8 - CONTROL "Slider1",IDC_SLIDER9,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,165,92,67,12 - LTEXT "Brightness",IDC_STATIC,165,111,67,8 - CONTROL "Slider1",IDC_SLIDER10,"msctls_trackbar32",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,165,121,67,12 - COMBOBOX IDC_COMBO1,152,23,77,144,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Preset:",IDC_STATIC,152,13,29,8 - PUSHBUTTON "Load",IDC_BUTTON1,152,39,36,14 - PUSHBUTTON "Save",IDC_BUTTON2,193,39,36,14 -END - IDD_EFFECTVISUALIZER DIALOGEX 0, 0, 422, 109 STYLE DS_SETFONT | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE @@ -1606,33 +1572,33 @@ CAPTION "Mixer" FONT 8, "MS Shell Dlg", 400, 0, 0x0 BEGIN - GROUPBOX "Resampling",IDC_STATIC,6,6,264,66 + GROUPBOX "Resampling",IDC_STATIC,6,6,264,48 LTEXT "Filter:",IDC_STATIC,12,18,24,12,SS_CENTERIMAGE COMBOBOX IDC_COMBO_FILTER,54,18,90,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - LTEXT "Bandwidth:",IDC_STATIC,12,36,42,12,SS_CENTERIMAGE - EDITTEXT IDC_WFIRCUTOFF,54,36,18,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - LTEXT "%",IDC_STATIC,78,36,8,12,SS_CENTERIMAGE - LTEXT "Window:",IDC_STATIC,12,54,30,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_FILTERWINDOW,54,54,84,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP - GROUPBOX "Volume Ramping",IDC_STATIC,6,78,264,48 - LTEXT "\xB5s up",IDC_STATIC,42,90,22,12,SS_CENTERIMAGE - EDITTEXT IDC_RAMPING_IN,12,90,24,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_EDIT_VOLRAMP_SAMPLES_UP,78,90,90,12,ES_AUTOHSCROLL | ES_READONLY - LTEXT "\xB5s down",IDC_STATIC,42,110,28,11,SS_CENTERIMAGE - EDITTEXT IDC_RAMPING_OUT,12,108,24,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER - EDITTEXT IDC_EDIT_VOLRAMP_SAMPLES_DOWN,78,108,90,12,ES_AUTOHSCROLL | ES_READONLY - GROUPBOX "Polyphony",IDC_STATIC,6,132,264,30 - LTEXT "Maximum Mixed Channels:",IDC_STATIC,12,144,84,12,SS_CENTERIMAGE - COMBOBOX IDC_COMBO_POLYPHONY,102,144,66,88,CBS_DROPDOWNLIST | WS_TABSTOP - GROUPBOX "Behaviour",IDC_STATIC,6,168,264,30 - LTEXT "Stereo Separation:",IDC_STATIC,12,180,62,8 - CONTROL "",IDC_SLIDER_STEREOSEP,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,78,180,54,12 - LTEXT "100%",IDC_TEXT_STEREOSEP,132,180,20,8 - GROUPBOX "Pre-1.17RC3 mixing levels",IDC_STATIC,6,204,264,60 - CONTROL "Soft Panning",IDC_CHECK_SOFTPAN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,222,60,12 - LTEXT "Pre-Amp",IDC_STATIC,78,222,30,12,SS_CENTERIMAGE - CONTROL "",IDC_SLIDER_PREAMP,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_TOOLTIPS | WS_TABSTOP,108,216,96,24 - LTEXT "Note: Pre-Amp and Soft Panning settings are ignored by songs with mix levels set to 1.17RC3 or later in Song Properties.",IDC_STATIC,12,240,204,18 + LTEXT "Bandwidth:",IDC_STATIC,156,18,42,12,SS_CENTERIMAGE + EDITTEXT IDC_WFIRCUTOFF,198,18,18,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER + LTEXT "%",IDC_STATIC,222,18,24,12,SS_CENTERIMAGE + LTEXT "Window:",IDC_STATIC,12,36,30,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_FILTERWINDOW,54,36,84,56,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + GROUPBOX "Volume Ramping",IDC_STATIC,6,60,264,48 + LTEXT "\xB5s up",IDC_STATIC,42,72,22,12,SS_CENTERIMAGE + EDITTEXT IDC_RAMPING_IN,12,72,24,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_EDIT_VOLRAMP_SAMPLES_UP,78,72,90,12,ES_AUTOHSCROLL | ES_READONLY + LTEXT "\xB5s down",IDC_STATIC,42,92,28,11,SS_CENTERIMAGE + EDITTEXT IDC_RAMPING_OUT,12,90,24,12,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER + EDITTEXT IDC_EDIT_VOLRAMP_SAMPLES_DOWN,78,90,90,12,ES_AUTOHSCROLL | ES_READONLY + GROUPBOX "Polyphony",IDC_STATIC,6,114,264,30 + LTEXT "Maximum Mixed Channels:",IDC_STATIC,12,126,84,12,SS_CENTERIMAGE + COMBOBOX IDC_COMBO_POLYPHONY,102,126,66,88,CBS_DROPDOWNLIST | WS_TABSTOP + GROUPBOX "Behaviour",IDC_STATIC,6,150,264,30 + LTEXT "Stereo Separation:",IDC_STATIC,12,162,62,8 + CONTROL "",IDC_SLIDER_STEREOSEP,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,78,162,54,12 + LTEXT "100%",IDC_TEXT_STEREOSEP,132,162,36,8 + GROUPBOX "Pre-1.17RC3 mixing levels",IDC_STATIC,6,186,264,72 + CONTROL "Soft Panning",IDC_CHECK_SOFTPAN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,204,66,12 + LTEXT "Sample Pre-Amp:",IDC_STATIC,90,204,60,12,SS_CENTERIMAGE + CONTROL "",IDC_SLIDER_PREAMP,"msctls_trackbar32",TBS_AUTOTICKS | TBS_BOTH | TBS_TOOLTIPS | WS_TABSTOP,156,198,96,24 + LTEXT "Warning: Only samples are affected by these settings! Modifying them will change the balance between samples and plugins in songs with mix levels set to 1.17RC2 or earlier in the Song Properties! ",IDC_STATIC,12,222,252,30 END @@ -1665,6 +1631,10 @@ BOTTOMMARGIN, 236 END + IDD_PROGRESS, DIALOG + BEGIN + END + IDD_OPTIONS_KEYBOARD, DIALOG BEGIN RIGHTMARGIN, 268 @@ -1780,6 +1750,10 @@ BOTTOMMARGIN, 65 END + IDD_SETUP_EQ, DIALOG + BEGIN + END + IDD_OPTIONS_AUTHOR, DIALOG BEGIN BOTTOMMARGIN, 150 Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2014-02-02 14:35:50 UTC (rev 3629) +++ trunk/OpenMPT/mptrack/resource.h 2014-02-02 16:25:26 UTC (rev 3630) @@ -98,7 +98,6 @@ #define IDD_EDITSAMPLEMAP 422 #define IDD_SELECTMIXPLUGIN 423 #define IDD_PLUGINEDITOR 424 -#define IDD_SETUP_REVERB 425 #define IDD_EFFECTVISUALIZER 426 #define IDB_VISNODE 427 #define IDB_SPLASHTEST 432 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <man...@us...> - 2014-02-09 10:26:41
|
Revision: 3676 http://sourceforge.net/p/modplug/code/3676 Author: manxorist Date: 2014-02-09 10:26:29 +0000 (Sun, 09 Feb 2014) Log Message: ----------- [New] Add hidden setting [Display]GUIUpdateInterval to set the GUI update timer interal in milliseconds separately from the audio driver period. The default is 0, which still does the old coupling. Modified Paths: -------------- trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/TrackerSettings.cpp trunk/OpenMPT/mptrack/TrackerSettings.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp =================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp 2014-02-09 10:10:49 UTC (rev 3675) +++ trunk/OpenMPT/mptrack/MainFrm.cpp 2014-02-09 10:26:29 UTC (rev 3676) @@ -1183,7 +1183,13 @@ if(!gpSoundDevice->Start()) return false; if(!m_NotifyTimer) { - m_NotifyTimer = SetTimer(TIMERID_NOTIFY, std::max<int>(1, Util::Round<int>(gpSoundDevice->GetBufferAttributes().UpdateInterval * 1000.0)), NULL); + if(TrackerSettings::Instance().GUIUpdateInterval.Get() > 0) + { + m_NotifyTimer = SetTimer(TIMERID_NOTIFY, TrackerSettings::Instance().GUIUpdateInterval, NULL); + } else + { + m_NotifyTimer = SetTimer(TIMERID_NOTIFY, std::max<int>(1, Util::Round<int>(gpSoundDevice->GetBufferAttributes().UpdateInterval * 1000.0)), NULL); + } } return true; } Modified: trunk/OpenMPT/mptrack/TrackerSettings.cpp =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-02-09 10:10:49 UTC (rev 3675) +++ trunk/OpenMPT/mptrack/TrackerSettings.cpp 2014-02-09 10:26:29 UTC (rev 3676) @@ -145,6 +145,7 @@ , gnPlugWindowHeight(conf, "Display", "PlugSelectWindowHeight", 332) , gnPlugWindowLast(conf, "Display", "PlugSelectWindowLast", 0) , gnMsgBoxVisiblityFlags(conf, "Display", "MDIGraphHeight", uint32_max) + , GUIUpdateInterval(conf, "Display", "GUIUpdateInterval", 0) , VuMeterUpdateInterval(conf, "Display", "VuMeterUpdateInterval", 15) // Misc , gbShowHackControls(conf, "Misc", "ShowHackControls", false) Modified: trunk/OpenMPT/mptrack/TrackerSettings.h =================================================================== --- trunk/OpenMPT/mptrack/TrackerSettings.h 2014-02-09 10:10:49 UTC (rev 3675) +++ trunk/OpenMPT/mptrack/TrackerSettings.h 2014-02-09 10:26:29 UTC (rev 3676) @@ -261,6 +261,7 @@ Setting<int32> gnPlugWindowLast; // Last selected plugin ID Setting<uint32> gnMsgBoxVisiblityFlags; + Setting<uint32> GUIUpdateInterval; CachedSetting<uint32> VuMeterUpdateInterval; // Misc This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-09 19:33:27
|
Revision: 3682 http://sourceforge.net/p/modplug/code/3682 Author: saga-games Date: 2014-02-09 19:33:19 +0000 (Sun, 09 Feb 2014) Log Message: ----------- [Mod] Pattern tab: Unify note properties dialog from three tabs into one single dialog. Modified Paths: -------------- trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/EffectInfo.h trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-02-09 15:34:26 UTC (rev 3681) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-02-09 19:33:19 UTC (rev 3682) @@ -20,10 +20,10 @@ struct MPTEFFECTINFO { ModCommand::COMMAND effect; // CMD_XXXX - DWORD paramMask; // 0 = default - DWORD paramValue; // 0 = default - DWORD paramLimit; // Parameter Editor limit - DWORD supportedFormats; // MOD_TYPE_XXX combo + ModCommand::PARAM paramMask; // 0 = default + ModCommand::PARAM paramValue; // 0 = default + ModCommand::PARAM paramLimit; // Parameter Editor limit + MODTYPE supportedFormats; // MOD_TYPE_XXX combo LPCSTR name; // e.g. "Tone Portamento" }; @@ -34,7 +34,7 @@ #define MOD_TYPE_XMIT (MOD_TYPE_XM | MOD_TYPE_IT) #define MOD_TYPE_XMITMPT (MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT) #define MOD_TYPE_ITMPT (MOD_TYPE_IT | MOD_TYPE_MPT) -#define MOD_TYPE_ALL 0xFFFFFFFF +#define MOD_TYPE_ALL ((MODTYPE)~0) const MPTEFFECTINFO gFXInfo[] = @@ -289,8 +289,8 @@ } -bool EffectInfo::GetEffectInfo(UINT ndx, LPSTR s, bool bXX, DWORD *prangeMin, DWORD *prangeMax) const -//--------------------------------------------------------------------------------------------------- +bool EffectInfo::GetEffectInfo(UINT ndx, LPSTR s, bool bXX, ModCommand::PARAM *prangeMin, ModCommand::PARAM *prangeMax) const +//--------------------------------------------------------------------------------------------------------------------------- { if (s) s[0] = 0; if (prangeMin) *prangeMin = 0; @@ -299,7 +299,7 @@ if (s) GetEffectName(s, gFXInfo[ndx].effect, gFXInfo[ndx].paramValue, bXX); if ((prangeMin) && (prangeMax)) { - UINT nmin = 0, nmax = 0xFF; + ModCommand::PARAM nmin = 0, nmax = 0xFF; if (gFXInfo[ndx].paramMask == 0xF0) { nmin = gFXInfo[ndx].paramValue; @@ -946,8 +946,8 @@ } -bool EffectInfo::GetVolCmdInfo(UINT ndx, LPSTR s, DWORD *prangeMin, DWORD *prangeMax) const -//----------------------------------------------------------------------------------------- +bool EffectInfo::GetVolCmdInfo(UINT ndx, LPSTR s, ModCommand::VOL *prangeMin, ModCommand::VOL *prangeMax) const +//------------------------------------------------------------------------------------------------------------- { if (s) s[0] = 0; if (prangeMin) *prangeMin = 0; Modified: trunk/OpenMPT/mptrack/EffectInfo.h =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.h 2014-02-09 15:34:26 UTC (rev 3681) +++ trunk/OpenMPT/mptrack/EffectInfo.h 2014-02-09 19:33:19 UTC (rev 3682) @@ -31,7 +31,7 @@ // Get size of list of known effect commands UINT GetNumEffects() const; // Get range information, effect name, etc... from a given effect. - bool GetEffectInfo(UINT ndx, LPSTR s, bool bXX = false, DWORD *prangeMin = nullptr, DWORD *prangeMax = nullptr) const; + bool GetEffectInfo(UINT ndx, LPSTR s, bool bXX = false, ModCommand::PARAM *prangeMin = nullptr, ModCommand::PARAM *prangeMax = nullptr) const; // Get effect index in effect list from effect command + param LONG GetIndexFromEffect(ModCommand::COMMAND command, ModCommand::PARAM param) const; // Get effect command + param from effect index @@ -57,5 +57,5 @@ // Get volume command from effect index ModCommand::VOLCMD GetVolCmdFromIndex(UINT ndx) const; // Get range information, effect name, etc... from a given effect. - bool GetVolCmdInfo(UINT ndx, LPSTR s, DWORD *prangeMin = nullptr, DWORD *prangeMax = nullptr) const; + bool GetVolCmdInfo(UINT ndx, LPSTR s, ModCommand::VOL *prangeMin = nullptr, ModCommand::VOL *prangeMax = nullptr) const; }; Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2014-02-09 15:34:26 UTC (rev 3681) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2014-02-09 19:33:19 UTC (rev 3682) @@ -316,7 +316,7 @@ // Update Param range if (((combo = (CComboBox *)GetDlgItem(IDC_COMBO4)) != NULL)) { - DWORD rangeMin, rangeMax; + ModCommand::VOL rangeMin, rangeMax; if(!effectInfo.GetVolCmdInfo(fxndx, nullptr, &rangeMin, &rangeMax)) { rangeMin = 0; @@ -600,68 +600,40 @@ //////////////////////////////////////////////////////////////////////////////////////////// // CEditCommand -BEGIN_MESSAGE_MAP(CEditCommand, CPropertySheet) +BEGIN_MESSAGE_MAP(CEditCommand, CDialog) ON_WM_ACTIVATE() ON_WM_CLOSE() - ON_WM_DESTROY() + + ON_CBN_SELCHANGE(IDC_COMBO1, OnNoteChanged) + ON_CBN_SELCHANGE(IDC_COMBO2, OnNoteChanged) + ON_CBN_SELCHANGE(IDC_COMBO3, OnVolCmdChanged) + ON_CBN_SELCHANGE(IDC_COMBO4, OnCommandChanged) + ON_WM_HSCROLL() END_MESSAGE_MAP() -CEditCommand::CEditCommand() -//-------------------------- +void CEditCommand::DoDataExchange(CDataExchange* pDX) +//--------------------------------------------------- { - m_pModDoc = NULL; - m_hWndView = NULL; - m_nPattern = 0; - m_nRow = 0; - m_nChannel = 0; - m_pageNote = NULL; - m_pageVolume = NULL; - m_pageEffect = NULL; - m_bModified = false; + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CSplitKeyboadSettings) + DDX_Control(pDX, IDC_COMBO1, cbnNote); + DDX_Control(pDX, IDC_COMBO2, cbnInstr); + DDX_Control(pDX, IDC_COMBO3, cbnVolCmd); + DDX_Control(pDX, IDC_COMBO4, cbnCommand); + DDX_Control(pDX, IDC_SLIDER1, sldVolParam); + DDX_Control(pDX, IDC_SLIDER2, sldParam); + //}}AFX_DATA_MAP } -BOOL CEditCommand::SetParent(CWnd *parent, CModDoc *pModDoc) -//---------------------------------------------------------- +CEditCommand::CEditCommand(CSoundFile &sndFile, CWnd *parent) : sndFile(sndFile), effectInfo(sndFile), m(nullptr), modified(false) +//-------------------------------------------------------------------------------------------------------------------------------- { - if ((!parent) || (!pModDoc)) return FALSE; - m_hWndView = parent->m_hWnd; - m_pModDoc = pModDoc; - m_pageNote = new CPageEditNote(m_pModDoc->GetrSoundFile(), *this); - m_pageVolume = new CPageEditVolume(m_pModDoc->GetrSoundFile(), *this); - m_pageEffect = new CPageEditEffect(m_pModDoc->GetrSoundFile(), *this); - AddPage(m_pageNote); - AddPage(m_pageVolume); - AddPage(m_pageEffect); - if (!CPropertySheet::Create(parent, - WS_SYSMENU|WS_POPUP|WS_CAPTION, WS_EX_DLGMODALFRAME)) return FALSE; - ModifyStyleEx(0, WS_EX_TOOLWINDOW|WS_EX_PALETTEWINDOW, SWP_FRAMECHANGED); - return TRUE; + CDialog::Create(IDD_PATTERN_EDITCOMMAND, parent); } -void CEditCommand::OnDestroy() -//---------------------------- -{ - CPropertySheet::OnDestroy(); - if (m_pageNote) - { - m_pageNote->DestroyWindow(); - delete m_pageNote; - } - if (m_pageVolume) - { - m_pageVolume->DestroyWindow(); - delete m_pageVolume; - } - if (m_pageEffect) - { - m_pageEffect->DestroyWindow(); - delete m_pageEffect; - } -} - BOOL CEditCommand::PreTranslateMessage(MSG *pMsg) //----------------------------------------------- { @@ -673,575 +645,481 @@ return TRUE; } } - return CPropertySheet::PreTranslateMessage(pMsg); + return CDialog::PreTranslateMessage(pMsg); } -BOOL CEditCommand::ShowEditWindow(PATTERNINDEX nPat, const PatternCursor &cursor) -//------------------------------------------------------------------------------- +bool CEditCommand::ShowEditWindow(PATTERNINDEX pat, const PatternCursor &cursor) +//------------------------------------------------------------------------------ { - CHAR s[64]; - CSoundFile &sndFile = m_pModDoc->GetrSoundFile(); - const ROWINDEX nRow = cursor.GetRow(); - const CHANNELINDEX nChannel = cursor.GetChannel(); + editPos.pattern = pat; + const ROWINDEX row = editPos.row = cursor.GetRow(); + const CHANNELINDEX chn = editPos.channel = cursor.GetChannel(); - if ((nPat >= sndFile.Patterns.Size()) || (!m_pModDoc) - || (nRow >= sndFile.Patterns[nPat].GetNumRows()) || (nChannel >= sndFile.GetNumChannels()) - || (!sndFile.Patterns[nPat])) return FALSE; - m_Command = *sndFile.Patterns[nPat].GetpModCommand(nRow, nChannel); - m_nRow = nRow; - m_nChannel = nChannel; - m_nPattern = nPat; - m_bModified = false; - // Init Pages - if (m_pageNote) m_pageNote->Init(m_Command); - if (m_pageVolume) m_pageVolume->Init(m_Command); + if(!sndFile.Patterns.IsValidPat(pat) + || !sndFile.Patterns[pat].IsValidRow(row) + || chn >= sndFile.GetNumChannels()) + { + ShowWindow(SW_HIDE); + return false; + } - // -> CODE#0010 - // -> DESC="add extended parameter mechanism to pattern effects" - // if (m_pageEffect) m_pageEffect->Init(m_Command); - if (m_pageEffect) + m = sndFile.Patterns[pat].GetpModCommand(row, chn); + modified = false; + + InitAll(); + + switch(cursor.GetColumnType()) { - UINT xp = 0, ml = 1; - getXParam(m_Command.command, nPat, nRow, nChannel, sndFile, xp, ml); - m_pageEffect->Init(m_Command); - m_pageEffect->XInit(xp,ml); + case PatternCursor::noteColumn: + GetDlgItem(IDC_COMBO1)->SetFocus(); + break; + case PatternCursor::instrColumn: + GetDlgItem(IDC_COMBO2)->SetFocus(); + break; + case PatternCursor::volumeColumn: + GetDlgItem(IDC_COMBO3)->SetFocus(); + break; + case PatternCursor::effectColumn: + GetDlgItem(IDC_COMBO4)->SetFocus(); + break; + case PatternCursor::paramColumn: + GetDlgItem(IDC_SLIDER2)->SetFocus(); + break; } - // -! NEW_FEATURE#0010 // Update Window Title - wsprintf(s, "Note Properties - Row %d, Channel %d", m_nRow, m_nChannel + 1); - SetTitle(s); - // Activate Page - UINT nPage = 2; - if(cursor.GetColumnType() < PatternCursor::volumeColumn) nPage = 0; - else if (cursor.GetColumnType() < PatternCursor::effectColumn) nPage = 1; - SetActivePage(nPage); - if (m_pageNote) m_pageNote->UpdateDialog(); - if (m_pageVolume) m_pageVolume->UpdateDialog(); - if (m_pageEffect) m_pageEffect->UpdateDialog(); - //ShowWindow(SW_SHOW); + CHAR s[64]; + wsprintf(s, "Note Properties - Row %d, Channel %d", row, chn + 1); + SetWindowText(s); + ShowWindow(SW_RESTORE); - return TRUE; + return true; } -void CEditCommand::UpdateNote(ModCommand::NOTE note, ModCommand::INSTR instr) -//--------------------------------------------------------------------------- +void CEditCommand::InitNote() +//--------------------------- { - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if ((m_nPattern >= pSndFile->Patterns.Size()) || (!m_pModDoc) - || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) - || (m_nChannel >= pSndFile->GetNumChannels()) - || (!pSndFile->Patterns[m_nPattern])) return; - ModCommand *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); - if ((m->note != note) || (m->instr != instr)) + // Note + cbnNote.SetRedraw(FALSE); + cbnNote.ResetContent(); + cbnNote.SetItemData(cbnNote.AddString("No note"), 0); + AppendNotesToControlEx(cbnNote, sndFile, m->instr); + + if(ModCommand::IsNoteOrEmpty(m->note)) { - if(!m_bModified) // let's create just one undo step. + // Normal note / no note + const ModCommand::NOTE noteStart = sndFile.GetModSpecifications().noteMin; + cbnNote.SetCurSel(m->note - (noteStart - 1)); + } else + { + // Special notes + for(int i = cbnNote.GetCount() - 1; i >= 0; --i) { - m_pModDoc->GetPatternUndo().PrepareUndo(m_nPattern, m_nChannel, m_nRow, 1, 1); - m_bModified = true; + if(cbnNote.GetItemData(i) == m->note) + { + cbnNote.SetCurSel(i); + break; + } } - m->note = note; - m->instr = instr; - m_Command = *m; - m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, (m_nRow << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); } -} + cbnNote.SetRedraw(TRUE); + // Instrument + cbnInstr.SetRedraw(FALSE); + cbnInstr.ResetContent(); -void CEditCommand::UpdateVolume(ModCommand::VOLCMD volcmd, ModCommand::VOL vol) -//----------------------------------------------------------------------------- -{ - CSoundFile *pSndFile = m_pModDoc->GetSoundFile(); - if ((m_nPattern >= pSndFile->Patterns.Size()) || (!m_pModDoc) - || (m_nRow >= pSndFile->Patterns[m_nPattern].GetNumRows()) - || (m_nChannel >= pSndFile->GetNumChannels()) - || (!pSndFile->Patterns[m_nPattern])) return; - ModCommand *m = pSndFile->Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); - if ((m->volcmd != volcmd) || (m->vol != vol)) + if(ModCommand::IsPcNote(m->note)) { - if(!m_bModified) // let's create just one undo step. + // control plugin param note + cbnInstr.SetItemData(cbnInstr.AddString("No Effect"), 0); + AddPluginNamesToCombobox(cbnInstr, sndFile.m_MixPlugins, false); + } else + { + // instrument / sample + cbnInstr.SetItemData(cbnInstr.AddString("No Instrument"), 0); + const uint32 nmax = sndFile.GetNumInstruments() ? sndFile.GetNumInstruments() : sndFile.GetNumSamples(); + for(uint32 i = 1; i <= nmax; i++) { - m_pModDoc->GetPatternUndo().PrepareUndo(m_nPattern, m_nChannel, m_nRow, 1, 1); - m_bModified = true; + std::string s = mpt::ToString(i) + ": "; + // instrument / sample + if(sndFile.GetNumInstruments()) + { + if(sndFile.Instruments[i]) + s += sndFile.Instruments[i]->name; + } else + s += sndFile.m_szNames[i]; + cbnInstr.SetItemData(cbnInstr.AddString(s.c_str()), i); } - m->volcmd = volcmd; - m->vol = vol; - m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, (m_nRow << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); } + cbnInstr.SetCurSel(m->instr); + cbnInstr.SetRedraw(TRUE); } -void CEditCommand::UpdateEffect(ModCommand::COMMAND command, ModCommand::PARAM param) -//----------------------------------------------------------------------------------- +void CEditCommand::InitVolume() +//----------------------------- { - CSoundFile &sndFile = m_pModDoc->GetrSoundFile(); - if ((m_nPattern >= sndFile.Patterns.Size()) || (!m_pModDoc) - || (m_nRow >= sndFile.Patterns[m_nPattern].GetNumRows()) - || (m_nChannel >= sndFile.GetNumChannels()) - || (!sndFile.Patterns[m_nPattern])) return; - ModCommand *m = sndFile.Patterns[m_nPattern].GetpModCommand(m_nRow, m_nChannel); - - // -> CODE#0010 - // -> DESC="add extended parameter mechanism to pattern effects" - if(command == CMD_OFFSET || command == CMD_PATTERNBREAK || command == CMD_TEMPO || command == CMD_XPARAM) + cbnVolCmd.SetRedraw(FALSE); + cbnVolCmd.ResetContent(); + if(sndFile.GetType() == MOD_TYPE_MOD || m->IsPcNote()) { - UINT xp = 0, ml = 1; - getXParam(command, m_nPattern, m_nRow, m_nChannel, sndFile, xp, ml); - m_pageEffect->XInit(xp,ml); - m_pageEffect->UpdateDialog(); - } - // -! NEW_FEATURE#0010 - - if ((m->command != command) || (m->param != param)) + cbnVolCmd.EnableWindow(FALSE); + sldVolParam.EnableWindow(FALSE); + } else { - if(!m_bModified) // let's create just one undo step. + // Normal volume column effect + cbnVolCmd.EnableWindow(TRUE); + sldVolParam.EnableWindow(TRUE); + uint32 count = effectInfo.GetNumVolCmds(); + cbnVolCmd.SetItemData(cbnVolCmd.AddString(" None"), (DWORD_PTR)-1); + cbnVolCmd.SetCurSel(0); + UINT fxndx = effectInfo.GetIndexFromVolCmd(m->volcmd); + for(uint32 i = 0; i < count; i++) { - m_pModDoc->GetPatternUndo().PrepareUndo(m_nPattern, m_nChannel, m_nRow, 1, 1); - m_bModified = true; + CHAR s[64]; + if(effectInfo.GetVolCmdInfo(i, s)) + { + int k = cbnVolCmd.AddString(s); + cbnVolCmd.SetItemData(k, i); + if(i == fxndx) cbnVolCmd.SetCurSel(k); + } } - m->command = command; - m->param = param; - m_pModDoc->SetModified(); - m_pModDoc->UpdateAllViews(NULL, (m_nRow << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); + UpdateVolCmdRange(); } + cbnVolCmd.SetRedraw(TRUE); } -void CEditCommand::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized) -//-------------------------------------------------------------------------- +void CEditCommand::InitEffect() +//----------------------------- { - CWnd::OnActivate(nState, pWndOther, bMinimized); - if (nState == WA_INACTIVE) ShowWindow(SW_HIDE); -} + xParam = 0; + xMultiplier = 1; + getXParam(m->command, editPos.pattern, editPos.row, editPos.channel, sndFile, xParam, xMultiplier); - -////////////////////////////////////////////////////////////////////////////////////// -// CPageEditCommand - -BOOL CPageEditCommand::OnInitDialog() -//----------------------------------- -{ - CPropertyPage::OnInitDialog(); - m_bInitialized = true; - UpdateDialog(); - return TRUE; -} - - -////////////////////////////////////////////////////////////////////////////////////// -// CPageEditNote - -BEGIN_MESSAGE_MAP(CPageEditNote, CPageEditCommand) - ON_CBN_SELCHANGE(IDC_COMBO1, OnNoteChanged) - ON_CBN_SELCHANGE(IDC_COMBO2, OnInstrChanged) -END_MESSAGE_MAP() - - -void CPageEditNote::UpdateDialog() -//-------------------------------- -{ - char s[64]; - CComboBox *combo; - - if ((!m_bInitialized)) return; - - // Note - if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) - { - combo->ResetContent(); - combo->SetItemData(combo->AddString("No note"), 0); - AppendNotesToControlEx(*combo, sndFile, m_nInstr); - - if (ModCommand::IsNoteOrEmpty(m_nNote)) + cbnCommand.SetRedraw(FALSE); + cbnCommand.ResetContent(); + if(m->IsPcNote()) + { + // Plugin param control note + if(m->instr > 0 && m->instr <= MAX_MIXPLUGINS) { - // Normal note / no note - const ModCommand::NOTE noteStart = sndFile.GetModSpecifications().noteMin; - combo->SetCurSel(m_nNote - (noteStart - 1)); - } else - { - // Special notes - for(int i = combo->GetCount() - 1; i >= 0; --i) - { - if(combo->GetItemData(i) == m_nNote) - { - combo->SetCurSel(i); - break; - } - } + cbnCommand.ModifyStyle(CBS_SORT, 0); // Y U NO WORK? + AddPluginParameternamesToCombobox(cbnCommand, sndFile.m_MixPlugins[m->instr - 1]); + cbnCommand.SetCurSel(m->GetValueVolCol()); } - - } - // Instrument - if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO2)) != NULL) + } else { - combo->ResetContent(); + // Normal effect + uint32 numfx = effectInfo.GetNumEffects(); + uint32 fxndx = effectInfo.GetIndexFromEffect(m->command, m->param); + cbnCommand.ModifyStyle(0, CBS_SORT); + cbnCommand.SetItemData(cbnCommand.AddString(" None"), (DWORD_PTR)-1); + if(m->command == CMD_NONE) cbnCommand.SetCurSel(0); - if(ModCommand::IsPcNote(m_nNote)) + CHAR s[128]; + for(uint32 i = 0; i < numfx; i++) { - // control plugin param note - combo->SetItemData(combo->AddString("No Effect"), 0); - AddPluginNamesToCombobox(*combo, sndFile.m_MixPlugins, false); - } else - { - // instrument / sample - combo->SetItemData(combo->AddString("No Instrument"), 0); - const UINT nmax = sndFile.GetNumInstruments() ? sndFile.GetNumInstruments() : sndFile.GetNumSamples(); - for (UINT i = 1; i <= nmax; i++) + if(effectInfo.GetEffectInfo(i, s, true)) { - wsprintf(s, "%02d: ", i); - int k = strlen(s); - // instrument / sample - if (sndFile.GetNumInstruments()) - { - if (sndFile.Instruments[i]) - memcpy(s + k, sndFile.Instruments[i]->name, CountOf(sndFile.Instruments[i]->name)); - } else - memcpy(s+k, sndFile.m_szNames[i], MAX_SAMPLENAME); - s[k+32] = 0; - combo->SetItemData(combo->AddString(s), i); + int k = cbnCommand.AddString(s); + cbnCommand.SetItemData(k, i); + if (i == fxndx) cbnCommand.SetCurSel(k); } } - combo->SetCurSel(m_nInstr); + cbnCommand.ModifyStyle(CBS_SORT, 0); } + UpdateEffectRange(false); + cbnCommand.SetRedraw(TRUE); } -void CPageEditNote::OnNoteChanged() -//--------------------------------- +void CEditCommand::UpdateVolCmdRange() +//------------------------------------ { - const bool bWasParamControl = ModCommand::IsPcNote(m_nNote); - - CComboBox *combo; - if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) + ModCommand::VOL rangeMin = 0, rangeMax = 0; + LONG fxndx = effectInfo.GetIndexFromVolCmd(m->volcmd); + bool ok = effectInfo.GetVolCmdInfo(fxndx, NULL, &rangeMin, &rangeMax); + if(ok && rangeMax > rangeMin) { - int n = combo->GetCurSel(); - if (n >= 0) m_nNote = static_cast<ModCommand::NOTE>(combo->GetItemData(n)); + sldVolParam.EnableWindow(TRUE); + sldVolParam.SetRange(rangeMin, rangeMax); + Limit(m->vol, rangeMin, rangeMax); + sldVolParam.SetPos(m->vol); + } else + { + // Why does this not update the display at all? + sldVolParam.SetRange(0, 0); + sldVolParam.SetPos(0); + sldVolParam.EnableWindow(FALSE); } - if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO2)) != NULL) +} + + +void CEditCommand::UpdateEffectRange(bool set) +//-------------------------------------------- +{ + DWORD pos; + bool enable = true; + + if(m->IsPcNote()) { - int n = combo->GetCurSel(); - if(n >= 0) - { - const ModCommand::INSTR oldInstr = m_nInstr; - m_nInstr = static_cast<ModCommand::INSTR>(combo->GetItemData(n)); - //Checking whether note names should be recreated. - if(!ModCommand::IsPcNote(m_nNote) && sndFile.Instruments[m_nInstr] && sndFile.Instruments[oldInstr]) - { - if(sndFile.Instruments[m_nInstr]->pTuning != sndFile.Instruments[oldInstr]->pTuning) - UpdateDialog(); - } - } + // plugin param control note + sldParam.SetRange(0, ModCommand::maxColumnValue); + pos = m->GetValueEffectCol(); + } else + { + // process as effect + ModCommand::PARAM rangeMin = 0, rangeMax = 0; + LONG fxndx = effectInfo.GetIndexFromEffect(m->command, m->param); + enable = ((fxndx >= 0) && (effectInfo.GetEffectInfo(fxndx, NULL, false, &rangeMin, &rangeMax))); + + pos = effectInfo.MapValueToPos(fxndx, m->param); + if(pos > rangeMax) pos = rangeMin | (pos & 0x0F); + Limit(pos, rangeMin, rangeMax); + + sldParam.SetRange(rangeMin, rangeMax); } - const bool bIsNowParamControl = ModCommand::IsPcNote(m_nNote); - if(bWasParamControl != bIsNowParamControl) + + if(enable) { - UpdateDialog(); - m_pParent.m_pageVolume->UpdateDialog(); - m_pParent.m_pageEffect->UpdateDialog(); + sldParam.EnableWindow(TRUE); + sldParam.SetPageSize(1); + sldParam.SetPos(pos); + } else + { + // Why does this not update the display at all? + sldParam.SetRange(0, 0); + sldParam.SetPos(0); + sldParam.EnableWindow(FALSE); } - - m_pParent.UpdateNote(m_nNote, m_nInstr); + UpdateEffectValue(set); } -void CPageEditNote::OnInstrChanged() -//---------------------------------- +void CEditCommand::OnNoteChanged() +//-------------------------------- { - OnNoteChanged(); -} + const bool wasParamControl = ModCommand::IsPcNote(m->note); + ModCommand::NOTE newNote = m->note; + ModCommand::INSTR newInstr = m->instr; + int n = cbnNote.GetCurSel(); + if(n >= 0) newNote = static_cast<ModCommand::NOTE>(cbnNote.GetItemData(n)); -////////////////////////////////////////////////////////////////////////////////////// -// CPageEditVolume + n = cbnInstr.GetCurSel(); + if(n >= 0) newInstr = static_cast<ModCommand::INSTR>(cbnInstr.GetItemData(n)); -BEGIN_MESSAGE_MAP(CPageEditVolume, CPageEditCommand) - ON_WM_HSCROLL() - ON_CBN_SELCHANGE(IDC_COMBO1, OnVolCmdChanged) -END_MESSAGE_MAP() + const bool isParamControl = ModCommand::IsPcNote(newNote); - -void CPageEditVolume::UpdateDialog() -//---------------------------------- -{ - CComboBox *combo; - - if ((!m_bInitialized)) return; - UpdateRanges(); - if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) + if(m->note != newNote || m->instr != newInstr) { - if (sndFile.GetType() == MOD_TYPE_MOD || m_bIsParamControl) + CModDoc *modDoc = sndFile.GetpModDoc(); + if(!modified) // let's create just one undo step. { - combo->EnableWindow(FALSE); - return; + modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); + modified = true; } - combo->EnableWindow(TRUE); - combo->ResetContent(); - UINT count = effectInfo.GetNumVolCmds(); - combo->SetItemData(combo->AddString(" None"), (DWORD)-1); - combo->SetCurSel(0); - UINT fxndx = effectInfo.GetIndexFromVolCmd(m_nVolCmd); - for (UINT i=0; i<count; i++) + m->note = newNote; + m->instr = newInstr; + + modDoc->SetModified(); + modDoc->UpdateAllViews(NULL, (editPos.row << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); + + if(wasParamControl != isParamControl) { - CHAR s[64]; - if (effectInfo.GetVolCmdInfo(i, s)) - { - int k = combo->AddString(s); - combo->SetItemData(k, i); - if (i == fxndx) combo->SetCurSel(k); - } + InitAll(); + } else if(!m->IsPcNote() + && m->instr <= sndFile.GetNumInstruments() + && newInstr <= sndFile.GetNumInstruments() + && sndFile.Instruments[m->instr] != nullptr + && sndFile.Instruments[newInstr] != nullptr + && sndFile.Instruments[newInstr]->pTuning != sndFile.Instruments[m->instr]->pTuning) + { + //Checking whether note names should be recreated. + InitNote(); + } else if(m->IsPcNote()) + { + // Update parameter list + InitEffect(); } } } -void CPageEditVolume::UpdateRanges() +void CEditCommand::OnVolCmdChanged() //---------------------------------- { - CSliderCtrl *slider = (CSliderCtrl *)GetDlgItem(IDC_SLIDER1); - if (slider != nullptr) + ModCommand::VOLCMD newVolCmd = m->volcmd; + ModCommand::VOL newVol = m->vol; + + int n = cbnVolCmd.GetCurSel(); + if(n >= 0) { - DWORD rangeMin = 0, rangeMax = 0; - LONG fxndx = effectInfo.GetIndexFromVolCmd(m_nVolCmd); - BOOL bOk = effectInfo.GetVolCmdInfo(fxndx, NULL, &rangeMin, &rangeMax); - if ((bOk) && (rangeMax > rangeMin)) - { - slider->EnableWindow(TRUE); - slider->SetRange(rangeMin, rangeMax); - UINT pos = m_nVolume; - if (pos < rangeMin) pos = rangeMin; - if (pos > rangeMax) pos = rangeMax; - slider->SetPos(pos); - } else - { - slider->EnableWindow(FALSE); - } + newVolCmd = effectInfo.GetVolCmdFromIndex(cbnVolCmd.GetItemData(n)); } -} + newVol = static_cast<ModCommand::VOL>(sldVolParam.GetPos()); -void CPageEditVolume::OnVolCmdChanged() -//------------------------------------- -{ - CComboBox *combo; - CSliderCtrl *slider; - if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) + const bool volCmdChanged = m->volcmd != newVolCmd; + if(volCmdChanged || m->vol != newVol) { - int n = combo->GetCurSel(); - if (n >= 0) + CModDoc *modDoc = sndFile.GetpModDoc(); + if(!modified) // let's create just one undo step. { - ModCommand::VOLCMD volcmd = effectInfo.GetVolCmdFromIndex(combo->GetItemData(n)); - if (volcmd != m_nVolCmd) - { - m_nVolCmd = volcmd; - UpdateRanges(); - } + modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); + modified = true; } - } - if ((slider = (CSliderCtrl *)GetDlgItem(IDC_SLIDER1)) != NULL) - { - m_nVolume = static_cast<ModCommand::VOL>(slider->GetPos()); - } - m_pParent.UpdateVolume(m_nVolCmd, m_nVolume); -} + m->volcmd = newVolCmd; + m->vol = newVol; + modDoc->SetModified(); + modDoc->UpdateAllViews(NULL, (editPos.row << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); -void CPageEditVolume::OnHScroll(UINT, UINT, CScrollBar *) -//------------------------------------------------------- -{ - OnVolCmdChanged(); + if(volCmdChanged) + { + UpdateVolCmdRange(); + } + } } -////////////////////////////////////////////////////////////////////////////////////// -// CPageEditEffect - -BEGIN_MESSAGE_MAP(CPageEditEffect, CPageEditCommand) - ON_WM_HSCROLL() - ON_CBN_SELCHANGE(IDC_COMBO1, OnCommandChanged) -END_MESSAGE_MAP() - - -void CPageEditEffect::UpdateDialog() -//---------------------------------- +void CEditCommand::OnCommandChanged() +//----------------------------------- { - CComboBox *combo; + uint16 newPlugParam = m->GetValueVolCol(); + ModCommand::COMMAND newCommand = m->command; + int newParam = m->param; - if (!m_bInitialized) return; - - if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) + int n = cbnCommand.GetCurSel(); + if(n >= 0) { - combo->ResetContent(); - if(m_bIsParamControl) + if(m->IsPcNote()) { - // plugin param control note - if(m_nPlugin > 0 && m_nPlugin <= MAX_MIXPLUGINS) - { - combo->ModifyStyle(CBS_SORT, 0); // Y U NO WORK? - AddPluginParameternamesToCombobox(*combo, sndFile.m_MixPlugins[m_nPlugin - 1]); - combo->SetCurSel(m_nPluginParam); - } + // Plugin param control note + newPlugParam = static_cast<uint16>(cbnCommand.GetItemData(n)); } else { - // process as effect - UINT numfx = effectInfo.GetNumEffects(); - UINT fxndx = effectInfo.GetIndexFromEffect(m_nCommand, m_nParam); - combo->ModifyStyle(0, CBS_SORT); - combo->SetItemData(combo->AddString(" None"), (DWORD)-1); - if (m_nCommand == CMD_NONE) combo->SetCurSel(0); + // Process as effect + int ndx = cbnCommand.GetItemData(n); + newParam = -1; + newCommand = static_cast<ModCommand::COMMAND>((ndx >= 0) ? effectInfo.GetEffectFromIndex(ndx, newParam) : CMD_NONE); + } - CHAR s[128]; - for (UINT i=0; i<numfx; i++) - { - if (effectInfo.GetEffectInfo(i, s, true)) - { - int k = combo->AddString(s); - combo->SetItemData(k, i); - if (i == fxndx) combo->SetCurSel(k); - } - } - combo->ModifyStyle(CBS_SORT, 0); - } } - UpdateRange(FALSE); -} + // -> CODE#0010 + // -> DESC="add extended parameter mechanism to pattern effects" + if(newCommand == CMD_OFFSET || newCommand == CMD_PATTERNBREAK || newCommand == CMD_TEMPO || newCommand == CMD_XPARAM) + { + xParam = 0; + xMultiplier = 1; + getXParam(newCommand, editPos.pattern, editPos.row, editPos.channel, sndFile, xParam, xMultiplier); + } + // -! NEW_FEATURE#0010 -void CPageEditEffect::UpdateRange(BOOL bSet) -//------------------------------------------ -{ - CSliderCtrl *slider = (CSliderCtrl *)GetDlgItem(IDC_SLIDER1); - if (slider) + if((!m->IsPcNote() && (m->command != newCommand || m->param != newParam)) + || (m->IsPcNote() && m->GetValueVolCol() != newPlugParam)) { - DWORD rangeMin = 0, rangeMax = 0, pos; - bool enable = true; - - if(m_bIsParamControl) + CModDoc *modDoc = sndFile.GetpModDoc(); + if(!modified) // let's create just one undo step. { - // plugin param control note - rangeMax = ModCommand::maxColumnValue; - pos = ModCommand::GetValueEffectCol(m_nCommand, m_nParam); - } else - { - // process as effect - LONG fxndx = effectInfo.GetIndexFromEffect(m_nCommand, m_nParam); - enable = ((fxndx >= 0) && (effectInfo.GetEffectInfo(fxndx, NULL, false, &rangeMin, &rangeMax))); - - pos = effectInfo.MapValueToPos(fxndx, m_nParam); - if (pos > rangeMax) pos = rangeMin | (pos & 0x0F); - if (pos < rangeMin) pos = rangeMin; - if (pos > rangeMax) pos = rangeMax; + modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); + modified = true; } - - if (enable) + if(m->IsPcNote()) { - slider->EnableWindow(TRUE); - slider->SetPageSize(1); - slider->SetRange(rangeMin, rangeMax); - slider->SetPos(pos); + m->SetValueVolCol(newPlugParam); } else { - slider->SetRange(0, 0); - slider->EnableWindow(FALSE); + m->command = newCommand; + if(newParam >= 0) + { + m->param = static_cast<ModCommand::PARAM>(newParam); + } } - UpdateValue(bSet); + UpdateEffectRange(true); + + modDoc->SetModified(); + modDoc->UpdateAllViews(NULL, (editPos.row << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); } } -void CPageEditEffect::UpdateValue(BOOL bSet) -//------------------------------------------ +void CEditCommand::UpdateEffectValue(bool set) +//-------------------------------------------- { CHAR s[128] = ""; - if(m_bIsParamControl) + uint16 newPlugParam = 0; + ModCommand::PARAM newParam = 0; + + if(m->IsPcNote()) { // plugin param control note - wsprintf(s, "Value: %u", ModCommand::GetValueEffectCol(m_nCommand, m_nParam)); + newPlugParam = static_cast<uint16>(sldParam.GetPos()); + wsprintf(s, "Value: %u", newPlugParam); } else { // process as effect - LONG fxndx = effectInfo.GetIndexFromEffect(m_nCommand, m_nParam); - if (fxndx >= 0) effectInfo.GetEffectNameEx(s, fxndx, m_nParam * m_nMultiplier + m_nXParam); + LONG fxndx = effectInfo.GetIndexFromEffect(m->command, m->param); + if(fxndx >= 0) + { + newParam = static_cast<ModCommand::PARAM>(effectInfo.MapPosToValue(fxndx, sldParam.GetPos())); + effectInfo.GetEffectNameEx(s, fxndx, newParam * xMultiplier + xParam); + } } SetDlgItemText(IDC_TEXT1, s); - if (bSet) m_pParent.UpdateEffect(m_nCommand, m_nParam); -} - - -void CPageEditEffect::OnCommandChanged() -//-------------------------------------- -{ - CComboBox *combo; - - if ((combo = (CComboBox *)GetDlgItem(IDC_COMBO1)) != NULL) + if(set) { - int n = combo->GetCurSel(); - - if(m_bIsParamControl) + if((!m->IsPcNote() && m->param != newParam) + || (m->IsPcNote() && m->GetValueVolCol() != newPlugParam)) { - // plugin param control note - if(n >= 0) + CModDoc *modDoc = sndFile.GetpModDoc(); + if(!modified) // let's create just one undo step. { - // TODO update in pattern - m_nPluginParam = n; + modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); + modified = true; } - } else - { - // process as effect - BOOL bSet = FALSE; - if (n >= 0) + if(m->IsPcNote()) { - int param = -1, ndx = combo->GetItemData(n); - m_nCommand = (ndx >= 0) ? effectInfo.GetEffectFromIndex(ndx, param) : 0; - if (param >= 0) m_nParam = static_cast<ModCommand::PARAM>(param); - bSet = TRUE; + m->SetValueEffectCol((uint16)newPlugParam); + } else + { + m->param = newParam; } - UpdateRange(bSet); + + modDoc->SetModified(); + modDoc->UpdateAllViews(NULL, (editPos.row << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); } } } - -void CPageEditEffect::OnHScroll(UINT, UINT, CScrollBar *) +void CEditCommand::OnHScroll(UINT, UINT, CScrollBar *bar) //------------------------------------------------------- { - CSliderCtrl *slider = (CSliderCtrl *)GetDlgItem(IDC_SLIDER1); - if (slider != nullptr) + if(bar == static_cast<CWnd *>(&sldVolParam)) { - if(m_bIsParamControl) - { - // plugin param control note - // HACK - ModCommand m; - m.SetValueEffectCol(static_cast<int16>(slider->GetPos())); - m_nCommand = m.command; - m_nParam = m.param; - UpdateValue(TRUE); - } else - { - // process as effect - LONG fxndx = effectInfo.GetIndexFromEffect(m_nCommand, m_nParam); - if (fxndx >= 0) - { - int pos = slider->GetPos(); - UINT param = effectInfo.MapPosToValue(fxndx, pos); - if (param != m_nParam) - { - m_nParam = static_cast<ModCommand::PARAM>(param); - UpdateValue(TRUE); - } - } - } + OnVolCmdChanged(); + } else if(bar == static_cast<CWnd *>(&sldParam)) + { + UpdateEffectValue(true); } } +void CEditCommand::OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized) +//-------------------------------------------------------------------------- +{ + CDialog::OnActivate(nState, pWndOther, bMinimized); + if(nState == WA_INACTIVE) ShowWindow(SW_HIDE); +} + + //////////////////////////////////////////////////////////////////////////////////////////// // Chord Editor Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2014-02-09 15:34:26 UTC (rev 3681) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2014-02-09 19:33:19 UTC (rev 3682) @@ -113,154 +113,51 @@ ////////////////////////////////////////////////////////////////////////// // Command Editing -class CEditCommand; -class CPageEditCommand; -//========================================== -class CPageEditCommand: public CPropertyPage -//========================================== +//================================ +class CEditCommand: public CDialog +//================================ { protected: + CComboBox cbnNote, cbnInstr, cbnVolCmd, cbnCommand; + CSliderCtrl sldVolParam, sldParam; CSoundFile &sndFile; EffectInfo effectInfo; - CEditCommand &m_pParent; - bool m_bInitialized; + ModCommand *m; + ModCommandPos editPos; + UINT xParam, xMultiplier; + bool modified; public: - CPageEditCommand(CSoundFile &sf, CEditCommand &parent, UINT id) : CPropertyPage(id), sndFile(sf), effectInfo(sf), m_pParent(parent), m_bInitialized(false) {}; + CEditCommand(CSoundFile &sndFile, CWnd *parent); - virtual ~CPageEditCommand() {} - virtual BOOL OnInitDialog(); - virtual void Init(ModCommand&)=0; - virtual void UpdateDialog() {} -}; - - -//========================================== -class CPageEditNote: public CPageEditCommand -//========================================== -{ -protected: - ModCommand::NOTE m_nNote; - ModCommand::INSTR m_nInstr; - public: - CPageEditNote(CSoundFile &sf, CEditCommand &parent) : CPageEditCommand(sf, parent, IDD_PAGEEDITNOTE) {} - void Init(ModCommand &m) { m_nNote = m.note; m_nInstr = m.instr; } - void UpdateDialog(); + bool ShowEditWindow(PATTERNINDEX pat, const PatternCursor &cursor); protected: - //{{AFX_MSG(CPageEditNote) - afx_msg void OnNoteChanged(); - afx_msg void OnInstrChanged(); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; + void InitAll() { InitNote(); InitVolume(); InitEffect(); } + void InitNote(); + void InitVolume(); + void InitEffect(); + void UpdateVolCmdRange(); + void UpdateEffectRange(bool set); + void UpdateEffectValue(bool set); -//============================================ -class CPageEditVolume: public CPageEditCommand -//============================================ -{ -protected: - ModCommand::VOLCMD m_nVolCmd; - ModCommand::VOL m_nVolume; - bool m_bIsParamControl; - -public: - CPageEditVolume(CSoundFile &sf, CEditCommand &parent) : CPageEditCommand(sf, parent, IDD_PAGEEDITVOLUME) {}; - void Init(ModCommand &m) { m_nVolCmd = m.volcmd; m_nVolume = m.vol; m_bIsParamControl = m.IsPcNote(); }; - void UpdateDialog(); - void UpdateRanges(); - -protected: - //{{AFX_MSG(CPageEditVolume) - afx_msg void OnVolCmdChanged(); - afx_msg void OnHScroll(UINT, UINT, CScrollBar *); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - -//============================================ -class CPageEditEffect: public CPageEditCommand -//============================================ -{ -protected: - ModCommand::COMMAND m_nCommand; - ModCommand::PARAM m_nParam; - PLUGINDEX m_nPlugin; - UINT m_nPluginParam; - bool m_bIsParamControl; - // -> CODE#0010 - // -> DESC="add extended parameter mechanism to pattern effects" - UINT m_nXParam, m_nMultiplier; - // -! NEW_FEATURE#0010 - - ModCommand* m_pModcommand; - -public: - CPageEditEffect(CSoundFile &sf, CEditCommand &parent) : CPageEditCommand(sf, parent, IDD_PAGEEDITEFFECT) {} - // -> CODE#0010 - // -> DESC="add extended parameter mechanism to pattern effects" - void Init(ModCommand &m) { m_nCommand = m.command; m_nParam = m.param; m_pModcommand = &m; m_bIsParamControl = m.IsPcNote(); m_nPlugin = m.instr; m_nPluginParam = m.GetValueVolCol();} - void XInit(UINT xparam = 0, UINT multiplier = 1) { m_nXParam = xparam; m_nMultiplier = multiplier; } - // -! NEW_FEATURE#0010 - void UpdateDialog(); - void UpdateRange(BOOL bSet); - void UpdateValue(BOOL bSet); - -protected: - //{{AFX_MSG(CPageEditEffect) - afx_msg void OnCommandChanged(); - afx_msg void OnHScroll(UINT, UINT, CScrollBar *); - //}}AFX_MSG - DECLARE_MESSAGE_MAP() -}; - - - -//======================================= -class CEditCommand: public CPropertySheet -//======================================= -{ - friend class CPageEditNote; -protected: - CPageEditNote *m_pageNote; - CPageEditVolume *m_pageVolume; - CPageEditEffect *m_pageEffect; - CModDoc *m_pModDoc; - HWND m_hWndView; - ROWINDEX m_nRow; - PATTERNINDEX m_nPattern; - CHANNELINDEX m_nChannel; - ModCommand m_Command; - bool m_bModified; - -public: - CEditCommand(); - -public: - BOOL SetParent(CWnd *parent, CModDoc *pModDoc); - BOOL ShowEditWindow(PATTERNINDEX nPat, const PatternCursor &cursor); - void OnSelListChange(); - void UpdateNote(ModCommand::NOTE note, ModCommand::INSTR instr); - void UpdateVolume(ModCommand::VOLCMD volcmd, ModCommand::VOL vol); - void UpdateEffect(ModCommand::COMMAND command, ModCommand::PARAM param); - -protected: //{{AFX_VIRTUAL(CEditCommand) + virtual void DoDataExchange(CDataExchange* pDX); virtual void OnOK() { ShowWindow(SW_HIDE); } virtual void OnCancel() { ShowWindow(SW_HIDE); } virtual BOOL PreTranslateMessage(MSG *pMsg); - //}}AFX_VIRTUAL - //{{AFX_MSG(CEditCommand) afx_msg void OnActivate(UINT nState, CWnd *pWndOther, BOOL bMinimized); afx_msg void OnClose() { ShowWindow(SW_HIDE); } + + afx_msg void OnNoteChanged(); + afx_msg void OnVolCmdChanged(); + afx_msg void OnCommandChanged(); + afx_msg void OnHScroll(UINT, UINT, CScrollBar *); //}}AFX_MSG DECLARE_MESSAGE_MAP() -public: - afx_msg void OnDestroy(); }; Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2014-02-09 15:34:26 UTC (rev 3681) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2014-02-09 19:33:19 UTC (rev 3682) @@ -635,8 +635,7 @@ { if (!m_pEditWnd) { - m_pEditWnd = new CEditCommand; - if (m_pEditWnd) m_pEditWnd->SetParent(this, GetDocument()); + m_pEditWnd = new CEditCommand(*GetSoundFile(), this); } if (m_pEditWnd) { @@ -2298,10 +2297,10 @@ // Fix volume command parameters if necessary. This is necesary e.g. // When there was a command "v24" and the user searched for v and replaced it by d. // In that case, d24 wouldn't be a valid command. - DWORD minVal = 0, maxVal = 64; + ModCommand::VOL minVal = 0, maxVal = 64; if(effectInfo.GetVolCmdInfo(effectInfo.GetIndexFromVolCmd(m->volcmd), nullptr, &minVal, &maxVal)) { - Limit(m->vol, (ModCommand::VOL)minVal, (ModCommand::VOL)maxVal); + Limit(m->vol, minVal, maxVal); } } @@ -2966,7 +2965,7 @@ } else { int vol = m[chn].vol + offset * (coarse ? 10 : 1); - DWORD minValue = 0, maxValue = 64; + ModCommand::VOL minValue = 0, maxValue = 64; effectInfo.GetVolCmdInfo(effectInfo.GetIndexFromVolCmd(m[chn].volcmd), nullptr, &minValue, &maxValue); Limit(vol, (int)minValue, (int)maxValue); m[chn].vol = (ModCommand::VOL)vol; @@ -2983,7 +2982,7 @@ } else { int param = m[chn].param + offset * (coarse ? 16 : 1); - DWORD minValue = 0, maxValue = 0xFF; + ModCommand::PARAM minValue = 0, maxValue = 0xFF; effectInfo.GetEffectInfo(effectInfo.GetIndexFromEffect(m[chn].command, m[chn].param), nullptr, false, &minValue, &maxValue); Limit(param, (int)minValue, (int)maxValue); m[chn].param = (ModCommand::PARAM)param; @@ -3551,7 +3550,7 @@ } if (nRow != GetCurrentRow()) { - SetCurrentRow((nRow < pSndFile->Patterns[nPat].GetNumRows()) ? nRow : 0, FALSE, FALSE); + SetCurrentRow((nRow < pSndFile->Patterns[nPat].GetNumRows()) ? nRow : 0, false, false); } } } else Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2014-02-09 15:34:26 UTC (rev 3681) +++ trunk/OpenMPT/mptrack/resource.h 2014-02-09 19:33:19 UTC (rev 3682) @@ -27,9 +27,6 @@ #define IDD_PATTERN_EDITCOMMAND 124 #define IDD_SHOWLOG 125 #define IDD_VIEW_GLOBALS 126 -#define IDD_PAGEEDITNOTE 127 -#define IDD_PAGEEDITVOLUME 128 -#define IDD_PAGEEDITEFFECT 129 #define IDD_SAMPLE_AMPLIFY 130 #define IDD_SAMPLE_RESAMPLE 131 #define IDD_SETUP_EQ 132 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-10 13:53:21
|
Revision: 3687 http://sourceforge.net/p/modplug/code/3687 Author: saga-games Date: 2014-02-10 13:53:14 +0000 (Mon, 10 Feb 2014) Log Message: ----------- [Fix] Note properties dialog: If there was no note in the pattern, the correct dropdown list entry was not selected. [Ref] Note properties dialog code cleanup Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2014-02-09 22:58:59 UTC (rev 3686) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2014-02-10 13:53:14 UTC (rev 3687) @@ -221,7 +221,7 @@ } } combo->SetCurSel(0); - UINT fxndx = effectInfo.GetIndexFromVolCmd(ModCommand::VOLCMD(m_Cmd.volcmd)); + UINT fxndx = effectInfo.GetIndexFromVolCmd(m_Cmd.volcmd); for (UINT i=0; i<=count; i++) if (fxndx == combo->GetItemData(i)) { combo->SetCurSel(i); @@ -258,7 +258,7 @@ } } combo->SetCurSel(0); - UINT fxndx = effectInfo.GetIndexFromEffect(ModCommand::COMMAND(m_Cmd.command), ModCommand::PARAM(m_Cmd.param)); + UINT fxndx = effectInfo.GetIndexFromEffect(m_Cmd.command, m_Cmd.param); for (UINT i=0; i<=count; i++) if (fxndx == combo->GetItemData(i)) { combo->SetCurSel(i); @@ -713,11 +713,14 @@ cbnNote.SetItemData(cbnNote.AddString("No note"), 0); AppendNotesToControlEx(cbnNote, sndFile, m->instr); - if(ModCommand::IsNoteOrEmpty(m->note)) + if(m->IsNote()) { // Normal note / no note const ModCommand::NOTE noteStart = sndFile.GetModSpecifications().noteMin; cbnNote.SetCurSel(m->note - (noteStart - 1)); + } else if(m->note == NOTE_NONE) + { + cbnNote.SetCurSel(0); } else { // Special notes @@ -736,7 +739,7 @@ cbnInstr.SetRedraw(FALSE); cbnInstr.ResetContent(); - if(ModCommand::IsPcNote(m->note)) + if(m->IsPcNote()) { // control plugin param note cbnInstr.SetItemData(cbnInstr.AddString("No Effect"), 0); @@ -908,7 +911,7 @@ void CEditCommand::OnNoteChanged() //-------------------------------- { - const bool wasParamControl = ModCommand::IsPcNote(m->note); + const bool wasParamControl = m->IsPcNote(); ModCommand::NOTE newNote = m->note; ModCommand::INSTR newInstr = m->instr; @@ -918,23 +921,16 @@ n = cbnInstr.GetCurSel(); if(n >= 0) newInstr = static_cast<ModCommand::INSTR>(cbnInstr.GetItemData(n)); - const bool isParamControl = ModCommand::IsPcNote(newNote); - if(m->note != newNote || m->instr != newInstr) { + PrepareUndo(); CModDoc *modDoc = sndFile.GetpModDoc(); - if(!modified) // let's create just one undo step. - { - modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); - modified = true; - } m->note = newNote; m->instr = newInstr; - modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (editPos.row << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); - if(wasParamControl != isParamControl) + if(wasParamControl != m->IsPcNote()) { InitAll(); } else if(!m->IsPcNote() @@ -972,16 +968,11 @@ const bool volCmdChanged = m->volcmd != newVolCmd; if(volCmdChanged || m->vol != newVol) { + PrepareUndo(); CModDoc *modDoc = sndFile.GetpModDoc(); - if(!modified) // let's create just one undo step. - { - modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); - modified = true; - } m->volcmd = newVolCmd; m->vol = newVol; - modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (editPos.row << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); if(volCmdChanged) @@ -1029,12 +1020,8 @@ if((!m->IsPcNote() && (m->command != newCommand || m->param != newParam)) || (m->IsPcNote() && m->GetValueVolCol() != newPlugParam)) { + PrepareUndo(); CModDoc *modDoc = sndFile.GetpModDoc(); - if(!modified) // let's create just one undo step. - { - modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); - modified = true; - } if(m->IsPcNote()) { m->SetValueVolCol(newPlugParam); @@ -1048,7 +1035,6 @@ } UpdateEffectRange(true); - modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (editPos.row << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); } } @@ -1084,27 +1070,36 @@ if((!m->IsPcNote() && m->param != newParam) || (m->IsPcNote() && m->GetValueVolCol() != newPlugParam)) { + PrepareUndo(); CModDoc *modDoc = sndFile.GetpModDoc(); - if(!modified) // let's create just one undo step. - { - modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); - modified = true; - } if(m->IsPcNote()) { - m->SetValueEffectCol((uint16)newPlugParam); + m->SetValueEffectCol(newPlugParam); } else { m->param = newParam; } - modDoc->SetModified(); modDoc->UpdateAllViews(NULL, (editPos.row << HINT_SHIFT_ROW) | HINT_PATTERNROW, NULL); } } } +void CEditCommand::PrepareUndo() +//------------------------------ +{ + CModDoc *modDoc = sndFile.GetpModDoc(); + if(!modified) + { + // Let's create just one undo step. + modDoc->GetPatternUndo().PrepareUndo(editPos.pattern, editPos.channel, editPos.row, 1, 1); + modified = true; + } + modDoc->SetModified(); +} + + void CEditCommand::OnHScroll(UINT, UINT, CScrollBar *bar) //------------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2014-02-09 22:58:59 UTC (rev 3686) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2014-02-10 13:53:14 UTC (rev 3687) @@ -144,6 +144,8 @@ void UpdateEffectRange(bool set); void UpdateEffectValue(bool set); + void PrepareUndo(); + //{{AFX_VIRTUAL(CEditCommand) virtual void DoDataExchange(CDataExchange* pDX); virtual void OnOK() { ShowWindow(SW_HIDE); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-10 15:02:33
|
Revision: 3688 http://sourceforge.net/p/modplug/code/3688 Author: saga-games Date: 2014-02-10 15:02:26 +0000 (Mon, 10 Feb 2014) Log Message: ----------- [Imp] Center note properties dialog in window, not in screen Modified Paths: -------------- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp trunk/OpenMPT/mptrack/PatternEditorDialogs.h Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2014-02-10 13:53:14 UTC (rev 3687) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2014-02-10 15:02:26 UTC (rev 3688) @@ -627,10 +627,10 @@ } -CEditCommand::CEditCommand(CSoundFile &sndFile, CWnd *parent) : sndFile(sndFile), effectInfo(sndFile), m(nullptr), modified(false) -//-------------------------------------------------------------------------------------------------------------------------------- +CEditCommand::CEditCommand(CSoundFile &sndFile) : sndFile(sndFile), effectInfo(sndFile), m(nullptr), modified(false) +//------------------------------------------------------------------------------------------------------------------ { - CDialog::Create(IDD_PATTERN_EDITCOMMAND, parent); + CDialog::Create(IDD_PATTERN_EDITCOMMAND); } @@ -649,8 +649,8 @@ } -bool CEditCommand::ShowEditWindow(PATTERNINDEX pat, const PatternCursor &cursor) -//------------------------------------------------------------------------------ +bool CEditCommand::ShowEditWindow(PATTERNINDEX pat, const PatternCursor &cursor, CWnd *parent) +//-------------------------------------------------------------------------------------------- { editPos.pattern = pat; const ROWINDEX row = editPos.row = cursor.GetRow(); @@ -699,6 +699,9 @@ wsprintf(s, "Note Properties - Row %d, Channel %d", row, chn + 1); SetWindowText(s); + SetParent(CMainFrame::GetMainFrame()); + CenterWindow(parent); + ShowWindow(SW_RESTORE); return true; } Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.h =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2014-02-10 13:53:14 UTC (rev 3687) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.h 2014-02-10 15:02:26 UTC (rev 3688) @@ -129,10 +129,10 @@ bool modified; public: - CEditCommand(CSoundFile &sndFile, CWnd *parent); + CEditCommand(CSoundFile &sndFile); public: - bool ShowEditWindow(PATTERNINDEX pat, const PatternCursor &cursor); + bool ShowEditWindow(PATTERNINDEX pat, const PatternCursor &cursor, CWnd *parent); protected: void InitAll() { InitNote(); InitVolume(); InitEffect(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-11 17:44:18
|
Revision: 3700 http://sourceforge.net/p/modplug/code/3700 Author: saga-games Date: 2014-02-11 17:44:09 +0000 (Tue, 11 Feb 2014) Log Message: ----------- [Fix] When reporting keymap errors, the reported line number was off-by-one (zero-based) [Mod] Allow editing the global volume in old XM files that still have it set to a non-default value [Ref] Various small changes Modified Paths: -------------- trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/Ctrl_gen.cpp trunk/OpenMPT/mptrack/Ctrl_pat.cpp trunk/OpenMPT/mptrack/Draw_pat.cpp trunk/OpenMPT/mptrack/MemoryMappedFile.cpp trunk/OpenMPT/mptrack/Mpt_midi.cpp trunk/OpenMPT/mptrack/Mptrack.cpp Modified: trunk/OpenMPT/mptrack/CommandSet.cpp =================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp 2014-02-11 13:48:40 UTC (rev 3699) +++ trunk/OpenMPT/mptrack/CommandSet.cpp 2014-02-11 17:44:09 UTC (rev 3700) @@ -1529,8 +1529,8 @@ while(iStrm.getline(s, CountOf(s))) { curLine = s; + l++; - //Cut everything after a // commentStart = curLine.Find("//"); if (commentStart>=0) @@ -1539,11 +1539,10 @@ if (!curLine.IsEmpty() && curLine.Compare("\n") !=0) { - bool ignoreLine = false; - - //ctx:UID:Description:Modifier:Key:EventMask int spos = 0; + // Format: ctx:UID:Description:Modifier:Key:EventMask + //context token=curLine.Tokenize(":",spos); kc.Context((InputTargetContext) atoi(token)); @@ -1560,7 +1559,7 @@ Log(err); } spos = -1; - ignoreLine = true; + continue; } //UID @@ -1595,42 +1594,36 @@ { // Don't fill in missing notes, as this will probably create awkward keymaps when loading // e.g. an IT-style keymap and it contains two keys mapped to the same notes. - ignoreLine = true; + continue; } - if(!ignoreLine) + //Error checking (TODO): + if (cmd < 0 || cmd >= kcNumCommands || kc.Context() >= kCtxMaxInputContexts || spos == -1) { - //Error checking (TODO): - if (cmd < 0 || cmd >= kcNumCommands || spos == -1) + errorCount++; + CString err; + if (errorCount < 10) { - errorCount++; - CString err; - if (errorCount < 10) + if(spos == -1) { - if(spos == -1) - { - err.Format("Line %d was not understood.", l); - } else - { - err.Format("Line %d contained an unknown command.", l); - } - errText += err + "\n"; - Log(err); - } else if (errorCount == 10) + err.Format("Line %d was not understood.", l); + } else { - err = "Too many errors detected, not reporting any more."; - errText += err + "\n"; - Log(err); + err.Format("Line %d contained an unknown command.", l); } - } else + errText += err + "\n"; + Log(err); + } else if (errorCount == 10) { - pTempCS->Add(kc, cmd, commandSet == nullptr); + err = "Too many errors detected, not reporting any more."; + errText += err + "\n"; + Log(err); } + } else + { + pTempCS->Add(kc, cmd, commandSet == nullptr); } - } - - l++; } //if(fileVersion < KEYMAP_VERSION) UpgradeKeymap(pTempCS, fileVersion); Modified: trunk/OpenMPT/mptrack/Ctrl_gen.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-02-11 13:48:40 UTC (rev 3699) +++ trunk/OpenMPT/mptrack/Ctrl_gen.cpp 2014-02-11 17:44:09 UTC (rev 3700) @@ -211,9 +211,10 @@ m_SliderTempo.EnableWindow(bIsNotMOD); m_EditSpeed.EnableWindow(bIsNotMOD); m_SpinSpeed.EnableWindow(bIsNotMOD); - m_SliderGlobalVol.EnableWindow(bIsNotMOD_XM); - m_EditGlobalVol.EnableWindow(bIsNotMOD_XM); - m_SpinGlobalVol.EnableWindow(bIsNotMOD_XM); + const BOOL globalVol = bIsNotMOD_XM || m_sndFile.m_nDefaultGlobalVolume != MAX_GLOBAL_VOLUME; + m_SliderGlobalVol.EnableWindow(globalVol); + m_EditGlobalVol.EnableWindow(globalVol); + m_SpinGlobalVol.EnableWindow(globalVol); m_EditSamplePA.EnableWindow(bIsNotMOD); m_SpinSamplePA.EnableWindow(bIsNotMOD); //m_SliderSamplePreAmp.EnableWindow(bIsNotMOD); Modified: trunk/OpenMPT/mptrack/Ctrl_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2014-02-11 13:48:40 UTC (rev 3699) +++ trunk/OpenMPT/mptrack/Ctrl_pat.cpp 2014-02-11 17:44:09 UTC (rev 3700) @@ -455,11 +455,11 @@ break; case CTRLMSG_PREVORDER: - m_OrderList.SetCurSel(m_OrderList.GetCurSel(true).firstOrd - 1, TRUE); + m_OrderList.SetCurSel(m_OrderList.GetCurSel(true).firstOrd - 1, true); break; case CTRLMSG_NEXTORDER: - m_OrderList.SetCurSel(m_OrderList.GetCurSel(true).firstOrd + 1, TRUE); + m_OrderList.SetCurSel(m_OrderList.GetCurSel(true).firstOrd + 1, true); break; //rewbs.customKeys Modified: trunk/OpenMPT/mptrack/Draw_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/Draw_pat.cpp 2014-02-11 13:48:40 UTC (rev 3699) +++ trunk/OpenMPT/mptrack/Draw_pat.cpp 2014-02-11 17:44:09 UTC (rev 3700) @@ -35,7 +35,7 @@ #define VUMETERS_LOWIDTH 16 -typedef struct PATTERNFONT +struct PATTERNFONT { int nWidth, nHeight; // Column Width & Height, including 4-pixels border int nClrX, nClrY; // Clear (empty note) location @@ -54,7 +54,7 @@ int nCmdOfs; // XOffset (-xxx) around the command letter int nParamHiWidth; int nInstrOfs, nInstr10Ofs, nInstrHiWidth; -} PATTERNFONT; +}; typedef const PATTERNFONT * PCPATTERNFONT; Modified: trunk/OpenMPT/mptrack/MemoryMappedFile.cpp =================================================================== --- trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2014-02-11 13:48:40 UTC (rev 3699) +++ trunk/OpenMPT/mptrack/MemoryMappedFile.cpp 2014-02-11 17:44:09 UTC (rev 3700) @@ -101,7 +101,7 @@ hmf, FILE_MAP_READ, 0, 0, - 0); + length); if(lpStream) { m_hFMap = hmf; Modified: trunk/OpenMPT/mptrack/Mpt_midi.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mpt_midi.cpp 2014-02-11 13:48:40 UTC (rev 3699) +++ trunk/OpenMPT/mptrack/Mpt_midi.cpp 2014-02-11 17:44:09 UTC (rev 3700) @@ -115,25 +115,23 @@ //------------------------------- { if (shMidiIn) return TRUE; - try + + if (midiInOpen(&shMidiIn, TrackerSettings::Instance().m_nMidiDevice, (DWORD_PTR)MidiInCallBack, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { - if (midiInOpen(&shMidiIn, TrackerSettings::Instance().m_nMidiDevice, (DWORD_PTR)MidiInCallBack, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) + shMidiIn = NULL; + + // Show MIDI configuration on fail. + CMainFrame::m_nLastOptionsPage = OPTIONS_PAGE_MIDI; + CMainFrame::GetMainFrame()->OnViewOptions(); + + // Let's see if the user updated the settings. + if(midiInOpen(&shMidiIn, TrackerSettings::Instance().m_nMidiDevice, (DWORD_PTR)MidiInCallBack, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) { shMidiIn = NULL; - - // Show MIDI configuration on fail. - CMainFrame::m_nLastOptionsPage = OPTIONS_PAGE_MIDI; - CMainFrame::GetMainFrame()->OnViewOptions(); - - // Let's see if the user updated the settings. - if(midiInOpen(&shMidiIn, TrackerSettings::Instance().m_nMidiDevice, (DWORD_PTR)MidiInCallBack, 0, CALLBACK_FUNCTION) != MMSYSERR_NOERROR) - { - shMidiIn = NULL; - return FALSE; - } + return FALSE; } - midiInStart(shMidiIn); - } catch (...) {} + } + midiInStart(shMidiIn); return TRUE; } Modified: trunk/OpenMPT/mptrack/Mptrack.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mptrack.cpp 2014-02-11 13:48:40 UTC (rev 3699) +++ trunk/OpenMPT/mptrack/Mptrack.cpp 2014-02-11 17:44:09 UTC (rev 3700) @@ -742,9 +742,9 @@ bool bIsAppDir = overridePortable; WCHAR tempConfigDirectory[MAX_PATH]; tempConfigDirectory[0] = 0; - if(!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tempConfigDirectory))) + if(SHGetFolderPathW(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, tempConfigDirectory) != S_OK) { - if(!SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, tempConfigDirectory))) + if(SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, SHGFP_TYPE_CURRENT, tempConfigDirectory) != S_OK) { bIsAppDir = true; } @@ -973,7 +973,7 @@ if(TrackerSettings::Instance().m_SoundSettingsOpenDeviceAtStartup) { pMainFrame->InitPreview(); - pMainFrame->PreparePreview(64); + pMainFrame->PreparePreview(NOTE_NOTECUT); pMainFrame->PlayPreview(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-11 17:45:57
|
Revision: 3701 http://sourceforge.net/p/modplug/code/3701 Author: saga-games Date: 2014-02-11 17:45:51 +0000 (Tue, 11 Feb 2014) Log Message: ----------- [Imp] Order list: When right-clicking an order item, don't move the playback position to this item. [Mod] OpenMPT: Version is now 1.22.07.21 Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_pat.h trunk/OpenMPT/mptrack/Ctrl_seq.cpp Modified: trunk/OpenMPT/mptrack/Ctrl_pat.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_pat.h 2014-02-11 17:44:09 UTC (rev 3700) +++ trunk/OpenMPT/mptrack/Ctrl_pat.h 2014-02-11 17:45:51 UTC (rev 3701) @@ -61,7 +61,7 @@ else if(!isSelectionKeyPressed && m_nScrollPos2nd != ORDERINDEX_INVALID) m_nScrollPos2nd = ORDERINDEX_INVALID; }; // Why VC wants to inline this huge function is beyond my understanding... - noinline bool SetCurSel(ORDERINDEX sel, bool bEdit = true, bool bShiftClick = false, bool bIgnoreCurSel = false); + noinline bool SetCurSel(ORDERINDEX sel, bool bEdit = true, bool bShiftClick = false, bool bIgnoreCurSel = false, bool setPlayPos = true); BOOL UpdateScrollInfo(); void UpdateInfoText(); int GetFontWidth(); Modified: trunk/OpenMPT/mptrack/Ctrl_seq.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-02-11 17:44:09 UTC (rev 3700) +++ trunk/OpenMPT/mptrack/Ctrl_seq.cpp 2014-02-11 17:45:51 UTC (rev 3701) @@ -276,8 +276,8 @@ } -bool COrderList::SetCurSel(ORDERINDEX sel, bool bEdit, bool bShiftClick, bool bIgnoreCurSel) -//------------------------------------------------------------------------------------------ +bool COrderList::SetCurSel(ORDERINDEX sel, bool bEdit, bool bShiftClick, bool bIgnoreCurSel, bool setPlayPos) +//----------------------------------------------------------------------------------------------------------- { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); CSoundFile &sndFile = m_pModDoc.GetrSoundFile(); @@ -317,7 +317,7 @@ if (bEdit) { PATTERNINDEX n = sndFile.Order[m_nScrollPos]; - if ((n < sndFile.Patterns.Size()) && (sndFile.Patterns[n]) && !bShiftClick) + if (sndFile.Patterns.IsValidPat(n) && setPlayPos && !bShiftClick) { CriticalSection cs; @@ -955,7 +955,7 @@ bool multiSelection = (m_nScrollPos2nd != ORDERINDEX_INVALID); - if(!multiSelection) SetCurSel(GetOrderFromPoint(rect, pt)); + if(!multiSelection) SetCurSel(GetOrderFromPoint(rect, pt), true, false, false, false); SetFocus(); HMENU hMenu = ::CreatePopupMenu(); if(!hMenu) return; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-14 22:11:50
|
Revision: 3716 http://sourceforge.net/p/modplug/code/3716 Author: saga-games Date: 2014-02-14 22:11:42 +0000 (Fri, 14 Feb 2014) Log Message: ----------- [New] Support MIDI mapping for aftertouch messages as well. Modified Paths: -------------- trunk/OpenMPT/mptrack/MIDIMapping.cpp trunk/OpenMPT/mptrack/MIDIMapping.h trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/Moddoc.cpp trunk/OpenMPT/mptrack/View_pat.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/MIDIMapping.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.cpp 2014-02-14 21:08:07 UTC (rev 3715) +++ trunk/OpenMPT/mptrack/MIDIMapping.cpp 2014-02-14 22:11:42 UTC (rev 3716) @@ -9,10 +9,10 @@ #include "stdafx.h" -#include "MIDIMapping.h" #include "../soundlib/MIDIEvents.h" #include "Mainfrm.h" #include "../soundlib/FileReader.h" +#include "MIDIMapping.h" std::string CMIDIMappingDirective::ToString() const @@ -116,46 +116,40 @@ } -bool CMIDIMapper::OnMIDImsg(const DWORD midimsg, BYTE& mappedIndex, uint32& paramindex, BYTE& paramval) -//----------------------------------------------------------------------------------------------------- +bool CMIDIMapper::OnMIDImsg(const DWORD midimsg, PLUGINDEX &mappedIndex, PlugParamIndex ¶mindex, uint8 ¶mval) +//------------------------------------------------------------------------------------------------------------------- { bool captured = false; - if(MIDIEvents::GetTypeFromEvent(midimsg) != MIDIEvents::evControllerChange) return captured; - //For now only controllers can be mapped so if event is not controller change, - //no mapping will be found and thus no search is done. - //NOTE: The event value is not checked in code below. + const MIDIEvents::EventType eventType = MIDIEvents::GetTypeFromEvent(midimsg); + const uint8 controller = MIDIEvents::GetDataByte1FromEvent(midimsg); + const uint8 channel = MIDIEvents::GetChannelFromEvent(midimsg); - const BYTE controller = MIDIEvents::GetDataByte1FromEvent(midimsg); + for(const_iterator citer = Begin(); citer != End() && !captured; citer++) + { + if(!citer->IsActive()) continue; + if(citer->GetEvent() != eventType) continue; + if(eventType == MIDIEvents::evControllerChange && citer->GetController() != controller) continue; + if(!citer->GetAnyChannel() && channel + 1 != citer->GetChannel()) continue; - const_iterator citer = std::lower_bound(Begin(), End(), controller); + const PLUGINDEX plugindex = citer->GetPlugIndex(); + const uint32 param = citer->GetParamIndex(); + const uint8 val = (citer->GetEvent() == MIDIEvents::evChannelAftertouch ? controller : MIDIEvents::GetDataByte2FromEvent(midimsg)) & 0x7F; - const BYTE channel = MIDIEvents::GetChannelFromEvent(midimsg); + if(citer->GetAllowPatternEdit()) + { + mappedIndex = plugindex; + paramindex = param; + paramval = val; + } + if(citer->GetCaptureMIDI()) captured = true; - for(; citer != End() && citer->GetController() == controller && !captured; citer++) - { - if(!citer->IsActive()) continue; - BYTE plugindex = 0; - uint32 param = 0; - if( citer->GetAnyChannel() || channel+1 == citer->GetChannel()) + if(plugindex > 0 && plugindex <= MAX_MIXPLUGINS) { - plugindex = citer->GetPlugIndex(); - param = citer->GetParamIndex(); - if(citer->GetAllowPatternEdit()) - { - mappedIndex = plugindex; - paramindex = param; - paramval = MIDIEvents::GetDataByte2FromEvent(midimsg); - } - if(citer->GetCaptureMIDI()) captured = true; - - if(plugindex > 0 && plugindex <= MAX_MIXPLUGINS) - { - IMixPlugin* pPlug = m_rSndFile.m_MixPlugins[plugindex-1].pMixPlugin; - if(!pPlug) continue; - pPlug->SetZxxParameter(param, (midimsg >> 16) & 0x7F); - CMainFrame::GetMainFrame()->ThreadSafeSetModified(m_rSndFile.GetpModDoc()); - } + IMixPlugin *pPlug = m_rSndFile.m_MixPlugins[plugindex - 1].pMixPlugin; + if(!pPlug) continue; + pPlug->SetZxxParameter(param, val); + CMainFrame::GetMainFrame()->ThreadSafeSetModified(m_rSndFile.GetpModDoc()); } } Modified: trunk/OpenMPT/mptrack/MIDIMapping.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.h 2014-02-14 21:08:07 UTC (rev 3715) +++ trunk/OpenMPT/mptrack/MIDIMapping.h 2014-02-14 22:11:42 UTC (rev 3716) @@ -92,7 +92,7 @@ // -paramvalue to parameter value. //In case of multiple mappings, these get the values from the last mapping found. //Returns true if MIDI was 'captured' by some directive, false otherwise. - bool OnMIDImsg(const DWORD midimsg, BYTE& mappedIndex, uint32& paramindex, BYTE& paramvalue); + bool OnMIDImsg(const DWORD midimsg, PLUGINDEX &mappedIndex, PlugParamIndex ¶mindex, uint8 ¶mvalue); //Swaps the positions of two elements. Returns true if swap was not done. bool Swap(const size_t a, const size_t b); Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2014-02-14 21:08:07 UTC (rev 3715) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2014-02-14 22:11:42 UTC (rev 3716) @@ -70,15 +70,25 @@ LRESULT CMIDIMappingDialog::OnMidiMsg(WPARAM dwMidiDataParam, LPARAM) //------------------------------------------------------------------- { - if(MIDIEvents::GetTypeFromEvent(dwMidiDataParam) == MIDIEvents::evControllerChange && IsDlgButtonChecked(IDC_CHECK_MIDILEARN)) + if(IsDlgButtonChecked(IDC_CHECK_MIDILEARN)) { - m_ChannelCBox.SetCurSel(1 + MIDIEvents::GetChannelFromEvent(dwMidiDataParam)); - m_EventCBox.SetCurSel(0); - m_ControllerCBox.SetCurSel(MIDIEvents::GetDataByte1FromEvent(dwMidiDataParam)); - OnCbnSelchangeComboChannel(); - OnCbnSelchangeComboEvent(); - OnCbnSelchangeComboController(); - UpdateString(); + for(int i = 0; i < m_EventCBox.GetCount(); i++) + { + if(static_cast<MIDIEvents::EventType>(m_EventCBox.GetItemData(i)) == MIDIEvents::GetTypeFromEvent(dwMidiDataParam)) + { + m_ChannelCBox.SetCurSel(1 + MIDIEvents::GetChannelFromEvent(dwMidiDataParam)); + m_EventCBox.SetCurSel(i); + if(MIDIEvents::GetTypeFromEvent(dwMidiDataParam) == MIDIEvents::evControllerChange) + { + m_ControllerCBox.SetCurSel(MIDIEvents::GetDataByte1FromEvent(dwMidiDataParam)); + } + OnCbnSelchangeComboChannel(); + OnCbnSelchangeComboEvent(); + OnCbnSelchangeComboController(); + UpdateString(); + break; + } + } } return 1; } @@ -89,7 +99,18 @@ { CDialog::OnInitDialog(); - m_EventCBox.SetCurSel(0); + 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.SetCurSel(-1); + for(int i = 0; i < m_EventCBox.GetCount(); i++) + { + if(m_EventCBox.GetItemData(i) == m_Setting.GetEvent()) + { + m_EventCBox.SetCurSel(i); + break; + } + } //Add controller names. for(size_t i = MIDIEvents::MIDICC_start; i <= MIDIEvents::MIDICC_end; i++) @@ -150,12 +171,16 @@ m_ChannelCBox.SetCurSel(activeSetting.GetChannel()); - if(m_Setting.GetEvent() == MIDIEvents::evControllerChange) - m_EventCBox.SetCurSel(0); - else - m_EventCBox.SetCurSel(-1); + m_EventCBox.SetCurSel(-1); + for(int i = 0; i < m_EventCBox.GetCount(); i++) + { + if(m_EventCBox.GetItemData(i) == m_Setting.GetEvent()) + { + m_EventCBox.SetCurSel(i); + break; + } + } - m_ControllerCBox.SetCurSel(activeSetting.GetController()); m_PluginCBox.SetCurSel(activeSetting.GetPlugIndex()-1); m_PlugParamCBox.SetCurSel(activeSetting.GetParamIndex()); @@ -240,13 +265,11 @@ void CMIDIMappingDialog::OnCbnSelchangeComboEvent() //------------------------------------------------- { - if(m_EventCBox.GetCurSel() == 0) - { - m_Setting.SetEvent(0xB); - m_ControllerCBox.EnableWindow(); - } - else - m_ControllerCBox.EnableWindow(FALSE); + uint8 eventType = static_cast<uint8>(m_EventCBox.GetItemData(m_EventCBox.GetCurSel())); + m_Setting.SetEvent(eventType); + m_ControllerCBox.EnableWindow(eventType == MIDIEvents::evControllerChange ? TRUE : FALSE); + if(eventType != MIDIEvents::evControllerChange) + m_ControllerCBox.SetCurSel(0); UpdateString(); } @@ -283,7 +306,7 @@ m_rSndFile.GetpModDoc()->SetModified(); m_List.DeleteString(i); - m_List.InsertString(newIndex, CreateListString(m_Setting)); + m_List.InsertString(newIndex, CreateListString(m_Setting)); m_List.SetCurSel(newIndex); OnLbnSelchangeList1(); } @@ -331,7 +354,7 @@ str.AppendChar('.'); //Controller name - if(s.GetController() <= MIDIEvents::MIDICC_end) + if(s.GetController() <= MIDIEvents::MIDICC_end && s.GetEvent() == MIDIEvents::evControllerChange) { CString tstr; tstr.Format("%d %s", s.GetController(), MIDIEvents::MidiCCNames[s.GetController()]); Modified: trunk/OpenMPT/mptrack/Moddoc.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moddoc.cpp 2014-02-14 21:08:07 UTC (rev 3715) +++ trunk/OpenMPT/mptrack/Moddoc.cpp 2014-02-14 22:11:42 UTC (rev 3716) @@ -971,8 +971,9 @@ if((event == MIDIEvents::evNoteOn) && !vol) event = MIDIEvents::evNoteOff; //Convert event to note-off if req'd - uint8 mappedIndex = 0, paramValue = 0; - uint32 paramIndex = 0; + PLUGINDEX mappedIndex = 0; + PlugParamIndex paramIndex = 0; + uint8 paramValue = 0; bool captured = m_SndFile.GetMIDIMapper().OnMIDImsg(midiData, mappedIndex, paramIndex, paramValue); // Handle MIDI messages assigned to shortcuts Modified: trunk/OpenMPT/mptrack/View_pat.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_pat.cpp 2014-02-14 21:08:07 UTC (rev 3715) +++ trunk/OpenMPT/mptrack/View_pat.cpp 2014-02-14 22:11:42 UTC (rev 3716) @@ -3833,9 +3833,10 @@ // Handle MIDI mapping. - uint8 mappedIndex = uint8_max, paramValue = uint8_max; - uint32 paramIndex = 0; - bool captured = sndFile.GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue); + PLUGINDEX mappedIndex = uint8_max; + PlugParamIndex paramIndex = 0; + uint8 paramValue = uint8_max; + bool captured = sndFile.GetMIDIMapper().OnMIDImsg(dwMidiData, mappedIndex, paramIndex, paramValue); // Handle MIDI messages assigned to shortcuts @@ -3854,7 +3855,7 @@ ModCommandPos editpos = GetEditPos(sndFile, liveRecord); ModCommand &m = GetModCommand(sndFile, editpos); - pModDoc->GetPatternUndo().PrepareUndo(editpos.pattern, editpos.channel, editpos.row, 1, 1, "MIDI Record Entry"); + pModDoc->GetPatternUndo().PrepareUndo(editpos.pattern, editpos.channel, editpos.row, 1, 1, "MIDI Mapping Record"); m.Set(NOTE_PCS, mappedIndex, static_cast<uint16>(paramIndex), static_cast<uint16>((paramValue * ModCommand::maxColumnValue) / 127)); if(!liveRecord) InvalidateRow(editpos.row); @@ -4045,14 +4046,8 @@ case VIEWMSG_DOMIDISPACING: if (m_nSpacing) { -// -> CODE#0012 -// -> DESC="midi keyboard split" - //CModDoc *pModDoc = GetDocument(); - //CSoundFile * pSndFile = pModDoc->GetSoundFile(); -// if (timeGetTime() - lParam >= 10) int temp = timeGetTime(); if (temp - lParam >= 60) -// -! NEW_FEATURE#0012 { CModDoc *pModDoc = GetDocument(); CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); @@ -4064,8 +4059,6 @@ } } else { -// -> CODE#0012 -// -> DESC="midi keyboard split" // Sleep(1); Sleep(0); PostMessage(WM_MOD_VIEWMSG, VIEWMSG_DOMIDISPACING, lParam); @@ -5553,6 +5546,11 @@ ModCommand newCommand = target; CSoundFile *pSndFile = GetSoundFile(); + if(target.IsPcNote()) + { + return; + } + switch(TrackerSettings::Instance().aftertouchBehaviour) { case atRecordAsVolume: Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-02-14 21:08:07 UTC (rev 3715) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-02-14 22:11:42 UTC (rev 3716) @@ -2795,9 +2795,6 @@ 0x3531, "\000" IDC_COMBO_CHANNEL, 0x403, 3, 0 0x3631, "\000" - IDC_COMBO_EVENT, 0x403, 24, 0 -0x6f43, 0x746e, 0x6f72, 0x6c6c, 0x7265, 0x6320, 0x6168, 0x676e, 0x2065, -0x3028, 0x4278, 0x0029, 0 END This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-15 13:46:11
|
Revision: 3717 http://sourceforge.net/p/modplug/code/3717 Author: saga-games Date: 2014-02-15 13:46:00 +0000 (Sat, 15 Feb 2014) Log Message: ----------- [Ref] Effect info code cleanup [Ref] MIDI Mapping Dialog code cleanup Modified Paths: -------------- trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/MIDIMapping.cpp trunk/OpenMPT/mptrack/MIDIMapping.h trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/MIDIMappingDialog.h Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-02-14 22:11:42 UTC (rev 3716) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-02-15 13:46:00 UTC (rev 3717) @@ -24,17 +24,17 @@ ModCommand::PARAM paramValue; // 0 = default ModCommand::PARAM paramLimit; // Parameter Editor limit MODTYPE supportedFormats; // MOD_TYPE_XXX combo - LPCSTR name; // e.g. "Tone Portamento" + const char *name; // e.g. "Tone Portamento" }; -#define MOD_TYPE_MODXM (MOD_TYPE_MOD | MOD_TYPE_XM) -#define MOD_TYPE_S3MIT (MOD_TYPE_S3M | MOD_TYPE_IT) -#define MOD_TYPE_S3MITMPT (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT) -#define MOD_TYPE_NOMOD (MOD_TYPE_S3M | MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT) -#define MOD_TYPE_XMIT (MOD_TYPE_XM | MOD_TYPE_IT) -#define MOD_TYPE_XMITMPT (MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT) -#define MOD_TYPE_ITMPT (MOD_TYPE_IT | MOD_TYPE_MPT) -#define MOD_TYPE_ALL ((MODTYPE)~0) +#define MOD_TYPE_MODXM (MOD_TYPE_MOD | MOD_TYPE_XM) +#define MOD_TYPE_S3MIT (MOD_TYPE_S3M | MOD_TYPE_IT) +#define MOD_TYPE_S3MITMPT (MOD_TYPE_S3M | MOD_TYPE_IT | MOD_TYPE_MPT) +#define MOD_TYPE_NOMOD (MOD_TYPE_S3M | MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT) +#define MOD_TYPE_XMIT (MOD_TYPE_XM | MOD_TYPE_IT) +#define MOD_TYPE_XMITMPT (MOD_TYPE_XM | MOD_TYPE_IT | MOD_TYPE_MPT) +#define MOD_TYPE_ITMPT (MOD_TYPE_IT | MOD_TYPE_MPT) +#define MOD_TYPE_ALL ((MODTYPE)~0) const MPTEFFECTINFO gFXInfo[] = @@ -112,13 +112,13 @@ {CMD_DELAYCUT, 0x00,0x00, 0, MOD_TYPE_MPT, "Note Delay and Cut"}, // -> CODE#0010 // -> DESC="add extended parameter mechanism to pattern effects" - {CMD_XPARAM, 0x00,0x00, 0, MOD_TYPE_XMITMPT, "Parameter Extension"}, + {CMD_XPARAM, 0,0, 0, MOD_TYPE_XMITMPT, "Parameter Extension"}, // -! NEW_FEATURE#0010 - {CMD_NOTESLIDEUP, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Up"}, // IMF / PTM effect - {CMD_NOTESLIDEDOWN, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Down"}, // IMF / PTM effect - {CMD_NOTESLIDEUPRETRIG, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Up + Retrigger Note"}, // PTM effect - {CMD_NOTESLIDEDOWNRETRIG, 0x00,0x00, 0, MOD_TYPE_NONE, "Note Slide Down+ Retrigger Note"}, // PTM effect - {CMD_REVERSEOFFSET, 0x00,0x00, 0, MOD_TYPE_NONE, "Revert Sample + Offset"}, // PTM effect + {CMD_NOTESLIDEUP, 0,0, 0, MOD_TYPE_IMF | MOD_TYPE_PTM, "Note Slide Up"}, // IMF / PTM effect + {CMD_NOTESLIDEDOWN, 0,0, 0, MOD_TYPE_IMF | MOD_TYPE_PTM, "Note Slide Down"}, // IMF / PTM effect + {CMD_NOTESLIDEUPRETRIG, 0,0, 0, MOD_TYPE_PTM, "Note Slide Up + Retrigger Note"}, // PTM effect + {CMD_NOTESLIDEDOWNRETRIG,0,0, 0, MOD_TYPE_PTM, "Note Slide Down + Retrigger Note"}, // PTM effect + {CMD_REVERSEOFFSET, 0,0, 0, MOD_TYPE_PTM, "Revert Sample + Offset"}, // PTM effect }; @@ -167,9 +167,8 @@ if ((gFXInfo[fxndx].paramMask & 0x0F) == 0x0F) pszDescription[2] = szHexChar[gFXInfo[fxndx].paramValue & 0x0F]; } strcat(pszDescription, gFXInfo[fxndx].name); - //rewbs.xinfo //Get channel specific info - if (nChn < sndFile.m_nChannels) + if (nChn < sndFile.GetNumChannels()) { CString chanSpec = ""; size_t macroIndex = size_t(-1); @@ -204,13 +203,12 @@ const PLUGINDEX plugin = sndFile.GetBestPlugin(nChn, PrioritiseChannel, EvenIfMuted) - 1; chanSpec.Append(sndFile.m_MidiCfg.GetParameteredMacroName(macroIndex, plugin, sndFile)); } - if (chanSpec != "") + if (!chanSpec.IsEmpty()) { strcat(pszDescription, chanSpec); } } - //end rewbs.xinfo } return bSupported; } @@ -323,11 +321,7 @@ case CMD_TEMPO: nmin = 0x20; if (sndFile.GetType() & MOD_TYPE_MOD) nmin = 0x21; else - // -> CODE#0010 - // -> DESC="add extended parameter mechanism to pattern effects" - // if (nType & MOD_TYPE_S3MIT) nmin = 1; if (sndFile.GetType() & MOD_TYPE_S3MITMPT) nmin = 0; - // -! NEW_FEATURE#0010 break; case CMD_VOLUMESLIDE: case CMD_TONEPORTAVOL: @@ -536,7 +530,9 @@ break; case CMD_TEMPO: - if (param < 0x10) + if (param == 0) + strcpy(s, "continue"); + else if (param < 0x10) wsprintf(s, "-%d bpm (slower)", param & 0x0F); else if (param < 0x20) wsprintf(s, "+%d bpm (faster)", param & 0x0F); @@ -545,12 +541,10 @@ break; case CMD_PANNING8: - wsprintf(s, "%d", param); - if(sndFile.GetType() == MOD_TYPE_S3M) - { - if(param == 0xA4) - strcpy(s, "Surround"); - } + if(sndFile.GetType() == MOD_TYPE_S3M && param == 0xA4) + strcpy(s, "Surround"); + else + wsprintf(s, "%d", param); break; case CMD_RETRIG: @@ -606,27 +600,23 @@ if (!param) { wsprintf(s, "continue"); + } else if ((sndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0x0F) == 0x0F) && (param & 0xF0)) + { + wsprintf(s, "fine %s%d", sPlusChar.c_str(), param >> 4); + } else if ((sndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0xF0) == 0xF0) && (param & 0x0F)) + { + wsprintf(s, "fine %s%d", sMinusChar.c_str(), param & 0x0F); + } else if ((param & 0x0F) != param && (param & 0xF0) != param) // both nibbles are set. + { + strcpy(s, "undefined"); + } else if (param & 0x0F) + { + wsprintf(s, "%s%d", sMinusChar.c_str(), param & 0x0F); } else - if ((sndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0x0F) == 0x0F) && (param & 0xF0)) - { - wsprintf(s, "fine %s%d", sPlusChar.c_str(), param >> 4); - } else - if ((sndFile.GetType() & MOD_TYPE_S3MITMPT) && ((param & 0xF0) == 0xF0) && (param & 0x0F)) - { - wsprintf(s, "fine %s%d", sMinusChar.c_str(), param & 0x0F); - } else - if ((param & 0x0F) != param && (param & 0xF0) != param) // both nibbles are set. - { - strcpy(s, "undefined"); - } else - if (param & 0x0F) - { - wsprintf(s, "%s%d", sMinusChar.c_str(), param & 0x0F); - } else - { - wsprintf(s, "%s%d", sPlusChar.c_str(), param >> 4); - } - break; + { + wsprintf(s, "%s%d", sPlusChar.c_str(), param >> 4); + } + break; case CMD_PATTERNBREAK: wsprintf(pszName, "Break to row %d", param); @@ -638,11 +628,7 @@ case CMD_OFFSET: if (param) - // -> CODE#0010 - // -> DESC="add extended parameter mechanism to pattern effects" - // wsprintf(pszName, "Set Offset to %u", param << 8); wsprintf(pszName, "Set Offset to %u", param); - // -! NEW_FEATURE#0010 else strcpy(s, "continue"); break; @@ -727,10 +713,10 @@ case 0x0A: strcpy(s, "7A: Pan Env On"); break; case 0x0B: strcpy(s, "7B: Pitch Env Off"); break; case 0x0C: strcpy(s, "7C: Pitch Env On"); break; - // intentional fall-through for non-MPT modules follows - MPT_FALLTHROUGH; case 0x0D: if(sndFile.GetType() == MOD_TYPE_MPT) { strcpy(s, "7D: Force Pitch Env"); break; } + MPT_FALLTHROUGH; case 0x0E: if(sndFile.GetType() == MOD_TYPE_MPT) { strcpy(s, "7E: Force Filter Env"); break; } + MPT_FALLTHROUGH; default: wsprintf(s, "%02X: undefined", param); break; } } else @@ -861,15 +847,16 @@ strcat(s, " rows"); break; case 0xF0: - if(sndFile.GetType() == MOD_TYPE_MOD) // invert loop + if(sndFile.GetType() == MOD_TYPE_MOD) { + // invert loop if((param & 0x0F) == 0) strcpy(s, "Stop"); else wsprintf(s, "Speed %d", param & 0x0F); - } - else // macro + } else { + // macro wsprintf(s, "SF%X", param & 0x0F); } break; @@ -892,12 +879,12 @@ //////////////////////////////////////////////////////////////////////////////////////// // Volume column effects description -typedef struct MPTVOLCMDINFO +struct MPTVOLCMDINFO { ModCommand::VOLCMD volCmd; // VOLCMD_XXXX - DWORD supportedFormats; // MOD_TYPE_XXX combo - LPCSTR name; // e.g. "Set Volume" -} MPTVOLCMDINFO; + MODTYPE supportedFormats; // MOD_TYPE_XXX combo + const char *name; // e.g. "Set Volume" +}; const MPTVOLCMDINFO gVolCmdInfo[] = { @@ -915,7 +902,7 @@ {VOLCMD_PORTAUP, MOD_TYPE_ITMPT, "Portamento up"}, {VOLCMD_PORTADOWN, MOD_TYPE_ITMPT, "Portamento down"}, {VOLCMD_DELAYCUT, MOD_TYPE_NONE, ""}, - {VOLCMD_OFFSET, MOD_TYPE_ITMPT, "Offset"}, //rewbs.volOff + {VOLCMD_OFFSET, MOD_TYPE_ITMPT, "Offset"}, }; STATIC_ASSERT(CountOf(gVolCmdInfo) == (MAX_VOLCMDS - 1)); Modified: trunk/OpenMPT/mptrack/MIDIMapping.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.cpp 2014-02-14 22:11:42 UTC (rev 3716) +++ trunk/OpenMPT/mptrack/MIDIMapping.cpp 2014-02-15 13:46:00 UTC (rev 3717) @@ -32,9 +32,9 @@ size_t s = 0; for(const_iterator citer = Begin(); citer != End(); citer++) { - if(citer->GetParamIndex() <= uint8_max) {s += 5; continue;} - if(citer->GetParamIndex() <= uint16_max) {s += 6; continue;} - s += 8; + if(citer->GetParamIndex() <= uint8_max) s += 5; + else if(citer->GetParamIndex() <= uint16_max) s += 6; + else s += 8; } return s; } Modified: trunk/OpenMPT/mptrack/MIDIMapping.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMapping.h 2014-02-14 22:11:42 UTC (rev 3716) +++ trunk/OpenMPT/mptrack/MIDIMapping.h 2014-02-15 13:46:00 UTC (rev 3717) @@ -46,15 +46,16 @@ BYTE GetController() const {return m_MIDIByte1;} //Note: Plug index starts from 1. - void SetPlugIndex(const int i) {m_PluginIndex = static_cast<BYTE>(i);} - BYTE GetPlugIndex() const {return m_PluginIndex;} + void SetPlugIndex(const int i) {m_PluginIndex = static_cast<PLUGINDEX>(i);} + PLUGINDEX GetPlugIndex() const {return m_PluginIndex;} void SetParamIndex(const int i) {m_Parameter = i;} uint32 GetParamIndex() const {return m_Parameter;} bool IsDefault() const {return *this == CMIDIMappingDirective();} - bool operator==(const CMIDIMappingDirective& d) const {return memcmp(this, &d, sizeof(CMIDIMappingDirective)) == 0;} + bool operator==(const CMIDIMappingDirective &other) const { return memcmp(this, &other, sizeof(CMIDIMappingDirective)) == 0; } + bool operator<(const CMIDIMappingDirective &other) const { return GetController() < other.GetController(); } std::string ToString() const; @@ -67,16 +68,13 @@ bool m_AnyChannel; uint8 m_ChnEvent; //0-3 channel, 4-7 event BYTE m_MIDIByte1; - BYTE m_PluginIndex; + PLUGINDEX m_PluginIndex; uint32 m_Parameter; }; class CSoundFile; class FileReader; -inline bool operator<(const CMIDIMappingDirective& a, const CMIDIMappingDirective& b) {return a.GetController() < b.GetController();} -inline bool operator<(const CMIDIMappingDirective& d, const BYTE& ctrlVal) {return d.GetController() < ctrlVal;} -inline bool operator<(const BYTE& ctrlVal, const CMIDIMappingDirective& d) {return ctrlVal < d.GetController();} //=============== class CMIDIMapper Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2014-02-14 22:11:42 UTC (rev 3716) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2014-02-15 13:46:00 UTC (rev 3717) @@ -17,7 +17,6 @@ // CMIDIMappingDialog dialog -IMPLEMENT_DYNAMIC(CMIDIMappingDialog, CDialog) CMIDIMappingDialog::CMIDIMappingDialog(CWnd* pParent /*=NULL*/, CSoundFile& rSndfile) : CDialog(CMIDIMappingDialog::IDD, pParent), m_rSndFile(rSndfile), m_rMIDIMapper(m_rSndFile.GetMIDIMapper()) @@ -99,20 +98,12 @@ { 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.SetCurSel(-1); - for(int i = 0; i < m_EventCBox.GetCount(); i++) - { - if(m_EventCBox.GetItemData(i) == m_Setting.GetEvent()) - { - m_EventCBox.SetCurSel(i); - break; - } - } - //Add controller names. + // Add controller names for(size_t i = MIDIEvents::MIDICC_start; i <= MIDIEvents::MIDICC_end; i++) { CString temp; @@ -120,35 +111,27 @@ m_ControllerCBox.AddString(temp); } - //Add Pluginnames + // Add plugin names AddPluginNamesToCombobox(m_PluginCBox, m_rSndFile.m_MixPlugins); - m_PluginCBox.SetCurSel(m_Setting.GetPlugIndex()-1); - //Add plugin parameter names - AddPluginParameternamesToCombobox(m_PlugParamCBox, m_rSndFile.m_MixPlugins[(m_Setting.GetPlugIndex() <= MAX_MIXPLUGINS) ? m_Setting.GetPlugIndex() - 1 : 0]); - m_PlugParamCBox.SetCurSel(m_Setting.GetParamIndex()); - - //Add directives to list. + // Add directives to list typedef CMIDIMapper::const_iterator CITER; for(CITER iter = m_rMIDIMapper.Begin(); iter != m_rMIDIMapper.End(); iter++) { m_List.AddString(CreateListString(*iter)); } + if(m_rMIDIMapper.GetCount() > 0 && m_Setting.IsDefault()) { m_List.SetCurSel(0); OnLbnSelchangeList1(); - } - else + } else { - m_ChannelCBox.SetCurSel(m_Setting.GetChannel()); - m_ControllerCBox.SetCurSel(m_Setting.GetController()); - CheckDlgButton(IDC_CHECKACTIVE, m_Setting.IsActive() ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(IDC_CHECKCAPTURE, m_Setting.GetCaptureMIDI() ? BST_CHECKED : BST_UNCHECKED); - GetDlgItem(IDC_CHECK_PATRECORD)->ShowWindow((m_rSndFile.GetType() == MOD_TYPE_MPT) ? SW_SHOW : SW_HIDE); - CheckDlgButton(IDC_CHECK_PATRECORD, m_Setting.GetAllowPatternEdit() ? BST_CHECKED : BST_UNCHECKED); + UpdateDialog(); } + GetDlgItem(IDC_CHECK_PATRECORD)->EnableWindow((m_rSndFile.GetType() == MOD_TYPE_MPT) ? TRUE : FALSE); + UpdateString(); CMainFrame::GetMainFrame()->SetMidiRecordWnd(GetSafeHwnd()); @@ -158,19 +141,16 @@ return TRUE; // return TRUE unless you set the focus to a control } -void CMIDIMappingDialog::OnLbnSelchangeList1() -//-------------------------------------------- + +void CMIDIMappingDialog::UpdateDialog() +//------------------------------------- { - const int i = m_List.GetCurSel(); - if(i < 0 || (size_t)i >= m_rMIDIMapper.GetCount()) return; - m_Setting = m_rMIDIMapper.GetDirective(i); - CMIDIMappingDirective& activeSetting = m_Setting; - CheckDlgButton(IDC_CHECKACTIVE, activeSetting.IsActive() ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(IDC_CHECKCAPTURE, activeSetting.GetCaptureMIDI() ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(IDC_CHECK_PATRECORD, activeSetting.GetAllowPatternEdit() ? BST_CHECKED : BST_UNCHECKED); - - m_ChannelCBox.SetCurSel(activeSetting.GetChannel()); + CheckDlgButton(IDC_CHECKACTIVE, m_Setting.IsActive() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_CHECKCAPTURE, m_Setting.GetCaptureMIDI() ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(IDC_CHECK_PATRECORD, m_Setting.GetAllowPatternEdit() ? BST_CHECKED : BST_UNCHECKED); + m_ChannelCBox.SetCurSel(m_Setting.GetChannel()); + m_EventCBox.SetCurSel(-1); for(int i = 0; i < m_EventCBox.GetCount(); i++) { @@ -181,19 +161,50 @@ } } - m_ControllerCBox.SetCurSel(activeSetting.GetController()); - m_PluginCBox.SetCurSel(activeSetting.GetPlugIndex()-1); - m_PlugParamCBox.SetCurSel(activeSetting.GetParamIndex()); - SetDlgItemText(IDC_EDIT1, activeSetting.ToString().c_str()); + m_ControllerCBox.SetCurSel(m_Setting.GetController()); + m_PluginCBox.SetCurSel(m_Setting.GetPlugIndex() - 1); + m_PlugParamCBox.SetCurSel(m_Setting.GetParamIndex()); + SetDlgItemText(IDC_EDIT1, m_Setting.ToString().c_str()); - OnCbnSelchangeComboPlugin(); - OnCbnSelchangeComboEvent(); + UpdateEvent(); + UpdateParameters(); - const bool enableMover = ( (i > 0 && m_rMIDIMapper.AreOrderEqual(i-1, i)) || (i + 1 < m_List.GetCount() && m_rMIDIMapper.AreOrderEqual(i, i+1))); + const int i = m_List.GetCurSel(); + const bool enableMover = i >= 0 && ( (i > 0 && m_rMIDIMapper.AreOrderEqual(i - 1, i)) || (i + 1 < m_List.GetCount() && m_rMIDIMapper.AreOrderEqual(i, i + 1))); m_SpinMoveMapping.EnableWindow(enableMover); } +void CMIDIMappingDialog::UpdateEvent() +//------------------------------------ +{ + m_ControllerCBox.EnableWindow(m_Setting.GetEvent() == MIDIEvents::evControllerChange ? TRUE : FALSE); + if(m_Setting.GetEvent() != MIDIEvents::evControllerChange) + m_ControllerCBox.SetCurSel(0); +} + + +void CMIDIMappingDialog::UpdateParameters() +//------------------------------------------ +{ + m_PlugParamCBox.SetRedraw(FALSE); + m_PlugParamCBox.ResetContent(); + AddPluginParameternamesToCombobox(m_PlugParamCBox, m_rSndFile.m_MixPlugins[m_Setting.GetPlugIndex()]); + m_PlugParamCBox.SetCurSel(m_Setting.GetParamIndex()); + m_PlugParamCBox.SetRedraw(TRUE); +} + + +void CMIDIMappingDialog::OnLbnSelchangeList1() +//-------------------------------------------- +{ + const int i = m_List.GetCurSel(); + if(i < 0 || (size_t)i >= m_rMIDIMapper.GetCount()) return; + m_Setting = m_rMIDIMapper.GetDirective(i); + UpdateDialog(); +} + + void CMIDIMappingDialog::OnBnClickedCheckactive() //----------------------------------------------- { @@ -247,9 +258,7 @@ int i = m_PluginCBox.GetCurSel(); if(i < 0 || i >= MAX_MIXPLUGINS) return; m_Setting.SetPlugIndex(i+1); - m_PlugParamCBox.ResetContent(); - AddPluginParameternamesToCombobox(m_PlugParamCBox, m_rSndFile.m_MixPlugins[i]); - m_PlugParamCBox.SetCurSel(m_Setting.GetParamIndex()); + UpdateParameters(); UpdateString(); } @@ -267,10 +276,7 @@ { uint8 eventType = static_cast<uint8>(m_EventCBox.GetItemData(m_EventCBox.GetCurSel())); m_Setting.SetEvent(eventType); - m_ControllerCBox.EnableWindow(eventType == MIDIEvents::evControllerChange ? TRUE : FALSE); - if(eventType != MIDIEvents::evControllerChange) - m_ControllerCBox.SetCurSel(0); - + UpdateEvent(); UpdateString(); } Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.h =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.h 2014-02-14 22:11:42 UTC (rev 3716) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.h 2014-02-15 13:46:00 UTC (rev 3717) @@ -21,48 +21,42 @@ class CMIDIMappingDialog : public CDialog //======================================= { - DECLARE_DYNAMIC(CMIDIMappingDialog) - public: - CMIDIMappingDialog(CWnd* pParent, CSoundFile& rSndfile); - virtual ~CMIDIMappingDialog(); - -// Dialog Data - enum { IDD = IDD_MIDIPARAMCONTROL }; - CMIDIMappingDirective m_Setting; protected: - virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - - DECLARE_MESSAGE_MAP() - -private: CSoundFile& m_rSndFile; CMIDIMapper& m_rMIDIMapper; HWND oldMIDIRecondWnd; -private: - void UpdateString(); - CString CreateListString(const CMIDIMappingDirective& s); -public: - virtual BOOL OnInitDialog(); -private: + // Dialog Data + enum { IDD = IDD_MIDIPARAMCONTROL }; CComboBox m_ControllerCBox; CComboBox m_PluginCBox; CComboBox m_PlugParamCBox; CComboBox m_ChannelCBox; CComboBox m_EventCBox; - CEdit m_EditValue; - CListBox m_List; - CSpinButtonCtrl m_SpinMoveMapping; - public: + CMIDIMappingDialog(CWnd* pParent, CSoundFile& rSndfile); + ~CMIDIMappingDialog(); + +protected: + void UpdateDialog(); + void UpdateEvent(); + void UpdateParameters(); + void UpdateString(); + CString CreateListString(const CMIDIMappingDirective& s); + + virtual BOOL OnInitDialog(); + virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support + + DECLARE_MESSAGE_MAP() + afx_msg void OnLbnSelchangeList1(); afx_msg void OnBnClickedCheckactive(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-15 16:54:17
|
Revision: 3719 http://sourceforge.net/p/modplug/code/3719 Author: saga-games Date: 2014-02-15 16:54:10 +0000 (Sat, 15 Feb 2014) Log Message: ----------- [Fix] Parameter Editor: Initial point spacing was a bit off, and the effect dropdown box was not wide enough to show some effect names completely [Ref] Some refactoring in the param editor... still looks ugly. Modified Paths: -------------- trunk/OpenMPT/mptrack/EffectInfo.cpp trunk/OpenMPT/mptrack/EffectInfo.h trunk/OpenMPT/mptrack/EffectVis.cpp trunk/OpenMPT/mptrack/EffectVis.h trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp Modified: trunk/OpenMPT/mptrack/EffectInfo.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-02-15 16:41:50 UTC (rev 3718) +++ trunk/OpenMPT/mptrack/EffectInfo.cpp 2014-02-15 16:54:10 UTC (rev 3719) @@ -233,10 +233,9 @@ //Returns command and corrects parameter refParam if necessary -ModCommand::COMMAND EffectInfo::GetEffectFromIndex(UINT ndx, int &refParam) const -//------------------------------------------------------------------------------- +ModCommand::COMMAND EffectInfo::GetEffectFromIndex(UINT ndx, ModCommand::PARAM &refParam) const +//--------------------------------------------------------------------------------------------- { - //if (pParam) *pParam = -1; if (ndx >= CountOf(gFXInfo)) { refParam = 0; @@ -246,10 +245,10 @@ // Cap parameter to match FX if necessary. if (gFXInfo[ndx].paramMask) { - if (refParam < static_cast<int>(gFXInfo[ndx].paramValue)) + if (refParam < gFXInfo[ndx].paramValue) { refParam = gFXInfo[ndx].paramValue; // for example: delay with param < D0 becomes SD0 - } else if (refParam > static_cast<int>(gFXInfo[ndx].paramValue) + 15) + } else if (refParam > gFXInfo[ndx].paramValue + 15) { refParam = gFXInfo[ndx].paramValue + 15; // for example: delay with param > DF becomes SDF } @@ -257,7 +256,7 @@ if (gFXInfo[ndx].paramLimit) { // used for Zxx macro control in parameter editor: limit to 7F max. - LimitMax(refParam, static_cast<int>(gFXInfo[ndx].paramLimit)); + LimitMax(refParam, gFXInfo[ndx].paramLimit); } return gFXInfo[ndx].effect; Modified: trunk/OpenMPT/mptrack/EffectInfo.h =================================================================== --- trunk/OpenMPT/mptrack/EffectInfo.h 2014-02-15 16:41:50 UTC (rev 3718) +++ trunk/OpenMPT/mptrack/EffectInfo.h 2014-02-15 16:54:10 UTC (rev 3719) @@ -35,7 +35,7 @@ // Get effect index in effect list from effect command + param LONG GetIndexFromEffect(ModCommand::COMMAND command, ModCommand::PARAM param) const; // Get effect command + param from effect index - ModCommand::COMMAND GetEffectFromIndex(UINT ndx, int &refParam) const; + ModCommand::COMMAND GetEffectFromIndex(UINT ndx, ModCommand::PARAM &refParam) const; ModCommand::COMMAND GetEffectFromIndex(UINT ndx) const; // Get parameter mask from effect (for extended effects) UINT GetEffectMaskFromIndex(UINT ndx) const; Modified: trunk/OpenMPT/mptrack/EffectVis.cpp =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.cpp 2014-02-15 16:41:50 UTC (rev 3718) +++ trunk/OpenMPT/mptrack/EffectVis.cpp 2014-02-15 16:54:10 UTC (rev 3719) @@ -31,7 +31,7 @@ // EffectVis dialog IMPLEMENT_DYNAMIC(CEffectVis, CDialog) -CEffectVis::CEffectVis(CViewPattern *pViewPattern, UINT startRow, UINT endRow, UINT nchn, CModDoc* pModDoc, UINT pat) : effectInfo(pModDoc->GetrSoundFile()) +CEffectVis::CEffectVis(CViewPattern *pViewPattern, ROWINDEX startRow, ROWINDEX endRow, CHANNELINDEX nchn, CModDoc *pModDoc, PATTERNINDEX pat) : effectInfo(pModDoc->GetrSoundFile()) { m_pViewPattern = pViewPattern; m_dwStatus = 0x00; @@ -42,9 +42,9 @@ m_nRowToErase = -1; m_nParamToErase = -1; - m_nLastDrawnRow = -1; + m_nLastDrawnRow = ROWINDEX_INVALID; m_nLastDrawnY = -1; - m_nOldPlayPos = UINT_MAX; + m_nOldPlayPos = ROWINDEX_INVALID; m_nFillEffect = effectInfo.GetIndexFromEffect(CMD_SMOOTHMIDI, 0); m_nAction=kAction_OverwriteFX; m_templatePCNote.Set(NOTE_PCS, 1, 0, 0); @@ -53,6 +53,7 @@ } BEGIN_MESSAGE_MAP(CEffectVis, CDialog) + ON_WM_ERASEBKGND() ON_WM_PAINT() ON_WM_SIZE() ON_WM_LBUTTONDOWN() @@ -60,9 +61,6 @@ ON_WM_MOUSEMOVE() ON_WM_RBUTTONDOWN() ON_WM_RBUTTONUP() -//{{AFX_MSG_MAP(CEffectVis) - ON_COMMAND(ID_EDIT_UNDO, OnEditUndo) -//}}AFX_MSG_MAP ON_CBN_SELCHANGE(IDC_VISACTION, OnActionChanged) ON_CBN_SELCHANGE(IDC_VISEFFECTLIST, OnEffectChanged) END_MESSAGE_MAP() @@ -78,9 +76,9 @@ void CEffectVis::OnActionChanged() { m_nAction = m_cmbActionList.GetItemData(m_cmbActionList.GetCurSel()); - if (m_nAction == (UINT)kAction_FillPC - || m_nAction == (UINT)kAction_OverwritePC - || m_nAction == (UINT)kAction_Preserve) + if (m_nAction == kAction_FillPC + || m_nAction == kAction_OverwritePC + || m_nAction == kAction_Preserve) m_cmbEffectList.EnableWindow(FALSE); else m_cmbEffectList.EnableWindow(TRUE); @@ -100,24 +98,23 @@ if ((!m_pModDoc) || !(&dc)) return; ShowVis(&dc, m_rcDraw); - + } -uint16 CEffectVis::GetParam(UINT row) -{ - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; +uint16 CEffectVis::GetParam(ROWINDEX row) const +{ uint16 paramValue = 0; - if (pcmd) + if(m_pSndFile->Patterns.IsValidPat(m_nPattern)) { - ModCommand cmd = pcmd[row*m_pSndFile->m_nChannels + m_nChan]; - if (cmd.IsPcNote()) + const ModCommand &m = *m_pSndFile->Patterns[m_nPattern].GetpModCommand(row, m_nChan); + if (m.IsPcNote()) { - paramValue = cmd.GetValueEffectCol(); + paramValue = m.GetValueEffectCol(); } else { - paramValue = cmd.param; + paramValue = m.param; } } @@ -127,82 +124,78 @@ // Sets a row's param value based on the vertical cursor position. // Sets either plain pattern effect parameter or PC note parameter // as appropriate, depending on contents of row. -void CEffectVis::SetParamFromY(UINT row, long y) +void CEffectVis::SetParamFromY(ROWINDEX row, int y) { - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (!pcmd) { + if(!m_pSndFile->Patterns.IsValidPat(m_nPattern)) return; - } - int offset = row*m_pSndFile->m_nChannels + m_nChan; + ModCommand &m = *m_pSndFile->Patterns[m_nPattern].GetpModCommand(row, m_nChan); if (IsPcNote(row)) { uint16 param = ScreenYToPCParam(y); CriticalSection cs; - pcmd[offset].SetValueEffectCol(param); - } - else - { - int param = ScreenYToFXParam(y); + m.SetValueEffectCol(param); + } else + { + ModCommand::PARAM param = ScreenYToFXParam(y); // Cap the parameter value as appropriate, based on effect type (e.g. Zxx gets capped to [0x00,0x7F]) - effectInfo.GetEffectFromIndex(effectInfo.GetIndexFromEffect(pcmd[offset].command, ModCommand::PARAM(param)), param); + effectInfo.GetEffectFromIndex(effectInfo.GetIndexFromEffect(m.command, param), param); CriticalSection cs; - pcmd[offset].param = static_cast<BYTE>(param); - } + m.param = param; + } } -BYTE CEffectVis::GetCommand(UINT row) +ModCommand::COMMAND CEffectVis::GetCommand(ROWINDEX row) const +//------------------------------------------------------------ { - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (pcmd) - return pcmd[row*m_pSndFile->m_nChannels + m_nChan].command; + if(m_pSndFile->Patterns.IsValidPat(m_nPattern)) + return m_pSndFile->Patterns[m_nPattern].GetpModCommand(row, m_nChan)->command; else - return 0; + return CMD_NONE; } -void CEffectVis::SetCommand(UINT row, BYTE command) +void CEffectVis::SetCommand(ROWINDEX row, BYTE command) { - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (pcmd) + if(m_pSndFile->Patterns.IsValidPat(m_nPattern)) { - CriticalSection cs; - int offset = row*m_pSndFile->m_nChannels + m_nChan; - if (pcmd[offset].IsPcNote()) { + ModCommand &m = *m_pSndFile->Patterns[m_nPattern].GetpModCommand(row, m_nChan); + if(m.IsPcNote()) + { // Clear PC note - pcmd[offset].note = 0; - pcmd[offset].instr = 0; - pcmd[offset].volcmd = 0; - pcmd[offset].vol = 0; + m.note = 0; + m.instr = 0; + m.volcmd = 0; + m.vol = 0; } - pcmd[offset].command = command; + m.command = command; } } -int CEffectVis::RowToScreenX(UINT row) +int CEffectVis::RowToScreenX(ROWINDEX row) const +//---------------------------------------------- { if ((row >= m_startRow) || (row <= m_endRow)) - return (int) (m_rcDraw.left + INNERLEFTBORDER + (row-m_startRow)*m_pixelsPerRow + 0.5); + return Util::Round<int>(m_rcDraw.left + INNERLEFTBORDER + (row - m_startRow) * m_pixelsPerRow); return -1; } -int CEffectVis::RowToScreenY(UINT row) +int CEffectVis::RowToScreenY(ROWINDEX row) const +//---------------------------------------------- { - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; int screenY = -1; - if (pcmd) + if(m_pSndFile->Patterns.IsValidPat(m_nPattern)) { - ModCommand cmd = pcmd[row*m_pSndFile->m_nChannels + m_nChan]; - if (cmd.IsPcNote()) + const ModCommand &m = *m_pSndFile->Patterns[m_nPattern].GetpModCommand(row, m_nChan); + if (m.IsPcNote()) { - uint16 paramValue = cmd.GetValueEffectCol(); + uint16 paramValue = m.GetValueEffectCol(); screenY = PCParamToScreenY(paramValue); - } - else + } else { - uint16 paramValue = cmd.param; + uint16 paramValue = m.param; screenY = FXParamToScreenY(paramValue); } } @@ -210,21 +203,24 @@ return screenY; } -int CEffectVis::FXParamToScreenY(uint16 param) +int CEffectVis::FXParamToScreenY(uint16 param) const +//-------------------------------------------------- { if ((param >= 0x00) || (param <= 0xFF)) - return (int) (m_rcDraw.bottom - param*m_pixelsPerFXParam + 0.5); + return Util::Round<int>(m_rcDraw.bottom - param * m_pixelsPerFXParam); return -1; } -int CEffectVis::PCParamToScreenY(uint16 param) +int CEffectVis::PCParamToScreenY(uint16 param) const +//-------------------------------------------------- { if ((param >= 0x00) || (param <= ModCommand::maxColumnValue)) - return (int) (m_rcDraw.bottom - param*m_pixelsPerPCParam + 0.5); + return Util::Round<int>(m_rcDraw.bottom - param*m_pixelsPerPCParam); return -1; } -BYTE CEffectVis::ScreenYToFXParam(int y) +ModCommand::PARAM CEffectVis::ScreenYToFXParam(int y) const +//--------------------------------------------------------- { if (y<=FXParamToScreenY(0xFF)) return 0xFF; @@ -232,10 +228,11 @@ if (y>=FXParamToScreenY(0x00)) return 0x00; - return (BYTE)((m_rcDraw.bottom-y)/m_pixelsPerFXParam+0.5); + return Util::Round<ModCommand::PARAM>((m_rcDraw.bottom - y) / m_pixelsPerFXParam); } -uint16 CEffectVis::ScreenYToPCParam(int y) +uint16 CEffectVis::ScreenYToPCParam(int y) const +//---------------------------------------------- { if (y<=PCParamToScreenY(ModCommand::maxColumnValue)) return ModCommand::maxColumnValue; @@ -243,18 +240,19 @@ if (y>=PCParamToScreenY(0x00)) return 0x00; - return (uint16)((m_rcDraw.bottom-y)/m_pixelsPerPCParam+0.5); + return Util::Round<uint16>((m_rcDraw.bottom - y) / m_pixelsPerPCParam); } -UINT CEffectVis::ScreenXToRow(int x) +ROWINDEX CEffectVis::ScreenXToRow(int x) const +//-------------------------------------------- { - if (x<=RowToScreenX(m_startRow)) + if (x <= RowToScreenX(m_startRow)) return m_startRow; - if (x>=RowToScreenX(m_endRow)) + if (x >= RowToScreenX(m_endRow)) return m_endRow; - return (UINT)(m_startRow + (x-INNERLEFTBORDER)/m_pixelsPerRow + 0.5); + return Util::Round<ROWINDEX>(m_startRow + (x - INNERLEFTBORDER) / m_pixelsPerRow); } CEffectVis::~CEffectVis() @@ -267,7 +265,7 @@ } -void CEffectVis::DrawGrid() +void CEffectVis::DrawGrid() { // Lots of room for optimisation here. // Draw vertical grid lines @@ -277,7 +275,7 @@ nBeat = m_pSndFile->Patterns[m_nPattern].GetRowsPerBeat(); nMeasure = m_pSndFile->Patterns[m_nPattern].GetRowsPerMeasure(); } - for (UINT row=m_startRow; row<=m_endRow; row++) + for (ROWINDEX row = m_startRow; row <= m_endRow; row++) { if (row % nMeasure == 0) CMainFrame::penScratch = CMainFrame::penGrayff; @@ -290,9 +288,9 @@ m_dcGrid.MoveTo(x1, m_rcDraw.top); m_dcGrid.LineTo(x1, m_rcDraw.bottom); } - + // Draw horizontal grid lines - const UINT numHorizontalLines = 4; + const UINT numHorizontalLines = 4; for (UINT i=0; i<numHorizontalLines; i++) { switch (i%4) @@ -302,7 +300,7 @@ case 2: CMainFrame::penScratch = CMainFrame::penGray80; break; case 3: CMainFrame::penScratch = CMainFrame::penGraycc; break; } - + m_dcGrid.SelectObject(CMainFrame::penScratch); int y1 = m_rcDraw.bottom/numHorizontalLines * i; @@ -310,9 +308,9 @@ m_dcGrid.LineTo(m_rcDraw.right-INNERRIGHTBORDER, y1); } -} +} -void CEffectVis::SetPlayCursor(UINT nPat, UINT nRow) +void CEffectVis::SetPlayCursor(PATTERNINDEX nPat, ROWINDEX nRow) { int x1; //erase current playpos: @@ -377,7 +375,7 @@ m_pbOldPlayPos = m_dcPlayPos.SelectObject(&m_bPlayPos); SetPlayCursor(m_nPattern, m_nOldPlayPos); - DrawGrid(); + DrawGrid(); DrawNodes(); } @@ -385,14 +383,16 @@ ShowVisImage(pDC); } -//----------------------------------------------------------------------------------------- + + void CEffectVis::ShowVisImage(CDC *pDC) +//------------------------------------- { CDC memDC ; CBitmap memBitmap ; CBitmap* oldBitmap ; // bitmap originally found in CMemDC - // to avoid flicker, establish a memory dc, draw to it + // to avoid flicker, establish a memory dc, draw to it // and then BitBlt it to the destination "pDC" memDC.CreateCompatibleDC(pDC); if (!memDC) @@ -415,7 +415,7 @@ // merge the nodes image with the grid memDC.TransparentBlt(0, 0, m_rcDraw.Width(), m_rcDraw.Height(), &m_dcNodes, 0, 0, m_rcDraw.Width(), m_rcDraw.Height(), 0x00000000) ; - // further merge the playpos + // further merge the playpos memDC.TransparentBlt(0, 0, m_rcDraw.Width(), m_rcDraw.Height(), &m_dcPlayPos, 0, 0, m_rcDraw.Width(), m_rcDraw.Height(), 0x00000000) ; // copy the resulting bitmap to the destination @@ -424,17 +424,17 @@ memDC.SelectObject(oldBitmap) ; -} // end ShowMeterImage +} + void CEffectVis::DrawNodes() -//--------------------------------------- +//-------------------------- { //erase if ((UINT)m_nRowToErase<m_startRow || m_nParamToErase < 0) { ::FillRect(m_dcNodes.m_hDC, &m_rcDraw, m_brushBlack); - } - else + } else { int x = RowToScreenX(m_nRowToErase); CRect r( x-NODEHALF-1, m_rcDraw.top, x-NODEHALF+NODESIZE+1, m_rcDraw.bottom); @@ -442,7 +442,7 @@ } //Draw - for (UINT row=m_startRow; row<=m_endRow; row++) + for (ROWINDEX row = m_startRow; row <= m_endRow; row++) { int x = RowToScreenX(row); int y = RowToScreenY(row); @@ -524,10 +524,6 @@ } - - - - void CEffectVis::OnSize(UINT nType, int cx, int cy) { MPT_UNREFERENCED_PARAMETER(nType); @@ -539,22 +535,22 @@ #define INFOWIDTH 200 #define ACTIONLISTWIDTH 150 -#define COMMANDLISTWIDTH 130 +#define COMMANDLISTWIDTH 150 if (IsWindow(m_edVisStatus.m_hWnd)) - m_edVisStatus.SetWindowPos(this, m_rcFullWin.left, m_rcDraw.bottom, m_rcFullWin.right-COMMANDLISTWIDTH-ACTIONLISTWIDTH, m_rcFullWin.bottom-m_rcDraw.bottom, SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_NOZORDER); + m_edVisStatus.SetWindowPos(this, m_rcFullWin.left, m_rcDraw.bottom, m_rcFullWin.right-COMMANDLISTWIDTH-ACTIONLISTWIDTH, m_rcFullWin.bottom-m_rcDraw.bottom, SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_NOZORDER); if (IsWindow(m_cmbActionList)) m_cmbActionList.SetWindowPos(this, m_rcFullWin.right-COMMANDLISTWIDTH-ACTIONLISTWIDTH, m_rcDraw.bottom, ACTIONLISTWIDTH, m_rcFullWin.bottom-m_rcDraw.bottom, SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_NOZORDER); if (IsWindow(m_cmbEffectList)) m_cmbEffectList.SetWindowPos(this, m_rcFullWin.right-COMMANDLISTWIDTH, m_rcDraw.bottom, COMMANDLISTWIDTH, m_rcFullWin.bottom-m_rcDraw.bottom, SWP_NOACTIVATE|SWP_NOCOPYBITS|SWP_SHOWWINDOW|SWP_NOZORDER); - m_pixelsPerRow = (float)(m_rcDraw.Width()-INNERLEFTBORDER-INNERRIGHTBORDER)/(float)m_nRows; + m_pixelsPerRow = (float)(m_rcDraw.Width()-INNERLEFTBORDER-INNERRIGHTBORDER)/(float)m_nRows; m_pixelsPerFXParam = (float)(m_rcDraw.Height())/(float)0xFF; m_pixelsPerPCParam = (float)(m_rcDraw.Height())/(float)ModCommand::maxColumnValue; m_boolForceRedraw = TRUE; - InvalidateRect(NULL, FALSE); //redraw everything -} + InvalidateRect(NULL, FALSE); //redraw everything +} void CEffectVis::Update() { @@ -574,52 +570,38 @@ } } -void CEffectVis::UpdateSelection(UINT startRow, UINT endRow, UINT nchn, CModDoc* pModDoc, UINT pat) +void CEffectVis::UpdateSelection(ROWINDEX startRow, ROWINDEX endRow, CHANNELINDEX nchn, CModDoc *pModDoc, PATTERNINDEX pat) { m_pModDoc = pModDoc; m_startRow = startRow; m_endRow = endRow; m_nRows = endRow - startRow; - m_nChan = static_cast<CHANNELINDEX>(nchn); + m_nChan = nchn; m_nPattern = pat; //Check document exists - if (!m_pModDoc) + if (!m_pModDoc || (m_pSndFile = m_pModDoc->GetSoundFile()) == nullptr) { DoClose(); return; } - //Check SoundFile exists - m_pSndFile = m_pModDoc->GetSoundFile(); - if (!m_pSndFile) - { - DoClose(); - return; - } - //Check pattern, start row and channel exist - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (!pcmd || (m_startRow >= m_pSndFile->Patterns[m_nPattern].GetNumRows()) || (m_nChan >= m_pSndFile->m_nChannels)) + if(!m_pSndFile->Patterns.IsValidPat(m_nPattern) || !m_pSndFile->Patterns[m_nPattern].IsValidRow(m_startRow) || m_nChan >= m_pSndFile->GetNumChannels()) { DoClose(); return; } //Check end exists - if ( (m_endRow >= m_pSndFile->Patterns[m_nPattern].GetNumRows()) ) + if (!m_pSndFile->Patterns[m_nPattern].IsValidRow(m_endRow)) { - m_endRow = m_pSndFile->Patterns[m_nPattern].GetNumRows()-1; - //ensure we still have some rows to process - if (m_endRow <= m_startRow) - { - DoClose(); - return; - } + m_endRow = m_pSndFile->Patterns[m_nPattern].GetNumRows() - 1; } - m_pixelsPerRow = (float)(m_rcDraw.right - m_rcDraw.left)/(float)m_nRows; - m_pixelsPerFXParam = (float)(m_rcDraw.bottom - m_rcDraw.top)/(float)0xFF; + m_pixelsPerRow = (float)(m_rcDraw.Width()-INNERLEFTBORDER-INNERRIGHTBORDER) / (float)m_nRows; + m_pixelsPerFXParam = (float)(m_rcDraw.Height())/(float)0xFF; + m_pixelsPerPCParam = (float)(m_rcDraw.Height())/(float)ModCommand::maxColumnValue; m_boolForceRedraw = TRUE; Update(); @@ -636,7 +618,7 @@ CRect rect; // Look if dragging a point m_nDragItem = -1; - for (UINT row=m_startRow; row<=m_endRow; row++) + for (ROWINDEX row = m_startRow; row <= m_endRow; row++) { int x = RowToScreenX(row); int y = RowToScreenY(row); @@ -646,7 +628,7 @@ m_pModDoc->GetPatternUndo().PrepareUndo(static_cast<PATTERNINDEX>(m_nPattern), m_nChan, row, m_nChan + 1, row + 1, "Parameter Editor entry"); m_nDragItem = row; } - } + } m_dwStatus |= FXVSTATUS_RDRAGGING; } @@ -669,7 +651,7 @@ if (!m_pModDoc) return; - UINT row = ScreenXToRow(point.x); + ROWINDEX row = ScreenXToRow(point.x); if ((m_dwStatus & FXVSTATUS_RDRAGGING) && (m_nDragItem>=0) ) { @@ -677,31 +659,28 @@ m_nParamToErase = GetParam(m_nDragItem); MakeChange(m_nDragItem, point.y); - } - else if ((m_dwStatus & FXVSTATUS_LDRAGGING)) + } else if ((m_dwStatus & FXVSTATUS_LDRAGGING)) { // Interpolate if we detect that rows have been skipped but the left mouse button was not released. // This ensures we produce a smooth curve even when we are not notified of mouse movements at a high frequency (e.g. if CPU usage is high) - if ((m_nLastDrawnRow>(int)m_startRow) && ((int)row != m_nLastDrawnRow) && ((int)row != m_nLastDrawnRow+1) && ((int)row != m_nLastDrawnRow-1)) + const int steps = abs((int)row - (int)m_nLastDrawnRow); + if (m_nLastDrawnRow != ROWINDEX_INVALID && m_nLastDrawnRow > m_startRow && steps > 1) { - int steps = abs((long)row-(long)m_nLastDrawnRow); - ASSERT(steps!=0); - int direction = ((int)(row-m_nLastDrawnRow) > 0) ? 1 : -1; + int direction = ((int)(row - m_nLastDrawnRow) > 0) ? 1 : -1; float factor = (float)(point.y - m_nLastDrawnY)/(float)steps + 0.5f; int currentRow; for (int i=1; i<=steps; i++) { currentRow = m_nLastDrawnRow+(direction*i); - int interpolatedY = static_cast<int>(m_nLastDrawnY+((float)i*factor+0.5f)); + int interpolatedY = Util::Round<int>(m_nLastDrawnY + ((float)i * factor)); MakeChange(currentRow, interpolatedY); } - - //Don't use single value update + + //Don't use single value update m_nRowToErase = -1; m_nParamToErase = -1; - } - else + } else { m_nRowToErase = -1; m_nParamToErase = -1; @@ -718,12 +697,12 @@ uint16 paramValue; - if (IsPcNote(row)) + if (IsPcNote(row)) { paramValue = ScreenYToPCParam(point.y); wsprintf(effectName, "%s", "Param Control"); // TODO - show smooth & plug+param } - else + else { paramValue = ScreenYToFXParam(point.y); effectInfo.GetEffectInfo(effectInfo.GetIndexFromEffect(GetCommand(row), ModCommand::PARAM(GetParam(row))), effectName, true); @@ -753,17 +732,10 @@ ReleaseCapture(); m_dwStatus = 0x00; CDialog::OnLButtonUp(nFlags, point); - m_nLastDrawnRow = -1; + m_nLastDrawnRow = ROWINDEX_INVALID; } -void CEffectVis::OnEditUndo() -//--------------------------- -{ - Reporting::Notification("Undo Through!"); -} - - BOOL CEffectVis::OnInitDialog() //----------------------------- { @@ -773,14 +745,13 @@ // If first selected row is a PC Note, default to PC note overwrite mode // and use it as a template for new PC notes that will be created via the visualiser. m_nAction = kAction_OverwritePC; - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (pcmd) { - int offset = m_startRow*m_pSndFile->m_nChannels + m_nChan; - m_templatePCNote.Set(pcmd[offset].note, pcmd[offset].instr, pcmd[offset].GetValueVolCol(), 0); + if(m_pSndFile->Patterns.IsValidPat(m_nPattern)) + { + ModCommand &m = *m_pSndFile->Patterns[m_nPattern].GetpModCommand(m_startRow, m_nChan); + m_templatePCNote.Set(m.note, m.instr, m.GetValueVolCol(), 0); } m_cmbEffectList.EnableWindow(FALSE); - } - else + } else { // Otherwise, default to FX overwrite and // use effect of first selected row as default effect type @@ -801,7 +772,7 @@ { k =m_cmbEffectList.AddString(s); m_cmbEffectList.SetItemData(k, i); - if ((long)i == m_nFillEffect) + if ((int)i == m_nFillEffect) m_cmbEffectList.SetCurSel(k); } } @@ -812,38 +783,35 @@ if (m_pModDoc->GetModType() == MOD_TYPE_MPT) { m_cmbActionList.SetItemData(m_cmbActionList.AddString("Overwrite with PC note"), kAction_OverwritePC); - m_cmbActionList.SetItemData(m_cmbActionList.AddString("Fill blanks with PC note"), kAction_FillPC); + m_cmbActionList.SetItemData(m_cmbActionList.AddString("Fill blanks with PC note"), kAction_FillPC); } - m_cmbActionList.SetItemData(m_cmbActionList.AddString("Never change effect type"), kAction_Preserve); - + m_cmbActionList.SetItemData(m_cmbActionList.AddString("Never change effect type"), kAction_Preserve); + m_cmbActionList.SetCurSel(m_nAction); return true; } -void CEffectVis::MakeChange(int row, long y) -//------------------------------------------ +void CEffectVis::MakeChange(ROWINDEX row, int y) +//----------------------------------------------- { - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (!pcmd) - { + if(!m_pSndFile->Patterns.IsValidPat(m_nPattern)) return; - } - int offset = row * m_pSndFile->GetNumChannels() + m_nChan; - + ModCommand &m = *m_pSndFile->Patterns[m_nPattern].GetpModCommand(row, m_nChan); + switch (m_nAction) { case kAction_FillFX: // Only set command if there isn't a command already at this row and it's not a PC note if (!GetCommand(row) && !IsPcNote(row)) - { + { SetCommand(row, effectInfo.GetEffectFromIndex(m_nFillEffect)); } // Always set param SetParamFromY(row, y); break; - - case kAction_OverwriteFX: + + case kAction_OverwriteFX: // Always set command and param. Blows away any PC notes. SetCommand(row, effectInfo.GetEffectFromIndex(m_nFillEffect)); SetParamFromY(row, y); @@ -851,7 +819,7 @@ case kAction_FillPC: // Fill only empty slots with PC notes - leave other slots alone. - if (pcmd[offset].IsEmpty()) + if (m.IsEmpty()) { SetPcNote(row); } @@ -859,7 +827,7 @@ SetParamFromY(row, y); break; - case kAction_OverwritePC: + case kAction_OverwritePC: // Always convert to PC Note and set param value SetPcNote(row); SetParamFromY(row, y); @@ -867,7 +835,7 @@ case kAction_Preserve: if (GetCommand(row) || IsPcNote(row)) - { + { // Only set param if we have an effect type or if this is a PC note. // Never change the effect type. SetParamFromY(row, y); @@ -875,28 +843,26 @@ break; } - + m_pModDoc->SetModified(); m_pModDoc->UpdateAllViews(NULL, HINT_PATTERNDATA | (m_nPattern << HINT_SHIFT_PAT), NULL); } -void CEffectVis::SetPcNote(int row) +void CEffectVis::SetPcNote(ROWINDEX row) +//-------------------------------------- { - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (!pcmd) { + if(!m_pSndFile->Patterns.IsValidPat(m_nPattern)) return; - } - int offset = row * m_pSndFile->GetNumChannels() + m_nChan; - CriticalSection cs; - pcmd[offset].Set(m_templatePCNote.note, m_templatePCNote.instr, m_templatePCNote.GetValueVolCol(), 0); + ModCommand &m = *m_pSndFile->Patterns[m_nPattern].GetpModCommand(row, m_nChan); + m.Set(m_templatePCNote.note, m_templatePCNote.instr, m_templatePCNote.GetValueVolCol(), 0); } -bool CEffectVis::IsPcNote(int row) +bool CEffectVis::IsPcNote(ROWINDEX row) const +//------------------------------------------- { - ModCommand *pcmd = m_pSndFile->Patterns[m_nPattern]; - if (pcmd) - return pcmd[row * m_pSndFile->GetNumChannels() + m_nChan].IsPcNote(); + if(m_pSndFile->Patterns.IsValidPat(m_nPattern)) + return m_pSndFile->Patterns[m_nPattern].GetpModCommand(row, m_nChan)->IsPcNote(); else return false; } \ No newline at end of file Modified: trunk/OpenMPT/mptrack/EffectVis.h =================================================================== --- trunk/OpenMPT/mptrack/EffectVis.h 2014-02-15 16:41:50 UTC (rev 3718) +++ trunk/OpenMPT/mptrack/EffectVis.h 2014-02-15 16:54:10 UTC (rev 3719) @@ -13,12 +13,9 @@ #include "afxwin.h" #include "EffectInfo.h" class CViewPattern; -//class CModScrollView; #define FXVSTATUS_LDRAGGING 0x01 #define FXVSTATUS_RDRAGGING 0x02 -//#define FXVSTATUS_NCLBTNDOWN 0x02 -//#define INSSTATUS_SPLITCURSOR 0x04 // EffectVis dialog class CEffectVis : public CDialog @@ -26,7 +23,7 @@ DECLARE_DYNAMIC(CEffectVis) public: - enum + enum { kAction_OverwriteFX=0, kAction_FillFX, @@ -35,25 +32,20 @@ kAction_Preserve }; - CEffectVis(CViewPattern *pViewPattern, UINT startRow, UINT endRow, UINT nchn, CModDoc* pModDoc, UINT pat); - virtual ~CEffectVis(); - //{{AFX_VIRTUAL(CEffectVis) - //virtual void OnDraw(CDC *); - //}}AFX_VIRTUAL + CEffectVis(CViewPattern *pViewPattern, ROWINDEX startRow, ROWINDEX endRow, CHANNELINDEX nchn, CModDoc *pModDoc, PATTERNINDEX pat); + ~CEffectVis(); // Dialog Data enum { IDD = IDD_EFFECTVISUALIZER }; protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support - //CFastBitmap m_Dib; EffectInfo effectInfo; CBitmap m_bGrid, m_bNodes, m_bPlayPos; CBitmap *m_pbOldGrid, *m_pbOldNodes, *m_pbOldPlayPos; CDC m_dcGrid, m_dcNodes, m_dcPlayPos; - //LPMODPLUGDIB nodeBMP; void DrawNodes(); void DrawGrid(); @@ -61,50 +53,48 @@ void ShowVisImage(CDC *pDC); BOOL m_boolForceRedraw, m_boolUseBitmaps; RECT invalidated; - - int m_nLastDrawnRow; // for interpolation - long m_nLastDrawnY; // for interpolation + + ROWINDEX m_nLastDrawnRow; // for interpolation + int m_nLastDrawnY; // for interpolation int m_nRowToErase; int m_nParamToErase; - UINT m_nOldPlayPos; + ROWINDEX m_nOldPlayPos; ModCommand m_templatePCNote; CBrush m_brushBlack; -public: - UINT m_startRow; - UINT m_endRow; - UINT m_nRows; +protected: + ROWINDEX m_startRow; + ROWINDEX m_endRow; + ROWINDEX m_nRows; CHANNELINDEX m_nChan; - UINT m_nPattern; - long m_nFillEffect, m_nAction; + PATTERNINDEX m_nPattern; + int m_nFillEffect, m_nAction; - int m_nDragItem; + int m_nDragItem; UINT m_nBtnMouseOver; DWORD m_dwStatus; - void InvalidateRow(int row); float m_pixelsPerRow, m_pixelsPerFXParam, m_pixelsPerPCParam; - void UpdateSelection(UINT startRow, UINT endRow, UINT nchn, CModDoc* m_pModDoc, UINT pats); - void Update(); - int RowToScreenX(UINT row); - int RowToScreenY(UINT row); - int PCParamToScreenY(uint16 param); - int FXParamToScreenY(uint16 param); - uint16 GetParam(UINT row); - BYTE GetCommand(UINT row); - void SetParamFromY(UINT row, long y); - void SetCommand(UINT row, BYTE cmd); - BYTE ScreenYToFXParam(int y); - uint16 ScreenYToPCParam(int y); - UINT ScreenXToRow(int x); - void SetPlayCursor(UINT nPat, UINT nRow); - bool IsPcNote(int row); - void SetPcNote(int row); - CSoundFile* m_pSndFile; - CModDoc* m_pModDoc; + void InvalidateRow(int row); + int RowToScreenX(ROWINDEX row) const; + int RowToScreenY(ROWINDEX row) const; + int PCParamToScreenY(uint16 param) const; + int FXParamToScreenY(uint16 param) const; + uint16 GetParam(ROWINDEX row) const; + BYTE GetCommand(ROWINDEX row) const; + void SetParamFromY(ROWINDEX row, int y); + void SetCommand(ROWINDEX row, BYTE cmd); + ModCommand::PARAM ScreenYToFXParam(int y) const; + uint16 ScreenYToPCParam(int y) const; + ROWINDEX ScreenXToRow(int x) const; + bool IsPcNote(ROWINDEX row) const; + void SetPcNote(ROWINDEX row); + + CSoundFile *m_pSndFile; + CModDoc *m_pModDoc; CRect m_rcDraw; CRect m_rcFullWin; @@ -113,20 +103,26 @@ virtual VOID OnOK(); virtual VOID OnCancel(); - BOOL OpenEditor(CWnd *parent); - VOID DoClose(); afx_msg void OnClose(); Setting<LONG>* GetSplitPosRef() {return NULL;} //rewbs.varWindowSize CViewPattern *m_pViewPattern; - + DECLARE_MESSAGE_MAP() BOOL OnInitDialog(); afx_msg void OnPaint(); - -public: //HACK for first window repos + +public: + + void UpdateSelection(ROWINDEX startRow, ROWINDEX endRow, CHANNELINDEX nchn, CModDoc *pModDoc, PATTERNINDEX pat); + void Update(); + BOOL OpenEditor(CWnd *parent); + void SetPlayCursor(PATTERNINDEX nPat, ROWINDEX nRow); + void DoClose(); + afx_msg void OnSize(UINT nType, int cx, int cy); + protected: afx_msg void OnLButtonDown(UINT nFlags, CPoint point); afx_msg void OnLButtonUp(UINT nFlags, CPoint point); @@ -135,11 +131,7 @@ afx_msg void OnRButtonUp(UINT nFlags, CPoint point); afx_msg void OnEffectChanged(); afx_msg void OnActionChanged(); - //{{AFX_MSG(CEffectVis) - afx_msg void OnEditUndo(); - //}}AFX_MSG + afx_msg BOOL OnEraseBkgnd(CDC *) { return TRUE; } -private: - - void MakeChange(int currentRow, long newY); -}; + void MakeChange(ROWINDEX currentRow, int newY); +}; \ No newline at end of file Modified: trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp =================================================================== --- trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2014-02-15 16:41:50 UTC (rev 3718) +++ trunk/OpenMPT/mptrack/PatternEditorDialogs.cpp 2014-02-15 16:54:10 UTC (rev 3719) @@ -413,7 +413,7 @@ int effectIndex = -1; if (((combo = (CComboBox *)GetDlgItem(IDC_COMBO5)) != NULL)) { - int n = -1; // unused parameter adjustment + ModCommand::PARAM n = 0; // unused parameter adjustment effectIndex = combo->GetItemData(combo->GetCurSel()); m_Cmd.command = effectInfo.GetEffectFromIndex(effectIndex, n); } @@ -991,7 +991,7 @@ { uint16 newPlugParam = m->GetValueVolCol(); ModCommand::COMMAND newCommand = m->command; - int newParam = m->param; + ModCommand::PARAM newParam = m->param; int n = cbnCommand.GetCurSel(); if(n >= 0) @@ -1004,7 +1004,6 @@ { // Process as effect int ndx = cbnCommand.GetItemData(n); - newParam = -1; newCommand = static_cast<ModCommand::COMMAND>((ndx >= 0) ? effectInfo.GetEffectFromIndex(ndx, newParam) : CMD_NONE); } @@ -1031,7 +1030,7 @@ } else { m->command = newCommand; - if(newParam >= 0) + if(newCommand != CMD_NONE) { m->param = static_cast<ModCommand::PARAM>(newParam); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-16 00:45:59
|
Revision: 3722 http://sourceforge.net/p/modplug/code/3722 Author: saga-games Date: 2014-02-16 00:45:51 +0000 (Sun, 16 Feb 2014) Log Message: ----------- [Fix] Envelopes longer than 32767 ticks can now be scrolled correctly [Fix] When zooming into samples longer than 32767 sampling points, it was possible that the last few points were not visible (http://bugs.openmpt.org/view.php?id=162) Modified Paths: -------------- trunk/OpenMPT/mptrack/Globals.cpp trunk/OpenMPT/mptrack/Globals.h trunk/OpenMPT/mptrack/View_ins.cpp trunk/OpenMPT/mptrack/View_ins.h trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h Modified: trunk/OpenMPT/mptrack/Globals.cpp =================================================================== --- trunk/OpenMPT/mptrack/Globals.cpp 2014-02-15 17:35:39 UTC (rev 3721) +++ trunk/OpenMPT/mptrack/Globals.cpp 2014-02-16 00:45:51 UTC (rev 3722) @@ -656,6 +656,72 @@ } +BOOL CModScrollView::OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll) +//------------------------------------------------------------------------ +{ + SCROLLINFO info; + if(LOBYTE(nScrollCode) == SB_THUMBTRACK) + { + GetScrollInfo(SB_HORZ, &info, SIF_TRACKPOS); + nPos = info.nTrackPos; + m_nScrollPosX = nPos; + } else if(HIBYTE(nScrollCode) == SB_THUMBTRACK) + { + GetScrollInfo(SB_VERT, &info, SIF_TRACKPOS); + nPos = info.nTrackPos; + m_nScrollPosY = nPos; + } + BOOL ret = CScrollView::OnScroll(nScrollCode, nPos, bDoScroll); + return ret; +} + + +BOOL CModScrollView::OnScrollBy(CSize sizeScroll, BOOL bDoScroll) +//--------------------------------------------------------------- +{ + BOOL ret = CScrollView::OnScrollBy(sizeScroll, bDoScroll); + if(ret) + { + SCROLLINFO info; + if(sizeScroll.cx) + { + GetScrollInfo(SB_HORZ, &info, SIF_POS); + m_nScrollPosX = info.nPos; + } + if(sizeScroll.cy) + { + GetScrollInfo(SB_VERT, &info, SIF_POS); + m_nScrollPosY = info.nPos; + } + } + return ret; +} + + +int CModScrollView::SetScrollPos(int nBar, int nPos, BOOL bRedraw) +//---------------------------------------------------------------- +{ + if(nBar == SB_HORZ) + m_nScrollPosX = nPos; + else if(nBar == SB_VERT) + m_nScrollPosY = nPos; + return CScrollView::SetScrollPos(nBar, nPos, bRedraw); +} + + +void CModScrollView::SetScrollSizes(int nMapMode, SIZE sizeTotal, const SIZE& sizePage, const SIZE& sizeLine) +//----------------------------------------------------------------------------------------------------------- +{ + CScrollView::SetScrollSizes(nMapMode, sizeTotal, sizePage, sizeLine); + // Fix scroll positions + SCROLLINFO info; + GetScrollInfo(SB_HORZ, &info, SIF_POS); + m_nScrollPosX = info.nPos; + GetScrollInfo(SB_VERT, &info, SIF_POS); + m_nScrollPosY = info.nPos; +} + + //////////////////////////////////////////////////////////////////////////// // CModControlBar Modified: trunk/OpenMPT/mptrack/Globals.h =================================================================== --- trunk/OpenMPT/mptrack/Globals.h 2014-02-15 17:35:39 UTC (rev 3721) +++ trunk/OpenMPT/mptrack/Globals.h 2014-02-16 00:45:51 UTC (rev 3722) @@ -190,10 +190,11 @@ { protected: HWND m_hWndCtrl; + int m_nScrollPosX, m_nScrollPosY; public: DECLARE_SERIAL(CModScrollView) - CModScrollView() { m_hWndCtrl = NULL; } + CModScrollView() : m_hWndCtrl(nullptr), m_nScrollPosX(0), m_nScrollPosY(0) { } virtual ~CModScrollView() {} public: @@ -220,6 +221,14 @@ afx_msg BOOL OnMouseWheel(UINT fFlags, short zDelta, CPoint point); afx_msg LRESULT OnDragonDropping(WPARAM bDoDrop, LPARAM lParam) { return OnDragonDrop((BOOL)bDoDrop, (const DRAGONDROP *)lParam); } LRESULT OnUpdatePosition(WPARAM, LPARAM); + + // Fixes for 16-bit limitation in MFC's CScrollView + virtual BOOL OnScroll(UINT nScrollCode, UINT nPos, BOOL bDoScroll = TRUE); + virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE); + virtual int SetScrollPos(int nBar, int nPos, BOOL bRedraw = TRUE); + virtual void SetScrollSizes(int nMapMode, SIZE sizeTotal, const SIZE& sizePage = CScrollView::sizeDefault, const SIZE& sizeLine = CScrollView::sizeDefault); + + //}}AFX_MSG DECLARE_MESSAGE_MAP() }; Modified: trunk/OpenMPT/mptrack/View_ins.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_ins.cpp 2014-02-15 17:35:39 UTC (rev 3721) +++ trunk/OpenMPT/mptrack/View_ins.cpp 2014-02-16 00:45:51 UTC (rev 3722) @@ -635,7 +635,7 @@ int CViewInstrument::TickToScreen(int nTick) const //------------------------------------------------ { - return ((int)((nTick + 1) * m_fZoom)) - GetScrollPos(SB_HORZ); + return ((int)((nTick + 1) * m_fZoom)) - m_nScrollPosX; } int CViewInstrument::PointToScreen(int nPoint) const @@ -648,16 +648,10 @@ int CViewInstrument::ScreenToTick(int x) const //-------------------------------------------- { - return (int)(((float)GetScrollPos(SB_HORZ) + (float)x + 1 - m_fZoom) / m_fZoom); + return (int)(((float)m_nScrollPosX + (float)x + 1 - m_fZoom) / m_fZoom); } -int CViewInstrument::QuickScreenToTick(int x, int cachedScrollPos) const -//---------------------------------------------------------------------- -{ - return (int)(((float)cachedScrollPos + (float)x + 1 - m_fZoom) / m_fZoom); -} - int CViewInstrument::ScreenToValue(int y) const //--------------------------------------------- { @@ -794,7 +788,6 @@ void CViewInstrument::DrawGrid(CDC *pDC, UINT speed) //-------------------------------------------------- { - int cachedScrollPos = GetScrollPos(SB_HORZ); bool windowResized = false; if (m_dcGrid.GetSafeHdc()) @@ -806,11 +799,11 @@ } - if (windowResized || m_bGridForceRedraw || (cachedScrollPos != m_GridScrollPos) || (speed != (UINT)m_GridSpeed)) + if (windowResized || m_bGridForceRedraw || (m_nScrollPosX != m_GridScrollPos) || (speed != (UINT)m_GridSpeed)) { m_GridSpeed = speed; - m_GridScrollPos = cachedScrollPos; + m_GridScrollPos = m_nScrollPosX; m_bGridForceRedraw = false; // create a memory based dc for drawing the grid @@ -832,7 +825,7 @@ for (int x = 3; x < width; x++) { - nTick = QuickScreenToTick(x, cachedScrollPos); + nTick = ScreenToTick(x); if (nTick != nPrevTick && !(nTick%speed)) { nPrevTick = nTick; @@ -860,7 +853,7 @@ //------------------------------------ { RECT rect; - int nScrollPos = GetScrollPos(SB_HORZ); + int nScrollPos = m_nScrollPosX; CModDoc *pModDoc = GetDocument(); HGDIOBJ oldpen; //HDC hdc; Modified: trunk/OpenMPT/mptrack/View_ins.h =================================================================== --- trunk/OpenMPT/mptrack/View_ins.h 2014-02-15 17:35:39 UTC (rev 3721) +++ trunk/OpenMPT/mptrack/View_ins.h 2014-02-16 00:45:51 UTC (rev 3722) @@ -140,7 +140,6 @@ int TickToScreen(int nTick) const; int PointToScreen(int nPoint) const; int ScreenToTick(int x) const; - int QuickScreenToTick(int x, int cachedScrollPos) const; int ScreenToPoint(int x, int y) const; int ValueToScreen(int val) const { return m_rcClient.bottom - 1 - (val * (m_rcClient.bottom - 1)) / 64; } int ScreenToValue(int y) const; Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-15 17:35:39 UTC (rev 3721) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-16 00:45:51 UTC (rev 3722) @@ -66,7 +66,6 @@ ON_WM_NCCALCSIZE() ON_WM_NCHITTEST() ON_WM_NCPAINT() - ON_WM_HSCROLL() ON_WM_MOUSEMOVE() ON_WM_NCMOUSEMOVE() ON_WM_LBUTTONDOWN() @@ -123,8 +122,6 @@ m_nGridSegments = 0; m_nSample = 1; m_nZoom = 0; - m_nScrollPos = 0; - m_nScrollFactor = 0; m_nBtnMouseOver = 0xFFFF; for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) { @@ -188,25 +185,11 @@ { m_sizeTotal.cx = m_rcClient.Width(); } - m_nScrollFactor = 0; UINT cx0 = m_sizeTotal.cx; UINT cx = cx0; - // Limit scroll size. FIXME: For long samples, this causes the last few sampling points to be invisible! (Rounding error?) - while (cx > 30000) - { - m_nScrollFactor++; - m_sizeTotal.cx /= 2; - cx = m_sizeTotal.cx; - if (cx > (UINT)m_rcClient.right) - { - UINT wantedsize = (cx0 - m_rcClient.right) >> m_nScrollFactor; - UINT mfcsize = cx - m_rcClient.right; - cx += wantedsize - mfcsize; - } - } m_sizeTotal.cx = cx; m_sizeTotal.cy = 1; - sizeLine.cx = (m_rcClient.right / (16 << m_nScrollFactor)) + 1; + sizeLine.cx = (m_rcClient.right / 16) + 1; sizeLine.cy = 1; sizePage.cx = sizeLine.cx * 4; sizePage.cy = sizeLine.cy; @@ -216,14 +199,8 @@ { const UINT nOldPos = ScrollPosToSamplePos(nZoomOld); const float fPosFraction = (dwLen > 0) ? static_cast<float>(nOldPos) / dwLen : 0; - m_nScrollPos = 0; - m_nScrollPos = SampleToScreen(nOldPos); SetScrollPos(SB_HORZ, static_cast<int>(fPosFraction * GetScrollLimit(SB_HORZ))); } - else - { - m_nScrollPos = GetScrollPos(SB_HORZ) << m_nScrollFactor; - } } } @@ -364,7 +341,7 @@ if (!nLen) return 0; if (m_nZoom) { - return (pos >> ((int32)m_nZoom - 1)) - m_nScrollPos; + return (pos >> ((int32)m_nZoom - 1)) - m_nScrollPosX; } else { return Util::muldiv(pos, m_sizeTotal.cx, nLen); @@ -386,7 +363,7 @@ if (!nLen) return 0; if (m_nZoom) { - n = (m_nScrollPos + x) << (m_nZoom-1); + n = (m_nScrollPosX + x) << (m_nZoom - 1); } else { if (x < 0) x = 0; @@ -423,7 +400,6 @@ if (pState->nSample == m_nSample) { SetCurSel(pState->dwBeginSel, pState->dwEndSel); - m_nScrollPos = pState->dwScrollPos << m_nScrollFactor; SetScrollPos(SB_HORZ, pState->dwScrollPos); UpdateScrollSize(); InvalidateSample(); @@ -436,7 +412,7 @@ { SAMPLEVIEWSTATE *pState = (SAMPLEVIEWSTATE *)lParam; pState->cbStruct = sizeof(SAMPLEVIEWSTATE); - pState->dwScrollPos = GetScrollPos(SB_HORZ); + pState->dwScrollPos = m_nScrollPosX; pState->dwBeginSel = m_dwBeginSel; pState->dwEndSel = m_dwEndSel; pState->nSample = m_nSample; @@ -1214,54 +1190,6 @@ } -void CViewSample::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) -//-------------------------------------------------------------------------- -{ - CScrollView::OnHScroll(nSBCode, nPos, pScrollBar); - m_nScrollPos = GetScrollPos(SB_HORZ) << m_nScrollFactor; -} - - -BOOL CViewSample::OnScrollBy(CSize sizeScroll, BOOL bDoScroll) -//------------------------------------------------------------- -{ - int xOrig, x; - - // don't scroll if there is no valid scroll range (ie. no scroll bar) - CScrollBar* pBar; - DWORD dwStyle = GetStyle(); - // vertical scroll bar not enabled - pBar = GetScrollBarCtrl(SB_HORZ); - if ((pBar != NULL && !pBar->IsWindowEnabled()) || (pBar == NULL && !(dwStyle & WS_HSCROLL))) - { - // horizontal scroll bar not enabled - sizeScroll.cx = 0; - } - - // adjust current x position - xOrig = x = GetScrollPos(SB_HORZ); - int xMax = GetScrollLimit(SB_HORZ); - x += sizeScroll.cx; - if (x < 0) - x = 0; - else if (x > xMax) - x = xMax; - - // did anything change? - if (x == xOrig) return FALSE; - - if (bDoScroll) - { - // do scroll and update scroll positions: - // CViewSample also handles the scroll factor so we can use ranges bigger than 64K - ScrollWindow(-((x-xOrig) << m_nScrollFactor), 0); - m_nScrollPos = x << m_nScrollFactor; - SetScrollPos(SB_HORZ, x); - } - return TRUE; -} - - void CViewSample::ScrollToPosition(int x) // logical coordinates //--------------------------------------- { @@ -1274,7 +1202,6 @@ pt.x = 0; else if (pt.x > xMax) pt.x = xMax; - pt.x <<= m_nScrollFactor; ScrollToDevicePosition(pt); } @@ -2440,8 +2367,7 @@ sz.cx = m_dwBeginSel >> (dwZoom-1); l = (m_rcClient.right - ((m_dwEndSel - m_dwBeginSel) >> (dwZoom-1))) / 2; if (l > 0) sz.cx -= l; - sz.cx >>= m_nScrollFactor; - sz.cx -= GetScrollPos(SB_HORZ); + sz.cx -= m_nScrollPosX; sz.cy = 0; OnScrollBy(sz, TRUE); } Modified: trunk/OpenMPT/mptrack/View_smp.h =================================================================== --- trunk/OpenMPT/mptrack/View_smp.h 2014-02-15 17:35:39 UTC (rev 3721) +++ trunk/OpenMPT/mptrack/View_smp.h 2014-02-16 00:45:51 UTC (rev 3722) @@ -34,7 +34,7 @@ HDC offScreenDC; HGDIOBJ offScreenBitmap; SIZE m_sizeTotal; - UINT m_nZoom, m_nScrollPos, m_nScrollFactor, m_nBtnMouseOver; + UINT m_nZoom, m_nBtnMouseOver; FlagSet<Flags> m_dwStatus; SmpLength m_dwBeginSel, m_dwEndSel, m_dwBeginDrag, m_dwEndDrag; DWORD m_dwMenuParam; @@ -95,7 +95,7 @@ bool CanZoomSelection() const { return GetSelectionZoomLevel() != 0; } UINT ScrollPosToSamplePos() const {return ScrollPosToSamplePos(m_nZoom);} - UINT ScrollPosToSamplePos(UINT nZoom) const {return (nZoom > 0) ? (m_nScrollPos << (nZoom - 1)) : 0;} + UINT ScrollPosToSamplePos(UINT nZoom) const {return (nZoom > 0) ? (m_nScrollPosX << (nZoom - 1)) : 0;} void AdjustLoopPoints(SmpLength &loopStart, SmpLength &loopEnd, SmpLength length) const; @@ -107,7 +107,6 @@ virtual void OnInitialUpdate(); virtual void UpdateView(DWORD dwHintMask=0, CObject *pObj=NULL); virtual LRESULT OnModViewMsg(WPARAM, LPARAM); - virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll=TRUE); virtual BOOL OnDragonDrop(BOOL, const DRAGONDROP *); virtual LRESULT OnPlayerNotify(Notification *); virtual BOOL PreTranslateMessage(MSG *pMsg); //rewbs.customKeys @@ -124,7 +123,6 @@ afx_msg UINT OnNcHitTest(CPoint point); #endif afx_msg void OnNcPaint(); - afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar); afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); afx_msg void OnNcLButtonDown(UINT, CPoint); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-18 18:24:22
|
Revision: 3731 http://sourceforge.net/p/modplug/code/3731 Author: saga-games Date: 2014-02-18 18:24:10 +0000 (Tue, 18 Feb 2014) Log Message: ----------- [New] Sample tab: Added zoom levels larger than 1:1. Modified Paths: -------------- trunk/OpenMPT/mptrack/Childfrm.h trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/View_smp.cpp trunk/OpenMPT/mptrack/View_smp.h Modified: trunk/OpenMPT/mptrack/Childfrm.h =================================================================== --- trunk/OpenMPT/mptrack/Childfrm.h 2014-02-18 16:54:05 UTC (rev 3730) +++ trunk/OpenMPT/mptrack/Childfrm.h 2014-02-18 18:24:10 UTC (rev 3731) @@ -36,7 +36,6 @@ typedef struct SAMPLEVIEWSTATE { - DWORD cbStruct; DWORD dwScrollPos; DWORD dwBeginSel; DWORD dwEndSel; Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-02-18 16:54:05 UTC (rev 3730) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-02-18 18:24:10 UTC (rev 3731) @@ -54,7 +54,7 @@ float Round(const float value, const int digit) { float v = 0.1f * (value * powf(10.0f, (float)(digit + 1)) + (value < 0.0f ? -5.0f : 5.0f)); - modff(v, &v); + modff(v, &v); return v / powf(10.0f, (float)digit); } @@ -205,16 +205,21 @@ m_bInitialized = FALSE; // Zoom Selection - m_ComboZoom.AddString("Auto"); - m_ComboZoom.AddString("1:1"); - m_ComboZoom.AddString("1:2"); - m_ComboZoom.AddString("1:4"); - m_ComboZoom.AddString("1:8"); - m_ComboZoom.AddString("1:16"); - m_ComboZoom.AddString("1:32"); - m_ComboZoom.AddString("1:64"); - m_ComboZoom.AddString("1:128"); - m_ComboZoom.SetCurSel(0); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("32:1"), (DWORD_PTR)-6); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("16:1"), (DWORD_PTR)-5); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("8:1"), (DWORD_PTR)-4); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("4:1"), (DWORD_PTR)-3); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("2:1"), (DWORD_PTR)-2); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("Auto"), 0); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("1:1"), 1); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("1:2"), 2); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("1:4"), 3); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("1:8"), 4); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("1:16"), 5); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("1:32"), 6); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("1:64"), 7); + m_ComboZoom.SetItemData(m_ComboZoom.AddString("1:128"), 8); + m_ComboZoom.SetCurSel(5); // File ToolBar m_ToolBar1.Init(); m_ToolBar1.AddButton(IDC_SAMPLE_NEW, TIMAGE_SAMPLE_NEW); @@ -347,10 +352,20 @@ SetDlgItemInt(IDC_EDIT_SAMPLE, m_nSample); m_SpinSample.SetRange(1, m_sndFile.GetNumSamples()); } - if (lZoom < 0) - lZoom = m_ComboZoom.GetCurSel(); - else - m_ComboZoom.SetCurSel(lZoom); + if (lZoom == -1) + { + lZoom = static_cast<int>(m_ComboZoom.GetItemData(m_ComboZoom.GetCurSel())); + } else + { + for(int i = 0; i< m_ComboZoom.GetCount(); i++) + { + if(static_cast<int>(m_ComboZoom.GetItemData(i)) == lZoom) + { + m_ComboZoom.SetCurSel(i); + break; + } + } + } PostViewMessage(VIEWMSG_SETCURRENTSAMPLE, (lZoom << 16) | m_nSample); UnlockControls(); return true; @@ -445,7 +460,7 @@ break; case CTRLMSG_SMP_SETZOOM: - SetCurrentSample(m_nSample, lParam, FALSE); + SetCurrentSample(m_nSample, static_cast<int>(lParam), FALSE); break; case CTRLMSG_SETCURRENTINSTRUMENT: @@ -1662,12 +1677,11 @@ //--------------------------------------------------- { CString str; - str.Format(__TEXT("%u %u %u %u"), + str.Format(_T("%u %u %u %u"), m_nSequenceMs, m_nSeekWindowMs, m_nOverlapMs, - m_nStretchProcessStepLength - ); + m_nStretchProcessStepLength); SetDlgItemText(IDC_EDIT_STRETCHPARAMS, str); } @@ -1777,13 +1791,13 @@ break; case 2 : wsprintf(str, _T("Stretch ratio is too %s. Must be between 50% and 200%."), (errorcode >> 8) == 1 ? _T("low") : _T("high")); break; - case 3 : wsprintf(str, _T("Not enough memory...")); + case 3 : _tcscpy(str, _T("Not enough memory...")); break; - case 5 : wsprintf(str, _T("Too low sample rate")); + case 5 : _tcscpy(str, _T("Too low sample rate")); break; - case 6 : wsprintf(str, _T("Too short sample")); + case 6 : _tcscpy(str, _T("Too short sample")); break; - default: wsprintf(str, _T("Unknown Error...")); + default: _tcscpy(str, _T("Unknown Error...")); break; } Reporting::Error(str); Modified: trunk/OpenMPT/mptrack/View_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-18 16:54:05 UTC (rev 3730) +++ trunk/OpenMPT/mptrack/View_smp.cpp 2014-02-18 18:24:10 UTC (rev 3731) @@ -35,7 +35,7 @@ #define SMP_LEFTBAR_CXBTN 24 #define SMP_LEFTBAR_CYBTN 22 -#define MIN_ZOOM 0 +#define MIN_ZOOM -6 #define MAX_ZOOM 8 // Defines the minimum length for selection for which @@ -160,8 +160,8 @@ } -void CViewSample::UpdateScrollSize(const UINT nZoomOld) -//----------------------------------------------------- +void CViewSample::UpdateScrollSize(const int nZoomOld) +//---------------------------------------------------- { CModDoc *pModDoc = GetDocument(); @@ -178,26 +178,29 @@ const ModSample &sample = pSndFile->GetSample(m_nSample); if (sample.pSample != nullptr) dwLen = sample.nLength; } - if (m_nZoom) - { - m_sizeTotal.cx = (dwLen + (1 << (m_nZoom-1)) - 1) >> (m_nZoom-1); - } else - { + // Compute scroll size in pixels + if (m_nZoom == 0) // Fit to display m_sizeTotal.cx = m_rcClient.Width(); - } - UINT cx0 = m_sizeTotal.cx; - UINT cx = cx0; - m_sizeTotal.cx = cx; + else if(m_nZoom == 1) // 1:1 + m_sizeTotal.cx = dwLen; + else if(m_nZoom > 1) // Zoom out + m_sizeTotal.cx = (dwLen + (1 << (m_nZoom - 1)) - 1) >> (m_nZoom - 1); + else // Zoom in - here, we don't compute the real number of visible pixels so that the scroll bar doesn't grow unnecessarily long. The scrolling code in OnScrollBy() compensates for this. + m_sizeTotal.cx = dwLen + m_rcClient.Width() - (m_rcClient.Width() >> (-m_nZoom - 1)); + m_sizeTotal.cy = 1; sizeLine.cx = (m_rcClient.right / 16) + 1; + if(m_nZoom < 0) + sizeLine.cx >>= (-m_nZoom - 1); sizeLine.cy = 1; sizePage.cx = sizeLine.cx * 4; - sizePage.cy = sizeLine.cy; + sizePage.cy = 1; + SetScrollSizes(MM_TEXT, m_sizeTotal, sizePage, sizeLine); if (nZoomOld != m_nZoom) // After zoom change, keep the view position. { - const UINT nOldPos = ScrollPosToSamplePos(nZoomOld); + const SmpLength nOldPos = ScrollPosToSamplePos(nZoomOld); const float fPosFraction = (dwLen > 0) ? static_cast<float>(nOldPos) / dwLen : 0; SetScrollPos(SB_HORZ, static_cast<int>(fPosFraction * GetScrollLimit(SB_HORZ))); } @@ -205,6 +208,53 @@ } +BOOL CViewSample::OnScrollBy(CSize sizeScroll, BOOL bDoScroll) +//------------------------------------------------------------ +{ + int xOrig, x; + + // don't scroll if there is no valid scroll range (ie. no scroll bar) + CScrollBar* pBar; + DWORD dwStyle = GetStyle(); + pBar = GetScrollBarCtrl(SB_HORZ); + if ((pBar != NULL && !pBar->IsWindowEnabled()) || + (pBar == NULL && !(dwStyle & WS_HSCROLL))) + { + // horizontal scroll bar not enabled + sizeScroll.cx = 0; + } + + // adjust current x position + xOrig = x = GetScrollPos(SB_HORZ); + int xMax = GetScrollLimit(SB_HORZ); + x += sizeScroll.cx; + if (x < 0) + x = 0; + else if (x > xMax) + x = xMax; + + // did anything change? + if (x == xOrig) + return FALSE; + + if (bDoScroll) + { + // do scroll and update scroll positions + int scrollBy = -(x - xOrig); + // Don't allow to scroll into the middle of a sampling point + if(m_nZoom < 0) + { + scrollBy *= (1 << (-m_nZoom - 1)); + } + + ScrollWindow(scrollBy, 0); + if (x != xOrig) + SetScrollPos(SB_HORZ, x); + } + return TRUE; +} + + BOOL CViewSample::SetCurrentSample(SAMPLEINDEX nSmp) //-------------------------------------------------- { @@ -233,8 +283,8 @@ } -BOOL CViewSample::SetZoom(UINT nZoom) -//----------------------------------- +BOOL CViewSample::SetZoom(int nZoom) +//---------------------------------- { if (nZoom == m_nZoom) @@ -242,7 +292,7 @@ if (nZoom > MAX_ZOOM) return FALSE; - const UINT nZoomOld = m_nZoom; + const int nZoomOld = m_nZoom; m_nZoom = nZoom; UpdateScrollSize(nZoomOld); InvalidateRect(NULL, FALSE); @@ -257,12 +307,14 @@ if(pSndFile == nullptr) return; + const ModSample &sample = pSndFile->GetSample(m_nSample); + // Snap to grid - if(m_nGridSegments > 0) + if(m_nGridSegments > 0 && m_nGridSegments < sample.nLength) { - const float sampsPerSegment = (float)(pSndFile->GetSample(m_nSample).nLength / m_nGridSegments); - nBegin = (SmpLength)(floor((float)(nBegin / sampsPerSegment) + 0.5f) * sampsPerSegment); - nEnd = (SmpLength)(floor((float)(nEnd / sampsPerSegment) + 0.5f) * sampsPerSegment); + const float sampsPerSegment = (float)(sample.nLength / m_nGridSegments); + nBegin = (SmpLength)(Util::Round((float)(nBegin / sampsPerSegment)) * sampsPerSegment); + nEnd = (SmpLength)(Util::Round((float)(nEnd / sampsPerSegment)) * sampsPerSegment); } if (nBegin > nEnd) @@ -339,13 +391,13 @@ { SmpLength nLen = pModDoc->GetrSoundFile().GetSample(m_nSample).nLength; if (!nLen) return 0; - if (m_nZoom) - { - return (pos >> ((int32)m_nZoom - 1)) - m_nScrollPosX; - } else - { + + if(m_nZoom > 0) + return (pos >> (m_nZoom - 1)) - m_nScrollPosX; + else if(m_nZoom < 0) + return (pos - m_nScrollPosX) << (-m_nZoom - 1); + else return Util::muldiv(pos, m_sizeTotal.cx, nLen); - } } return 0; } @@ -361,10 +413,12 @@ { SmpLength nLen = pModDoc->GetrSoundFile().GetSample(m_nSample).nLength; if (!nLen) return 0; - if (m_nZoom) - { + + if(m_nZoom > 0) n = (m_nScrollPosX + x) << (m_nZoom - 1); - } else + else if(m_nZoom < 0) + n = m_nScrollPosX + (x >> (-m_nZoom - 1)); + else { if (x < 0) x = 0; if (m_sizeTotal.cx) n = Util::muldiv(x, nLen, m_sizeTotal.cx); @@ -389,7 +443,7 @@ switch(wParam) { case VIEWMSG_SETCURRENTSAMPLE: - SetZoom(lParam >> 16); + SetZoom(static_cast<int>(lParam) >> 16); SetCurrentSample(lParam & 0xFFFF); break; @@ -411,7 +465,6 @@ if (lParam) { SAMPLEVIEWSTATE *pState = (SAMPLEVIEWSTATE *)lParam; - pState->cbStruct = sizeof(SAMPLEVIEWSTATE); pState->dwScrollPos = m_nScrollPosX; pState->dwBeginSel = m_dwBeginSel; pState->dwEndSel = m_dwEndSel; @@ -452,14 +505,14 @@ #define YCVT(n, bits) (ymed - (((n) * yrange) >> (bits))) -// Draw sample data, 1:1 ratio -void CViewSample::DrawSampleData1(HDC hdc, int ymed, int cx, int cy, int len, int uFlags, PVOID pSampleData) -//---------------------------------------------------------------------------------------------------------- +// Draw one channel of sample data, 1:1 ratio or higher (zoomed in) +void CViewSample::DrawSampleData1(HDC hdc, int ymed, int cx, int cy, SmpLength len, int uFlags, const void *pSampleData) +//---------------------------------------------------------------------------------------------------------------------- { int smplsize; int yrange = cy/2; - signed char *psample = (signed char *)pSampleData; - int y0 = 0, looplen, loopdiv; + const int8 *psample = static_cast<const int8 *>(pSampleData); + int y0 = 0; smplsize = (uFlags & CHN_16BIT) ? 2 : 1; if (uFlags & CHN_STEREO) smplsize *= 2; @@ -471,34 +524,44 @@ y0 = YCVT(*(psample-smplsize),7); } ::MoveToEx(hdc, -1, y0, NULL); - // Linear 1:1 scale - if (m_nZoom) + + SmpLength numDrawSamples, loopDiv = 0; + int loopShift = 0; + if (m_nZoom == 1) { - looplen = cx; - if (looplen > len) looplen = len; - loopdiv = cx; + // Linear 1:1 scale + numDrawSamples = cx; + } else if(m_nZoom < 0) + { + // 2:1, 4:1, etc... zoom + loopShift = (-m_nZoom - 1); + // Round up + numDrawSamples = (cx + (1 << loopShift) - 1) >> loopShift; } else - // Stretch { - looplen = len; - loopdiv = len; + // Stretch to screen + ASSERT(!m_nZoom); + numDrawSamples = len; + loopDiv = numDrawSamples; } - // 16-Bit + LimitMax(numDrawSamples, len); + if (uFlags & CHN_16BIT) { - for (int n=0; n<=looplen; n++) + // 16-Bit + for (SmpLength n = 0; n <= numDrawSamples; n++) { - int x = (n*cx) / loopdiv; - int y = *(signed short *)psample; + int x = loopDiv ? ((n * cx) / loopDiv) : (n << loopShift); + int y = *(const int16 *)psample; ::LineTo(hdc, x, YCVT(y,15)); psample += smplsize; } } else - // 8-bit { - for (int n=0; n<=looplen; n++) + // 8-bit + for (SmpLength n = 0; n <= numDrawSamples; n++) { - int x = (n*cx) / loopdiv; + int x = loopDiv ? ((n * cx) / loopDiv) : (n << loopShift); int y = *psample; ::LineTo(hdc, x, YCVT(y,7)); psample += smplsize; @@ -509,8 +572,8 @@ #if defined(ENABLE_X86_AMD) || defined(ENABLE_SSE) -static void amdmmxext_or_sse_findminmax16(void *p, int scanlen, int smplsize, int *smin, int *smax) -//------------------------------------------------------------------------------------------------- +static void amdmmxext_or_sse_findminmax16(const void *p, int scanlen, int smplsize, int *smin, int *smax) +//------------------------------------------------------------------------------------------------------- { _asm { mov ebx, p @@ -571,8 +634,8 @@ } -static void amdmmxext_or_sse_findminmax8(void *p, int scanlen, int smplsize, int *smin, int *smax) -//------------------------------------------------------------------------------------------------ +static void amdmmxext_or_sse_findminmax8(const void *p, int scanlen, int smplsize, int *smin, int *smax) +//------------------------------------------------------------------------------------------------------ { _asm { mov ebx, p @@ -649,14 +712,15 @@ #endif -void CViewSample::DrawSampleData2(HDC hdc, int ymed, int cx, int cy, int len, int uFlags, PVOID pSampleData) -//---------------------------------------------------------------------------------------------------------- +// Draw one channel of zoomed-out sample data +void CViewSample::DrawSampleData2(HDC hdc, int ymed, int cx, int cy, SmpLength len, int uFlags, const void *pSampleData) +//---------------------------------------------------------------------------------------------------------------------- { int smplsize, oldsmin, oldsmax; int yrange = cy/2; - signed char *psample = (signed char *)pSampleData; - //int y0 = 0, xmax, posincr, posfrac, poshi; - int32 y0 = 0, xmax, poshi; + const int8 *psample = static_cast<const int8 *>(pSampleData); + int32 y0 = 0, xmax; + SmpLength poshi; uint64 posincr, posfrac; // Increments have 16-bit fractional part if (len <= 0) return; @@ -664,13 +728,13 @@ if (uFlags & CHN_STEREO) smplsize *= 2; if (uFlags & CHN_16BIT) { - y0 = YCVT(*((signed short *)(psample-smplsize)), 15); + y0 = YCVT(*((const int16 *)(psample-smplsize)), 15); } else { y0 = YCVT(*(psample-smplsize), 7); } oldsmin = oldsmax = y0; - if (m_nZoom) + if (m_nZoom > 0) { xmax = len>>(m_nZoom-1); if (xmax > cx) xmax = cx; @@ -688,12 +752,12 @@ { //int smin, smax, scanlen; int smin, smax; - int32 scanlen; + SmpLength scanlen; posfrac += posincr; scanlen = static_cast<int32>((posfrac+0xffff) >> 16); if (poshi >= len) poshi = len-1; - if (poshi+scanlen > len) scanlen = len-poshi; + if (poshi + scanlen > len) scanlen = len-poshi; if (scanlen < 1) scanlen = 1; // 16-bit if (uFlags & CHN_16BIT) @@ -708,7 +772,7 @@ } else #endif { - for (int i=0; i<scanlen; i++) + for (SmpLength i=0; i<scanlen; i++) { int s = *p; if (s < smin) smin = s; @@ -721,7 +785,7 @@ } else // 8-bit { - signed char *p = psample + poshi * smplsize; + const int8 *p = psample + poshi * smplsize; smin = 127; smax = -128; #if defined(ENABLE_X86_AMD) || defined(ENABLE_SSE) @@ -731,7 +795,7 @@ } else #endif { - for (int i=0; i<scanlen; i++) + for (SmpLength i=0; i<scanlen; i++) { int s = *p; @@ -867,9 +931,10 @@ // Drawing Sample Data ::SelectObject(offScreenDC, CMainFrame::penSample); int smplsize = sample.GetBytesPerSample(); - if ((m_nZoom == 1) || ((!m_nZoom) && (sample.nLength <= (UINT)rect.right))) + if (m_nZoom == 1 || m_nZoom < 0 || ((!m_nZoom) && (sample.nLength <= (SmpLength)rect.right))) { - int len = sample.nLength - nSmpScrollPos; + // Draw sample data in 1:1 ratio or higher (zoom in) + SmpLength len = sample.nLength - nSmpScrollPos; signed char *psample = ((signed char *)sample.pSample) + nSmpScrollPos * smplsize; if (sample.uFlags[CHN_STEREO]) { @@ -881,9 +946,10 @@ } } else { - int len = sample.nLength; + // Draw zoomed-out saple data + SmpLength len = sample.nLength; int xscroll = 0; - if (m_nZoom) + if (m_nZoom > 0) { xscroll = nSmpScrollPos; len -= nSmpScrollPos; @@ -901,15 +967,18 @@ } } - if(m_nGridSegments) + if(m_nGridSegments && m_nGridSegments < sample.nLength) { // Draw sample grid ::SelectObject(offScreenDC, CMainFrame::penHalfDarkGray); - for(int i = 0; i < m_nGridSegments; i++) + for(SmpLength i = 1; i < m_nGridSegments; i++) { int screenPos = SampleToScreen(sample.nLength * i / m_nGridSegments); - ::MoveToEx(offScreenDC, screenPos, rect.top, nullptr); - ::LineTo(offScreenDC, screenPos, rect.bottom); + if(screenPos >= rect.left && screenPos <= rect.right) + { + ::MoveToEx(offScreenDC, screenPos, rect.top, nullptr); + ::LineTo(offScreenDC, screenPos, rect.bottom); + } } } @@ -1459,7 +1528,7 @@ CSoundFile *pSndFile = pModDoc->GetSoundFile(); const ModSample &sample = pSndFile->GetSample(m_nSample); HMENU hMenu = ::CreatePopupMenu(); - CInputHandler* ih = (CMainFrame::GetMainFrame())->GetInputHandler(); //rewbs.customKeys + CInputHandler* ih = (CMainFrame::GetMainFrame())->GetInputHandler(); if (!hMenu) return; if (sample.nLength) { @@ -1718,19 +1787,16 @@ // cut part is before loop start loopStart -= m_dwEndSel - m_dwBeginSel; loopEnd -= m_dwEndSel - m_dwBeginSel; - } - else if(m_dwBeginSel < loopStart && m_dwEndSel < loopEnd) + } else if(m_dwBeginSel < loopStart && m_dwEndSel < loopEnd) { // cut part is partly before loop start loopStart = m_dwBeginSel; loopEnd -= m_dwEndSel - m_dwBeginSel; - } - else if(m_dwBeginSel >= loopStart && m_dwEndSel < loopEnd) + } else if(m_dwBeginSel >= loopStart && m_dwEndSel < loopEnd) { // cut part is in the loop loopEnd -= m_dwEndSel - m_dwBeginSel; - } - else if(m_dwBeginSel >= loopStart && m_dwBeginSel < loopEnd && m_dwEndSel > loopEnd) + } else if(m_dwBeginSel >= loopStart && m_dwBeginSel < loopEnd && m_dwEndSel > loopEnd) { // cut part is partly before loop end loopEnd = m_dwBeginSel; @@ -2345,49 +2411,80 @@ } -UINT CViewSample::GetSelectionZoomLevel() const -//--------------------------------------------- +void CViewSample::OnZoomOnSel() +//----------------------------- { - UINT zoom = 0; - while(((static_cast<UINT>(m_rcClient.right) << zoom) < m_dwEndSel - m_dwBeginSel) && (zoom < MAX_ZOOM - 1)) + int zoom = 0; + SmpLength selLength = (m_dwEndSel - m_dwBeginSel); + if (selLength > 0 && m_rcClient.right > 0) { - zoom++; + zoom = GetZoomLevel(selLength); + if(zoom < 0) + { + zoom++; + if(zoom >= -1) + zoom = 1; + else if(zoom < MIN_ZOOM) + zoom = MIN_ZOOM; + } else if(zoom > MAX_ZOOM) + { + zoom = 0; + } } - if(zoom++ < MAX_ZOOM) - return zoom; - else - return 0; -} - -void CViewSample::OnZoomOnSel() -//----------------------------- -{ - if ((m_dwEndSel > m_dwBeginSel) && (m_rcClient.right > 0)) + SendCtrlMessage(CTRLMSG_SMP_SETZOOM, zoom); + if (zoom) { - DWORD dwZoom = GetSelectionZoomLevel(); + CSize sz; + SetZoom(zoom); + UpdateScrollSize(); + sz.cx = m_dwBeginSel; - SendCtrlMessage(CTRLMSG_SMP_SETZOOM, dwZoom); - if (dwZoom) + // Compute width of new selection and center it in the view + int scrollToSample = (m_dwBeginSel + selLength / 2) >> (std::max(1, zoom) - 1); + scrollToSample -= (m_rcClient.Width() / 2) >> (-std::min(-1, zoom) - 1); + + int minPos, maxPos; + GetScrollRange(SB_HORZ, &minPos, &maxPos); + Limit(scrollToSample, minPos, maxPos); + SetScrollPos(SB_HORZ, scrollToSample); + Invalidate(); + + /* + if(zoom > 1) { - LONG l; - CSize sz; - SetZoom(dwZoom); - UpdateScrollSize(); - sz.cx = m_dwBeginSel >> (dwZoom-1); - l = (m_rcClient.right - ((m_dwEndSel - m_dwBeginSel) >> (dwZoom-1))) / 2; - if (l > 0) sz.cx -= l; + sz.cx >>= (zoom - 1); + selLength >>= (zoom - 1); + } else if(zoom < -1) + { + sz.cx <<= (-zoom - 1); + selLength <<= (-zoom - 1); + } + + int l = (m_rcClient.right - selLength) / 2; + if (l > 0) sz.cx -= l; + if(m_nZoom > 0) sz.cx -= m_nScrollPosX; - sz.cy = 0; - OnScrollBy(sz, TRUE); - } - } else - { - SendCtrlMessage(CTRLMSG_SMP_SETZOOM, 0); + else + sz.cx -= m_nScrollPosX << (-zoom - 1); + sz.cy = 0; + OnScrollBy(sz, TRUE);*/ } } +SmpLength CViewSample::ScrollPosToSamplePos(int nZoom) const +//---------------------------------------------------------- +{ + if(nZoom < 0) + return m_nScrollPosX; + else if(nZoom > 0) + return m_nScrollPosX << (nZoom - 1); + else + return 0; +} + + void CViewSample::OnSetLoopStart() //-------------------------------- { @@ -2467,15 +2564,14 @@ void CViewSample::OnZoomUp() //-------------------------- { - if (m_nZoom >= MIN_ZOOM) - SendCtrlMessage(CTRLMSG_SMP_SETZOOM, (m_nZoom>MIN_ZOOM) ? m_nZoom-1 : MAX_ZOOM); + DoZoom(1); } void CViewSample::OnZoomDown() //---------------------------- { - SendCtrlMessage(CTRLMSG_SMP_SETZOOM, (m_nZoom<MAX_ZOOM) ? m_nZoom+1 : MIN_ZOOM); + DoZoom(-1); } @@ -2700,27 +2796,70 @@ } +bool CViewSample::CanZoomSelection() const +//---------------------------------------- +{ + return GetZoomLevel(m_dwEndSel - m_dwBeginSel) <= MAX_ZOOM; +} + + // Returns auto-zoom level compared to other zoom levels. -// If auto-zoom gives bigger zoom than zoom level N but smaller than zoom level N-1, -// return value is N. If zoom is bigger than the biggest zoom, returns MIN_ZOOM + 1 and -// if smaller than the smallest zoom, returns value >= MAX_ZOOM + 1. -UINT CViewSample::GetAutoZoomLevel(const ModSample& smp) -//------------------------------------------------------ +// Result is not limited to MIN_ZOOM...MAX_ZOOM range. +int CViewSample::GetZoomLevel(SmpLength length) const +//--------------------------------------------------- { - m_rcClient.NormalizeRect(); - if (m_rcClient.Width() == 0 || smp.nLength <= 0) + if (m_rcClient.Width() == 0 || length == 0) return MAX_ZOOM + 1; // When m_nZoom > 0, 2^(m_nZoom - 1) = samplesPerPixel [1] // With auto-zoom setting the whole sample is fitted to screen: // ViewScreenWidthInPixels * samplesPerPixel = sampleLength (approximately) [2]. // Solve samplesPerPixel from [2], then "m_nZoom" from [1]. - float zoom = static_cast<float>(smp.nLength) / static_cast<float>(m_rcClient.Width()); + float zoom = static_cast<float>(length) / static_cast<float>(m_rcClient.Width()); zoom = 1 + (log10(zoom) / log10(2.0f)); - return static_cast<UINT>(std::max(zoom + 1, MIN_ZOOM + 1.0f)); + if(zoom <= 0) zoom -= 2; + + return static_cast<int>(zoom + sgn(zoom)); } +void CViewSample::DoZoom(int direction) +//------------------------------------- +{ + const CSoundFile &sndFile = GetDocument()->GetrSoundFile(); + // zoomOrder: Biggest to smallest zoom order. + int zoomOrder[(-MIN_ZOOM - 1) + (MAX_ZOOM + 1)]; + for(size_t i = 2; i < -MIN_ZOOM + 1; ++i) + zoomOrder[i - 2] = MIN_ZOOM + i - 2; // -6, -5, -4, -3... + + for(size_t i = 1; i <= MAX_ZOOM; ++i) + zoomOrder[i + - 1 + (-MIN_ZOOM - 1)] = i; // 1, 2, 3... + zoomOrder[CountOf(zoomOrder) - 1] = 0; + int* const pZoomOrderEnd = zoomOrder + CountOf(zoomOrder); + int autoZoomLevel = GetZoomLevel(sndFile.GetSample(m_nSample).nLength); + if(autoZoomLevel < MIN_ZOOM) autoZoomLevel = MIN_ZOOM; + + // If auto-zoom is not the smallest zoom, move auto-zoom index(=zero) + // to the right position in the zoom order. + if (autoZoomLevel < MAX_ZOOM + 1) + { + int* p = std::find(zoomOrder, pZoomOrderEnd, autoZoomLevel); + if (p != pZoomOrderEnd) + { + memmove(p + 1, p, sizeof(zoomOrder[0]) * (pZoomOrderEnd - (p+1))); + *p = 0; + } + else + ASSERT(false); + } + const ptrdiff_t nPos = std::find(zoomOrder, pZoomOrderEnd, m_nZoom) - zoomOrder; + if (direction > 0 && nPos > 0) // Zoom in + SendCtrlMessage(CTRLMSG_SMP_SETZOOM, zoomOrder[nPos - 1]); + else if (direction < 0 && nPos + 1 < CountOf(zoomOrder)) + SendCtrlMessage(CTRLMSG_SMP_SETZOOM, zoomOrder[nPos + 1]); +} + + BOOL CViewSample::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt) //------------------------------------------------------------------ { @@ -2728,38 +2867,9 @@ // One scroll direction zooms in and the other zooms out. // This behaviour is different from what would happen if simply scrolling // the zoom levels in the zoom combobox. - if (nFlags == MK_CONTROL) + if (nFlags == MK_CONTROL && GetDocument()) { - CSoundFile* const pSndFile = (GetDocument()) ? GetDocument()->GetSoundFile() : nullptr; - if (pSndFile != nullptr) - { - // zoomOrder: Biggest to smallest zoom order. - UINT zoomOrder[MAX_ZOOM + 1]; - for(size_t i = 1; i < CountOf(zoomOrder); ++i) - zoomOrder[i-1] = i; // [0]=1, [1]=2, ... - zoomOrder[CountOf(zoomOrder) - 1] = 0; - UINT* const pZoomOrderEnd = zoomOrder + CountOf(zoomOrder); - const UINT nAutoZoomLevel = GetAutoZoomLevel(pSndFile->GetSample(m_nSample)); - - // If auto-zoom is not the smallest zoom, move auto-zoom index(=zero) - // to the right position in the zoom order. - if (nAutoZoomLevel < MAX_ZOOM + 1) - { - UINT* p = std::find(zoomOrder, pZoomOrderEnd, nAutoZoomLevel); - if (p != pZoomOrderEnd) - { - memmove(p + 1, p, sizeof(zoomOrder[0]) * (pZoomOrderEnd - (p+1))); - *p = 0; - } - else - ASSERT(false); - } - const ptrdiff_t nPos = std::find(zoomOrder, pZoomOrderEnd, m_nZoom) - zoomOrder; - if (zDelta > 0 && nPos > 0) - SendCtrlMessage(CTRLMSG_SMP_SETZOOM, zoomOrder[nPos - 1]); - else if (zDelta < 0 && nPos + 1 < CountOf(zoomOrder)) - SendCtrlMessage(CTRLMSG_SMP_SETZOOM, zoomOrder[nPos + 1]); - } + DoZoom(zDelta); } return CModScrollView::OnMouseWheel(nFlags, zDelta, pt); Modified: trunk/OpenMPT/mptrack/View_smp.h =================================================================== --- trunk/OpenMPT/mptrack/View_smp.h 2014-02-18 16:54:05 UTC (rev 3730) +++ trunk/OpenMPT/mptrack/View_smp.h 2014-02-18 18:24:10 UTC (rev 3731) @@ -34,11 +34,12 @@ HDC offScreenDC; HGDIOBJ offScreenBitmap; SIZE m_sizeTotal; - UINT m_nZoom, m_nBtnMouseOver; + UINT m_nBtnMouseOver; + int m_nZoom; FlagSet<Flags> m_dwStatus; SmpLength m_dwBeginSel, m_dwEndSel, m_dwBeginDrag, m_dwEndDrag; DWORD m_dwMenuParam; - int m_nGridSegments; + SmpLength m_nGridSegments; SAMPLEINDEX m_nSample; std::vector<CHANNELINDEX> noteChannel; // Note -> Preview channel assignment @@ -56,9 +57,9 @@ protected: void UpdateScrollSize() {UpdateScrollSize(m_nZoom);} - void UpdateScrollSize(const UINT nZoomOld); + void UpdateScrollSize(const int nZoomOld); BOOL SetCurrentSample(SAMPLEINDEX nSmp); - BOOL SetZoom(UINT nZoom); + BOOL SetZoom(int nZoom); int32 SampleToScreen(SmpLength pos) const; SmpLength ScreenToSample(int32 x) const; void PlayNote(ModCommand::NOTE note, const SmpLength nStartPos = 0); @@ -66,8 +67,8 @@ void SetCurSel(SmpLength nBegin, SmpLength nEnd); void ScrollToPosition(int x); void DrawPositionMarks(); - void DrawSampleData1(HDC hdc, int ymed, int cx, int cy, int len, int uFlags, PVOID pSampleData); - void DrawSampleData2(HDC hdc, int ymed, int cx, int cy, int len, int uFlags, PVOID pSampleData); + void DrawSampleData1(HDC hdc, int ymed, int cx, int cy, SmpLength len, int uFlags, const void *pSampleData); + void DrawSampleData2(HDC hdc, int ymed, int cx, int cy, SmpLength len, int uFlags, const void *pSampleData); void DrawNcButton(CDC *pDC, UINT nBtn); BOOL GetNcButtonRect(UINT nBtn, LPRECT lpRect); void UpdateNcButtonState(); @@ -84,19 +85,13 @@ template<class T, class uT> T GetSampleValueFromPoint(const CPoint &point); - // Returns auto-zoom level compared to other zoom levels. - // If auto-zoom gives bigger zoom than zoom level N but smaller than zoom level N-1, - // return value is N. If zoom is bigger than the biggest zoom, returns MIN_ZOOM + 1 and - // if smaller than the smallest zoom, returns value >= MAX_ZOOM + 1. - UINT GetAutoZoomLevel(const ModSample &smp); + int GetZoomLevel(SmpLength length) const; + void DoZoom(int direction); + bool CanZoomSelection() const; - // Calculate zoom level based on the current selection - UINT GetSelectionZoomLevel() const; - bool CanZoomSelection() const { return GetSelectionZoomLevel() != 0; } + SmpLength ScrollPosToSamplePos() const {return ScrollPosToSamplePos(m_nZoom);} + inline SmpLength ScrollPosToSamplePos(int nZoom) const; - UINT ScrollPosToSamplePos() const {return ScrollPosToSamplePos(m_nZoom);} - UINT ScrollPosToSamplePos(UINT nZoom) const {return (nZoom > 0) ? (m_nScrollPosX << (nZoom - 1)) : 0;} - void AdjustLoopPoints(SmpLength &loopStart, SmpLength &loopEnd, SmpLength length) const; void OnMonoConvert(ctrlSmp::StereoToMonoMode convert); @@ -110,6 +105,7 @@ virtual BOOL OnDragonDrop(BOOL, const DRAGONDROP *); virtual LRESULT OnPlayerNotify(Notification *); virtual BOOL PreTranslateMessage(MSG *pMsg); //rewbs.customKeys + virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE); //}}AFX_VIRTUAL protected: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sag...@us...> - 2014-02-18 18:56:02
|
Revision: 3734 http://sourceforge.net/p/modplug/code/3734 Author: saga-games Date: 2014-02-18 18:55:50 +0000 (Tue, 18 Feb 2014) Log Message: ----------- [Fix] Error message when (new) soundtouch dll is missing was outdated. [Fix] Time stretching parameter tooltip text was outdated. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/mptrack.rc Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-02-18 18:42:29 UTC (rev 3733) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2014-02-18 18:55:50 UTC (rev 3734) @@ -545,7 +545,7 @@ } break; case IDC_EDIT_STRETCHPARAMS: - wsprintf(pszText, "SequenceMs SeekwindowMs OverlapMs ProcessStepLength"); + wsprintf(pszText, "SequenceMs SeekwindowMs OverlapMs"); return TRUE; } } @@ -1490,7 +1490,7 @@ if (sample.uFlags[CHN_16BIT]) { if (dwStart > 0) memcpy(pNewSample, pOriginal, dwStart*smplsize); - if (dwEnd < sample.nLength) memcpy(((LPSTR)pNewSample)+(dwStart+(dwEnd-dwStart)*2)*smplsize, ((LPSTR)pOriginal)+(dwEnd*smplsize), (sample.nLength-dwEnd)*smplsize); + if (dwEnd < sample.nLength) memcpy(((int8 *)pNewSample)+(dwStart+(dwEnd-dwStart)*2)*smplsize, ((int8 *)pOriginal)+(dwEnd*smplsize), (sample.nLength-dwEnd)*smplsize); } else { if (dwStart > 0) @@ -1519,7 +1519,7 @@ if (sample.nSustainEnd > dwStart) sample.nSustainEnd += (sample.nSustainEnd - dwStart); sample.uFlags.set(CHN_16BIT); - ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, dwNewLen, m_sndFile); + ctrlSmp::ReplaceSample(sample, pNewSample, dwNewLen, m_sndFile); // Update loop wrap-around buffer sample.PrecomputeLoops(m_sndFile); @@ -1623,7 +1623,7 @@ } } if (dwStart > 0) memcpy(pNewSample, pOriginal, dwStart*smplsize); - if (dwEnd < sample.nLength) memcpy(((LPSTR)pNewSample)+(dwStart+dwRemove)*smplsize, ((LPSTR)pOriginal)+((dwStart+dwRemove*2)*smplsize), (sample.nLength-dwEnd)*smplsize); + if (dwEnd < sample.nLength) memcpy(((int8 *)pNewSample)+(dwStart+dwRemove)*smplsize, ((int8 *)pOriginal)+((dwStart+dwRemove*2)*smplsize), (sample.nLength-dwEnd)*smplsize); if (sample.nLoopStart >= dwEnd) sample.nLoopStart -= dwRemove; else if (sample.nLoopStart > dwStart) sample.nLoopStart -= (sample.nLoopStart - dwStart)/2; if (sample.nLoopEnd >= dwEnd) sample.nLoopEnd -= dwRemove; else @@ -1635,7 +1635,7 @@ if (sample.nSustainEnd > dwStart) sample.nSustainEnd -= (sample.nSustainEnd - dwStart)/2; if (sample.nSustainEnd > dwNewLen) sample.nSustainEnd = dwNewLen; - ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, dwNewLen, m_sndFile); + ctrlSmp::ReplaceSample(sample, pNewSample, dwNewLen, m_sndFile); // Update loop wrap-around buffer sample.PrecomputeLoops(m_sndFile); @@ -2044,7 +2044,7 @@ m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_replace, "Time Stretch"); // Swap sample buffer pointer to new buffer, update song + sample data & free old sample buffer - ctrlSmp::ReplaceSample(sample, (LPSTR)pNewSample, std::min(outPos, nNewSampleLength), m_sndFile); + ctrlSmp::ReplaceSample(sample, pNewSample, std::min(outPos, nNewSampleLength), m_sndFile); // Free progress bar brushes DeleteObject((HBRUSH)green); Modified: trunk/OpenMPT/mptrack/mptrack.rc =================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc 2014-02-18 18:42:29 UTC (rev 3733) +++ trunk/OpenMPT/mptrack/mptrack.rc 2014-02-18 18:55:50 UTC (rev 3734) @@ -2104,7 +2104,7 @@ STRINGTABLE BEGIN - IDS_SOUNDTOUCH_LOADFAILURE "Unable to load OpenMPT_soundtouch_i16.dll." + IDS_SOUNDTOUCH_LOADFAILURE "Unable to load OpenMPT_soundtouch_f32.dll." IDS_ERR_FILEOPEN "Unable to open file." IDS_ERR_FILETYPE "Unsupported file type" IDS_ERR_SAVEINS "Unable to save instrument" @@ -2165,26 +2165,6 @@ STRINGTABLE BEGIN - ID_FILE_MRU_FILE1 "Open this document" - ID_FILE_MRU_FILE2 "Open this document" - ID_FILE_MRU_FILE3 "Open this document" - ID_FILE_MRU_FILE4 "Open this document" - ID_FILE_MRU_FILE5 "Open this document" - ID_FILE_MRU_FILE6 "Open this document" - ID_FILE_MRU_FILE7 "Open this document" - ID_FILE_MRU_FILE8 "Open this document" - ID_FILE_MRU_FILE9 "Open this document" - ID_FILE_MRU_FILE10 "Open this document" - ID_FILE_MRU_FILE11 "Open this document" - ID_FILE_MRU_FILE12 "Open this document" - ID_FILE_MRU_FILE13 "Open this document" - ID_FILE_MRU_FILE14 "Open this document" - ID_FILE_MRU_FILE15 "Open this document" - ID_FILE_MRU_FILE16 "Open this document" -END - -STRINGTABLE -BEGIN ID_NEXT_PANE "Switch to the next window pane\nNext Pane" ID_PREV_PANE "Switch back to the previous window pane\nPrevious Pane" END This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |