mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-03 22:19:07 +02:00
A preference governs where the pinned head goes, not always exact center
This commit is contained in:
parent
b502d88285
commit
1c5e523a1e
@ -169,6 +169,7 @@ scroll information. It also has some status flags.
|
||||
#include "commands/CommandContext.h"
|
||||
|
||||
#include "prefs/QualityPrefs.h"
|
||||
#include "prefs/TracksPrefs.h"
|
||||
|
||||
#include "../images/AudacityLogoAlpha.xpm"
|
||||
|
||||
@ -6287,7 +6288,8 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
||||
trackPanel->Refresh(false);
|
||||
}
|
||||
else if (mMode != Mode::Off) {
|
||||
// Pan the view, so that we center the play indicator.
|
||||
// Pan the view, so that we put the play indicator at some fixed
|
||||
// fraction of the window width.
|
||||
|
||||
ViewInfo &viewInfo = mProject->GetViewInfo();
|
||||
TrackPanel *const trackPanel = mProject->GetTrackPanel();
|
||||
@ -6301,7 +6303,9 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
||||
wxASSERT(false);
|
||||
/* fallthru */
|
||||
case Mode::Pinned:
|
||||
deltaX = posX - width / 2; break;
|
||||
deltaX =
|
||||
posX - width * TracksPrefs::GetPinnedHeadPositionPreference();
|
||||
break;
|
||||
case Mode::Right:
|
||||
deltaX = posX - width; break;
|
||||
}
|
||||
|
@ -42,6 +42,16 @@ namespace {
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const wxChar *PinnedHeadPositionPreferenceKey()
|
||||
{
|
||||
return wxT("/AudioIO/PinnedHeadPosition");
|
||||
}
|
||||
|
||||
double PinnedHeadPositionPreferenceDefault()
|
||||
{
|
||||
return 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -324,6 +334,21 @@ void TracksPrefs::SetPinnedHeadPreference(bool value, bool flush)
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
double TracksPrefs::GetPinnedHeadPositionPreference()
|
||||
{
|
||||
auto value = gPrefs->ReadDouble(
|
||||
PinnedHeadPositionPreferenceKey(),
|
||||
PinnedHeadPositionPreferenceDefault());
|
||||
return std::max(0.0, std::min(1.0, value));
|
||||
}
|
||||
|
||||
void TracksPrefs::SetPinnedHeadPositionPreference(double value, bool flush)
|
||||
{
|
||||
gPrefs->Write(PinnedHeadPositionPreferenceKey(), value);
|
||||
if(flush)
|
||||
gPrefs->Flush();
|
||||
}
|
||||
|
||||
wxString TracksPrefs::GetDefaultAudioTrackNamePreference()
|
||||
{
|
||||
const auto name =
|
||||
|
@ -35,6 +35,9 @@ class TracksPrefs final : public PrefsPanel
|
||||
static bool GetPinnedHeadPreference();
|
||||
static void SetPinnedHeadPreference(bool value, bool flush = false);
|
||||
|
||||
static double GetPinnedHeadPositionPreference();
|
||||
static void SetPinnedHeadPositionPreference(double value, bool flush = false);
|
||||
|
||||
static wxString GetDefaultAudioTrackNamePreference();
|
||||
|
||||
static WaveTrack::WaveTrackDisplay ViewModeChoice();
|
||||
|
@ -162,23 +162,25 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
|
||||
mProject->TP_DisplaySelection();
|
||||
|
||||
// BG: Scroll screen if option is set
|
||||
// msmeyer: But only if not playing looped or in one-second mode
|
||||
// PRL: and not scrolling with play/record head fixed right
|
||||
if (viewInfo.bUpdateTrackIndicator &&
|
||||
mProject->mLastPlayMode != PlayMode::loopedPlay &&
|
||||
mProject->mLastPlayMode != PlayMode::oneSecondPlay &&
|
||||
mProject->GetPlaybackScroller().GetMode() !=
|
||||
AudacityProject::PlaybackScroller::Mode::Right &&
|
||||
playPos >= 0 &&
|
||||
!onScreen &&
|
||||
!gAudioIO->IsPaused())
|
||||
{
|
||||
mProject->TP_ScrollWindow(playPos);
|
||||
// Might yet be off screen, check it
|
||||
onScreen = playPos >= 0.0 &&
|
||||
if( viewInfo.bUpdateTrackIndicator &&
|
||||
playPos >= 0 && !onScreen ) {
|
||||
// msmeyer: But only if not playing looped or in one-second mode
|
||||
// PRL: and not scrolling with play/record head fixed
|
||||
using Mode = AudacityProject::PlaybackScroller::Mode;
|
||||
const Mode mode = mProject->GetPlaybackScroller().GetMode();
|
||||
const bool pinned = ( mode == Mode::Pinned || mode == Mode::Right );
|
||||
if (!pinned &&
|
||||
mProject->mLastPlayMode != PlayMode::loopedPlay &&
|
||||
mProject->mLastPlayMode != PlayMode::oneSecondPlay &&
|
||||
!gAudioIO->IsPaused())
|
||||
{
|
||||
mProject->TP_ScrollWindow(playPos);
|
||||
// Might yet be off screen, check it
|
||||
onScreen = playPos >= 0.0 &&
|
||||
between_incexc(viewInfo.h,
|
||||
playPos,
|
||||
mProject->GetScreenEndTime());
|
||||
}
|
||||
}
|
||||
|
||||
// Always update scrollbars even if not scrolling the window. This is
|
||||
|
@ -68,8 +68,10 @@ namespace {
|
||||
// with the time at the midline of the screen mapping to 0,
|
||||
// and the extremes to the maximum scrub speed.
|
||||
|
||||
// Width of visible track area, in time terms:
|
||||
const double origin = viewInfo.h + screen / 2.0;
|
||||
auto partScreen = screen * TracksPrefs::GetPinnedHeadPositionPreference();
|
||||
const double origin = viewInfo.h + partScreen;
|
||||
if (timeAtMouse >= origin)
|
||||
partScreen = screen - partScreen;
|
||||
|
||||
// There are various snapping zones that are this fraction of screen:
|
||||
const double snap = 0.05;
|
||||
@ -77,8 +79,9 @@ namespace {
|
||||
// By shrinking denom a bit, we make margins left and right
|
||||
// that snap to maximum and negative maximum speeds.
|
||||
const double factor = 1.0 - (snap * 2);
|
||||
const double denom = factor * screen / 2.0;
|
||||
double fraction = std::min(1.0, fabs(timeAtMouse - origin) / denom);
|
||||
const double denom = factor * partScreen;
|
||||
double fraction = (denom <= 0.0) ? 0.0 :
|
||||
std::min(1.0, fabs(timeAtMouse - origin) / denom);
|
||||
|
||||
// Snap to 1.0 and -1.0
|
||||
const double unity = 1.0 / maxScrubSpeed;
|
||||
@ -115,14 +118,16 @@ namespace {
|
||||
const double extreme = std::max(1.0, maxScrubSpeed * ARBITRARY_MULTIPLIER);
|
||||
|
||||
// Width of visible track area, in time terms:
|
||||
const double halfScreen = screen / 2.0;
|
||||
const double origin = viewInfo.h + halfScreen;
|
||||
auto partScreen = screen * TracksPrefs::GetPinnedHeadPositionPreference();
|
||||
const double origin = viewInfo.h + partScreen;
|
||||
if (timeAtMouse >= origin)
|
||||
partScreen = screen - partScreen;
|
||||
|
||||
// The snapping zone is this fraction of screen, on each side of the
|
||||
// center line:
|
||||
const double snap = 0.05;
|
||||
const double fraction =
|
||||
std::max(snap, std::min(1.0, fabs(timeAtMouse - origin) / halfScreen));
|
||||
const double fraction = (partScreen <= 0.0) ? 0.0 :
|
||||
std::max(snap, std::min(1.0, fabs(timeAtMouse - origin) / partScreen));
|
||||
|
||||
double result = 1.0 + ((fraction - snap) / (1.0 - snap)) * (extreme - 1.0);
|
||||
if (timeAtMouse < origin)
|
||||
@ -343,7 +348,9 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
||||
if (mDragging && mSmoothScrollingScrub) {
|
||||
auto delta = time0 - time1;
|
||||
time0 = std::max(0.0, std::min(maxTime,
|
||||
(viewInfo.h + mProject->GetScreenEndTime()) / 2
|
||||
viewInfo.h +
|
||||
(mProject->GetScreenEndTime() - viewInfo.h)
|
||||
* TracksPrefs::GetPinnedHeadPositionPreference()
|
||||
));
|
||||
time1 = time0 + delta;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user