From 494c0731b76d9ae383c7bdfede625627d90c974f Mon Sep 17 00:00:00 2001 From: Johannes Schultz Date: Wed, 1 Jan 2025 17:32:24 +0000 Subject: [PATCH] [Ref] Turn pattern and MIDI setup flags into enum class FlagSets, and rename many flags to have more understandable names. git-svn-id: https://source.openmpt.org/svn/openmpt/trunk/OpenMPT@22684 56274372-70c3-4bfc-bfc3-4c3a0b034d27 --- mptrack/ColorConfigDlg.cpp | 20 ++--- mptrack/Ctrl_pat.cpp | 8 +- mptrack/Ctrl_seq.cpp | 2 +- mptrack/Draw_pat.cpp | 36 ++++----- mptrack/GeneralConfigDlg.cpp | 68 ++++++++-------- mptrack/Globals.cpp | 12 +-- mptrack/MainFrm.cpp | 20 ++--- mptrack/Mainbar.cpp | 2 +- mptrack/Mainfrm.h | 3 +- mptrack/Moddoc.cpp | 6 +- mptrack/Mpdlgs.cpp | 54 ++++++------- mptrack/Mpdlgs.h | 4 +- mptrack/Mpt_midi.cpp | 12 +-- mptrack/Mptrack.cpp | 2 +- mptrack/PatternClipboard.cpp | 2 +- mptrack/TrackerSettings.cpp | 48 +++++------- mptrack/TrackerSettings.h | 111 +++++++++++++++----------- mptrack/View_ins.cpp | 9 ++- mptrack/View_pat.cpp | 147 +++++++++++++++++++---------------- mptrack/View_smp.cpp | 11 +-- mptrack/View_tre.cpp | 11 +-- soundlib/Sndfile.cpp | 2 +- soundlib/Sndmix.cpp | 2 +- 23 files changed, 315 insertions(+), 277 deletions(-) diff --git a/mptrack/ColorConfigDlg.cpp b/mptrack/ColorConfigDlg.cpp index ca3b10912b9..e01d490f2a2 100644 --- a/mptrack/ColorConfigDlg.cpp +++ b/mptrack/ColorConfigDlg.cpp @@ -48,8 +48,8 @@ static constexpr struct ColorDescriptions { const TCHAR *name; int previewImage; - ModColor colorIndex[3]; - const TCHAR *descText[3]; + std::array colorIndex; + std::array descText; } colorDefs[] = { { _T("Pattern Editor"), 0, { MODCOLOR_BACKNORMAL, MODCOLOR_TEXTNORMAL, MODCOLOR_BACKHILIGHT }, { _T("Background:"), _T("Foreground:"), _T("Highlighted:") } }, @@ -182,9 +182,10 @@ BOOL COptionsColors::OnInitDialog() 0, 0, HighDPISupport::ScalePixels(PREVIEWBMP_WIDTH * 2, m_hWnd) + 2, HighDPISupport::ScalePixels(PREVIEWBMP_HEIGHT * 2, m_hWnd) + 2, SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_STDHIGHLIGHT) CheckDlgButton(IDC_CHECK1, BST_CHECKED); - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_EFFECTHILIGHT) CheckDlgButton(IDC_CHECK2, BST_CHECKED); - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_2NDHIGHLIGHT) CheckDlgButton(IDC_CHECK4, BST_CHECKED); + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; + if(patternSetup[PatternSetup::HighlightMeasures]) CheckDlgButton(IDC_CHECK1, BST_CHECKED); + if(patternSetup[PatternSetup::EffectHighlight]) CheckDlgButton(IDC_CHECK2, BST_CHECKED); + if(patternSetup[PatternSetup::HighlightBeats]) CheckDlgButton(IDC_CHECK4, BST_CHECKED); CheckDlgButton(IDC_CHECK3, TrackerSettings::Instance().patternIgnoreSongTimeSignature ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(IDC_CHECK5, TrackerSettings::Instance().rememberSongWindows ? BST_CHECKED : BST_UNCHECKED); CheckRadioButton(IDC_RADIO1, IDC_RADIO2, TrackerSettings::Instance().accidentalFlats ? IDC_RADIO2 : IDC_RADIO1); @@ -269,10 +270,11 @@ void COptionsColors::OnOK() } } - TrackerSettings::Instance().m_dwPatternSetup &= ~(PATTERN_STDHIGHLIGHT|PATTERN_2NDHIGHLIGHT|PATTERN_EFFECTHILIGHT); - if(IsDlgButtonChecked(IDC_CHECK1)) TrackerSettings::Instance().m_dwPatternSetup |= PATTERN_STDHIGHLIGHT; - if(IsDlgButtonChecked(IDC_CHECK2)) TrackerSettings::Instance().m_dwPatternSetup |= PATTERN_EFFECTHILIGHT; - if(IsDlgButtonChecked(IDC_CHECK4)) TrackerSettings::Instance().m_dwPatternSetup |= PATTERN_2NDHIGHLIGHT; + FlagSet patternSetup = TrackerSettings::Instance().patternSetup; + patternSetup.set(PatternSetup::HighlightMeasures, IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED); + patternSetup.set(PatternSetup::EffectHighlight, IsDlgButtonChecked(IDC_CHECK2) != BST_UNCHECKED); + patternSetup.set(PatternSetup::HighlightBeats, IsDlgButtonChecked(IDC_CHECK4) != BST_UNCHECKED); + TrackerSettings::Instance().patternSetup = patternSetup; TrackerSettings::Instance().patternIgnoreSongTimeSignature = IsDlgButtonChecked(IDC_CHECK3) != BST_UNCHECKED; TrackerSettings::Instance().rememberSongWindows = IsDlgButtonChecked(IDC_CHECK5) != BST_UNCHECKED; TrackerSettings::Instance().accidentalFlats = IsDlgButtonChecked(IDC_RADIO2) != BST_UNCHECKED; diff --git a/mptrack/Ctrl_pat.cpp b/mptrack/Ctrl_pat.cpp index e44235b097a..a217e9682b7 100644 --- a/mptrack/Ctrl_pat.cpp +++ b/mptrack/Ctrl_pat.cpp @@ -171,7 +171,7 @@ BOOL CCtrlPatterns::OnInitDialog() m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP); m_ToolBar.AddButton(ID_PATTERNDETAIL_DROPDOWN, TIMAGE_PATTERN_DETAIL, TBSTYLE_BUTTON | TBSTYLE_DROPDOWN); m_ToolBar.AddButton(ID_SEPARATOR, 0, TBSTYLE_SEP); - m_ToolBar.AddButton(ID_OVERFLOWPASTE, TIMAGE_PATTERN_OVERFLOWPASTE, TBSTYLE_CHECK, ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OVERFLOWPASTE) ? TBSTATE_CHECKED : 0) | TBSTATE_ENABLED); + m_ToolBar.AddButton(ID_OVERFLOWPASTE, TIMAGE_PATTERN_OVERFLOWPASTE, TBSTYLE_CHECK, ((TrackerSettings::Instance().patternSetup & PatternSetup::OverflowPaste) ? TBSTATE_CHECKED : 0) | TBSTATE_ENABLED); m_EditPatName.SetLimitText(MAX_PATTERNNAME - 1); // Spin controls @@ -182,7 +182,7 @@ BOOL CCtrlPatterns::OnInitDialog() m_SpinInstrument.SetPos(0); SetDlgItemInt(IDC_EDIT_SPACING, TrackerSettings::Instance().gnPatternSpacing); - CheckDlgButton(IDC_PATTERN_FOLLOWSONG, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FOLLOWSONGOFF) ? BST_UNCHECKED : BST_CHECKED); + CheckDlgButton(IDC_PATTERN_FOLLOWSONG, (TrackerSettings::Instance().patternSetup & PatternSetup::FollowSongOffByDefault) ? BST_UNCHECKED : BST_CHECKED); m_SpinSequence.SetRange32(1, m_sndFile.Order.GetNumSequences()); m_SpinSequence.SetPos(m_sndFile.Order.GetCurrentSequenceIndex() + 1); @@ -544,7 +544,7 @@ LRESULT CCtrlPatterns::OnModCtrlMsg(WPARAM wParam, LPARAM lParam) break; case CTRLMSG_PAT_UPDATE_TOOLBAR: - m_ToolBar.CheckButton(ID_OVERFLOWPASTE, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OVERFLOWPASTE) ? TRUE : FALSE); + m_ToolBar.CheckButton(ID_OVERFLOWPASTE, (TrackerSettings::Instance().patternSetup & PatternSetup::OverflowPaste) ? TRUE : FALSE); m_ToolBar.CheckButton(IDC_METRONOME, TrackerSettings::Instance().metronomeEnabled ? TRUE : FALSE); break; @@ -1105,7 +1105,7 @@ void CCtrlPatterns::OnPatternViewPlugNames() void CCtrlPatterns::OnToggleOverflowPaste() { - TrackerSettings::Instance().m_dwPatternSetup ^= PATTERN_OVERFLOWPASTE; + TrackerSettings::Instance().patternSetup ^= PatternSetup::OverflowPaste; theApp.PostMessageToAllViews(WM_MOD_CTRLMSG, CTRLMSG_PAT_UPDATE_TOOLBAR); SwitchToView(); } diff --git a/mptrack/Ctrl_seq.cpp b/mptrack/Ctrl_seq.cpp index 47e2bc00837..f18a244bba8 100644 --- a/mptrack/Ctrl_seq.cpp +++ b/mptrack/Ctrl_seq.cpp @@ -709,7 +709,7 @@ void COrderList::UpdateInfoText() const ORDERINDEX length = order.GetLengthTailTrimmed(); CString s; - if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_HEXDISPLAY) + if(TrackerSettings::Instance().patternSetup & PatternSetup::RowAndOrderNumbersHex) s.Format(_T("Position %02Xh of %02Xh"), m_nScrollPos, length); else s.Format(_T("Position %u of %u (%02Xh of %02Xh)"), m_nScrollPos, length, m_nScrollPos, length); diff --git a/mptrack/Draw_pat.cpp b/mptrack/Draw_pat.cpp index f5bbdfb7fdd..55e2a4f45f1 100644 --- a/mptrack/Draw_pat.cpp +++ b/mptrack/Draw_pat.cpp @@ -166,7 +166,7 @@ UINT CViewPattern::GetColumnOffset(PatternCursor::Columns column) const int CViewPattern::GetSmoothScrollOffset() const { - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SMOOTHSCROLL) != 0 // Actually using the smooth scroll feature + if((TrackerSettings::Instance().patternSetup & PatternSetup::SmoothScrolling) // Actually using the smooth scroll feature && (m_Status & (psFollowSong | psDragActive)) == psFollowSong // Not drawing a selection during playback && (m_nMidRow != 0 || GetYScrollPos() > 0) // If active row is not centered, only scroll when display position is actually not at the top && IsLiveRecord() // Actually playing live (not paused or stepping) @@ -544,7 +544,7 @@ void CViewPattern::OnDraw(CDC *pDC) const int chanColorHeight = MulDiv(4, m_dpi, 96); const int chanColorOffset = MulDiv(2, m_dpi, 96); const int recordInsX = MulDiv(3, m_dpi, 96); - const bool doSmoothScroll = (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SMOOTHSCROLL) != 0; + const bool doSmoothScroll = (TrackerSettings::Instance().patternSetup & PatternSetup::SmoothScrolling); GetClientRect(&rcClient); @@ -593,7 +593,7 @@ void CViewPattern::OnDraw(CDC *pDC) PATTERNINDEX nPrevPat = PATTERNINDEX_INVALID; // Display previous pattern - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SHOWPREVIOUS) + if(TrackerSettings::Instance().patternSetup & PatternSetup::ShowPrevNextPattern) { if(m_nOrder > 0 && m_nOrder < ordCount) { @@ -640,7 +640,7 @@ void CViewPattern::OnDraw(CDC *pDC) DrawPatternData(hdc, m_nPattern, true, (pMainFrm->GetModPlaying() == pModDoc), yofs, nrows, xofs, rcClient, &ypaint); // Display next pattern - if ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SHOWPREVIOUS) && (ypaint < rcClient.bottom) && (ypaint == ypatternend)) + if((TrackerSettings::Instance().patternSetup & PatternSetup::ShowPrevNextPattern) && (ypaint < rcClient.bottom) && (ypaint == ypatternend)) { int nVisRows = (rcClient.bottom - ypaint + m_szCell.cy - 1) / m_szCell.cy; if(nVisRows > 0) @@ -829,7 +829,7 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl if(!sndFile.Patterns.IsValidPat(nPattern)) return; const CPattern &pattern = sndFile.Patterns[nPattern]; - const auto patternSetupFlags = TrackerSettings::Instance().m_dwPatternSetup.Get(); + const FlagSet patternSetupFlags = TrackerSettings::Instance().patternSetup; const bool volumeColumnIsHex = TrackerSettings::Instance().patternVolColHex; const PATTERNFONT *pfnt = PatternFont::currentFont; @@ -887,7 +887,7 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl nMeasure = sndFile.Patterns[nPattern].GetRowsPerMeasure(); } - const bool hexNumbers = (patternSetupFlags & PATTERN_HEXDISPLAY); + const bool hexNumbers = patternSetupFlags[PatternSetup::RowAndOrderNumbersHex]; bool bRowSel = false; int row_col = -1, row_bkcol = -1; for(ROWINDEX row = startRow; row < numRows; row++) @@ -929,8 +929,7 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl ROWINDEX highlightRow = compRow; if(nMeasure > 0) highlightRow %= nMeasure; - if ((patternSetupFlags & PATTERN_2NDHIGHLIGHT) - && nBeat > 0) + if(patternSetupFlags[PatternSetup::HighlightBeats] && nBeat > 0) { if((highlightRow % nBeat) == 0) { @@ -938,8 +937,7 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl } } // primary highlight (measures) - if((patternSetupFlags & PATTERN_STDHIGHLIGHT) - && nMeasure > 0) + if(patternSetupFlags[PatternSetup::HighlightMeasures] && nMeasure > 0) { if(highlightRow == 0) { @@ -989,13 +987,13 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl const ModCommand *m = pattern.GetpModCommand(row, static_cast(col)); // Should empty volume commands be replaced with a volume command showing the default volume? - const auto defaultVolume = (patternSetupFlags & PATTERN_SHOWDEFAULTVOLUME) ? DrawDefaultVolume(*m) : std::nullopt; + const auto defaultVolume = patternSetupFlags[PatternSetup::ShowDefaultVolume] ? DrawDefaultVolume(*m) : std::nullopt; DWORD dwSpeedUpMask = 0; if(useSpeedUpMask && (m_chnState[col].selectedCols & COLUMN_BITS_SKIP) && (row)) { const ModCommand *mold = m - ncols; - const auto oldDefaultVolume = (patternSetupFlags & PATTERN_SHOWDEFAULTVOLUME) ? DrawDefaultVolume(*mold) : std::nullopt; + const auto oldDefaultVolume = patternSetupFlags[PatternSetup::ShowDefaultVolume] ? DrawDefaultVolume(*mold) : std::nullopt; if(m->note == mold->note || !m_visibleColumns[PatternCursor::noteColumn]) dwSpeedUpMask |= COLUMN_BITS_NOTE; @@ -1043,7 +1041,7 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl { tx_col = row_col; bk_col = row_bkcol; - if((patternSetupFlags & PATTERN_EFFECTHILIGHT) && m->IsNote()) + if(patternSetupFlags[PatternSetup::EffectHighlight] && m->IsNote()) { tx_col = MODCOLOR_NOTE; @@ -1084,7 +1082,7 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl { tx_col = row_col; bk_col = row_bkcol; - if ((patternSetupFlags & PATTERN_EFFECTHILIGHT) && (m->instr)) + if(patternSetupFlags[PatternSetup::EffectHighlight] && (m->instr)) { tx_col = MODCOLOR_INSTRUMENT; } @@ -1111,7 +1109,7 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl { tx_col = MODCOLOR_TEXTSELECTED; bk_col = MODCOLOR_BACKSELECTED; - } else if (!m->IsPcNote() && (patternSetupFlags & PATTERN_EFFECTHILIGHT)) + } else if (!m->IsPcNote() && patternSetupFlags[PatternSetup::EffectHighlight]) { auto fxColor = effectColors[static_cast(m->GetVolumeEffectType())]; if(m->volcmd != VOLCMD_NONE && m->volcmd < MAX_VOLCMDS && fxColor != 0) @@ -1136,7 +1134,7 @@ void CViewPattern::DrawPatternData(HDC hdc, PATTERNINDEX nPattern, bool selEnabl uint16 val = m->GetValueEffectCol(); if(val > ModCommand::maxColumnValue) val = ModCommand::maxColumnValue; fx_col = row_col; - if (!isPCnote && m->command != CMD_NONE && m->command < MAX_EFFECTS && (patternSetupFlags & PATTERN_EFFECTHILIGHT)) + if (!isPCnote && m->command != CMD_NONE && m->command < MAX_EFFECTS && patternSetupFlags[PatternSetup::EffectHighlight]) { if(auto fxColor = effectColors[static_cast(m->GetEffectType())]; fxColor != 0) fx_col = fxColor; @@ -1401,8 +1399,10 @@ void CViewPattern::UpdateScrollSize() sizePage.cy = sizeLine.cy * 8; GetClientRect(&rect); m_nMidRow = 0; - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CENTERROW) m_nMidRow = (rect.Height() - m_szHeader.cy) / (m_szCell.cy * 2); - if (m_nMidRow) sizeTotal.cy += m_nMidRow * m_szCell.cy * 2; + if(TrackerSettings::Instance().patternSetup & PatternSetup::CenterActiveRow) + m_nMidRow = (rect.Height() - m_szHeader.cy) / (m_szCell.cy * 2); + if(m_nMidRow) + sizeTotal.cy += m_nMidRow * m_szCell.cy * 2; SetScrollSizes(MM_TEXT, sizeTotal, sizePage, sizeLine); m_bWholePatternFitsOnScreen = (rect.Height() >= sizeTotal.cy); if(m_bWholePatternFitsOnScreen) diff --git a/mptrack/GeneralConfigDlg.cpp b/mptrack/GeneralConfigDlg.cpp index b4c22dc7f1c..76b41f0ddc0 100644 --- a/mptrack/GeneralConfigDlg.cpp +++ b/mptrack/GeneralConfigDlg.cpp @@ -44,39 +44,39 @@ COptionsGeneral::COptionsGeneral() : CPropertyPage{IDD_OPTIONS_GENERAL} static constexpr struct GeneralOptionsDescriptions { - uint32 flag; + PatternSetup flag; const char *name, *description; } generalOptionsList[] = { - {PATTERN_PLAYNEWNOTE, "Play new notes while recording", "When this option is enabled, notes entered in the pattern editor will always be played (If not checked, notes won't be played in record mode)."}, - {PATTERN_PLAYEDITROW, "Play whole row while recording", "When this option is enabled, all notes on the current row are played when entering notes in the pattern editor."}, - {PATTERN_PLAYNAVIGATEROW, "Play whole row when navigating", "When this option is enabled, all notes on the current row are played when navigating vertically in the pattern editor."}, - {PATTERN_PLAYTRANSPOSE, "Play notes when transposing", "When transposing a single note, the new note is previewed."}, - {PATTERN_CENTERROW, "Always center active row", "Turn on this option to have the active row always centered in the pattern editor."}, - {PATTERN_SMOOTHSCROLL, "Smooth pattern scrolling", "Scroll patterns tick by tick rather than row by row at the expense of an increased CPU load."}, - {PATTERN_HEXDISPLAY, "Display rows in hex", "With this option enabled, row numbers and sequence numbers will be displayed in hexadecimal."}, - {PATTERN_WRAP, "Cursor wrap in pattern editor", "When this option is active, going past the end of a pattern row or channel will move the cursor to the beginning. When \"Continuous scroll\"-option is enabled, row wrap is disabled."}, - {PATTERN_DRAGNDROPEDIT, "Drag and Drop Editing", "Enable moving a selection in the pattern editor (copying if pressing shift while dragging)"}, - {PATTERN_FLATBUTTONS, "Flat Buttons", "Use flat buttons in toolbars"}, - {PATTERN_SINGLEEXPAND, "Single click to expand tree", "Single-clicking in the left tree view will expand a node."}, - {PATTERN_MUTECHNMODE, "Ignored muted channels", "Notes will not be played on muted channels (unmuting will only start on a new note)."}, - {PATTERN_NOEXTRALOUD, "No loud sample preview", "Disable loud playback of samples in the sample/instrument editor. Sample volume depends on the sample volume slider on the general tab when activated (if disabled, samples are previewed at 0 dB)."}, - {PATTERN_SHOWPREVIOUS, "Show Prev/Next patterns", "Displays grayed-out version of the previous/next patterns in the pattern editor. Does not work if \"always center active row\" is disabled."}, - {PATTERN_CONTSCROLL, "Continuous scroll", "Jumps to the next pattern when moving past the end of a pattern"}, - {PATTERN_KBDNOTEOFF, "Record note off", "Record note off when a key is released on the PC keyboard."}, - {PATTERN_FOLLOWSONGOFF, "Follow Song off by default", "Ensure Follow Song is off when opening or starting a new song."}, - {PATTERN_NOFOLLOWONCLICK,"Disable Follow Song on click", "Follow Song is deactivated when clicking into the pattern."}, - {PATTERN_OLDCTXMENUSTYLE, "Old style pattern context menu", "Check this option to hide unavailable items in the pattern editor context menu. Uncheck to grey-out unavailable items instead."}, - {PATTERN_SYNCMUTE, "Maintain sample sync on mute", "Samples continue to be processed when channels are muted (like in IT2 and FT2)"}, - {PATTERN_SYNCSAMPLEPOS, "Maintain sample sync on seek", "Sample that are still active from previous patterns are continued to be played after seeking.\nNote: Some pattern commands may prevent samples from being synced. This feature may slow down seeking."}, - {PATTERN_AUTODELAY, "Automatic delay commands", "Automatically insert appropriate note-delay commands when recording notes during live playback."}, - {PATTERN_NOTEFADE, "Note fade on key up", "Enable to fade / stop notes on key up in pattern tab."}, - {PATTERN_OVERFLOWPASTE, "Overflow paste mode", "Wrap pasted pattern data into next pattern. This is useful for creating echo channels."}, - {PATTERN_RESETCHANNELS, "Reset channels on loop", "If enabled, channels will be reset to their initial state when song looping is enabled.\nNote: This does not affect manual song loops (i.e. triggered by pattern commands) and is not recommended to be enabled."}, - {PATTERN_LIVEUPDATETREE,"Update sample status in tree", "If enabled, active samples and instruments will be indicated by a different icon in the treeview."}, - {PATTERN_NOCLOSEDIALOG, "Disable modern close dialog", "When closing the main window, a confirmation window is shown for every unsaved document instead of one single window with a list of unsaved documents."}, - {PATTERN_DBLCLICKSELECT, "Double-click to select channel", "Instead of showing the note properties, double-clicking a pattern cell selects the whole channel."}, - {PATTERN_SHOWDEFAULTVOLUME, "Show default volume commands", "If there is no volume command next to a note + instrument combination, the sample's default volume is shown."}, + {PatternSetup::PlayNewNotesWhileRecording, "Play new notes while recording", "When this option is enabled, notes entered in the pattern editor will always be played (If not checked, notes won't be played in record mode)."}, + {PatternSetup::PlayRowOnNoteEntry, "Play whole row while recording", "When this option is enabled, all notes on the current row are played when entering notes in the pattern editor."}, + {PatternSetup::PlayRowOnNavigate, "Play whole row when navigating", "When this option is enabled, all notes on the current row are played when navigating vertically in the pattern editor."}, + {PatternSetup::PreviewNoteTransposition, "Play notes when transposing", "When transposing a single note, the new note is previewed."}, + {PatternSetup::CenterActiveRow, "Always center active row", "Turn on this option to have the active row always centered in the pattern editor."}, + {PatternSetup::SmoothScrolling, "Smooth pattern scrolling", "Scroll patterns tick by tick rather than row by row at the expense of an increased CPU load."}, + {PatternSetup::RowAndOrderNumbersHex, "Display rows / orders in hex", "With this option enabled, row numbers and sequence numbers will be displayed in hexadecimal."}, + {PatternSetup::CursorWrap, "Cursor wrap in pattern editor", "When this option is active, going past the end of a pattern row or channel will move the cursor to the beginning. When \"Continuous scroll\"-option is enabled, row wrap is disabled."}, + {PatternSetup::DragNDropEdit, "Drag and Drop Editing", "Enable moving a selection in the pattern editor (copying if pressing shift while dragging)"}, + {PatternSetup::FlatToolbarButtons, "Flat Buttons", "Use flat buttons in toolbars"}, + {PatternSetup::SingleClickToExpand, "Single click to expand tree", "Single-clicking in the left tree view will expand a node."}, + {PatternSetup::IgnoreMutedChannels, "Ignored muted channels", "Notes will not be played on muted channels (unmuting will only start on a new note)."}, + {PatternSetup::NoLoudSamplePreview, "No loud sample preview", "Disable loud playback of samples in the sample/instrument editor. Sample volume depends on the sample volume slider on the general tab when activated (if disabled, samples are previewed at 0 dB)."}, + {PatternSetup::ShowPrevNextPattern, "Show Prev/Next patterns", "Displays grayed-out version of the previous/next patterns in the pattern editor. Does not work if \"always center active row\" is disabled."}, + {PatternSetup::ContinuousScrolling, "Continuous scroll", "Jumps to the next pattern when moving past the end of a pattern"}, + {PatternSetup::RecordNoteOff, "Record note off", "Record note off when a key is released on the PC keyboard."}, + {PatternSetup::FollowSongOffByDefault, "Follow Song off by default", "Ensure Follow Song is off when opening or starting a new song."}, + {PatternSetup::DisableFollowOnClick, "Disable Follow Song on click", "Follow Song is deactivated when clicking into the pattern."}, + {PatternSetup::HideUnavailableMenuEntries, "Old style pattern context menu", "Check this option to hide unavailable items in the pattern editor context menu. Uncheck to grey-out unavailable items instead."}, + {PatternSetup::SyncMute, "Maintain sample sync on mute", "Samples continue to be processed when channels are muted (like in IT2 and FT2)"}, + {PatternSetup::SampleSyncOnSeek, "Maintain sample sync on seek", "Sample that are still active from previous patterns are continued to be played after seeking.\nNote: Some pattern commands may prevent samples from being synced. This feature may slow down seeking."}, + {PatternSetup::AutoDelayCommands, "Automatic delay commands", "Automatically insert appropriate note-delay commands when recording notes during live playback."}, + {PatternSetup::NoteFadeOnKeyUp, "Note fade on key up", "Enable to fade / stop notes on key up in pattern tab."}, + {PatternSetup::OverflowPaste, "Overflow paste mode", "Wrap pasted pattern data into next pattern. This is useful for creating echo channels."}, + {PatternSetup::ResetChannelsOnLoop, "Reset channels on loop", "If enabled, channels will be reset to their initial state when song looping is enabled.\nNote: This does not affect manual song loops (i.e. triggered by pattern commands) and is not recommended to be enabled."}, + {PatternSetup::LiveUpdateTreeView, "Update sample status in tree", "If enabled, active samples and instruments will be indicated by a different icon in the treeview."}, + {PatternSetup::NoCustomCloseDialog, "Disable modern close dialog", "When closing the main window, a confirmation window is shown for every unsaved document instead of one single window with a list of unsaved documents."}, + {PatternSetup::DblClickSelectsChannel, "Double-click to select channel", "Instead of showing the note properties, double-clicking a pattern cell selects the whole channel."}, + {PatternSetup::ShowDefaultVolume, "Show default volume commands", "If there is no volume command next to a note + instrument combination, the sample's default volume is shown."}, }; @@ -141,10 +141,11 @@ BOOL COptionsGeneral::OnInitDialog() CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO1 + TrackerSettings::Instance().defaultNewFileAction); + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; for(const auto &opt : generalOptionsList) { auto idx = m_CheckList.AddString(mpt::ToCString(mpt::Charset::ASCII, opt.name)); - const int check = (TrackerSettings::Instance().m_dwPatternSetup & opt.flag) != 0 ? BST_CHECKED : BST_UNCHECKED; + const int check = patternSetup[opt.flag] ? BST_CHECKED : BST_UNCHECKED; m_CheckList.SetCheck(idx, check); } m_CheckList.SetCurSel(0); @@ -172,13 +173,14 @@ void COptionsGeneral::OnOK() } TrackerSettings::Instance().defaultNewFileAction = action; + FlagSet patternSetup = TrackerSettings::Instance().patternSetup; for(int i = 0; i < mpt::saturate_cast(std::size(generalOptionsList)); i++) { const bool check = (m_CheckList.GetCheck(i) != BST_UNCHECKED); - if(check) TrackerSettings::Instance().m_dwPatternSetup |= generalOptionsList[i].flag; - else TrackerSettings::Instance().m_dwPatternSetup &= ~generalOptionsList[i].flag; + patternSetup.set(generalOptionsList[i].flag, check); } + TrackerSettings::Instance().patternSetup = patternSetup; CMainFrame::GetMainFrame()->SetupMiscOptions(); diff --git a/mptrack/Globals.cpp b/mptrack/Globals.cpp index 693aa07d9c1..1cd0db9ce9b 100644 --- a/mptrack/Globals.cpp +++ b/mptrack/Globals.cpp @@ -851,13 +851,13 @@ void CModControlBar::UpdateStyle() { if (m_hWnd) { - LONG lStyleOld = GetWindowLong(m_hWnd, GWL_STYLE); - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS) - lStyleOld |= TBSTYLE_FLAT; + LONG style = GetWindowLong(m_hWnd, GWL_STYLE); + if(TrackerSettings::Instance().patternSetup & PatternSetup::FlatToolbarButtons) + style |= TBSTYLE_FLAT; else - lStyleOld &= ~TBSTYLE_FLAT; - lStyleOld |= CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER | TBSTYLE_TOOLTIPS; - SetWindowLong(m_hWnd, GWL_STYLE, lStyleOld); + style &= ~TBSTYLE_FLAT; + style |= CCS_NORESIZE | CCS_NOPARENTALIGN | CCS_NODIVIDER | TBSTYLE_TOOLTIPS; + SetWindowLong(m_hWnd, GWL_STYLE, style); Invalidate(); } } diff --git a/mptrack/MainFrm.cpp b/mptrack/MainFrm.cpp index 40b42ed0ab7..ef325b646f1 100644 --- a/mptrack/MainFrm.cpp +++ b/mptrack/MainFrm.cpp @@ -326,7 +326,8 @@ int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) UpdateColors(); - if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_ENABLE_RECORD_DEFAULT) midiOpenDevice(false); + if(TrackerSettings::Instance().midiSetup & MidiSetup::EnableMidiInOnStartup) + midiOpenDevice(false); #if MPT_COMPILER_MSVC #pragma warning(push) @@ -446,7 +447,7 @@ BOOL CMainFrame::DestroyWindow() void CMainFrame::OnClose() { MPT_TRACE_SCOPE(); - if(!(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOCLOSEDIALOG)) + if(!(TrackerSettings::Instance().patternSetup & PatternSetup::NoCustomCloseDialog)) { // Show modified documents window CloseMainDialog dlg; @@ -1274,7 +1275,7 @@ void CMainFrame::UpdateDspEffects(CSoundFile &sndFile, bool reset) void CMainFrame::UpdateAudioParameters(CSoundFile &sndFile, bool reset) { CriticalSection cs; - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_MUTECHNMODE) + if (TrackerSettings::Instance().patternSetup & PatternSetup::IgnoreMutedChannels) TrackerSettings::Instance().MixerFlags |= SNDMIX_MUTECHNMODE; else TrackerSettings::Instance().MixerFlags &= ~SNDMIX_MUTECHNMODE; @@ -1805,7 +1806,7 @@ void CMainFrame::PreparePreview(ModCommand::NOTE note, int volume) m_WaveFile.ResetPlayPos(); const CModDoc *activeDoc = GetActiveDoc(); - if(activeDoc != nullptr && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOEXTRALOUD)) + if(activeDoc != nullptr && (TrackerSettings::Instance().patternSetup & PatternSetup::NoLoudSamplePreview)) { m_WaveFile.SetMixLevels(activeDoc->GetSoundFile().GetMixLevels()); m_WaveFile.m_nSamplePreAmp = activeDoc->GetSoundFile().m_nSamplePreAmp; @@ -1934,7 +1935,8 @@ void CMainFrame::SetupPlayer() void CMainFrame::SetupMiscOptions() { - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_MUTECHNMODE) + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; + if(patternSetup[PatternSetup::IgnoreMutedChannels]) TrackerSettings::Instance().MixerFlags |= SNDMIX_MUTECHNMODE; else TrackerSettings::Instance().MixerFlags &= ~SNDMIX_MUTECHNMODE; @@ -1943,17 +1945,17 @@ void CMainFrame::SetupMiscOptions() if(GetSoundFilePlaying()) UpdateAudioParameters(*GetSoundFilePlaying()); } - m_wndToolBar.EnableFlatButtons(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS); + m_wndToolBar.EnableFlatButtons(patternSetup[PatternSetup::FlatToolbarButtons]); UpdateTree(nullptr, UpdateHint().MPTOptions()); theApp.UpdateAllViews(UpdateHint().MPTOptions()); } -void CMainFrame::SetupMidi(DWORD d, UINT n) +void CMainFrame::SetupMidi(FlagSet d, UINT n) { bool deviceChanged = (TrackerSettings::Instance().m_nMidiDevice != n); - TrackerSettings::Instance().m_dwMidiSetup = d; + TrackerSettings::Instance().midiSetup = d; TrackerSettings::Instance().SetMIDIDevice(n); if(deviceChanged && shMidiIn) { @@ -2070,7 +2072,7 @@ void CMainFrame::OnViewOptions() #if !defined(NO_REVERB) || !defined(NO_DSP) || !defined(NO_EQ) || !defined(NO_AGC) COptionsPlayer dspdlg; #endif - CMidiSetupDlg mididlg{TrackerSettings::Instance().m_dwMidiSetup, TrackerSettings::Instance().GetCurrentMIDIDevice()}; + CMidiSetupDlg mididlg{TrackerSettings::Instance().midiSetup, TrackerSettings::Instance().GetCurrentMIDIDevice()}; PathConfigDlg pathsdlg; #if defined(MPT_ENABLE_UPDATE) CUpdateSetupDlg updatedlg; diff --git a/mptrack/Mainbar.cpp b/mptrack/Mainbar.cpp index e1816760fa2..e14f2fe65ca 100644 --- a/mptrack/Mainbar.cpp +++ b/mptrack/Mainbar.cpp @@ -408,7 +408,7 @@ void CMainToolBar::UpdateSizes() void CMainToolBar::Init(CMainFrame *pMainFrm) { - EnableFlatButtons(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS); + EnableFlatButtons(TrackerSettings::Instance().patternSetup & PatternSetup::FlatToolbarButtons); SetHorizontal(); pMainFrm->DockControlBar(this); } diff --git a/mptrack/Mainfrm.h b/mptrack/Mainfrm.h index 69a6880e3df..5490f5185ec 100644 --- a/mptrack/Mainfrm.h +++ b/mptrack/Mainfrm.h @@ -36,6 +36,7 @@ class QuickStartDlg; struct UpdateCheckResult; struct UpdateHint; struct MODPLUGDIB; +enum class MidiSetup: int32; enum class MainToolBarItem : uint8; enum SoundDeviceStopMode : int; namespace SoundDevice { @@ -357,7 +358,7 @@ class CMainFrame void SetupMiscOptions(); void SetupPlayer(); - void SetupMidi(DWORD d, UINT n); + void SetupMidi(FlagSet d, UINT n); HWND GetFollowSong() const; HWND GetFollowSong(const CModDoc *pDoc) const { return (pDoc == GetModPlaying()) ? GetFollowSong() : nullptr; } void ResetNotificationBuffer(); diff --git a/mptrack/Moddoc.cpp b/mptrack/Moddoc.cpp index dbf142b7bc2..34dc657e527 100644 --- a/mptrack/Moddoc.cpp +++ b/mptrack/Moddoc.cpp @@ -1032,7 +1032,7 @@ void CModDoc::ProcessMIDI(uint32 midiData, SAMPLEINDEX smp, INSTRUMENTINDEX ins, break; } - if((TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDITOPLUG) && CMainFrame::GetMainFrame()->GetModPlaying() == this && plugin != nullptr) + if((TrackerSettings::Instance().midiSetup & MidiSetup::SendMidiToPlugins) && CMainFrame::GetMainFrame()->GetModPlaying() == this && plugin != nullptr) { plugin->MidiSend(midiData); // Sending midi may modify the plug. For now, if MIDI data is not active sensing or aftertouch messages, set modified. @@ -1128,7 +1128,7 @@ CHANNELINDEX CModDoc::PlayNote(PlayNoteParam ¶ms, NoteToChannelMap *noteChan } // Handle extra-loud flag - chn.dwFlags.set(CHN_EXTRALOUD, !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOEXTRALOUD) && params.m_sample); + chn.dwFlags.set(CHN_EXTRALOUD, !(TrackerSettings::Instance().patternSetup & PatternSetup::NoLoudSamplePreview) && params.m_sample); // Handle custom start position if(params.m_sampleOffset > 0 && chn.pModSample) @@ -3009,7 +3009,7 @@ void CModDoc::SetElapsedTime(ORDERINDEX nOrd, ROWINDEX nRow, bool setSamplePos) { if(nOrd == ORDERINDEX_INVALID) return; - double t = m_SndFile.GetPlaybackTimeAt(nOrd, nRow, true, setSamplePos && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SYNCSAMPLEPOS) != 0); + double t = m_SndFile.GetPlaybackTimeAt(nOrd, nRow, true, setSamplePos && (TrackerSettings::Instance().patternSetup & PatternSetup::SampleSyncOnSeek)); if(t < 0) { // Position is never played regularly, but we may want to continue playing from here nevertheless. diff --git a/mptrack/Mpdlgs.cpp b/mptrack/Mpdlgs.cpp index a1b26646a37..6cde968528f 100644 --- a/mptrack/Mpdlgs.cpp +++ b/mptrack/Mpdlgs.cpp @@ -1743,9 +1743,9 @@ void CMidiSetupDlg::DoDataExchange(CDataExchange* pDX) } -CMidiSetupDlg::CMidiSetupDlg(DWORD flags, UINT device) +CMidiSetupDlg::CMidiSetupDlg(FlagSet flags, UINT device) : CPropertyPage{IDD_OPTIONS_MIDI} - , m_dwMidiSetup{flags} + , m_midiSetup{flags} , m_nMidiDevice{device} { m_editAmp.SetAccessibleSuffix(_T("%")); @@ -1756,16 +1756,16 @@ BOOL CMidiSetupDlg::OnInitDialog() { CPropertyPage::OnInitDialog(); // Flags - if (m_dwMidiSetup & MIDISETUP_RECORDVELOCITY) CheckDlgButton(IDC_CHECK1, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_RECORDNOTEOFF) CheckDlgButton(IDC_CHECK2, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_ENABLE_RECORD_DEFAULT) CheckDlgButton(IDC_CHECK3, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_TRANSPOSEKEYBOARD) CheckDlgButton(IDC_CHECK4, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_MIDITOPLUG) CheckDlgButton(IDC_MIDI_TO_PLUGIN, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_MIDIMACROCONTROL) CheckDlgButton(IDC_MIDI_MACRO_CONTROL, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) CheckDlgButton(IDC_MIDIVOL_TO_NOTEVOL, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_RESPONDTOPLAYCONTROLMSGS) CheckDlgButton(IDC_MIDIPLAYCONTROL, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_PLAYPATTERNONMIDIIN) CheckDlgButton(IDC_MIDIPLAYPATTERNONMIDIIN, BST_CHECKED); - if (m_dwMidiSetup & MIDISETUP_MIDIMACROPITCHBEND) CheckDlgButton(IDC_CHECK5, BST_CHECKED); + if(m_midiSetup[MidiSetup::RecordVelocity]) CheckDlgButton(IDC_CHECK1, BST_CHECKED); + if(m_midiSetup[MidiSetup::RecordNoteOff]) CheckDlgButton(IDC_CHECK2, BST_CHECKED); + if(m_midiSetup[MidiSetup::EnableMidiInOnStartup]) CheckDlgButton(IDC_CHECK3, BST_CHECKED); + if(m_midiSetup[MidiSetup::TransposeKeyboard]) CheckDlgButton(IDC_CHECK4, BST_CHECKED); + if(m_midiSetup[MidiSetup::SendMidiToPlugins]) CheckDlgButton(IDC_MIDI_TO_PLUGIN, BST_CHECKED); + if(m_midiSetup[MidiSetup::RecordCCsAsMacros]) CheckDlgButton(IDC_MIDI_MACRO_CONTROL, BST_CHECKED); + if(m_midiSetup[MidiSetup::ApplyChannelVolumeToVelocity]) CheckDlgButton(IDC_MIDIVOL_TO_NOTEVOL, BST_CHECKED); + if(m_midiSetup[MidiSetup::RespondToPlayControl]) CheckDlgButton(IDC_MIDIPLAYCONTROL, BST_CHECKED); + if(m_midiSetup[MidiSetup::PlayPatternOnMidiNote]) CheckDlgButton(IDC_MIDIPLAYPATTERNONMIDIIN, BST_CHECKED); + if(m_midiSetup[MidiSetup::RecordPitchBend]) CheckDlgButton(IDC_CHECK5, BST_CHECKED); // Midi In Device RefreshDeviceList(m_nMidiDevice); @@ -1876,21 +1876,22 @@ void CMidiSetupDlg::OnRenameDevice() void CMidiSetupDlg::OnOK() { CMainFrame *pMainFrm = CMainFrame::GetMainFrame(); - m_dwMidiSetup = 0; - m_nMidiDevice = MIDI_MAPPER; - if (IsDlgButtonChecked(IDC_CHECK1)) m_dwMidiSetup |= MIDISETUP_RECORDVELOCITY; - if (IsDlgButtonChecked(IDC_CHECK2)) m_dwMidiSetup |= MIDISETUP_RECORDNOTEOFF; - if (IsDlgButtonChecked(IDC_CHECK3)) m_dwMidiSetup |= MIDISETUP_ENABLE_RECORD_DEFAULT; - if (IsDlgButtonChecked(IDC_CHECK4)) m_dwMidiSetup |= MIDISETUP_TRANSPOSEKEYBOARD; - if (IsDlgButtonChecked(IDC_MIDI_TO_PLUGIN)) m_dwMidiSetup |= MIDISETUP_MIDITOPLUG; - if (IsDlgButtonChecked(IDC_MIDI_MACRO_CONTROL)) m_dwMidiSetup |= MIDISETUP_MIDIMACROCONTROL; - if (IsDlgButtonChecked(IDC_MIDIVOL_TO_NOTEVOL)) m_dwMidiSetup |= MIDISETUP_MIDIVOL_TO_NOTEVOL; - if (IsDlgButtonChecked(IDC_MIDIPLAYCONTROL)) m_dwMidiSetup |= MIDISETUP_RESPONDTOPLAYCONTROLMSGS; - if (IsDlgButtonChecked(IDC_MIDIPLAYPATTERNONMIDIIN)) m_dwMidiSetup |= MIDISETUP_PLAYPATTERNONMIDIIN; - if (IsDlgButtonChecked(IDC_CHECK5)) m_dwMidiSetup |= MIDISETUP_MIDIMACROPITCHBEND; + m_midiSetup.set(MidiSetup::RecordVelocity, IsDlgButtonChecked(IDC_CHECK1) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::RecordNoteOff, IsDlgButtonChecked(IDC_CHECK2) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::EnableMidiInOnStartup, IsDlgButtonChecked(IDC_CHECK3) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::TransposeKeyboard, IsDlgButtonChecked(IDC_CHECK4) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::SendMidiToPlugins, IsDlgButtonChecked(IDC_MIDI_TO_PLUGIN) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::RecordCCsAsMacros, IsDlgButtonChecked(IDC_MIDI_MACRO_CONTROL) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::ApplyChannelVolumeToVelocity, IsDlgButtonChecked(IDC_MIDIVOL_TO_NOTEVOL) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::RespondToPlayControl, IsDlgButtonChecked(IDC_MIDIPLAYCONTROL) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::PlayPatternOnMidiNote, IsDlgButtonChecked(IDC_MIDIPLAYPATTERNONMIDIIN) != BST_UNCHECKED); + m_midiSetup.set(MidiSetup::RecordPitchBend, IsDlgButtonChecked(IDC_CHECK5) != BST_UNCHECKED); int n = m_InputDevice.GetCurSel(); - if (n >= 0) m_nMidiDevice = static_cast(m_InputDevice.GetItemData(n)); + if(n >= 0) + m_nMidiDevice = static_cast(m_InputDevice.GetItemData(n)); + else + m_nMidiDevice = MIDI_MAPPER; TrackerSettings::Instance().aftertouchBehaviour = static_cast(m_ATBehaviour.GetItemData(m_ATBehaviour.GetCurSel())); @@ -1910,7 +1911,8 @@ void CMidiSetupDlg::OnOK() TrackerSettings::Instance().midiImportQuantize = static_cast(m_Quantize.GetItemData(m_Quantize.GetCurSel())); } - if (pMainFrm) pMainFrm->SetupMidi(m_dwMidiSetup, m_nMidiDevice); + if(pMainFrm) + pMainFrm->SetupMidi(m_midiSetup, m_nMidiDevice); CPropertyPage::OnOK(); } diff --git a/mptrack/Mpdlgs.h b/mptrack/Mpdlgs.h index d3bb79786da..b5c63d5f1f4 100644 --- a/mptrack/Mpdlgs.h +++ b/mptrack/Mpdlgs.h @@ -200,11 +200,11 @@ class COptionsPlayer: public CPropertyPage class CMidiSetupDlg: public CPropertyPage { public: - DWORD m_dwMidiSetup; + FlagSet m_midiSetup; UINT m_nMidiDevice; public: - CMidiSetupDlg(DWORD flags, UINT device); + CMidiSetupDlg(FlagSet flags, UINT device); protected: BOOL OnInitDialog() override; diff --git a/mptrack/Mpt_midi.cpp b/mptrack/Mpt_midi.cpp index 4d4cdc31784..d43f7711840 100644 --- a/mptrack/Mpt_midi.cpp +++ b/mptrack/Mpt_midi.cpp @@ -36,16 +36,17 @@ HMIDIIN CMainFrame::shMidiIn = nullptr; int CMainFrame::ApplyVolumeRelatedSettings(const DWORD &dwParam1, uint8 midiChannelVolume) { int nVol = MIDIEvents::GetDataByte2FromEvent(dwParam1); - if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_RECORDVELOCITY) + const FlagSet midiSetup = TrackerSettings::Instance().midiSetup; + if(midiSetup[MidiSetup::RecordVelocity]) { - if(!(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL)) + if(!midiSetup[MidiSetup::ApplyChannelVolumeToVelocity]) midiChannelVolume = 127; nVol = Util::muldivr_unsigned(CDLSBank::DLSMidiVolumeToLinear(nVol), TrackerSettings::Instance().midiVelocityAmp * midiChannelVolume, 100 * 127 * 256); Limit(nVol, 1, 256); } else { // Case: No velocity record. - if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIVOL_TO_NOTEVOL) + if(midiSetup[MidiSetup::ApplyChannelVolumeToVelocity]) nVol = (midiChannelVolume + 1) * 2; else //Use default volume nVol = -1; @@ -57,8 +58,9 @@ int CMainFrame::ApplyVolumeRelatedSettings(const DWORD &dwParam1, uint8 midiChan void ApplyTransposeKeyboardSetting(CMainFrame &rMainFrm, uint32 &dwParam1) { - if ( (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_TRANSPOSEKEYBOARD) - && (MIDIEvents::GetChannelFromEvent(dwParam1) != 9) ) + const FlagSet midiSetup = TrackerSettings::Instance().midiSetup; + if(midiSetup[MidiSetup::TransposeKeyboard] + && (MIDIEvents::GetChannelFromEvent(dwParam1) != 9)) { int nTranspose = rMainFrm.GetBaseOctave() - 4; if (nTranspose) diff --git a/mptrack/Mptrack.cpp b/mptrack/Mptrack.cpp index bf22663e328..df9e3e0e26a 100644 --- a/mptrack/Mptrack.cpp +++ b/mptrack/Mptrack.cpp @@ -243,7 +243,7 @@ struct AllSoundDeviceComponents void CTrackApp::OnFileCloseAll() { - if(!(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOCLOSEDIALOG)) + if(!(TrackerSettings::Instance().patternSetup & PatternSetup::NoCustomCloseDialog)) { // Show modified documents window CloseMainDialog dlg; diff --git a/mptrack/PatternClipboard.cpp b/mptrack/PatternClipboard.cpp index 71e68ac3d74..7003a340688 100644 --- a/mptrack/PatternClipboard.cpp +++ b/mptrack/PatternClipboard.cpp @@ -551,7 +551,7 @@ bool PatternClipboard::HandlePaste(CSoundFile &sndFile, PatternEditPos &pastePos } const CModSpecifications &sourceSpecs = CSoundFile::GetModSpecifications(pasteFormat); - const bool overflowPaste = (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OVERFLOWPASTE) && mode != pmPasteFlood && mode != pmPushForward && patternMode != kMultiInsert && curOrder != ORDERINDEX_INVALID; + const bool overflowPaste = (TrackerSettings::Instance().patternSetup & PatternSetup::OverflowPaste) && mode != pmPasteFlood && mode != pmPushForward && patternMode != kMultiInsert && curOrder != ORDERINDEX_INVALID; const bool doITStyleMix = (mode == pmMixPasteIT); const bool doMixPaste = (mode == pmMixPaste) || doITStyleMix; const bool clipboardHasS3MCommands = (pasteFormat & (MOD_TYPE_IT | MOD_TYPE_MPT | MOD_TYPE_S3M)); diff --git a/mptrack/TrackerSettings.cpp b/mptrack/TrackerSettings.cpp index 765c9334cc6..f0d8757c167 100644 --- a/mptrack/TrackerSettings.cpp +++ b/mptrack/TrackerSettings.cpp @@ -93,17 +93,6 @@ MODTYPE SettingsStringToModType(const mpt::ustring &str) } -static uint32 GetDefaultPatternSetup() -{ - return PATTERN_PLAYNEWNOTE | PATTERN_EFFECTHILIGHT - | PATTERN_CENTERROW | PATTERN_DRAGNDROPEDIT - | PATTERN_FLATBUTTONS | PATTERN_NOEXTRALOUD | PATTERN_2NDHIGHLIGHT - | PATTERN_STDHIGHLIGHT | PATTERN_SHOWPREVIOUS | PATTERN_CONTSCROLL - | PATTERN_SYNCMUTE | PATTERN_AUTODELAY | PATTERN_NOTEFADE - | PATTERN_SHOWDEFAULTVOLUME | PATTERN_LIVEUPDATETREE | PATTERN_SYNCSAMPLEPOS; -} - - void SampleUndoBufferSize::CalculateSize() { if(sizePercent < 0) @@ -257,7 +246,7 @@ TrackerSettings::TrackerSettings(SettingsContainer &conf) // MIDI Settings , m_nMidiDevice(conf, UL_("MIDI Settings"), UL_("MidiDevice"), 0) , midiDeviceName(conf, UL_("MIDI Settings"), UL_("MidiDeviceName"), _T("")) - , m_dwMidiSetup(conf, UL_("MIDI Settings"), UL_("MidiSetup"), MIDISETUP_RECORDVELOCITY | MIDISETUP_RECORDNOTEOFF | MIDISETUP_TRANSPOSEKEYBOARD | MIDISETUP_MIDITOPLUG) + , midiSetup(conf, UL_("MIDI Settings"), UL_("MidiSetup"), MidiSetup::Default) , aftertouchBehaviour(conf, UL_("MIDI Settings"), UL_("AftertouchBehaviour"), atDoNotRecord) , midiVelocityAmp(conf, UL_("MIDI Settings"), UL_("MidiVelocityAmp"), 100) , midiIgnoreCCs(conf, UL_("MIDI Settings"), UL_("IgnoredCCs"), std::bitset<128>()) @@ -273,7 +262,7 @@ TrackerSettings::TrackerSettings(SettingsContainer &conf) , patternNoEditPopup(conf, UL_("Pattern Editor"), UL_("NoEditPopup"), false) , patternStepCommands(conf, UL_("Pattern Editor"), UL_("EditStepAppliesToCommands"), false) , patternVolColHex(conf, UL_("Pattern Editor"), UL_("VolumeColumnInHex"), false) - , m_dwPatternSetup(conf, UL_("Pattern Editor"), UL_("PatternSetup"), GetDefaultPatternSetup()) + , patternSetup(conf, UL_("Pattern Editor"), UL_("PatternSetup"), PatternSetup::Default) , m_nRowHighlightMeasures(conf, UL_("Pattern Editor"), UL_("RowSpacing"), 16) , m_nRowHighlightBeats(conf, UL_("Pattern Editor"), UL_("RowSpacing2"), 4) , patternIgnoreSongTimeSignature(conf, UL_("Pattern Editor"), UL_("IgnoreSongTimeSignature"), false) @@ -639,59 +628,60 @@ TrackerSettings::TrackerSettings(SettingsContainer &conf) } // MIDI Settings - if((m_dwMidiSetup & 0x40) != 0 && storedVersion < MPT_V("1.20.00.86")) + static constexpr MidiSetup LegacyFlagAmplify2x = static_cast(0x40); + if(midiSetup.Get()[LegacyFlagAmplify2x] && storedVersion < MPT_V("1.20.00.86")) { // This flag used to be "amplify MIDI Note Velocity" - with a fixed amplification factor of 2. midiVelocityAmp = 200; - m_dwMidiSetup &= ~0x40; + midiSetup &= ~LegacyFlagAmplify2x; } // Pattern Editor if(storedVersion < MPT_V("1.17.02.50")) { - m_dwPatternSetup |= PATTERN_NOTEFADE; + patternSetup |= PatternSetup::NoteFadeOnKeyUp; } if(storedVersion < MPT_V("1.17.03.01")) { - m_dwPatternSetup |= PATTERN_RESETCHANNELS; + patternSetup |= PatternSetup::ResetChannelsOnLoop; } if(storedVersion < MPT_V("1.19.00.07")) { - m_dwPatternSetup &= ~0x800; // this was previously deprecated and is now used for something else + patternSetup &= ~PatternSetup(0x800); // this was previously deprecated and is now used for something else } if(storedVersion < MPT_V("1.20.00.04")) { - m_dwPatternSetup &= ~0x200000; // ditto + patternSetup &= ~PatternSetup(0x200000); // ditto } if(storedVersion < MPT_V("1.20.00.07")) { - m_dwPatternSetup &= ~0x400000; // ditto + patternSetup &= ~PatternSetup(0x400000); // ditto } if(storedVersion < MPT_V("1.20.00.39")) { - m_dwPatternSetup &= ~0x10000000; // ditto + patternSetup &= ~PatternSetup(0x10000000); // ditto } if(storedVersion < MPT_V("1.24.01.04")) { - commentsFont = FontSetting(UL_("Courier New"), (m_dwPatternSetup & 0x02) ? 120 : 90); - patternFont = FontSetting((m_dwPatternSetup & 0x08) ? PATTERNFONT_SMALL : PATTERNFONT_LARGE, 0); - m_dwPatternSetup &= ~(0x08 | 0x02); + commentsFont = FontSetting(UL_("Courier New"), (patternSetup & PatternSetup(0x02)) ? 120 : 90); + patternFont = FontSetting((patternSetup & PatternSetup(0x08)) ? PATTERNFONT_SMALL : PATTERNFONT_LARGE, 0); + patternSetup &= ~PatternSetup(0x08 | 0x02); } if(storedVersion < MPT_V("1.25.00.08") && glGeneralWindowHeight < 222) { glGeneralWindowHeight += 44; } - if(storedVersion < MPT_V("1.25.00.16") && (m_dwPatternSetup & 0x100000)) + if(storedVersion < MPT_V("1.25.00.16") && (patternSetup & PatternSetup(0x100000))) { // Move MIDI recording to MIDI setup - m_dwPatternSetup &= ~0x100000; - m_dwMidiSetup |= MIDISETUP_ENABLE_RECORD_DEFAULT; + patternSetup &= ~PatternSetup(0x100000); + midiSetup |= MidiSetup::EnableMidiInOnStartup; } if(storedVersion < MPT_V("1.27.00.51")) { // Moving option out of pattern config - CreateBackupFiles = (m_dwPatternSetup & 0x200) != 0; - m_dwPatternSetup &= ~0x200; + CreateBackupFiles = (patternSetup & PatternSetup(0x200)); + patternSetup &= ~PatternSetup(0x200); } // Export diff --git a/mptrack/TrackerSettings.h b/mptrack/TrackerSettings.h index 9fcc261621c..7738ecc9bb6 100644 --- a/mptrack/TrackerSettings.h +++ b/mptrack/TrackerSettings.h @@ -98,53 +98,70 @@ enum ModColor : uint8 // Pattern Setup (contains also non-pattern related settings) // Feel free to replace the deprecated flags by new flags, but be sure to // update TrackerSettings::TrackerSettings() as well. -#define PATTERN_PLAYNEWNOTE 0x01 // play new notes while recording -#define PATTERN_SMOOTHSCROLL 0x02 // scroll tick by tick, not row by row -#define PATTERN_STDHIGHLIGHT 0x04 // enable primary highlight (measures) -#define PATTERN_NOFOLLOWONCLICK 0x08 // disable song follow when clicking into pattern -#define PATTERN_CENTERROW 0x10 // always center active row -#define PATTERN_WRAP 0x20 // wrap around cursor in editor -#define PATTERN_EFFECTHILIGHT 0x40 // effect syntax highlighting -#define PATTERN_HEXDISPLAY 0x80 // display row number in hex -#define PATTERN_FLATBUTTONS 0x100 // flat toolbar buttons -#define PATTERN_PLAYNAVIGATEROW 0x200 // play whole row when navigating -#define PATTERN_SINGLEEXPAND 0x400 // single click to expand tree -#define PATTERN_PLAYEDITROW 0x800 // play all notes on the current row while entering notes -#define PATTERN_NOEXTRALOUD 0x1000 // no loud samples in sample editor -#define PATTERN_DRAGNDROPEDIT 0x2000 // enable drag and drop editing -#define PATTERN_2NDHIGHLIGHT 0x4000 // activate secondary highlight (beats) -#define PATTERN_MUTECHNMODE 0x8000 // ignore muted channels -#define PATTERN_SHOWPREVIOUS 0x10000 // show prev/next patterns -#define PATTERN_CONTSCROLL 0x20000 // continous pattern scrolling -#define PATTERN_KBDNOTEOFF 0x40000 // Record note-off events -#define PATTERN_FOLLOWSONGOFF 0x80000 // follow song off by default -#define PATTERN_PLAYTRANSPOSE 0x100000 // Preview note transposition -#define PATTERN_NOCLOSEDIALOG 0x200000 // Don't use OpenMPT's custom close dialog with a list of saved files when closing the main window -#define PATTERN_DBLCLICKSELECT 0x400000 // Double-clicking pattern selects whole channel -#define PATTERN_OLDCTXMENUSTYLE 0x800000 // Hide pattern context menu entries instead of greying them out. -#define PATTERN_SYNCMUTE 0x1000000 // maintain sample sync on mute -#define PATTERN_AUTODELAY 0x2000000 // automatically insert delay commands in pattern when entering notes -#define PATTERN_NOTEFADE 0x4000000 // alt. note fade behaviour when entering notes -#define PATTERN_OVERFLOWPASTE 0x8000000 // continue paste in the next pattern instead of cutting off -#define PATTERN_SHOWDEFAULTVOLUME 0x10000000 // if there is no volume command next to note+instr, display the sample's default volume. -#define PATTERN_RESETCHANNELS 0x20000000 // reset channels when looping -#define PATTERN_LIVEUPDATETREE 0x40000000 // update active sample / instr icons in treeview -#define PATTERN_SYNCSAMPLEPOS 0x80000000 // sync sample positions when seeking +enum class PatternSetup : uint32 +{ + PlayNewNotesWhileRecording = 0x01, // play new notes while recording + SmoothScrolling = 0x02, // scroll tick by tick, not row by row + HighlightMeasures = 0x04, // enable primary highlight (measures) + DisableFollowOnClick = 0x08, // disable song follow when clicking into pattern + CenterActiveRow = 0x10, // always center active row + CursorWrap = 0x20, // wrap around cursor in editor + EffectHighlight = 0x40, // effect syntax highlighting + RowAndOrderNumbersHex = 0x80, // display row number and order in hex + FlatToolbarButtons = 0x100, // flat toolbar buttons + PlayRowOnNavigate = 0x200, // play whole row when navigating + SingleClickToExpand = 0x400, // single click to expand tree + PlayRowOnNoteEntry = 0x800, // play all notes on the current row while entering notes + NoLoudSamplePreview = 0x1000, // no loud samples in sample editor + DragNDropEdit = 0x2000, // enable drag and drop editing + HighlightBeats = 0x4000, // activate secondary highlight (beats) + IgnoreMutedChannels = 0x8000, // ignore muted channels + ShowPrevNextPattern = 0x10000, // show prev/next patterns + ContinuousScrolling = 0x20000, // continous pattern scrolling + RecordNoteOff = 0x40000, // Record note-off events + FollowSongOffByDefault = 0x80000, // follow song off by default + PreviewNoteTransposition = 0x100000, // Preview note transposition + NoCustomCloseDialog = 0x200000, // Don't use OpenMPT's custom close dialog with a list of saved files when closing the main window + DblClickSelectsChannel = 0x400000, // Double-clicking pattern selects whole channel + HideUnavailableMenuEntries = 0x800000, // Hide pattern context menu entries instead of greying them out. + SyncMute = 0x1000000, // maintain sample sync on mute + AutoDelayCommands = 0x2000000, // automatically insert delay commands in pattern when entering notes + NoteFadeOnKeyUp = 0x4000000, // alt. note fade behaviour when entering notes + OverflowPaste = 0x8000000, // continue paste in the next pattern instead of cutting off + ShowDefaultVolume = 0x10000000, // if there is no volume command next to note+instr, display the sample's default volume. + ResetChannelsOnLoop = 0x20000000, // reset channels when looping + LiveUpdateTreeView = 0x40000000, // update active sample / instr icons in treeview + SampleSyncOnSeek = 0x80000000, // sync sample positions when seeking + + Default = PlayNewNotesWhileRecording | EffectHighlight + | CenterActiveRow | DragNDropEdit + | FlatToolbarButtons | NoLoudSamplePreview | HighlightBeats + | HighlightMeasures | ShowPrevNextPattern | ContinuousScrolling + | SyncMute | AutoDelayCommands | NoteFadeOnKeyUp + | ShowDefaultVolume | LiveUpdateTreeView | SampleSyncOnSeek +}; +DECLARE_FLAGSET(PatternSetup) #define PATTERNFONT_SMALL UL_("@1") #define PATTERNFONT_LARGE UL_("@2") // MIDI Setup -#define MIDISETUP_RECORDVELOCITY 0x01 // Record MIDI velocity -#define MIDISETUP_TRANSPOSEKEYBOARD 0x02 // Apply transpose value to MIDI Notes -#define MIDISETUP_MIDITOPLUG 0x04 // Pass MIDI messages to plugins -#define MIDISETUP_MIDIVOL_TO_NOTEVOL 0x08 // Combine MIDI volume to note velocity -#define MIDISETUP_RECORDNOTEOFF 0x10 // Record MIDI Note Off to pattern -#define MIDISETUP_RESPONDTOPLAYCONTROLMSGS 0x20 // Respond to Restart/Continue/Stop MIDI commands -#define MIDISETUP_MIDIMACROCONTROL 0x80 // Record MIDI controller changes a MIDI macro changes in pattern -#define MIDISETUP_PLAYPATTERNONMIDIIN 0x100 // Play pattern if MIDI Note is received and playback is paused -#define MIDISETUP_ENABLE_RECORD_DEFAULT 0x200 // Enable MIDI recording by default -#define MIDISETUP_MIDIMACROPITCHBEND 0x400 // Record MIDI pitch bend messages a MIDI macro changes in pattern +enum class MidiSetup : int32 +{ + RecordVelocity = 0x01, // Record MIDI velocity + TransposeKeyboard = 0x02, // Apply transpose value to MIDI Notes + SendMidiToPlugins = 0x04, // Pass MIDI messages to plugins + ApplyChannelVolumeToVelocity = 0x08, // Combine MIDI volume to note velocity + RecordNoteOff = 0x10, // Record MIDI Note Off to pattern + RespondToPlayControl = 0x20, // Respond to Restart/Continue/Stop MIDI commands + RecordCCsAsMacros = 0x80, // Record MIDI controller changes a MIDI macro changes in pattern + PlayPatternOnMidiNote = 0x100, // Play pattern if MIDI Note is received and playback is paused + EnableMidiInOnStartup = 0x200, // Enable MIDI recording by default + RecordPitchBend = 0x400, // Record MIDI pitch bend messages a MIDI macro changes in pattern + + Default = RecordVelocity | RecordNoteOff | TransposeKeyboard | SendMidiToPlugins +}; +DECLARE_FLAGSET(MidiSetup) #ifndef NO_EQ @@ -333,6 +350,12 @@ template<> inline DefaultChannelColors FromSettingValue(const SettingValue& val) template<> inline SettingValue ToSettingValue(const DPIAwarenessMode &val) { return SettingValue(int32(val)); } template<> inline DPIAwarenessMode FromSettingValue(const SettingValue &val) { return DPIAwarenessMode(val.as()); } +template<> inline SettingValue ToSettingValue(const FlagSet& val) { return SettingValue(int32(val.GetRaw())); } +template<> inline FlagSet FromSettingValue(const SettingValue& val) { return PatternSetup(val.as()); } + +template<> inline SettingValue ToSettingValue(const FlagSet &val) { return SettingValue(int32(val.GetRaw())); } +template<> inline FlagSet FromSettingValue(const SettingValue &val) { return MidiSetup(val.as()); } + template<> inline SettingValue ToSettingValue(const MODTYPE &val) { return SettingValue(SettingsModTypeToString(val), "MODTYPE"); } template<> inline MODTYPE FromSettingValue(const SettingValue &val) { ASSERT(val.GetTypeTag() == "MODTYPE"); return SettingsStringToModType(val.as()); } @@ -801,7 +824,7 @@ class TrackerSettings // FIXME: MIDI recording is currently done in its own callback/thread and // accesses settings framework from in there. Work-around the ASSERTs for // now by using cached settings. - CachedSetting m_dwMidiSetup; + CachedSetting> midiSetup; CachedSetting aftertouchBehaviour; CachedSetting midiVelocityAmp; CachedSetting > midiIgnoreCCs; @@ -820,7 +843,7 @@ class TrackerSettings CachedSetting patternNoEditPopup; CachedSetting patternStepCommands; CachedSetting patternVolColHex; - CachedSetting m_dwPatternSetup; + CachedSetting> patternSetup; CachedSetting m_nRowHighlightMeasures; // primary (measures) and secondary (beats) highlight CachedSetting m_nRowHighlightBeats; // primary (measures) and secondary (beats) highlight CachedSetting patternIgnoreSongTimeSignature; diff --git a/mptrack/View_ins.cpp b/mptrack/View_ins.cpp index 27ceac3c4cd..cef0f8b2934 100644 --- a/mptrack/View_ins.cpp +++ b/mptrack/View_ins.cpp @@ -1246,6 +1246,7 @@ void CViewInstrument::DrawNcButton(CDC *pDC, UINT nBtn) COLORREF crFc = GetSysColor(COLOR_3DFACE); COLORREF c1, c2; + const bool flat = (TrackerSettings::Instance().patternSetup & PatternSetup::FlatToolbarButtons); if(GetNcButtonRect(nBtn, rect)) { DWORD dwStyle = m_NcButtonState[nBtn]; @@ -1253,7 +1254,7 @@ void CViewInstrument::DrawNcButton(CDC *pDC, UINT nBtn) int xofs = 0, yofs = 0, nImage = 0; c1 = c2 = c3 = c4 = crFc; - if(!(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS)) + if(!flat) { c1 = c3 = crHi; c2 = crDk; @@ -1263,13 +1264,13 @@ void CViewInstrument::DrawNcButton(CDC *pDC, UINT nBtn) { c1 = crDk; c2 = crHi; - if(!(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS)) + if(!flat) { c4 = crHi; c3 = (dwStyle & NCBTNS_PUSHED) ? RGB(0, 0, 0) : crDk; } xofs = yofs = 1; - } else if((dwStyle & NCBTNS_MOUSEOVER) && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS)) + } else if((dwStyle & NCBTNS_MOUSEOVER) && flat) { c1 = crHi; c2 = crDk; @@ -1305,7 +1306,7 @@ void CViewInstrument::DrawNcButton(CDC *pDC, UINT nBtn) } else { c1 = c2 = crFc; - if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS) + if(flat) { c1 = crDk; c2 = crHi; diff --git a/mptrack/View_pat.cpp b/mptrack/View_pat.cpp index f72ab04a170..e308d516b89 100644 --- a/mptrack/View_pat.cpp +++ b/mptrack/View_pat.cpp @@ -281,13 +281,14 @@ ROWINDEX CViewPattern::SetCurrentRow(ROWINDEX row, WrapMode wrapMode, bool updat if(pSndFile == nullptr || !pSndFile->Patterns.IsValidIndex(m_nPattern) || !m_szCell.cy) return ROWINDEX_INVALID; + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; ROWINDEX numRows = pSndFile->Patterns[m_nPattern].GetNumRows(); if(wrapMode == WrapMode::WrapAround && numRows) { const auto &order = Order(); if(static_cast(row) < 0) { - if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) + if(patternSetup[PatternSetup::ContinuousScrolling]) { PATTERNINDEX curPattern = m_nPattern; ORDERINDEX curOrder = GetCurrentOrder(); @@ -316,13 +317,13 @@ ROWINDEX CViewPattern::SetCurrentRow(ROWINDEX row, WrapMode wrapMode, bool updat SetCurrentPattern(curPattern, row); } MPT_ASSERT(numRows == pSndFile->Patterns[m_nPattern].GetNumRows()); - } else if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_WRAP) + } else if(patternSetup[PatternSetup::CursorWrap]) { row = static_cast(mpt::wrapping_modulo(static_cast(row), numRows)); } } else if(row >= numRows) { - if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) + if(patternSetup[PatternSetup::ContinuousScrolling]) { PATTERNINDEX curPattern = m_nPattern; ORDERINDEX curOrder = GetCurrentOrder(); @@ -351,7 +352,7 @@ ROWINDEX CViewPattern::SetCurrentRow(ROWINDEX row, WrapMode wrapMode, bool updat SetCurrentPattern(curPattern, row); } MPT_ASSERT(numRows == pSndFile->Patterns[m_nPattern].GetNumRows()); - } else if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_WRAP) + } else if(patternSetup[PatternSetup::CursorWrap]) { row %= pSndFile->Patterns[m_nPattern].GetNumRows(); } @@ -650,7 +651,7 @@ bool CViewPattern::SetPlayCursor(PATTERNINDEX pat, ROWINDEX row, uint32 tick) m_nPlayRow = row; m_nPlayTick = tick; - if(m_nPlayTick != oldTick && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SMOOTHSCROLL)) + if(m_nPlayTick != oldTick && (TrackerSettings::Instance().patternSetup & PatternSetup::SmoothScrolling)) InvalidatePattern(true, true); else if(oldPat == m_nPattern) InvalidateRow(oldRow); @@ -1148,6 +1149,7 @@ void CViewPattern::OnLButtonDown(UINT nFlags, CPoint point) PatternCursor pointCursor(GetPositionFromPoint(point)); SetCapture(); + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; if(point.x >= m_szHeader.cx && point.y <= m_szHeader.cy - m_szPluginHeader.cy) { // Click on channel header @@ -1161,7 +1163,7 @@ void CViewPattern::OnLButtonDown(UINT nFlags, CPoint point) } else if(point.x >= m_szHeader.cx && point.y > m_szHeader.cy) { // Click on pattern data - if(IsLiveRecord() && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOFOLLOWONCLICK)) + if(IsLiveRecord() && patternSetup[PatternSetup::DisableFollowOnClick]) { SendCtrlMessage(CTRLMSG_PAT_FOLLOWSONG, 0); } @@ -1191,12 +1193,12 @@ void CViewPattern::OnLButtonDown(UINT nFlags, CPoint point) { SetCurSel(m_StartSel); } - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_DRAGNDROPEDIT) + if(patternSetup[PatternSetup::DragNDropEdit] && ((m_Selection.GetUpperLeft() != m_Selection.GetLowerRight()) || m_Status[psCtrlDragSelect]) && m_Selection.Contains(m_StartSel)) { m_Status.set(psDragnDropEdit); - } else if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CENTERROW) + } else if(patternSetup[PatternSetup::CenterActiveRow]) { SetCurSel(m_StartSel); } else @@ -1232,7 +1234,7 @@ void CViewPattern::OnLButtonDblClk(UINT uFlags, CPoint point) if(cursor == m_Cursor && point.y >= m_szHeader.cy) { // Double-click pattern cell: Select whole column or show cell properties. - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_DBLCLICKSELECT)) + if(TrackerSettings::Instance().patternSetup & PatternSetup::DblClickSelectsChannel) { OnSelectCurrentChannel(); m_Status.set(psChannelSelection | psDragging); @@ -1749,7 +1751,7 @@ void CViewPattern::OnMouseMove(UINT nFlags, CPoint point) m_Status.set(psDragnDropping); OnDrawDragSel(); } - } else if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CENTERROW) + } else if(TrackerSettings::Instance().patternSetup & PatternSetup::CenterActiveRow) { // Default: selection DragToSel(cursor, true, true); @@ -2264,9 +2266,9 @@ void CViewPattern::PatternStep(ROWINDEX row) pModDoc->SetNotifications(Notification::Position | Notification::VUMeters); if(row == ROWINDEX_INVALID) { + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; SetCurrentRow(GetCurrentRow() + 1, - ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) || // Wrap around to next pattern if continous scroll is enabled... - (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_WRAP)) // ...or otherwise if cursor wrap is enabled. + (patternSetup[PatternSetup::ContinuousScrolling | PatternSetup::CursorWrap]) // Wrap around to next pattern if continous scroll is enabled or otherwise if cursor wrap is enabled ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); } @@ -2367,7 +2369,8 @@ void CViewPattern::OnCursorPaste() SetModified(false); } // Preview Row - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !IsLiveRecord()) + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; + if(patternSetup[PatternSetup::PlayRowOnNoteEntry] && !IsLiveRecord()) { PatternStep(GetCurrentRow()); } @@ -2375,7 +2378,7 @@ void CViewPattern::OnCursorPaste() if(sndFile.IsPaused() || !m_Status[psFollowSong] || (CMainFrame::GetMainFrame() && CMainFrame::GetMainFrame()->GetFollowSong(GetDocument()) != m_hWnd)) { InvalidateCell(m_Cursor); - SetCurrentRow(GetCurrentRow() + m_nSpacing, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); + SetCurrentRow(GetCurrentRow() + m_nSpacing, patternSetup[PatternSetup::ContinuousScrolling] ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); SetSelToCursor(); } } @@ -2881,7 +2884,7 @@ bool CViewPattern::TransposeSelection(int transp) SetModified(false); InvalidateSelection(); - if(m_Selection.GetNumChannels() == 1 && m_Selection.GetNumRows() == 1 && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYTRANSPOSE)) + if(m_Selection.GetNumChannels() == 1 && m_Selection.GetNumRows() == 1 && (TrackerSettings::Instance().patternSetup & PatternSetup::PreviewNoteTransposition)) { // Preview a single transposed note PreviewNote(m_Selection.GetStartRow(), m_Selection.GetStartChannel()); @@ -3030,7 +3033,7 @@ bool CViewPattern::DataEntry(bool up, bool coarse) InvalidatePattern(); UpdateIndicator(); - if(column == PatternCursor::noteColumn && m_Selection.GetNumChannels() == 1 && m_Selection.GetNumRows() == 1 && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYTRANSPOSE)) + if(column == PatternCursor::noteColumn && m_Selection.GetNumChannels() == 1 && m_Selection.GetNumRows() == 1 && (TrackerSettings::Instance().patternSetup & PatternSetup::PreviewNoteTransposition)) { // Preview a single transposed note PreviewNote(m_Selection.GetStartRow(), m_Selection.GetStartChannel()); @@ -3627,6 +3630,7 @@ LRESULT CViewPattern::OnPlayerNotify(Notification *pnotify) if(!pSndFile->m_PlayState.m_flags[SONG_PAUSED | SONG_STEP]) { const auto &order = Order(); + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; if(ord >= order.GetLength() || order[ord] != pat) { //order doesn't correlate with pattern, so mark it as invalid @@ -3640,7 +3644,7 @@ LRESULT CViewPattern::OnPlayerNotify(Notification *pnotify) // Simple detection of backwards-going patterns to avoid jerky animation m_nNextPlayRow = ROWINDEX_INVALID; - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SMOOTHSCROLL) && pSndFile->Patterns.IsValidPat(pat) && pSndFile->Patterns[pat].IsValidRow(row)) + if(patternSetup[PatternSetup::SmoothScrolling] && pSndFile->Patterns.IsValidPat(pat) && pSndFile->Patterns[pat].IsValidRow(row)) { for(const ModCommand &m : pSndFile->Patterns[pat].GetRow(row)) { @@ -3664,7 +3668,7 @@ LRESULT CViewPattern::OnPlayerNotify(Notification *pnotify) { if(pat != m_nPattern) SetCurrentPattern(pat, row); - else if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SHOWPREVIOUS) + else if(patternSetup[PatternSetup::ShowPrevNextPattern]) InvalidatePattern(true, true); // Redraw previous / next pattern m_nOrder = ord; @@ -4011,6 +4015,7 @@ LRESULT CViewPattern::OnMidiMsg(WPARAM dwMidiDataParam, LPARAM) return 1; } + const FlagSet midiSetup = TrackerSettings::Instance().midiSetup; const auto &modSpecs = sndFile.GetModSpecifications(); bool recordParamAsZxx = false; @@ -4025,12 +4030,12 @@ LRESULT CViewPattern::OnMidiMsg(WPARAM dwMidiDataParam, LPARAM) // The following method takes care of: // . Silencing specific active notes (just setting nNote to 255 as was done before is not acceptible) // . Entering a note off in pattern if required - TempStopNote(nNote, ((TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_RECORDNOTEOFF) != 0)); + TempStopNote(nNote, midiSetup[MidiSetup::RecordNoteOff]); break; case MIDIEvents::evNoteOn: // Note On // Continue playing as soon as MIDI notes are being received - if((pMainFrm->GetSoundFilePlaying() != &sndFile || sndFile.IsPaused()) && (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_PLAYPATTERNONMIDIIN)) + if((pMainFrm->GetSoundFilePlaying() != &sndFile || sndFile.IsPaused()) && midiSetup[MidiSetup::PlayPatternOnMidiNote]) pModDoc->OnPatternPlayNoLoop(); vol = CMainFrame::ApplyVolumeRelatedSettings(midiData, midiVolume); @@ -4050,14 +4055,14 @@ LRESULT CViewPattern::OnMidiMsg(WPARAM dwMidiDataParam, LPARAM) break; case MIDIEvents::evPitchBend: // Pitch wheel - recordParamAsZxx = (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIMACROPITCHBEND) != 0 || modSpecs.HasCommand(CMD_FINETUNE); + recordParamAsZxx = midiSetup[MidiSetup::RecordPitchBend] || modSpecs.HasCommand(CMD_FINETUNE); break; case MIDIEvents::evControllerChange: //Controller change // Checking whether to record MIDI controller change as MIDI macro change. // Don't write this if command was already written by MIDI mapping. if((paramValue == uint16_max || sndFile.GetType() != MOD_TYPE_MPT) - && (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDIMACROCONTROL) + && midiSetup[MidiSetup::RecordCCsAsMacros] && !TrackerSettings::Instance().midiIgnoreCCs.Get()[midiByte1 & 0x7F]) { recordParamAsZxx = true; @@ -4086,7 +4091,7 @@ LRESULT CViewPattern::OnMidiMsg(WPARAM dwMidiDataParam, LPARAM) break; case MIDIEvents::evSystem: - if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_RESPONDTOPLAYCONTROLMSGS) + if(midiSetup[MidiSetup::RespondToPlayControl]) { // Respond to MIDI song messages switch(channel) @@ -4156,7 +4161,7 @@ LRESULT CViewPattern::OnMidiMsg(WPARAM dwMidiDataParam, LPARAM) } // Pass MIDI to plugin - if(TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_MIDITOPLUG + if(midiSetup[MidiSetup::SendMidiToPlugins] && pMainFrm->GetModPlaying() == pModDoc && event != MIDIEvents::evNoteOn && event != MIDIEvents::evNoteOff) @@ -4370,16 +4375,17 @@ void CViewPattern::CursorJump(int distance, bool snap) sndFile.m_PlayState.m_nNextOrder++; } CMainFrame::GetMainFrame()->ResetNotificationBuffer(); - } else if(row != ROWINDEX_INVALID && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYNAVIGATEROW)) + } else if(row != ROWINDEX_INVALID && (TrackerSettings::Instance().patternSetup & PatternSetup::PlayRowOnNavigate)) { PatternStep(row); } } -static void ToggleFlag(CachedSetting &flagSet, uint32 flag, const TCHAR *description) +template +static void ToggleFlag(CachedSetting> &flagSet, T flag, const TCHAR *description) { - flagSet ^= flag; + flagSet = flagSet.Get().flip(flag); CString text = description; if(flagSet & flag) text += _T(" is now On"); @@ -4466,7 +4472,7 @@ LRESULT CViewPattern::OnCustomKeyMsg(WPARAM wParam, LPARAM lParam) case kcDataEntryDownStop: case kcDataEntryUpCoarseStop: case kcDataEntryDownCoarseStop: - if(m_Selection.GetNumChannels() == 1 && m_Selection.GetNumRows() == 1 && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYTRANSPOSE)) + if(m_Selection.GetNumChannels() == 1 && m_Selection.GetNumRows() == 1 && (TrackerSettings::Instance().patternSetup & PatternSetup::PreviewNoteTransposition)) { StopPreview(m_Selection.GetStartRow(), m_Selection.GetStartChannel()); } @@ -4757,14 +4763,14 @@ LRESULT CViewPattern::OnCustomKeyMsg(WPARAM wParam, LPARAM lParam) case kcDuplicatePattern: SendCtrlMessage(CTRLMSG_PAT_DUPPATTERN); return wParam; case kcSwitchToOrderList: OnSwitchToOrderList(); return wParam; - case kcToggleNoteOffRecordPC: ToggleFlag(TrackerSettings::Instance().m_dwPatternSetup, PATTERN_KBDNOTEOFF, _T("Record Note Off")); return wParam; - case kcToggleNoteOffRecordMIDI: ToggleFlag(TrackerSettings::Instance().m_dwMidiSetup, MIDISETUP_RECORDNOTEOFF, _T("Record MIDI Note Off")); return wParam; - case kcToggleOctaveTransposeMIDI: ToggleFlag(TrackerSettings::Instance().m_dwMidiSetup, MIDISETUP_TRANSPOSEKEYBOARD, _T("Apply Octave Transpose")); return wParam; - case kcToggleContinueSongOnMIDINote: ToggleFlag(TrackerSettings::Instance().m_dwMidiSetup, MIDISETUP_PLAYPATTERNONMIDIIN, _T("Continue Song when MIDI Note is received")); return wParam; - case kcToggleContinueSongOnMIDIPlayEvents: ToggleFlag(TrackerSettings::Instance().m_dwMidiSetup, MIDISETUP_RESPONDTOPLAYCONTROLMSGS, _T("Respond to Play / Continue Song MIDI messages")); return wParam; - case kcToggleRecordMIDIVelocity: ToggleFlag(TrackerSettings::Instance().m_dwMidiSetup, MIDISETUP_RECORDVELOCITY, _T("Record MIDI Velocity")); return wParam; - case kcToggleRecordMIDIPitchBend: ToggleFlag(TrackerSettings::Instance().m_dwMidiSetup, MIDISETUP_MIDIMACROPITCHBEND, _T("Record MIDI Pitch Bend")); return wParam; - case kcToggleRecordMIDICCs: ToggleFlag(TrackerSettings::Instance().m_dwMidiSetup, MIDISETUP_MIDIMACROCONTROL, _T("Record MIDI CCs")); return wParam; + case kcToggleNoteOffRecordPC: ToggleFlag(TrackerSettings::Instance().patternSetup, PatternSetup::RecordNoteOff, _T("Record Note Off")); return wParam; + case kcToggleNoteOffRecordMIDI: ToggleFlag(TrackerSettings::Instance().midiSetup, MidiSetup::RecordNoteOff, _T("Record MIDI Note Off")); return wParam; + case kcToggleOctaveTransposeMIDI: ToggleFlag(TrackerSettings::Instance().midiSetup, MidiSetup::TransposeKeyboard, _T("Apply Octave Transpose")); return wParam; + case kcToggleContinueSongOnMIDINote: ToggleFlag(TrackerSettings::Instance().midiSetup, MidiSetup::PlayPatternOnMidiNote, _T("Continue Song when MIDI Note is received")); return wParam; + case kcToggleContinueSongOnMIDIPlayEvents: ToggleFlag(TrackerSettings::Instance().midiSetup, MidiSetup::RespondToPlayControl, _T("Respond to Play / Continue Song MIDI messages")); return wParam; + case kcToggleRecordMIDIVelocity: ToggleFlag(TrackerSettings::Instance().midiSetup, MidiSetup::RecordVelocity, _T("Record MIDI Velocity")); return wParam; + case kcToggleRecordMIDIPitchBend: ToggleFlag(TrackerSettings::Instance().midiSetup, MidiSetup::RecordPitchBend, _T("Record MIDI Pitch Bend")); return wParam; + case kcToggleRecordMIDICCs: ToggleFlag(TrackerSettings::Instance().midiSetup, MidiSetup::RecordCCsAsMacros, _T("Record MIDI CCs")); return wParam; case kcToggleVisibilityInstrColumn: UpdateVisibileColumns(m_visibleColumns.flip(PatternCursor::instrColumn)); return wParam; case kcToggleVisibilityVolumeColumn: UpdateVisibileColumns(m_visibleColumns.flip(PatternCursor::volumeColumn)); return wParam; @@ -4854,8 +4860,8 @@ LRESULT CViewPattern::OnCustomKeyMsg(WPARAM wParam, LPARAM lParam) } return wParam; case kcTogglePatternPlayRow: - TrackerSettings::Instance().m_dwPatternSetup ^= PATTERN_PLAYNAVIGATEROW; - CMainFrame::GetMainFrame()->SetHelpText((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYNAVIGATEROW) + TrackerSettings::Instance().patternSetup ^= PatternSetup::PlayRowOnNavigate; + CMainFrame::GetMainFrame()->SetHelpText((TrackerSettings::Instance().patternSetup & PatternSetup::PlayRowOnNavigate) ? _T("Play whole row when navigating is now enabled.") : _T("Play whole row when navigating is now disabled.")); return wParam; } @@ -4944,7 +4950,7 @@ void CViewPattern::MoveCursor(bool moveRight) if(!moveRight) { // Move cursor one column to the left - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_WRAP) && m_Cursor.IsInFirstColumn()) + if((TrackerSettings::Instance().patternSetup & PatternSetup::CursorWrap) && m_Cursor.IsInFirstColumn()) { // Wrap around to last channel SetCurrentColumn(GetDocument()->GetNumChannels() - 1, LastVisibleColumn()); @@ -4962,7 +4968,7 @@ void CViewPattern::MoveCursor(bool moveRight) const PatternCursor rightmost(0, GetDocument()->GetNumChannels() - 1, LastVisibleColumn()); if(m_Cursor.CompareColumn(rightmost) >= 0) { - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_WRAP)) + if((TrackerSettings::Instance().patternSetup & PatternSetup::CursorWrap)) { // Wrap around to first channel. SetCurrentColumn(0); @@ -5091,9 +5097,10 @@ void CViewPattern::TempEnterVol(CommandID cmd) // Cursor step for command letter if(!m.IsPcNote() && !isDigit && m_nSpacing > 0 && !IsLiveRecord() && TrackerSettings::Instance().patternStepCommands) { - if(m_Cursor.GetRow() + m_nSpacing < pSndFile->Patterns[m_nPattern].GetNumRows() || (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL)) + const bool continuousScrolling = (TrackerSettings::Instance().patternSetup & PatternSetup::ContinuousScrolling); + if(m_Cursor.GetRow() + m_nSpacing < pSndFile->Patterns[m_nPattern].GetNumRows() || continuousScrolling) { - SetCurrentRow(m_Cursor.GetRow() + m_nSpacing, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); + SetCurrentRow(m_Cursor.GetRow() + m_nSpacing, continuousScrolling ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); } } } @@ -5164,9 +5171,10 @@ void CViewPattern::TempEnterFX(ModCommand::COMMAND c, int v) // Cursor step for command letter if(!m.IsPcNote() && m_nSpacing > 0 && !IsLiveRecord() && TrackerSettings::Instance().patternStepCommands) { - if(m_Cursor.GetRow() + m_nSpacing < pSndFile->Patterns[m_nPattern].GetNumRows() || (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL)) + const bool continuousScrolling = (TrackerSettings::Instance().patternSetup & PatternSetup::ContinuousScrolling); + if(m_Cursor.GetRow() + m_nSpacing < pSndFile->Patterns[m_nPattern].GetNumRows() || continuousScrolling) { - SetCurrentRow(m_Cursor.GetRow() + m_nSpacing, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); + SetCurrentRow(m_Cursor.GetRow() + m_nSpacing, continuousScrolling ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); } } } @@ -5286,7 +5294,7 @@ void CViewPattern::TempStopNote(ModCommand::NOTE note, const bool fromMidi, bool } else { m_baPlayingNote.reset(note); - pModDoc->NoteOff(note, ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_NOTEFADE) || sndFile.GetNumInstruments() == 0), static_cast(ins), m_noteChannel[note - NOTE_MIN]); + pModDoc->NoteOff(note, ((TrackerSettings::Instance().patternSetup & PatternSetup::NoteFadeOnKeyUp) || sndFile.GetNumInstruments() == 0), static_cast(ins), m_noteChannel[note - NOTE_MIN]); m_noteChannel[note - NOTE_MIN] = CHANNELINDEX_INVALID; } } @@ -5301,19 +5309,19 @@ void CViewPattern::TempStopNote(ModCommand::NOTE note, const bool fromMidi, bool activeNoteMap[note] = NOTE_CHANNEL_MAP_INVALID; //unlock channel - if(!((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_KBDNOTEOFF) || fromMidi)) + if(!((TrackerSettings::Instance().patternSetup & PatternSetup::RecordNoteOff) || fromMidi)) { // We don't want to write the note-off into the pattern if this feature is disabled and we're not recording from MIDI. return; } // -- write sdx if playing live - const bool usePlaybackPosition = (!chordMode) && (liveRecord && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_AUTODELAY)); + const bool usePlaybackPosition = (!chordMode) && (liveRecord && (TrackerSettings::Instance().patternSetup & PatternSetup::AutoDelayCommands)); //Work out where to put the note off PatternEditPos editPos = GetEditPos(sndFile, usePlaybackPosition); - const bool doQuantize = (liveRecord || (fromMidi && (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_PLAYPATTERNONMIDIIN))) && TrackerSettings::Instance().recordQuantizeRows != 0; + const bool doQuantize = (liveRecord || (fromMidi && (TrackerSettings::Instance().midiSetup & MidiSetup::PlayPatternOnMidiNote))) && TrackerSettings::Instance().recordQuantizeRows != 0; if(doQuantize) { QuantizeRow(editPos.pattern, editPos.row); @@ -5539,8 +5547,9 @@ void CViewPattern::TempEnterNote(ModCommand::NOTE note, int vol, bool fromMidi) return; } + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; const bool liveRecord = IsLiveRecord(); - const bool usePlaybackPosition = (liveRecord && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_AUTODELAY) && !sndFile.m_PlayState.m_flags[SONG_STEP]); + const bool usePlaybackPosition = (liveRecord && patternSetup[PatternSetup::AutoDelayCommands] && !sndFile.m_PlayState.m_flags[SONG_STEP]); const bool isSpecial = note >= NOTE_MIN_SPECIAL; const bool isSplit = IsNoteSplit(note); @@ -5596,7 +5605,7 @@ void CViewPattern::TempEnterNote(ModCommand::NOTE note, int vol, bool fromMidi) } // Quantize - const bool doQuantize = (liveRecord || (fromMidi && (TrackerSettings::Instance().m_dwMidiSetup & MIDISETUP_PLAYPATTERNONMIDIIN))) && TrackerSettings::Instance().recordQuantizeRows != 0; + const bool doQuantize = (liveRecord || (fromMidi && (TrackerSettings::Instance().midiSetup & MidiSetup::PlayPatternOnMidiNote))) && TrackerSettings::Instance().recordQuantizeRows != 0; if(doQuantize) { QuantizeRow(editPos.pattern, editPos.row); @@ -5712,9 +5721,9 @@ void CViewPattern::TempEnterNote(ModCommand::NOTE note, int vol, bool fromMidi) } // -- play note - if(((TrackerSettings::Instance().m_dwPatternSetup & (PATTERN_PLAYNEWNOTE | PATTERN_PLAYEDITROW)) || !recordEnabled) && !newcmd.IsPcNote()) + if((patternSetup[PatternSetup::PlayNewNotesWhileRecording | PatternSetup::PlayRowOnNoteEntry] || !recordEnabled) && !newcmd.IsPcNote()) { - const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); + const bool playWholeRow = patternSetup[PatternSetup::PlayRowOnNoteEntry] && !liveRecord; if(playWholeRow) { // play the whole row in "step mode" @@ -5785,9 +5794,9 @@ void CViewPattern::TempEnterNote(ModCommand::NOTE note, int vol, bool fromMidi) { if(m_nSpacing > 0) { - if(editPos.row + m_nSpacing < sndFile.Patterns[editPos.pattern].GetNumRows() || (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL)) + if(editPos.row + m_nSpacing < sndFile.Patterns[editPos.pattern].GetNumRows() || patternSetup[PatternSetup::ContinuousScrolling]) { - SetCurrentRow(editPos.row + m_nSpacing, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); + SetCurrentRow(editPos.row + m_nSpacing, patternSetup[PatternSetup::ContinuousScrolling] ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); } } @@ -6013,15 +6022,16 @@ void CViewPattern::TempEnterChord(ModCommand::NOTE note) } } + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; // -- play note - if((TrackerSettings::Instance().m_dwPatternSetup & (PATTERN_PLAYNEWNOTE | PATTERN_PLAYEDITROW)) || !recordEnabled) + if(patternSetup[PatternSetup::PlayNewNotesWhileRecording |PatternSetup::PlayRowOnNoteEntry] || !recordEnabled) { if(m_prevChordNote != NOTE_NONE) { TempStopChord(m_prevChordNote); } - const bool playWholeRow = ((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !liveRecord); + const bool playWholeRow = patternSetup[PatternSetup::PlayRowOnNoteEntry] && !liveRecord; if(playWholeRow) { // play the whole row in "step mode" @@ -6078,7 +6088,7 @@ void CViewPattern::TempEnterChord(ModCommand::NOTE note) { if(m_nSpacing > 0) { - SetCurrentRow(GetCurrentRow() + m_nSpacing, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); + SetCurrentRow(GetCurrentRow() + m_nSpacing, patternSetup[PatternSetup::ContinuousScrolling] ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); } SetSelToCursor(); } @@ -6428,13 +6438,14 @@ void CViewPattern::OnClearField(const std::bitset mas (CMainFrame::GetMainFrame() != nullptr && CMainFrame::GetMainFrame()->GetFollowSong(GetDocument()) != m_hWnd))) { // Preview Row - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYEDITROW) && !IsLiveRecord()) + const FlagSet patternSetup = TrackerSettings::Instance().patternSetup; + if(patternSetup[PatternSetup::PlayRowOnNoteEntry] && !IsLiveRecord()) { PatternStep(GetCurrentRow()); } if(m_nSpacing > 0) - SetCurrentRow(GetCurrentRow() + m_nSpacing, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_CONTSCROLL) ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); + SetCurrentRow(GetCurrentRow() + m_nSpacing, patternSetup[PatternSetup::ContinuousScrolling] ? WrapMode::WrapAround : WrapMode::LimitAtPatternEnd); SetSelToCursor(); } @@ -6715,7 +6726,7 @@ bool CViewPattern::BuildInterpolationCtxMenu(HMENU hMenu, CInputHandler *ih) con addSeparator |= BuildInterpolationCtxMenu(subMenu, PatternCursor::instrColumn, ih->GetKeyTextFromCommand(kcPatternInterpolateInstr, isPCNote ? _T("&Plugin Column") : _T("&Instrument Column")), ID_PATTERN_INTERPOLATE_INSTR); addSeparator |= BuildInterpolationCtxMenu(subMenu, PatternCursor::volumeColumn, ih->GetKeyTextFromCommand(kcPatternInterpolateVol, isPCNote ? _T("&Parameter Column") : _T("&Volume Column")), ID_PATTERN_INTERPOLATE_VOLUME); addSeparator |= BuildInterpolationCtxMenu(subMenu, PatternCursor::effectColumn, ih->GetKeyTextFromCommand(kcPatternInterpolateEffect, isPCNote ? _T("&Value Column") : _T("&Effect Column")), ID_PATTERN_INTERPOLATE_EFFECT); - if(addSeparator || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + if(addSeparator || !(TrackerSettings::Instance().patternSetup & PatternSetup::HideUnavailableMenuEntries)) { AppendMenu(hMenu, MF_POPUP | (addSeparator ? 0 : MF_GRAYED), reinterpret_cast(subMenu), _T("I&nterpolate...")); return true; @@ -6733,7 +6744,7 @@ bool CViewPattern::BuildInterpolationCtxMenu(HMENU hMenu, PatternCursor::Columns addSeparator = IsInterpolationPossible(PatternCursor::paramColumn); } - if(addSeparator || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + if(addSeparator || !(TrackerSettings::Instance().patternSetup & PatternSetup::HideUnavailableMenuEntries)) { AppendMenu(hMenu, MF_STRING | (addSeparator ? 0 : MF_GRAYED), command, label); } @@ -6755,12 +6766,12 @@ bool CViewPattern::BuildEditCtxMenu(HMENU hMenu, CInputHandler *ih, CModDoc *pMo AppendMenu(pasteSpecialMenu, MF_STRING, ID_EDIT_PUSHFORWARDPASTE, ih->GetKeyTextFromCommand(kcEditPushForwardPaste, _T("&Push Forward Paste (Insert)"))); DWORD greyed = pModDoc->GetPatternUndo().CanUndo() ? MF_ENABLED : MF_GRAYED; - if(!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + if(!greyed || !(TrackerSettings::Instance().patternSetup & PatternSetup::HideUnavailableMenuEntries)) { AppendMenu(hMenu, MF_STRING | greyed, ID_EDIT_UNDO, ih->GetKeyTextFromCommand(kcEditUndo, _T("&Undo"))); } greyed = pModDoc->GetPatternUndo().CanRedo() ? MF_ENABLED : MF_GRAYED; - if(!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + if(!greyed || !(TrackerSettings::Instance().patternSetup & PatternSetup::HideUnavailableMenuEntries)) { AppendMenu(hMenu, MF_STRING | greyed, ID_EDIT_REDO, ih->GetKeyTextFromCommand(kcEditRedo, _T("&Redo"))); } @@ -6774,7 +6785,7 @@ bool CViewPattern::BuildVisFXCtxMenu(HMENU hMenu, CInputHandler *ih) const { DWORD greyed = (IsColumnSelected(PatternCursor::effectColumn) || IsColumnSelected(PatternCursor::paramColumn)) ? FALSE : MF_GRAYED; - if(!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + if(!greyed || !(TrackerSettings::Instance().patternSetup & PatternSetup::HideUnavailableMenuEntries)) { AppendMenu(hMenu, MF_STRING | greyed, ID_PATTERN_VISUALIZE_EFFECT, ih->GetKeyTextFromCommand(kcPatternVisualizeEffect, _T("&Visualize Effect"))); return true; @@ -6789,7 +6800,7 @@ bool CViewPattern::BuildTransposeCtxMenu(HMENU hMenu, CInputHandler *ih) const std::vector validChans; DWORD greyed = IsColumnSelected(PatternCursor::noteColumn) ? FALSE : MF_GRAYED; - if(!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + if(!greyed || !(TrackerSettings::Instance().patternSetup & PatternSetup::HideUnavailableMenuEntries)) { AppendMenu(transMenu, MF_STRING | greyed, ID_TRANSPOSE_UP, ih->GetKeyTextFromCommand(kcTransposeUp, _T("Transpose +&1"))); AppendMenu(transMenu, MF_STRING | greyed, ID_TRANSPOSE_DOWN, ih->GetKeyTextFromCommand(kcTransposeDown, _T("Transpose -&1"))); @@ -6807,7 +6818,7 @@ bool CViewPattern::BuildAmplifyCtxMenu(HMENU hMenu, CInputHandler *ih) const std::vector validChans; DWORD greyed = IsColumnSelected(PatternCursor::volumeColumn) ? 0 : MF_GRAYED; - if(!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + if(!greyed || !(TrackerSettings::Instance().patternSetup & PatternSetup::HideUnavailableMenuEntries)) { AppendMenu(hMenu, MF_STRING | greyed, ID_PATTERN_AMPLIFY, ih->GetKeyTextFromCommand(kcPatternAmplify, _T("&Amplify"))); return true; @@ -6858,7 +6869,7 @@ bool CViewPattern::BuildSetInstCtxMenu(HMENU hMenu, CInputHandler *ih) const std::vector validChans; DWORD greyed = IsColumnSelected(PatternCursor::instrColumn) ? 0 : MF_GRAYED; - if(!greyed || !(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_OLDCTXMENUSTYLE)) + if(!greyed || !(TrackerSettings::Instance().patternSetup & PatternSetup::HideUnavailableMenuEntries)) { if((sndFile->Patterns.IsValidPat(m_nPattern))) { @@ -7468,7 +7479,7 @@ void CViewPattern::JumpToPrevOrNextEntry(bool nextEntry, bool select) { SetCurrentOrder(ord); SetCurrentPattern(pat, row); - if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_PLAYNAVIGATEROW) + if(TrackerSettings::Instance().patternSetup & PatternSetup::PlayRowOnNavigate) { PatternStep(row); } diff --git a/mptrack/View_smp.cpp b/mptrack/View_smp.cpp index 073e7e8f9c0..381ef6a2b07 100644 --- a/mptrack/View_smp.cpp +++ b/mptrack/View_smp.cpp @@ -1493,6 +1493,7 @@ void CViewSample::DrawNcButton(CDC *pDC, UINT nBtn) COLORREF crFc = GetSysColor(COLOR_3DFACE); COLORREF c1, c2; + const bool flat = (TrackerSettings::Instance().patternSetup & PatternSetup::FlatToolbarButtons); if(GetNcButtonRect(nBtn, rect)) { DWORD dwStyle = m_NcButtonState[nBtn]; @@ -1500,24 +1501,24 @@ void CViewSample::DrawNcButton(CDC *pDC, UINT nBtn) int xofs = 0, yofs = 0, nImage = 0; c1 = c2 = c3 = c4 = crFc; - if (!(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS)) + if(!flat) { c1 = c3 = crHi; c2 = crDk; c4 = RGB(0,0,0); } - if (dwStyle & (NCBTNS_PUSHED|NCBTNS_CHECKED)) + if(dwStyle & (NCBTNS_PUSHED | NCBTNS_CHECKED)) { c1 = crDk; c2 = crHi; - if (!(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS)) + if(!flat) { c4 = crHi; c3 = (dwStyle & NCBTNS_PUSHED) ? RGB(0,0,0) : crDk; } xofs = yofs = 1; } else - if ((dwStyle & NCBTNS_MOUSEOVER) && (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS)) + if((dwStyle & NCBTNS_MOUSEOVER) && flat) { c1 = crHi; c2 = crDk; @@ -1542,7 +1543,7 @@ void CViewSample::DrawNcButton(CDC *pDC, UINT nBtn) } else { c1 = c2 = crFc; - if (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_FLATBUTTONS) + if(flat) { c1 = crDk; c2 = crHi; diff --git a/mptrack/View_tre.cpp b/mptrack/View_tre.cpp index df558d7150c..c8ca722a98c 100644 --- a/mptrack/View_tre.cpp +++ b/mptrack/View_tre.cpp @@ -213,7 +213,7 @@ void CModTree::Init() dwRemove |= (TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS); dwAdd &= ~(TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS); } - if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SINGLEEXPAND) + if(TrackerSettings::Instance().patternSetup & PatternSetup::SingleClickToExpand) { dwRemove &= ~TVS_SINGLEEXPAND; dwAdd |= TVS_SINGLEEXPAND; @@ -434,7 +434,7 @@ void CModTree::OnOptionsChanged() { DWORD dwRemove = TVS_SINGLEEXPAND, dwAdd = 0; m_dwStatus &= ~TREESTATUS_SINGLEEXPAND; - if(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SINGLEEXPAND) + if(TrackerSettings::Instance().patternSetup & PatternSetup::SingleClickToExpand) { dwRemove = 0; dwAdd = TVS_SINGLEEXPAND; @@ -1006,14 +1006,15 @@ void CModTree::UpdateView(ModTreeDocInfo &info, UpdateHint hint) if(sndFile.Order(seq)[iOrd] < sndFile.Patterns.Size()) { patName = mpt::ToCString(sndFile.GetCharsetInternal(), sndFile.Patterns[sndFile.Order(seq)[iOrd]].GetName()); + const bool hexOrders = (TrackerSettings::Instance().patternSetup & PatternSetup::RowAndOrderNumbersHex); if(!patName.IsEmpty()) { - wsprintf(s, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_HEXDISPLAY) ? _T("[%02Xh] %u: ") : _T("[%02u] %u: "), + wsprintf(s, hexOrders ? _T("[%02Xh] %u: ") : _T("[%02u] %u: "), iOrd, sndFile.Order(seq)[iOrd]); _tcscat(s, patName.GetString()); } else { - wsprintf(s, (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_HEXDISPLAY) ? _T("[%02Xh] Pattern %u") : _T("[%02u] Pattern %u"), + wsprintf(s, hexOrders ? _T("[%02Xh] Pattern %u") : _T("[%02u] Pattern %u"), iOrd, sndFile.Order(seq)[iOrd]); } } else @@ -2810,7 +2811,7 @@ void CModTree::UpdatePlayPos(CModDoc &modDoc, Notification *pNotify) // Update sample / instrument playing status icons (will only detect instruments with samples, though) - if((TrackerSettings::Instance().m_dwPatternSetup & PATTERN_LIVEUPDATETREE) == 0) + if(!(TrackerSettings::Instance().patternSetup & PatternSetup::LiveUpdateTreeView)) return; // TODO: Is there a way to find out if the treeview is actually visible? /*static int nUpdateCount = 0; diff --git a/soundlib/Sndfile.cpp b/soundlib/Sndfile.cpp index 1abe46840bd..0b5b3f8d0e3 100644 --- a/soundlib/Sndfile.cpp +++ b/soundlib/Sndfile.cpp @@ -1937,7 +1937,7 @@ double CSoundFile::GetRowDuration(TEMPO tempo, uint32 speed) const ChannelFlags CSoundFile::GetChannelMuteFlag() { #ifdef MODPLUG_TRACKER - return (TrackerSettings::Instance().m_dwPatternSetup & PATTERN_SYNCMUTE) ? CHN_SYNCMUTE : CHN_MUTE; + return (TrackerSettings::Instance().patternSetup & PatternSetup::SyncMute) ? CHN_SYNCMUTE : CHN_MUTE; #else return CHN_SYNCMUTE; #endif diff --git a/soundlib/Sndmix.cpp b/soundlib/Sndmix.cpp index 97e1ceaf5b0..3d65584ab18 100644 --- a/soundlib/Sndmix.cpp +++ b/soundlib/Sndmix.cpp @@ -496,7 +496,7 @@ bool CSoundFile::ProcessRow() // If channel resetting is disabled in MPT, we will emulate a pattern break (and we always do it if we're not in MPT) #ifdef MODPLUG_TRACKER - if(!(TrackerSettings::Instance().m_dwPatternSetup & PATTERN_RESETCHANNELS)) + if(!(TrackerSettings::Instance().patternSetup & PatternSetup::ResetChannelsOnLoop)) #endif // MODPLUG_TRACKER { m_PlayState.m_flags.set(SONG_BREAKTOROW);