mirror of
https://github.com/cookiengineer/audacity
synced 2025-05-05 14:18:53 +02:00
Merge pull request #150 from RaphaelMarinier/optimize_selection_bar_update_master
Optimize the refresh of the selection bar while Audacity is playing.
This commit is contained in:
commit
1cad18c479
@ -1800,9 +1800,20 @@ void NumericTextCtrl::Updated(bool keyup /* = false */)
|
||||
|
||||
void NumericTextCtrl::ValueToControls()
|
||||
{
|
||||
const wxString previousValueString = mValueString;
|
||||
NumericConverter::ValueToControls(mValue);
|
||||
if (mValueString != previousValueString) {
|
||||
// Doing this only when needed is an optimization.
|
||||
// NumerixTextCtrls are used in the selection bar at the bottom
|
||||
// of Audacity, and are updated at high frequency through
|
||||
// SetValue() when Audacity is playing. This consumes a
|
||||
// significant amount of CPU. Typically, when a track is
|
||||
// playing, only one of the NumericTextCtrl actually changes
|
||||
// (the audio position). We save CPU by updating the control
|
||||
// only when needed.
|
||||
Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void NumericTextCtrl::ControlsToValue()
|
||||
|
@ -66,9 +66,16 @@ public:
|
||||
|
||||
virtual ~NumericConverter();
|
||||
|
||||
// ValueToControls() formats a raw value (either provided as
|
||||
// argument, or mValue, depending on the version of the function
|
||||
// called). The result is stored to mValueString.
|
||||
virtual void ValueToControls();
|
||||
virtual void ValueToControls(double rawValue, bool nearest = true);
|
||||
|
||||
// Converts the stored formatted string (mValueString) back to a
|
||||
// raw value (mValue).
|
||||
virtual void ControlsToValue();
|
||||
|
||||
virtual void ParseFormatString(const wxString & format);
|
||||
|
||||
void PrintDebugInfo();
|
||||
@ -115,6 +122,7 @@ protected:
|
||||
wxString mPrefix;
|
||||
wxString mValueTemplate;
|
||||
wxString mValueMask;
|
||||
// Formatted mValue, by ValueToControls().
|
||||
wxString mValueString;
|
||||
|
||||
double mScalingFactor;
|
||||
@ -181,6 +189,9 @@ private:
|
||||
void OnFocus(wxFocusEvent &event);
|
||||
void OnContext(wxContextMenuEvent &event);
|
||||
|
||||
// Formats mValue into mValueString, using the method of the base class.
|
||||
// Triggers a refresh of the wx window only when the value actually
|
||||
// changed since last time a refresh was triggered.
|
||||
void ValueToControls() override;
|
||||
void ControlsToValue() override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user