diff --git a/mptrack/Ctrl_gen.cpp b/mptrack/Ctrl_gen.cpp index 1bdd792dd1..52794b3a29 100644 --- a/mptrack/Ctrl_gen.cpp +++ b/mptrack/Ctrl_gen.cpp @@ -93,7 +93,7 @@ CCtrlGeneral::CCtrlGeneral(CModControlView &parent, CModDoc &document) : CModCon // Display range for XM / S3M should be 0...64, for other formats it's 0...256. uint32 CCtrlGeneral::GetGlobalVolumeFactor() const { - return (m_sndFile.GetType() & (MOD_TYPE_XM | MOD_TYPE_S3M)) ? uint32(MAX_SLIDER_GLOBAL_VOL / 64) : uint32(MAX_SLIDER_GLOBAL_VOL / 128); + return MAX_GLOBAL_VOLUME / m_sndFile.GlobalVolumeRange(); } @@ -109,7 +109,7 @@ BOOL CCtrlGeneral::OnInitDialog() m_SpinVSTiVol.SetRange(0, 2000); m_SpinRestartPos.SetRange32(0, ORDERINDEX_MAX); - m_SliderGlobalVol.SetRange(0, MAX_SLIDER_GLOBAL_VOL); + m_SliderGlobalVol.SetRange(0, MAX_GLOBAL_VOLUME); m_SliderVSTiVol.SetRange(0, MAX_SLIDER_VSTI_VOL); m_SliderSamplePreAmp.SetRange(0, MAX_SLIDER_SAMPLE_VOL); @@ -372,7 +372,7 @@ void CCtrlGeneral::UpdateView(UpdateHint hint, CObject *pHint) SetDlgItemInt(IDC_EDIT_SAMPLEPA, m_sndFile.m_nSamplePreAmp, FALSE); } - m_SliderGlobalVol.SetPos(MAX_SLIDER_GLOBAL_VOL - m_sndFile.m_nDefaultGlobalVolume); + m_SliderGlobalVol.SetPos(MAX_GLOBAL_VOLUME - m_sndFile.m_nDefaultGlobalVolume); m_SliderVSTiVol.SetPos(MAX_SLIDER_VSTI_VOL - m_sndFile.m_nVSTiVolume); m_SliderSamplePreAmp.SetPos(MAX_SLIDER_SAMPLE_VOL - m_sndFile.m_nSamplePreAmp); } @@ -421,8 +421,8 @@ void CCtrlGeneral::OnVScroll(UINT code, UINT pos, CScrollBar *pscroll) else if (pSlider == &m_SliderGlobalVol) { - const UINT gv = MAX_SLIDER_GLOBAL_VOL - m_SliderGlobalVol.GetPos(); - if ((gv >= 0) && (gv <= MAX_SLIDER_GLOBAL_VOL) && (gv != m_sndFile.m_nDefaultGlobalVolume)) + const UINT gv = MAX_GLOBAL_VOLUME - m_SliderGlobalVol.GetPos(); + if ((gv >= 0) && (gv <= MAX_GLOBAL_VOLUME) && (gv != m_sndFile.m_nDefaultGlobalVolume)) { m_sndFile.m_PlayState.m_nGlobalVolume = gv; m_sndFile.m_nDefaultGlobalVolume = gv; diff --git a/mptrack/Ctrl_gen.h b/mptrack/Ctrl_gen.h index 9bf12429e9..51597a001e 100644 --- a/mptrack/Ctrl_gen.h +++ b/mptrack/Ctrl_gen.h @@ -79,7 +79,6 @@ class CCtrlGeneral final : public CModControlDlg //}}AFX_VIRTUAL protected: - static constexpr int MAX_SLIDER_GLOBAL_VOL = 256; static constexpr int MAX_SLIDER_VSTI_VOL = 255; static constexpr int MAX_SLIDER_SAMPLE_VOL = 255; diff --git a/mptrack/MainFrm.cpp b/mptrack/MainFrm.cpp index f660534d19..735b87aa37 100644 --- a/mptrack/MainFrm.cpp +++ b/mptrack/MainFrm.cpp @@ -125,13 +125,19 @@ BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd) ON_COMMAND(ID_UPDATE_AVAILABLE, &CMainFrame::OnUpdateAvailable) ON_COMMAND(ID_HELP_SHOWSETTINGSFOLDER, &CMainFrame::OnShowSettingsFolder) #if defined(MPT_ENABLE_UPDATE) - ON_MESSAGE(MPT_WM_APP_UPDATECHECK_START, &CMainFrame::OnUpdateCheckStart) + ON_MESSAGE(MPT_WM_APP_UPDATECHECK_START, &CMainFrame::OnUpdateCheckStart) ON_MESSAGE(MPT_WM_APP_UPDATECHECK_PROGRESS, &CMainFrame::OnUpdateCheckProgress) ON_MESSAGE(MPT_WM_APP_UPDATECHECK_CANCELED, &CMainFrame::OnUpdateCheckCanceled) - ON_MESSAGE(MPT_WM_APP_UPDATECHECK_FAILURE, &CMainFrame::OnUpdateCheckFailure) - ON_MESSAGE(MPT_WM_APP_UPDATECHECK_SUCCESS, &CMainFrame::OnUpdateCheckSuccess) + ON_MESSAGE(MPT_WM_APP_UPDATECHECK_FAILURE, &CMainFrame::OnUpdateCheckFailure) + ON_MESSAGE(MPT_WM_APP_UPDATECHECK_SUCCESS, &CMainFrame::OnUpdateCheckSuccess) #endif // MPT_ENABLE_UPDATE - ON_COMMAND(ID_HELPSHOW, &CMainFrame::OnHelp) + ON_COMMAND(ID_HELPSHOW, &CMainFrame::OnHelp) + ON_COMMAND(ID_MAINBAR_SHOW_OCTAVE, &CMainFrame::OnToggleMainBarShowOctave) + ON_COMMAND(ID_MAINBAR_SHOW_TEMPO, &CMainFrame::OnToggleMainBarShowTempo) + ON_COMMAND(ID_MAINBAR_SHOW_SPEED, &CMainFrame::OnToggleMainBarShowSpeed) + ON_COMMAND(ID_MAINBAR_SHOW_ROWSPERBEAT, &CMainFrame::OnToggleMainBarShowRowsPerBeat) + ON_COMMAND(ID_MAINBAR_SHOW_GLOBALVOLUME, &CMainFrame::OnToggleMainBarShowGlobalVolume) + ON_COMMAND(ID_MAINBAR_SHOW_VUMETER, &CMainFrame::OnToggleMainBarShowVUMeter) #ifdef MPT_ENABLE_PLAYBACK_TEST_MENU ON_COMMAND(ID_CREATE_MIXERDUMP, &CMainFrame::OnCreateMixerDump) @@ -571,12 +577,12 @@ LRESULT CALLBACK CMainFrame::FocusChangeProc(int code, WPARAM wParam, LPARAM lPa 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)) + if((pMsg->message == WM_RBUTTONUP) || (pMsg->message == WM_NCRBUTTONUP)) { CControlBar *pBar = nullptr; - if(CWnd *pWnd = CWnd::FromHandlePermanent(pMsg->hwnd); pWnd && (pMsg->message == WM_RBUTTONDOWN)) + if(CWnd *pWnd = CWnd::FromHandlePermanent(pMsg->hwnd); pWnd && (pMsg->message == WM_RBUTTONUP)) pBar = dynamic_cast(pWnd); - if(pBar != nullptr || (pMsg->message == WM_NCRBUTTONDOWN && pMsg->wParam == HTMENU)) + if(pBar != nullptr || (pMsg->message == WM_NCRBUTTONUP && pMsg->wParam == HTMENU)) { CPoint pt; GetCursorPos(&pt); @@ -2511,15 +2517,34 @@ void CMainFrame::OnRButtonDown(UINT, CPoint pt) void CMainFrame::ShowToolbarMenu(CPoint screenPt) { - CMenu menu; - if(!menu.CreatePopupMenu()) + CMenu menu, subMenu; + if(!menu.CreatePopupMenu() || !subMenu.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)); + + const FlagSet visibleItems = TrackerSettings::Instance().mainToolBarVisibleItems.Get(); + + subMenu.AppendMenu(MF_STRING | (visibleItems[MainToolBarItem::Octave] ? MF_CHECKED : 0), ID_MAINBAR_SHOW_OCTAVE, _T("Base &Octave")); + subMenu.AppendMenu(MF_STRING | (visibleItems[MainToolBarItem::Tempo] ? MF_CHECKED : 0), ID_MAINBAR_SHOW_TEMPO, _T("&Tempo")); + subMenu.AppendMenu(MF_STRING | (visibleItems[MainToolBarItem::Speed] ? MF_CHECKED : 0), ID_MAINBAR_SHOW_SPEED, _T("Ticks/&Row")); + subMenu.AppendMenu(MF_STRING | (visibleItems[MainToolBarItem::RowsPerBeat] ? MF_CHECKED : 0), ID_MAINBAR_SHOW_ROWSPERBEAT, _T("Rows Per &Beat")); + subMenu.AppendMenu(MF_STRING | (visibleItems[MainToolBarItem::GlobalVolume] ? MF_CHECKED : 0), ID_MAINBAR_SHOW_GLOBALVOLUME, _T("&Global Volume")); + subMenu.AppendMenu(MF_STRING | (visibleItems[MainToolBarItem::VUMeter] ? MF_CHECKED : 0), ID_MAINBAR_SHOW_VUMETER, _T("&VU Meters")); + menu.AppendMenu(MF_POPUP, reinterpret_cast(subMenu.m_hMenu), _T("Main Toolbar &Items")); + menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, screenPt.x, screenPt.y, this); } +void CMainFrame::OnToggleMainBarShowOctave() { m_wndToolBar.ToggleVisibility(MainToolBarItem::Octave); } +void CMainFrame::OnToggleMainBarShowTempo() { m_wndToolBar.ToggleVisibility(MainToolBarItem::Tempo); } +void CMainFrame::OnToggleMainBarShowSpeed() { m_wndToolBar.ToggleVisibility(MainToolBarItem::Speed); } +void CMainFrame::OnToggleMainBarShowRowsPerBeat() { m_wndToolBar.ToggleVisibility(MainToolBarItem::RowsPerBeat); } +void CMainFrame::OnToggleMainBarShowGlobalVolume() { m_wndToolBar.ToggleVisibility(MainToolBarItem::GlobalVolume); } +void CMainFrame::OnToggleMainBarShowVUMeter() { m_wndToolBar.ToggleVisibility(MainToolBarItem::VUMeter); } + + LRESULT CMainFrame::OnCustomKeyMsg(WPARAM wParam, LPARAM lParam) { switch(wParam) diff --git a/mptrack/Mainbar.cpp b/mptrack/Mainbar.cpp index cd658bba04..42f04587c2 100644 --- a/mptrack/Mainbar.cpp +++ b/mptrack/Mainbar.cpp @@ -87,21 +87,32 @@ CSize CToolBarEx::CalcDynamicLayout(int nLength, DWORD dwMode) } -BOOL CToolBarEx::EnableControl(CWnd &wnd, UINT nIndex, UINT nHeight) +void CToolBarEx::UpdateControl(bool show, CWnd &wnd, int index, int id, int height) { - if(wnd.m_hWnd != NULL) + if(show) { CRect rect; - GetItemRect(nIndex, rect); - if(nHeight) + wnd.GetClientRect(rect); + SetButtonInfo(index, id, TBBS_SEPARATOR, rect.right); + + if(wnd.m_hWnd) { - int n = (rect.bottom + rect.top - nHeight) / 2; - if(n > rect.top) rect.top = n; + GetItemRect(index, rect); + if(height) + { + int n = (rect.bottom + rect.top - height) / 2; + if(n > rect.top) + rect.top = n; + } + wnd.SetWindowPos(nullptr, rect.left, rect.top, 0, 0, SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); + wnd.ShowWindow(SW_SHOW); } - wnd.SetWindowPos(NULL, rect.left, rect.top, 0, 0, SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOCOPYBITS); - wnd.ShowWindow(SW_SHOW); + } else + { + SetButtonInfo(index, ID_SEPARATOR, TBBS_SEPARATOR, 1); + if(wnd.m_hWnd) + wnd.ShowWindow(SW_HIDE); } - return TRUE; } @@ -133,19 +144,22 @@ void CToolBarEx::EnableFlatButtons(BOOL bFlat) enum ToolbarItemIndex { - PLAYCMD_INDEX = 10, // Play / Pause - EDITOCTAVE_INDEX = 13, // Base Octave - SPINOCTAVE_INDEX = EDITOCTAVE_INDEX + 1, // Spin Base Octave - TEMPOTEXT_INDEX = SPINOCTAVE_INDEX + 1, // Static "Tempo:" - EDITTEMPO_INDEX = TEMPOTEXT_INDEX + 1, // Edit Tempo - SPINTEMPO_INDEX = EDITTEMPO_INDEX + 1, // Spin Tempo - SPEEDTEXT_INDEX = SPINTEMPO_INDEX + 1, // Static "Speed:" - EDITSPEED_INDEX = SPEEDTEXT_INDEX + 1, // Edit Speed - SPINSPEED_INDEX = EDITSPEED_INDEX + 1, // Spin Speed - RPBTEXT_INDEX = SPINSPEED_INDEX + 1, // Static "Rows/Beat:" - EDITRPB_INDEX = RPBTEXT_INDEX + 1, // Edit Speed - SPINRPB_INDEX = EDITRPB_INDEX + 1, // Spin Speed - VUMETER_INDEX = SPINRPB_INDEX + 6, // VU Meters + PLAYCMD_INDEX = 10, // Play / Pause + EDITOCTAVE_INDEX = 13, // Base Octave + SPINOCTAVE_INDEX = EDITOCTAVE_INDEX + 1, // Spin Base Octave + TEMPOTEXT_INDEX = SPINOCTAVE_INDEX + 1, // Static "Tempo:" + EDITTEMPO_INDEX = TEMPOTEXT_INDEX + 1, // Edit Tempo + SPINTEMPO_INDEX = EDITTEMPO_INDEX + 1, // Spin Tempo + SPEEDTEXT_INDEX = SPINTEMPO_INDEX + 1, // Static "Speed:" + EDITSPEED_INDEX = SPEEDTEXT_INDEX + 1, // Edit Speed + SPINSPEED_INDEX = EDITSPEED_INDEX + 1, // Spin Speed + RPBTEXT_INDEX = SPINSPEED_INDEX + 1, // Static "Rows/Beat:" + EDITRPB_INDEX = RPBTEXT_INDEX + 1, // Edit Speed + SPINRPB_INDEX = EDITRPB_INDEX + 1, // Spin Speed + GLOBALVOLTEXT_INDEX = SPINRPB_INDEX + 1, // Static "Rows/Beat:" + EDITGLOBALVOL_INDEX = GLOBALVOLTEXT_INDEX + 1, // Edit Speed + SPINGLOBALVOL_INDEX = EDITGLOBALVOL_INDEX + 1, // Spin Speed + VUMETER_INDEX = SPINGLOBALVOL_INDEX + 6, // VU Meters }; #define TOOLBAR_IMAGE_PAUSE 8 @@ -185,6 +199,9 @@ static UINT MainButtons[] = ID_SEPARATOR, ID_SEPARATOR, // Rows Per Beat ID_SEPARATOR, + ID_SEPARATOR, + ID_SEPARATOR, // Global Volume + ID_SEPARATOR, ID_SEPARATOR, ID_SEPARATOR, ID_VIEW_OPTIONS, @@ -240,6 +257,10 @@ BOOL CMainToolBar::Create(CWnd *parent) m_StaticRowsPerBeat.Create(_T("Rows/Beat:"), WS_CHILD | SS_CENTER | SS_CENTERIMAGE, rect, this, IDC_TEXT_RPB); m_EditRowsPerBeat.Create(WS_CHILD | WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_NUMBER, rect, this, IDC_EDIT_RPB); m_SpinRowsPerBeat.Create(WS_CHILD | UDS_ALIGNRIGHT | UDS_AUTOBUDDY, rect, this, IDC_SPIN_RPB); + // Global Volume + m_StaticGlobalVolume.Create(_T("Global Volume:"), WS_CHILD | SS_CENTER | SS_CENTERIMAGE, rect, this, IDC_TEXT_GLOBALVOL); + m_EditGlobalVolume.Create(WS_CHILD | WS_BORDER | ES_READONLY | ES_AUTOHSCROLL | ES_NUMBER, rect, this, IDC_EDIT_GLOBALVOL); + m_SpinGlobalVolume.Create(WS_CHILD | UDS_ALIGNRIGHT | UDS_AUTOBUDDY, rect, this, IDC_SPIN_GLOBALVOL); // VU Meter rect.SetRect(0, 0, VUMETER_WIDTH, VUMETER_HEIGHT); @@ -255,6 +276,8 @@ BOOL CMainToolBar::Create(CWnd *parent) m_SpinSpeed.SetPos(0); m_SpinRowsPerBeat.SetRange(-1, 1); m_SpinRowsPerBeat.SetPos(0); + m_SpinGlobalVolume.SetRange(-1, 1); + m_SpinGlobalVolume.SetPos(0); // Display everything SetWindowText(_T("Main")); @@ -272,14 +295,18 @@ LRESULT CMainToolBar::OnDPIChangedAfterParent(WPARAM, LPARAM) { auto result = Default(); UpdateSizes(); + RefreshToolbar(); + return result; +} + +void CMainToolBar::RefreshToolbar() +{ if(m_bVertical) SetVertical(); else SetHorizontal(); - - CMainFrame::GetMainFrame()->RecalcLayout(); // Update bar height - return result; + CMainFrame::GetMainFrame()->RecalcLayout(); // Update bar height (in case of DPI change) } @@ -300,13 +327,15 @@ void CMainToolBar::UpdateSizes() }; const TextWndInfo TextWnds[] = { - {m_EditOctave, _T("Octave 9"), EDITOCTAVE_INDEX, IDC_EDIT_BASEOCTAVE}, - {m_StaticTempo, _T("Tempo"), TEMPOTEXT_INDEX, IDC_TEXT_CURRENTTEMPO}, - {m_EditTempo, _T("999.9999"), EDITTEMPO_INDEX, IDC_EDIT_CURRENTTEMPO}, - {m_StaticSpeed, _T("Ticks/Row:"), SPEEDTEXT_INDEX, IDC_TEXT_CURRENTSPEED}, - {m_EditSpeed, _T("999"), EDITSPEED_INDEX, IDC_EDIT_CURRENTSPEED}, - {m_StaticRowsPerBeat, _T("Rows/Beat:"), RPBTEXT_INDEX, IDC_TEXT_RPB}, - {m_EditRowsPerBeat, _T("9999"), EDITRPB_INDEX, IDC_EDIT_RPB}, + {m_EditOctave, _T("Octave 9"), EDITOCTAVE_INDEX, IDC_EDIT_BASEOCTAVE }, + {m_StaticTempo, _T("Tempo"), TEMPOTEXT_INDEX, IDC_TEXT_CURRENTTEMPO}, + {m_EditTempo, _T("999.9999"), EDITTEMPO_INDEX, IDC_EDIT_CURRENTTEMPO}, + {m_StaticSpeed, _T("Ticks/Row:"), SPEEDTEXT_INDEX, IDC_TEXT_CURRENTSPEED}, + {m_EditSpeed, _T("999"), EDITSPEED_INDEX, IDC_EDIT_CURRENTSPEED}, + {m_StaticRowsPerBeat, _T("Rows/Beat:"), RPBTEXT_INDEX, IDC_TEXT_RPB }, + {m_EditRowsPerBeat, _T("9999"), EDITRPB_INDEX, IDC_EDIT_RPB }, + {m_StaticGlobalVolume, _T("Global Volume:"), GLOBALVOLTEXT_INDEX, IDC_TEXT_GLOBALVOL }, + {m_EditGlobalVolume, _T("999"), EDITGLOBALVOL_INDEX, IDC_EDIT_GLOBALVOL }, }; auto oldFont = dc->SelectObject(CMainFrame::GetGUIFont()); @@ -318,7 +347,7 @@ void CMainToolBar::UpdateSizes() const int height = std::max(static_cast(size.cy) + textPaddingY, textMinHeight); // For some reason, DeferWindowPos doesn't work here info.wnd.SendMessage(WM_SETFONT, hFont, FALSE); - info.wnd.SetWindowPos(nullptr, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOCOPYBITS); + info.wnd.SetWindowPos(nullptr, 0, 0, width, height, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE); } dc->SelectObject(oldFont); ReleaseDC(dc); @@ -335,10 +364,11 @@ void CMainToolBar::UpdateSizes() SetButtonStyle(CommandToIndex(ID_MIDI_RECORD), GetButtonStyle(CommandToIndex(ID_MIDI_RECORD)) | TBSTYLE_DROPDOWN); const int spinnerWidth = SPINNER_WIDTH, spinnerHeight = SPINNER_HEIGHT; - m_SpinOctave.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOCOPYBITS); - m_SpinTempo.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOCOPYBITS); - m_SpinSpeed.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOCOPYBITS); - m_SpinRowsPerBeat.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE | SWP_NOCOPYBITS); + m_SpinOctave.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE); + m_SpinTempo.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE); + m_SpinSpeed.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE); + m_SpinRowsPerBeat.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE); + m_SpinGlobalVolume.SetWindowPos(nullptr, 0, 0, spinnerWidth, spinnerHeight, SWP_NOMOVE | SWP_NOZORDER | SWP_NOREPOSITION | SWP_NOACTIVATE); // VU Meter m_VuMeter.SetWindowPos(nullptr, 0, 0, VUMETER_WIDTH, VUMETER_HEIGHT, SWP_NOMOVE | SWP_NOZORDER); @@ -353,81 +383,58 @@ void CMainToolBar::Init(CMainFrame *pMainFrm) } -static int GetWndWidth(const CWnd &wnd) -{ - CRect rect; - wnd.GetClientRect(rect); - return rect.right; -} - - void CMainToolBar::SetHorizontal() { CToolBarEx::SetHorizontal(); - m_VuMeter.SetOrientation(true); - SetButtonInfo(EDITOCTAVE_INDEX, IDC_EDIT_BASEOCTAVE, TBBS_SEPARATOR, GetWndWidth(m_EditOctave)); - SetButtonInfo(SPINOCTAVE_INDEX, IDC_SPIN_BASEOCTAVE, TBBS_SEPARATOR, SPINNER_WIDTH); - SetButtonInfo(TEMPOTEXT_INDEX, IDC_TEXT_CURRENTTEMPO, TBBS_SEPARATOR, GetWndWidth(m_StaticTempo)); - SetButtonInfo(EDITTEMPO_INDEX, IDC_EDIT_CURRENTTEMPO, TBBS_SEPARATOR, GetWndWidth(m_EditTempo)); - SetButtonInfo(SPINTEMPO_INDEX, IDC_SPIN_CURRENTTEMPO, TBBS_SEPARATOR, SPINNER_WIDTH); - SetButtonInfo(SPEEDTEXT_INDEX, IDC_TEXT_CURRENTSPEED, TBBS_SEPARATOR, GetWndWidth(m_StaticSpeed)); - SetButtonInfo(EDITSPEED_INDEX, IDC_EDIT_CURRENTSPEED, TBBS_SEPARATOR, GetWndWidth(m_EditSpeed)); - SetButtonInfo(SPINSPEED_INDEX, IDC_SPIN_CURRENTSPEED, TBBS_SEPARATOR, SPINNER_WIDTH); - SetButtonInfo(RPBTEXT_INDEX, IDC_TEXT_RPB, TBBS_SEPARATOR, GetWndWidth(m_StaticRowsPerBeat)); - SetButtonInfo(EDITRPB_INDEX, IDC_EDIT_RPB, TBBS_SEPARATOR, GetWndWidth(m_EditRowsPerBeat)); - SetButtonInfo(SPINRPB_INDEX, IDC_SPIN_RPB, TBBS_SEPARATOR, SPINNER_WIDTH); - SetButtonInfo(VUMETER_INDEX, IDC_VUMETER, TBBS_SEPARATOR, VUMETER_WIDTH); - - // Octave Box - EnableControl(m_EditOctave, EDITOCTAVE_INDEX); - EnableControl(m_SpinOctave, SPINOCTAVE_INDEX); - // Tempo - EnableControl(m_StaticTempo, TEMPOTEXT_INDEX, TEXTFIELD_HEIGHT); - EnableControl(m_EditTempo, EDITTEMPO_INDEX, TEXTFIELD_HEIGHT); - EnableControl(m_SpinTempo, SPINTEMPO_INDEX, SPINNER_HEIGHT); - // Speed - EnableControl(m_StaticSpeed, SPEEDTEXT_INDEX, TEXTFIELD_HEIGHT); - EnableControl(m_EditSpeed, EDITSPEED_INDEX, TEXTFIELD_HEIGHT); - EnableControl(m_SpinSpeed, SPINSPEED_INDEX, SPINNER_HEIGHT); - // Rows per Beat - EnableControl(m_StaticRowsPerBeat, RPBTEXT_INDEX, TEXTFIELD_HEIGHT); - EnableControl(m_EditRowsPerBeat, EDITRPB_INDEX, TEXTFIELD_HEIGHT); - EnableControl(m_SpinRowsPerBeat, SPINRPB_INDEX, SPINNER_HEIGHT); - EnableControl(m_VuMeter, VUMETER_INDEX, VUMETER_HEIGHT); + UpdateControls(); } void CMainToolBar::SetVertical() { CToolBarEx::SetVertical(); - m_VuMeter.SetOrientation(false); - // Change Buttons - SetButtonInfo(EDITOCTAVE_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(SPINOCTAVE_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(TEMPOTEXT_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(EDITTEMPO_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(SPINTEMPO_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(SPEEDTEXT_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(EDITSPEED_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(SPINSPEED_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(RPBTEXT_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(EDITRPB_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(SPINRPB_INDEX, ID_SEPARATOR, TBBS_SEPARATOR, 1); - SetButtonInfo(VUMETER_INDEX, IDC_VUMETER, TBBS_SEPARATOR, VUMETER_HEIGHT); - - // Hide Controls - if(m_EditOctave.m_hWnd) m_EditOctave.ShowWindow(SW_HIDE); - if(m_SpinOctave.m_hWnd) m_SpinOctave.ShowWindow(SW_HIDE); - if(m_StaticTempo.m_hWnd) m_StaticTempo.ShowWindow(SW_HIDE); - if(m_EditTempo.m_hWnd) m_EditTempo.ShowWindow(SW_HIDE); - if(m_SpinTempo.m_hWnd) m_SpinTempo.ShowWindow(SW_HIDE); - if(m_StaticSpeed.m_hWnd) m_StaticSpeed.ShowWindow(SW_HIDE); - if(m_EditSpeed.m_hWnd) m_EditSpeed.ShowWindow(SW_HIDE); - if(m_SpinSpeed.m_hWnd) m_SpinSpeed.ShowWindow(SW_HIDE); - if(m_StaticRowsPerBeat.m_hWnd) m_StaticRowsPerBeat.ShowWindow(SW_HIDE); - if(m_EditRowsPerBeat.m_hWnd) m_EditRowsPerBeat.ShowWindow(SW_HIDE); - if(m_SpinRowsPerBeat.m_hWnd) m_SpinRowsPerBeat.ShowWindow(SW_HIDE); - EnableControl(m_VuMeter, VUMETER_INDEX, VUMETER_HEIGHT); + UpdateControls(); +} + + +void CMainToolBar::UpdateControls() +{ + const FlagSet visibleItems = TrackerSettings::Instance().mainToolBarVisibleItems.Get(); + + UpdateControl(visibleItems[MainToolBarItem::Octave], m_EditOctave, EDITOCTAVE_INDEX, IDC_EDIT_BASEOCTAVE); + UpdateControl(visibleItems[MainToolBarItem::Octave], m_SpinOctave, SPINOCTAVE_INDEX, IDC_SPIN_BASEOCTAVE); + + UpdateControl(visibleItems[MainToolBarItem::Tempo], m_StaticTempo, TEMPOTEXT_INDEX, IDC_TEXT_CURRENTTEMPO); + UpdateControl(visibleItems[MainToolBarItem::Tempo], m_EditTempo, EDITTEMPO_INDEX, IDC_EDIT_CURRENTTEMPO); + UpdateControl(visibleItems[MainToolBarItem::Tempo], m_SpinTempo, SPINTEMPO_INDEX, IDC_SPIN_CURRENTTEMPO); + + UpdateControl(visibleItems[MainToolBarItem::Speed], m_StaticSpeed, SPEEDTEXT_INDEX, IDC_TEXT_CURRENTSPEED); + UpdateControl(visibleItems[MainToolBarItem::Speed], m_EditSpeed, EDITSPEED_INDEX, IDC_EDIT_CURRENTSPEED); + UpdateControl(visibleItems[MainToolBarItem::Speed], m_SpinSpeed, SPINSPEED_INDEX, IDC_SPIN_CURRENTSPEED); + + UpdateControl(visibleItems[MainToolBarItem::RowsPerBeat], m_StaticRowsPerBeat, RPBTEXT_INDEX, IDC_TEXT_RPB); + UpdateControl(visibleItems[MainToolBarItem::RowsPerBeat], m_EditRowsPerBeat, EDITRPB_INDEX, IDC_EDIT_RPB); + UpdateControl(visibleItems[MainToolBarItem::RowsPerBeat], m_SpinRowsPerBeat, SPINRPB_INDEX, IDC_SPIN_RPB); + + UpdateControl(visibleItems[MainToolBarItem::GlobalVolume], m_StaticGlobalVolume, GLOBALVOLTEXT_INDEX, IDC_TEXT_GLOBALVOL); + UpdateControl(visibleItems[MainToolBarItem::GlobalVolume], m_EditGlobalVolume, EDITGLOBALVOL_INDEX, IDC_EDIT_GLOBALVOL); + UpdateControl(visibleItems[MainToolBarItem::GlobalVolume], m_SpinGlobalVolume, SPINGLOBALVOL_INDEX, IDC_SPIN_GLOBALVOL); + + m_VuMeter.SetOrientation(!m_bVertical); + if(m_bVertical) + m_VuMeter.SetWindowPos(nullptr, 0, 0, VUMETER_HEIGHT, VUMETER_HEIGHT, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); + else + m_VuMeter.SetWindowPos(nullptr, 0, 0, VUMETER_WIDTH, VUMETER_HEIGHT, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); + UpdateControl(visibleItems[MainToolBarItem::VUMeter], m_VuMeter, VUMETER_INDEX, IDC_VUMETER, VUMETER_HEIGHT); +} + + +void CMainToolBar::ToggleVisibility(MainToolBarItem item) +{ + FlagSet visibleItems = TrackerSettings::Instance().mainToolBarVisibleItems.Get(); + visibleItems.flip(item); + TrackerSettings::Instance().mainToolBarVisibleItems = visibleItems.value().as_enum(); + RefreshToolbar(); } @@ -457,10 +464,7 @@ BOOL CMainToolBar::SetBaseOctave(UINT nOctave) bool CMainToolBar::ShowUpdateInfo(const CString &newVersion, const CString &infoURL, bool showHighLight) { GetToolBarCtrl().SetState(ID_UPDATE_AVAILABLE, TBSTATE_ENABLED); - if(m_bVertical) - SetVertical(); - else - SetHorizontal(); + RefreshToolbar(); // Trying to show the tooltip while the window is minimized hangs the application during TTM_TRACKACTIVATE. if(!showHighLight || CMainFrame::GetMainFrame()->IsIconic()) @@ -530,11 +534,21 @@ BOOL CMainToolBar::SetCurrentSong(CSoundFile *pSndFile) int nRowsPerBeat = pSndFile->m_PlayState.m_nCurrentRowsPerBeat; if(nRowsPerBeat != nCurrentRowsPerBeat) { - if(nCurrentRowsPerBeat < 0) m_SpinRowsPerBeat.EnableWindow(TRUE); + if(nCurrentRowsPerBeat < 0) + m_SpinRowsPerBeat.EnableWindow(TRUE); nCurrentRowsPerBeat = nRowsPerBeat; wsprintf(s, _T("%u"), static_cast(nCurrentRowsPerBeat)); m_EditRowsPerBeat.SetWindowText(s); } + int globalVol = pSndFile->m_PlayState.m_nGlobalVolume; + if(globalVol != m_currentGlobalVolume) + { + if(m_currentGlobalVolume < 0) + m_SpinGlobalVolume.EnableWindow(TRUE); + m_currentGlobalVolume = globalVol; + wsprintf(s, _T("%u"), static_cast(Util::muldivr(m_currentGlobalVolume, pSndFile->GlobalVolumeRange(), MAX_GLOBAL_VOLUME))); + m_EditGlobalVolume.SetWindowText(s); + } } else { if(nCurrentTempo > TEMPO(0, 0)) @@ -556,6 +570,12 @@ BOOL CMainToolBar::SetCurrentSong(CSoundFile *pSndFile) m_EditRowsPerBeat.SetWindowText(_T("---")); m_SpinRowsPerBeat.EnableWindow(FALSE); } + if(m_currentGlobalVolume != -1) + { + m_currentGlobalVolume = -1; + m_EditGlobalVolume.SetWindowText(_T("---")); + m_SpinGlobalVolume.EnableWindow(FALSE); + } } return TRUE; } @@ -621,6 +641,12 @@ void CMainToolBar::OnVScroll(UINT nCode, UINT nPos, CScrollBar *pScrollBar) // Update pattern editor pMainFrm->PostMessage(WM_MOD_INVALIDATEPATTERNS, HINT_MPTOPTIONS); } + if((n = m_SpinGlobalVolume.GetPos32()) != 0) + { + n = Util::muldiv(n, MAX_GLOBAL_VOLUME, pSndFile->GlobalVolumeRange()); + pSndFile->m_PlayState.m_nGlobalVolume = Clamp(pSndFile->m_PlayState.m_nGlobalVolume + n, 0, int(MAX_GLOBAL_VOLUME)); + m_SpinGlobalVolume.SetPos(0); + } SetCurrentSong(pSndFile); } diff --git a/mptrack/Mainbar.h b/mptrack/Mainbar.h index 9205cbb79e..b35d7a04f5 100644 --- a/mptrack/Mainbar.h +++ b/mptrack/Mainbar.h @@ -18,6 +18,8 @@ OPENMPT_NAMESPACE_BEGIN +enum class MainToolBarItem : uint8; + class CStereoVU: public CStatic { protected: @@ -63,7 +65,7 @@ class CToolBarEx: public CToolBar ~CToolBarEx() override {} public: - BOOL EnableControl(CWnd &wnd, UINT nIndex, UINT nHeight=0); + void UpdateControl(bool show, CWnd &wnd, int index, int id, int height = 0); void ChangeCtrlStyle(LONG lStyle, BOOL bSetStyle); void EnableFlatButtons(BOOL bFlat); @@ -81,10 +83,10 @@ class CMainToolBar: public CToolBarEx protected: UpdateToolTip m_tooltip; CImageListEx m_ImageList, m_ImageListDisabled; - CEdit m_EditTempo, m_EditSpeed, m_EditOctave, m_EditRowsPerBeat; - CStatic m_StaticTempo, m_StaticSpeed, m_StaticRowsPerBeat; - CSpinButtonCtrl m_SpinTempo, m_SpinSpeed, m_SpinOctave, m_SpinRowsPerBeat; - int nCurrentSpeed = 0, nCurrentOctave = 0, nCurrentRowsPerBeat = 0; + CEdit m_EditTempo, m_EditSpeed, m_EditOctave, m_EditRowsPerBeat, m_EditGlobalVolume; + CStatic m_StaticTempo, m_StaticSpeed, m_StaticRowsPerBeat, m_StaticGlobalVolume; + CSpinButtonCtrl m_SpinTempo, m_SpinSpeed, m_SpinOctave, m_SpinRowsPerBeat, m_SpinGlobalVolume; + int nCurrentSpeed = 0, nCurrentOctave = 0, nCurrentRowsPerBeat = 0, m_currentGlobalVolume = 0; TEMPO nCurrentTempo; public: CStereoVU m_VuMeter; @@ -118,8 +120,12 @@ class CMainToolBar: public CToolBarEx bool ShowUpdateInfo(const CString &newVersion, const CString &infoURL, bool showHighLight); void RemoveUpdateInfo(); + void ToggleVisibility(MainToolBarItem item); + protected: + void RefreshToolbar(); void UpdateSizes(); + void UpdateControls(); //{{AFX_MSG(CMainToolBar) afx_msg LRESULT OnDPIChangedAfterParent(WPARAM, LPARAM); diff --git a/mptrack/Mainfrm.h b/mptrack/Mainfrm.h index 50f5addde0..9d70be0633 100644 --- a/mptrack/Mainfrm.h +++ b/mptrack/Mainfrm.h @@ -444,6 +444,13 @@ class CMainFrame afx_msg BOOL OnQueryEndSession(); afx_msg void OnActivateApp(BOOL active, DWORD threadID); + afx_msg void OnToggleMainBarShowOctave(); + afx_msg void OnToggleMainBarShowTempo(); + afx_msg void OnToggleMainBarShowSpeed(); + afx_msg void OnToggleMainBarShowRowsPerBeat(); + afx_msg void OnToggleMainBarShowGlobalVolume(); + afx_msg void OnToggleMainBarShowVUMeter(); + afx_msg void OnCreateMixerDump(); afx_msg void OnVerifyMixerDump(); afx_msg void OnConvertMixerDumpToText(); diff --git a/mptrack/TrackerSettings.cpp b/mptrack/TrackerSettings.cpp index 04cfe07b7d..f82d8c9a62 100644 --- a/mptrack/TrackerSettings.cpp +++ b/mptrack/TrackerSettings.cpp @@ -201,6 +201,7 @@ TrackerSettings::TrackerSettings(SettingsContainer &conf) , useOldStyleFolderBrowser(conf, UL_("Display"), UL_("UseOldStyleFolderBrowser"), false) , defaultRainbowChannelColors(conf, UL_("Display"), UL_("DefaultChannelColors"), DefaultChannelColors::Random) , commentsFont(conf, UL_("Display"), UL_("Comments Font"), FontSetting(UL_("Courier New"), 120)) + , mainToolBarVisibleItems(conf, UL_("Display"), UL_("MainToolBarVisibleItems"), MainToolBarItem::Default) // Misc , defaultModType(conf, UL_("Misc"), UL_("DefaultModType"), MOD_TYPE_IT) , defaultNewFileAction(conf, UL_("Misc"), UL_("DefaultNewFileAction"), nfDefaultFormat) diff --git a/mptrack/TrackerSettings.h b/mptrack/TrackerSettings.h index e410f7c205..dbe406e047 100644 --- a/mptrack/TrackerSettings.h +++ b/mptrack/TrackerSettings.h @@ -361,6 +361,22 @@ template<> inline Resampling::AmigaFilter FromSettingValue(const SettingValue &v template<> inline SettingValue ToSettingValue(const NewFileAction &val) { return SettingValue(int32(val)); } template<> inline NewFileAction FromSettingValue(const SettingValue &val) { return NewFileAction(val.as()); } +enum class MainToolBarItem : uint8 +{ + Octave = 0x01, + Tempo = 0x02, + Speed = 0x04, + RowsPerBeat = 0x08, + GlobalVolume = 0x10, + VUMeter = 0x20, + + Default = Octave | Tempo | Speed | GlobalVolume | VUMeter +}; +DECLARE_FLAGSET(MainToolBarItem) + +template<> inline SettingValue ToSettingValue(const MainToolBarItem &val) { return SettingValue(static_cast(val)); } +template<> inline MainToolBarItem FromSettingValue(const SettingValue &val) { return static_cast(val.as()); } + template<> inline SettingValue ToSettingValue(const std::bitset<128> &val) { return SettingValue(IgnoredCCsToString(val), "IgnoredCCs"); @@ -699,6 +715,8 @@ class TrackerSettings Setting commentsFont; + Setting mainToolBarVisibleItems; + // Misc Setting defaultModType; diff --git a/mptrack/resource.h b/mptrack/resource.h index e8df027211..cfab15d65e 100644 --- a/mptrack/resource.h +++ b/mptrack/resource.h @@ -763,6 +763,7 @@ #define IDC_EDIT_MISC_ACTIONS 2284 #define IDC_TREE_TUNING 2292 #define IDC_PATTERN_FOLLOWSONG 2293 +#define IDC_TEXT_GLOBALVOL 2299 #define IDC_TEXT_BPM 2300 #define IDC_TEXT_RPB 2301 #define IDC_SPIN_RPB 2302 @@ -1173,6 +1174,12 @@ #define ID_ADDTUNINGGENERAL 36034 #define ID_ADDTUNINGGROUPGEOMETRIC 36035 #define ID_ADDTUNINGGEOMETRIC 36036 +#define ID_MAINBAR_SHOW_OCTAVE 36037 +#define ID_MAINBAR_SHOW_TEMPO 36038 +#define ID_MAINBAR_SHOW_SPEED 36039 +#define ID_MAINBAR_SHOW_ROWSPERBEAT 36040 +#define ID_MAINBAR_SHOW_GLOBALVOLUME 36041 +#define ID_MAINBAR_SHOW_VUMETER 36042 #define ID_SELECTINST 36100 // From here: Command range [ID_SELECTINST, ID_SELECTINST + MAX_INSTRUMENTS] #define ID_PLUG_RECORDAUTOMATION 37003 diff --git a/soundlib/Sndfile.h b/soundlib/Sndfile.h index 20d70c814a..86a7d971ae 100644 --- a/soundlib/Sndfile.h +++ b/soundlib/Sndfile.h @@ -1169,6 +1169,11 @@ class CSoundFile return UseCombinedPortamentoCommands(GetType()); } + uint32 GlobalVolumeRange() const noexcept + { + return !(GetType() & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_IMF | MOD_TYPE_J2B | MOD_TYPE_MID | MOD_TYPE_AMS | MOD_TYPE_DBM | MOD_TYPE_PTM | MOD_TYPE_MDL | MOD_TYPE_DTM)) ? 64 : 128; + } + bool DestroySample(SAMPLEINDEX nSample); bool DestroySampleThreadsafe(SAMPLEINDEX nSample);