1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-23 17:30:17 +01:00

Bug 2418 - Time toolbar displays incorrect time if project rate isn't 44100

This commit is contained in:
Leland Lucius
2020-05-31 03:22:53 -05:00
parent 419e152ebd
commit c43c757bce
4 changed files with 40 additions and 10 deletions

View File

@@ -23,12 +23,13 @@
#include <wx/sizer.h>
#endif
#include "SelectionBarListener.h"
#include "TimeToolBar.h"
#include "ToolManager.h"
#include "SelectionBarListener.h"
#include "../AudioIO.h"
#include "../ProjectAudioIO.h"
#include "../ProjectSettings.h"
#include "../ViewInfo.h"
IMPLEMENT_CLASS(TimeToolBar, ToolBar);
@@ -51,6 +52,7 @@ TimeToolBar::TimeToolBar(AudacityProject &project)
mListener(NULL),
mAudioTime(NULL)
{
project.Bind(EVT_PROJECT_SETTINGS_CHANGE, &TimeToolBar::OnSettingsChanged, this);
}
TimeToolBar::~TimeToolBar()
@@ -70,16 +72,13 @@ const TimeToolBar &TimeToolBar::Get(const AudacityProject &project)
void TimeToolBar::Populate()
{
const auto &settings = ProjectSettings::Get(mProject);
// Get the default sample rate
auto rate = gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"),
AudioIO::GetOptimalSupportedSampleRate());
auto rate = settings.GetRate();
// Get the default time format
auto format = NumericConverter::HoursMinsSecondsFormat();
if (mListener)
{
format = mListener->TT_GetAudioTimeFormat();
}
auto format = settings.GetAudioTimeFormat();
// Create the read-only time control
mAudioTime = safenew NumericTextCtrl(this, AudioPositionID, NumericConverter::TIME, format, 0.0, rate);
@@ -261,6 +260,18 @@ void TimeToolBar::SetResizingLimits()
SetMaxSize(maxSize);
}
// Called when the project settings change
void TimeToolBar::OnSettingsChanged(wxCommandEvent &evt)
{
evt.Skip(false);
if (evt.GetInt() == ProjectSettings::ChangedProjectRate && mAudioTime)
{
const auto &settings = ProjectSettings::Get(mProject);
mAudioTime->SetSampleRate(settings.GetRate());
}
}
// Called when the format drop downs is changed.
// This causes recreation of the toolbar contents.
void TimeToolBar::OnUpdate(wxCommandEvent &evt)

View File

@@ -46,6 +46,7 @@ private:
void SetResizingLimits();
wxSize ComputeSizing(int digitH);
void OnSettingsChanged(wxCommandEvent &evt);
void OnUpdate(wxCommandEvent &evt);
void OnSize(wxSizeEvent &evt);
void OnIdle(wxIdleEvent &evt);