Skip to content

Commit

Permalink
[New] The main toolbar shows the global volume of the currently playi…
Browse files Browse the repository at this point in the history
…ng module now, and can also be used to modify it.

[Imp] All custom controls in the main toolbar can now be toggled via the context menu.
[Mod] By default, the main toolbar no longer shows the rows/beat. This makes the default toolbar layout still mostly usable at a 1024 pixel width after adding the global volume, and this information is rarely needed anyways (it can be directly seen in the pattenr data itself). Once dynamic toolbar sizing is working, it might be brought back by default.

git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22127 56274372-70c3-4bfc-bfc3-4c3a0b034d27
  • Loading branch information
sagamusix committed Nov 9, 2024
1 parent f239961 commit c88d41e
Show file tree
Hide file tree
Showing 10 changed files with 222 additions and 128 deletions.
10 changes: 5 additions & 5 deletions mptrack/Ctrl_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}


Expand All @@ -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);

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 0 additions & 1 deletion mptrack/Ctrl_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
43 changes: 34 additions & 9 deletions mptrack/MainFrm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<CControlBar *>(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);
Expand Down Expand Up @@ -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<MainToolBarItem> 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<UINT_PTR>(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)
Expand Down
Loading

0 comments on commit c88d41e

Please sign in to comment.