From: <sv...@op...> - 2024-09-23 12:24:27
|
Author: sagamusix Date: Mon Sep 23 14:24:15 2024 New Revision: 21689 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=21689 Log: [Fix] Prevent "Close All" keyboard shortcut from being activated when a dialog is open. It wasn't able to close the files anyway (due to using SafeFileClose call), but it reset the modified status of open files. [Fix] "Close All" menu item didn't show associated keyboard shortcut. [Mod] Make toolbar toggling menu entry titles more obvious, and show available keyboard shortcuts when opening via context menu. [Ref] Unify implementations for toolbar toggling menu. Modified: trunk/OpenMPT/mptrack/InputHandler.cpp trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainfrm.h trunk/OpenMPT/mptrack/mptrack.rc trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/InputHandler.cpp ============================================================================== --- trunk/OpenMPT/mptrack/InputHandler.cpp Mon Sep 23 01:29:09 2024 (r21688) +++ trunk/OpenMPT/mptrack/InputHandler.cpp Mon Sep 23 14:24:15 2024 (r21689) @@ -434,8 +434,8 @@ { ID_VIEW_INSTRUMENTS, kcViewInstruments, _T("&Instruments") }, { ID_VIEW_COMMENTS, kcViewComments, _T("&Comments") }, { ID_VIEW_OPTIONS, kcViewOptions, _T("S&etup") }, - { ID_VIEW_TOOLBAR, kcViewMain, _T("&Main") }, - { IDD_TREEVIEW, kcViewTree, _T("&Tree") }, + { ID_VIEW_TOOLBAR, kcViewMain, _T("Show &Main Toolbar") }, + { IDD_TREEVIEW, kcViewTree, _T("Show &Tree View") }, { ID_PLUGIN_SETUP, kcViewAddPlugin, _T("Pl&ugin Manager") }, { ID_CHANNEL_MANAGER, kcViewChannelManager, _T("Ch&annel Manager") }, { ID_CLIPBOARD_MANAGER, kcToggleClipboardManager, _T("C&lipboard Manager") }, @@ -474,6 +474,7 @@ ID_FILE_OPEN, ID_FILE_APPENDMODULE, ID_FILE_CLOSE, + ID_FILE_CLOSEALL, ID_FILE_SAVE, ID_FILE_SAVE_AS, ID_FILE_SAVEASWAVE, Modified: trunk/OpenMPT/mptrack/MainFrm.cpp ============================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp Mon Sep 23 01:29:09 2024 (r21688) +++ trunk/OpenMPT/mptrack/MainFrm.cpp Mon Sep 23 14:24:15 2024 (r21689) @@ -547,24 +547,17 @@ BOOL CMainFrame::PreTranslateMessage(MSG* pMsg) { + // Right-click menu to disable/enable tree view and main toolbar when right-clicking on either the menu strip or main toolbar if((pMsg->message == WM_RBUTTONDOWN) || (pMsg->message == WM_NCRBUTTONDOWN)) { - CWnd* pWnd = CWnd::FromHandlePermanent(pMsg->hwnd); - CControlBar* pBar = NULL; - HWND hwnd = (pWnd) ? pWnd->m_hWnd : NULL; - - if ((hwnd) && (pMsg->message == WM_RBUTTONDOWN)) pBar = DYNAMIC_DOWNCAST(CControlBar, pWnd); - if ((pBar != NULL) || ((pMsg->message == WM_NCRBUTTONDOWN) && (pMsg->wParam == HTMENU))) + CControlBar *pBar = nullptr; + if(CWnd *pWnd = CWnd::FromHandlePermanent(pMsg->hwnd); pWnd && (pMsg->message == WM_RBUTTONDOWN)) + pBar = dynamic_cast<CControlBar *>(pWnd); + if(pBar != nullptr || (pMsg->message == WM_NCRBUTTONDOWN && pMsg->wParam == HTMENU)) { - CMenu Menu; CPoint pt; - GetCursorPos(&pt); - if (Menu.LoadMenu(IDR_TOOLBARS)) - { - CMenu* pSubMenu = Menu.GetSubMenu(0); - if (pSubMenu!=NULL) pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,pt.x,pt.y,this); - } + ShowToolbarMenu(pt); } } @@ -2468,13 +2461,19 @@ void CMainFrame::OnRButtonDown(UINT, CPoint pt) { - CMenu Menu; ClientToScreen(&pt); - if (Menu.LoadMenu(IDR_TOOLBARS)) - { - CMenu *pSubMenu = Menu.GetSubMenu(0); - if (pSubMenu != nullptr) pSubMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, this); - } + ShowToolbarMenu(pt); +} + + +void CMainFrame::ShowToolbarMenu(CPoint screenPt) +{ + CMenu menu; + if(!menu.CreatePopupMenu()) + return; + menu.AppendMenu(MF_STRING, ID_VIEW_TOOLBAR, m_InputHandler->GetMenuText(ID_VIEW_TOOLBAR)); + menu.AppendMenu(MF_STRING, IDD_TREEVIEW, m_InputHandler->GetMenuText(IDD_TREEVIEW)); + menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, screenPt.x, screenPt.y, this); } @@ -2485,19 +2484,23 @@ case kcViewTree: OnBarCheck(IDD_TREEVIEW); break; case kcViewOptions: OnViewOptions(); break; case kcViewMain: OnBarCheck(ID_VIEW_TOOLBAR); break; - case kcFileImportMidiLib: OnImportMidiLib(); break; + case kcFileImportMidiLib: OnImportMidiLib(); break; case kcFileAddSoundBank: OnAddDlsBank(); break; - case kcPauseSong: OnPlayerPause(); break; - case kcPrevOctave: OnPrevOctave(); break; - case kcNextOctave: OnNextOctave(); break; - case kcFileNew: theApp.OnFileNew(); break; - case kcFileOpen: theApp.OnFileOpen(); break; - case kcMidiRecord: OnMidiRecord(); break; - case kcHelp: OnHelp(); break; + case kcPauseSong: OnPlayerPause(); break; + case kcPrevOctave: OnPrevOctave(); break; + case kcNextOctave: OnNextOctave(); break; + case kcFileNew: theApp.OnFileNew(); break; + case kcFileOpen: theApp.OnFileOpen(); break; + case kcMidiRecord: OnMidiRecord(); break; + case kcHelp: OnHelp(); break; case kcViewAddPlugin: OnPluginManager(); break; - case kcNextDocument: MDINext(); break; - case kcPrevDocument: MDIPrev(); break; - case kcFileCloseAll: theApp.OnFileCloseAll(); break; + case kcNextDocument: MDINext(); break; + case kcPrevDocument: MDIPrev(); break; + case kcFileCloseAll: + if(GetActiveWindow() != this) + return kcNull; + theApp.OnFileCloseAll(); + break; //D'oh!! moddoc isn't a CWnd so we have to handle its messages and pass them on. Modified: trunk/OpenMPT/mptrack/Mainfrm.h ============================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h Mon Sep 23 01:29:09 2024 (r21688) +++ trunk/OpenMPT/mptrack/Mainfrm.h Mon Sep 23 14:24:15 2024 (r21689) @@ -371,6 +371,8 @@ /// Opens either template or example menu item. void OpenMenuItemFile(const UINT nId, const bool isTemplateFile); + void ShowToolbarMenu(CPoint screenPt); + public: void UpdateMRUList(); Modified: trunk/OpenMPT/mptrack/mptrack.rc ============================================================================== --- trunk/OpenMPT/mptrack/mptrack.rc Mon Sep 23 01:29:09 2024 (r21688) +++ trunk/OpenMPT/mptrack/mptrack.rc Mon Sep 23 14:24:15 2024 (r21689) @@ -2875,15 +2875,6 @@ END END -IDR_TOOLBARS MENU -BEGIN - POPUP "&ToolBars" - BEGIN - MENUITEM "&Main", ID_VIEW_TOOLBAR - MENUITEM "&Tree", IDD_TREEVIEW - END -END - IDR_ENVELOPES MENU BEGIN POPUP "&Envelope" Modified: trunk/OpenMPT/mptrack/resource.h ============================================================================== --- trunk/OpenMPT/mptrack/resource.h Mon Sep 23 01:29:09 2024 (r21688) +++ trunk/OpenMPT/mptrack/resource.h Mon Sep 23 14:24:15 2024 (r21689) @@ -31,7 +31,6 @@ #define IDD_OPTIONS_EFFECTS 133 #define IDR_MAINFRAME 200 #define IDR_MODULETYPE 201 -#define IDR_TOOLBARS 202 #define ID_PATTERN_CHANNELMANAGER 202 #define IDR_ENVELOPES 203 #define ID_INDICATOR_CPU 203 |