From: <sv...@op...> - 2024-11-10 20:48:49
|
Author: sagamusix Date: Sun Nov 10 21:48:42 2024 New Revision: 22149 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22149 Log: [Mod] Don't enable scroll wheel / cursor keys on the octave switcher. Keys behave weirdly, and it should probably not be so easy to accidentally switch the octave with the mouse wheel. [Fix] Also send update to envelope editors when the mainbar speed input field has keyboard focus. [Fix] Various other small issues with live-editing input fields in main toolbar. Modified: trunk/OpenMPT/mptrack/MainFrm.cpp trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/Mainbar.h trunk/OpenMPT/mptrack/Mainfrm.h Modified: trunk/OpenMPT/mptrack/MainFrm.cpp ============================================================================== --- trunk/OpenMPT/mptrack/MainFrm.cpp Sun Nov 10 20:50:22 2024 (r22148) +++ trunk/OpenMPT/mptrack/MainFrm.cpp Sun Nov 10 21:48:42 2024 (r22149) @@ -2391,6 +2391,7 @@ if(pnotify->type[Notification::EOS]) { PostMessage(WM_COMMAND, ID_PLAYER_STOP); + m_currentSpeed = 0; } //Log("OnUpdatePosition: row=%d time=%lu\n", pnotify->nRow, pnotify->TimestampSamples); if(CModDoc *modDoc = GetModPlaying(); modDoc != nullptr) @@ -2407,6 +2408,12 @@ } m_pSndFile->m_pluginDryWetRatioChanged.reset(); } + // Update envelope views if speed has changed + if(m_pSndFile->m_PlayState.m_nMusicSpeed != m_currentSpeed) + { + m_currentSpeed = m_pSndFile->m_PlayState.m_nMusicSpeed; + modDoc->UpdateAllViews(InstrumentHint().Envelope()); + } } m_nMixChn = pnotify->mixedChannels; Modified: trunk/OpenMPT/mptrack/Mainbar.cpp ============================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp Sun Nov 10 20:50:22 2024 (r22148) +++ trunk/OpenMPT/mptrack/Mainbar.cpp Sun Nov 10 21:48:42 2024 (r22149) @@ -255,7 +255,7 @@ // Octave m_EditOctave.Create(WS_CHILD | WS_BORDER | WS_TABSTOP | ES_READONLY | ES_AUTOHSCROLL | ES_CENTER, rect, this, IDC_EDIT_BASEOCTAVE); - m_SpinOctave.Create(WS_CHILD | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS, rect, this, IDC_SPIN_BASEOCTAVE); + m_SpinOctave.Create(WS_CHILD | UDS_ALIGNRIGHT | UDS_AUTOBUDDY, rect, this, IDC_SPIN_BASEOCTAVE); // Tempo m_StaticTempo.Create(_T("Tempo:"), WS_CHILD | SS_CENTER | SS_CENTERIMAGE, rect, this, IDC_TEXT_CURRENTTEMPO); m_EditTempo.Create(WS_CHILD | WS_BORDER | WS_TABSTOP | ES_READONLY | ES_AUTOHSCROLL | ES_NUMBER, rect, this, IDC_EDIT_CURRENTTEMPO); @@ -503,9 +503,10 @@ } -BOOL CMainToolBar::SetCurrentSong(CSoundFile *pSndFile) +void CMainToolBar::SetCurrentSong(CSoundFile *pSndFile) { // Update Info + m_updating = true; if(pSndFile) { // Update play/pause button @@ -516,12 +517,6 @@ const CWnd *focus = GetFocus(); if(nSpeed != m_currentSpeed && focus != &m_EditSpeed) { - if(CModDoc *modDoc = pSndFile->GetpModDoc(); modDoc != nullptr) - { - // Update envelope views if speed has changed - modDoc->UpdateAllViews(InstrumentHint().Envelope()); - } - if(m_currentSpeed < 0) { m_EditSpeed.SetReadOnly(FALSE); @@ -601,7 +596,7 @@ m_SpinGlobalVolume.EnableWindow(FALSE); } } - return TRUE; + m_updating = false; } @@ -680,7 +675,7 @@ void CMainToolBar::OnSpeedChanged() { - if(CMainFrame *mainFrm = CMainFrame::GetMainFrame()) + if(CMainFrame *mainFrm = CMainFrame::GetMainFrame(); mainFrm && !m_updating) { BOOL ok = FALSE; uint32 newSpeed = GetDlgItemInt(IDC_EDIT_CURRENTSPEED, &ok, FALSE); @@ -690,13 +685,14 @@ const auto &specs = sndFile->GetModSpecifications(); sndFile->m_PlayState.m_nMusicSpeed = Clamp(newSpeed, specs.speedMin, specs.speedMax); } + m_currentSpeed = 0; // Force display update once focus moves away from this input field } } void CMainToolBar::OnTempoChanged() { - if(CMainFrame *mainFrm = CMainFrame::GetMainFrame()) + if(CMainFrame *mainFrm = CMainFrame::GetMainFrame(); mainFrm && !m_updating) { TEMPO newTempo = m_EditTempo.GetTempoValue(); CSoundFile *sndFile = mainFrm->GetSoundFilePlaying(); @@ -705,21 +701,23 @@ const auto &specs = sndFile->GetModSpecifications(); sndFile->m_PlayState.m_nMusicTempo = Clamp(newTempo, specs.GetTempoMin(), specs.GetTempoMax()); } + m_currentTempo.Set(0, 1); // Force display update once focus moves away from this input field } } void CMainToolBar::OnRPBChanged() { - if(CMainFrame *mainFrm = CMainFrame::GetMainFrame()) + if(CMainFrame *mainFrm = CMainFrame::GetMainFrame(); mainFrm && !m_updating) { BOOL ok = FALSE; uint32 newRPB = GetDlgItemInt(IDC_EDIT_RPB, &ok, FALSE); CSoundFile *sndFile = mainFrm->GetSoundFilePlaying(); - if(sndFile && ok) + if(sndFile && ok && newRPB > 0) { SetRowsPerBeat(newRPB); } + m_currentRowsPerBeat = -2; // Force display update once focus moves away from this input field } } @@ -735,6 +733,7 @@ { sndFile->m_PlayState.m_nGlobalVolume = Clamp(Util::muldivr_unsigned(newGlobalVol, MAX_GLOBAL_VOLUME, sndFile->GlobalVolumeRange()), uint32(0), MAX_GLOBAL_VOLUME); } + m_currentGlobalVolume = -2; // Force display update once focus moves away from this input field } } Modified: trunk/OpenMPT/mptrack/Mainbar.h ============================================================================== --- trunk/OpenMPT/mptrack/Mainbar.h Sun Nov 10 20:50:22 2024 (r22148) +++ trunk/OpenMPT/mptrack/Mainbar.h Sun Nov 10 21:48:42 2024 (r22149) @@ -90,6 +90,7 @@ CSpinButtonCtrl m_SpinTempo, m_SpinSpeed, m_SpinOctave, m_SpinRowsPerBeat, m_SpinGlobalVolume; int m_currentSpeed = 0, m_currentOctave = -1, m_currentRowsPerBeat = 0, m_currentGlobalVolume = 0; TEMPO m_currentTempo{1, 0}; + bool m_updating = false; public: CStereoVU m_VuMeter; @@ -117,7 +118,7 @@ void Init(CMainFrame *); UINT GetBaseOctave() const; BOOL SetBaseOctave(UINT nOctave); - BOOL SetCurrentSong(CSoundFile *pModDoc); + void SetCurrentSong(CSoundFile *pModDoc); bool ShowUpdateInfo(const CString &newVersion, const CString &infoURL, bool showHighLight); void RemoveUpdateInfo(); Modified: trunk/OpenMPT/mptrack/Mainfrm.h ============================================================================== --- trunk/OpenMPT/mptrack/Mainfrm.h Sun Nov 10 20:50:22 2024 (r22148) +++ trunk/OpenMPT/mptrack/Mainfrm.h Sun Nov 10 21:48:42 2024 (r22149) @@ -186,6 +186,7 @@ samplecount_t m_dwTimeSec = 0; UINT_PTR m_nTimer = 0; UINT m_nAvgMixChn = 0, m_nMixChn = 0; + uint32 m_currentSpeed = 0; // Misc class COptionsSoundcard *m_SoundCardOptionsDialog = nullptr; #if defined(MPT_ENABLE_UPDATE) |