From: <sag...@us...> - 2015-02-24 22:32:30
|
Revision: 4791 http://sourceforge.net/p/modplug/code/4791 Author: saga-games Date: 2015-02-24 22:32:25 +0000 (Tue, 24 Feb 2015) Log Message: ----------- [Fix] Sample tab: Entering a finetune amount or middle-C frequency created an undo step for every entered digit. Modified Paths: -------------- trunk/OpenMPT/mptrack/Ctrl_smp.cpp trunk/OpenMPT/mptrack/Ctrl_smp.h Modified: trunk/OpenMPT/mptrack/Ctrl_smp.cpp =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2015-02-24 21:24:29 UTC (rev 4790) +++ trunk/OpenMPT/mptrack/Ctrl_smp.cpp 2015-02-24 22:32:25 UTC (rev 4791) @@ -33,7 +33,7 @@ #include "FileDialog.h" #include "../common/ComponentManager.h" #ifdef _DEBUG -#include <math.h> +#include <cmath> #endif #include "../include/r8brain/CDSPResampler.h" @@ -49,19 +49,15 @@ // Round floating point value to "digit" number of digits static float Round(const float value, const int digit) { - float v = 0.1f * (value * powf(10.0f, (float)(digit + 1)) + (value < 0.0f ? -5.0f : 5.0f)); - modff(v, &v); - return v / powf(10.0f, (float)digit); + float v = 0.1f * (value * std::pow(10.0f, (float)(digit + 1)) + (value < 0.0f ? -5.0f : 5.0f)); + std::modf(v, &v); + return v / std::pow(10.0f, (float)digit); } -template<int v> -static int PowerOf2Exponent() -{ - if(v <= 1) - return 0; - else - return 1 + PowerOf2Exponent<v / 2>(); -} +template<unsigned int v> +struct PowerOf2Exponent { enum { value = 1 + PowerOf2Exponent<v / 2>::value }; }; +template<> +struct PowerOf2Exponent<1> { enum { value = 0 }; }; #define BASENOTE_MIN (1*12) // C-1 @@ -199,6 +195,7 @@ { CModControlDlg::OnInitDialog(); m_bInitialized = FALSE; + finetuneBoxActive = false; SetRedraw(FALSE); // Zoom Selection @@ -299,7 +296,7 @@ if(combo) { // Deduce exponent from equation : MAX_FRAME_LENGTH = 2^exponent - const int exponent = PowerOf2Exponent<MAX_FRAME_LENGTH>(); + const int exponent = PowerOf2Exponent<MAX_FRAME_LENGTH>::value; // Allow FFT size from 2^8 (256) to 2^exponent (MAX_FRAME_LENGTH) for(int i = 8 ; i <= exponent ; i++) { @@ -337,7 +334,7 @@ if (m_nSample != nSmp) { m_nSample = nSmp; - UpdateView(SampleHint(m_nSample).Info(), NULL); + UpdateView(SampleHint(m_nSample).Info()); } if (bUpdNum) { @@ -2479,7 +2476,11 @@ { if (IsLocked()) return; int n = GetDlgItemInt(IDC_EDIT5); - m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Finetune"); + if(!finetuneBoxActive) + { + m_modDoc.GetSampleUndo().PrepareUndo(m_nSample, sundo_none, "Finetune"); + finetuneBoxActive = true; + } ModSample &sample = m_sndFile.GetSample(m_nSample); if (m_sndFile.m_nType & (MOD_TYPE_IT|MOD_TYPE_S3M|MOD_TYPE_MPT)) { @@ -2514,6 +2515,7 @@ void CCtrlSamples::OnFineTuneChangedDone() //---------------------------------------- { + finetuneBoxActive = false; // Update all playing channels ModSample &sample = m_sndFile.GetSample(m_nSample); for(CHANNELINDEX i = 0; i < MAX_CHANNELS; i++) @@ -3236,8 +3238,8 @@ // When changing auto vibrato properties, propagate them to other samples of the same instrument in XM edit mode. -void CCtrlSamples::PropagateAutoVibratoChanges() const -//---------------------------------------------------- +void CCtrlSamples::PropagateAutoVibratoChanges() +//---------------------------------------------- { if(!(m_sndFile.GetType() & MOD_TYPE_XM)) { @@ -3259,7 +3261,7 @@ m_sndFile.GetSample(*sample).nVibType = m_sndFile.GetSample(m_nSample).nVibType; m_sndFile.GetSample(*sample).nVibRate = m_sndFile.GetSample(m_nSample).nVibRate; m_sndFile.GetSample(*sample).nVibSweep = m_sndFile.GetSample(m_nSample).nVibSweep; - m_modDoc.UpdateAllViews(nullptr, SampleHint(*sample).Info(), (CObject *)this); + m_modDoc.UpdateAllViews(nullptr, SampleHint(*sample).Info(), this); } } } Modified: trunk/OpenMPT/mptrack/Ctrl_smp.h =================================================================== --- trunk/OpenMPT/mptrack/Ctrl_smp.h 2015-02-24 21:24:29 UTC (rev 4790) +++ trunk/OpenMPT/mptrack/Ctrl_smp.h 2015-02-24 22:32:25 UTC (rev 4791) @@ -43,7 +43,8 @@ uint32 m_nSeekWindowMs; uint32 m_nOverlapMs; SampleIO m_nPreviousRawFormat; - bool rememberRawFormat; + bool finetuneBoxActive : 1; + bool rememberRawFormat : 1; CComboBox m_ComboPitch, m_ComboQuality, m_ComboFFT; @@ -60,7 +61,7 @@ SampleSelectionPoints GetSelectionPoints(); void SetSelectionPoints(SmpLength nStart, SmpLength nEnd); - void PropagateAutoVibratoChanges() const; + void PropagateAutoVibratoChanges(); public: CCtrlSamples(CModControlView &parent, CModDoc &document); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |