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 "commands/CommandContext.h"
|
||||||
|
|
||||||
#include "prefs/QualityPrefs.h"
|
#include "prefs/QualityPrefs.h"
|
||||||
|
#include "prefs/TracksPrefs.h"
|
||||||
|
|
||||||
#include "../images/AudacityLogoAlpha.xpm"
|
#include "../images/AudacityLogoAlpha.xpm"
|
||||||
|
|
||||||
@ -6287,7 +6288,8 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
|||||||
trackPanel->Refresh(false);
|
trackPanel->Refresh(false);
|
||||||
}
|
}
|
||||||
else if (mMode != Mode::Off) {
|
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();
|
ViewInfo &viewInfo = mProject->GetViewInfo();
|
||||||
TrackPanel *const trackPanel = mProject->GetTrackPanel();
|
TrackPanel *const trackPanel = mProject->GetTrackPanel();
|
||||||
@ -6301,7 +6303,9 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
|||||||
wxASSERT(false);
|
wxASSERT(false);
|
||||||
/* fallthru */
|
/* fallthru */
|
||||||
case Mode::Pinned:
|
case Mode::Pinned:
|
||||||
deltaX = posX - width / 2; break;
|
deltaX =
|
||||||
|
posX - width * TracksPrefs::GetPinnedHeadPositionPreference();
|
||||||
|
break;
|
||||||
case Mode::Right:
|
case Mode::Right:
|
||||||
deltaX = posX - width; break;
|
deltaX = posX - width; break;
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,16 @@ namespace {
|
|||||||
{
|
{
|
||||||
return false;
|
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();
|
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()
|
wxString TracksPrefs::GetDefaultAudioTrackNamePreference()
|
||||||
{
|
{
|
||||||
const auto name =
|
const auto name =
|
||||||
|
@ -34,7 +34,10 @@ class TracksPrefs final : public PrefsPanel
|
|||||||
|
|
||||||
static bool GetPinnedHeadPreference();
|
static bool GetPinnedHeadPreference();
|
||||||
static void SetPinnedHeadPreference(bool value, bool flush = false);
|
static void SetPinnedHeadPreference(bool value, bool flush = false);
|
||||||
|
|
||||||
|
static double GetPinnedHeadPositionPreference();
|
||||||
|
static void SetPinnedHeadPositionPreference(double value, bool flush = false);
|
||||||
|
|
||||||
static wxString GetDefaultAudioTrackNamePreference();
|
static wxString GetDefaultAudioTrackNamePreference();
|
||||||
|
|
||||||
static WaveTrack::WaveTrackDisplay ViewModeChoice();
|
static WaveTrack::WaveTrackDisplay ViewModeChoice();
|
||||||
|
@ -162,23 +162,25 @@ void PlayIndicatorOverlay::OnTimer(wxCommandEvent &event)
|
|||||||
mProject->TP_DisplaySelection();
|
mProject->TP_DisplaySelection();
|
||||||
|
|
||||||
// BG: Scroll screen if option is set
|
// BG: Scroll screen if option is set
|
||||||
// msmeyer: But only if not playing looped or in one-second mode
|
if( viewInfo.bUpdateTrackIndicator &&
|
||||||
// PRL: and not scrolling with play/record head fixed right
|
playPos >= 0 && !onScreen ) {
|
||||||
if (viewInfo.bUpdateTrackIndicator &&
|
// msmeyer: But only if not playing looped or in one-second mode
|
||||||
mProject->mLastPlayMode != PlayMode::loopedPlay &&
|
// PRL: and not scrolling with play/record head fixed
|
||||||
mProject->mLastPlayMode != PlayMode::oneSecondPlay &&
|
using Mode = AudacityProject::PlaybackScroller::Mode;
|
||||||
mProject->GetPlaybackScroller().GetMode() !=
|
const Mode mode = mProject->GetPlaybackScroller().GetMode();
|
||||||
AudacityProject::PlaybackScroller::Mode::Right &&
|
const bool pinned = ( mode == Mode::Pinned || mode == Mode::Right );
|
||||||
playPos >= 0 &&
|
if (!pinned &&
|
||||||
!onScreen &&
|
mProject->mLastPlayMode != PlayMode::loopedPlay &&
|
||||||
!gAudioIO->IsPaused())
|
mProject->mLastPlayMode != PlayMode::oneSecondPlay &&
|
||||||
{
|
!gAudioIO->IsPaused())
|
||||||
mProject->TP_ScrollWindow(playPos);
|
{
|
||||||
// Might yet be off screen, check it
|
mProject->TP_ScrollWindow(playPos);
|
||||||
onScreen = playPos >= 0.0 &&
|
// Might yet be off screen, check it
|
||||||
|
onScreen = playPos >= 0.0 &&
|
||||||
between_incexc(viewInfo.h,
|
between_incexc(viewInfo.h,
|
||||||
playPos,
|
playPos,
|
||||||
mProject->GetScreenEndTime());
|
mProject->GetScreenEndTime());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always update scrollbars even if not scrolling the window. This is
|
// 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,
|
// with the time at the midline of the screen mapping to 0,
|
||||||
// and the extremes to the maximum scrub speed.
|
// and the extremes to the maximum scrub speed.
|
||||||
|
|
||||||
// Width of visible track area, in time terms:
|
auto partScreen = screen * TracksPrefs::GetPinnedHeadPositionPreference();
|
||||||
const double origin = viewInfo.h + screen / 2.0;
|
const double origin = viewInfo.h + partScreen;
|
||||||
|
if (timeAtMouse >= origin)
|
||||||
|
partScreen = screen - partScreen;
|
||||||
|
|
||||||
// There are various snapping zones that are this fraction of screen:
|
// There are various snapping zones that are this fraction of screen:
|
||||||
const double snap = 0.05;
|
const double snap = 0.05;
|
||||||
@ -77,8 +79,9 @@ namespace {
|
|||||||
// By shrinking denom a bit, we make margins left and right
|
// By shrinking denom a bit, we make margins left and right
|
||||||
// that snap to maximum and negative maximum speeds.
|
// that snap to maximum and negative maximum speeds.
|
||||||
const double factor = 1.0 - (snap * 2);
|
const double factor = 1.0 - (snap * 2);
|
||||||
const double denom = factor * screen / 2.0;
|
const double denom = factor * partScreen;
|
||||||
double fraction = std::min(1.0, fabs(timeAtMouse - origin) / denom);
|
double fraction = (denom <= 0.0) ? 0.0 :
|
||||||
|
std::min(1.0, fabs(timeAtMouse - origin) / denom);
|
||||||
|
|
||||||
// Snap to 1.0 and -1.0
|
// Snap to 1.0 and -1.0
|
||||||
const double unity = 1.0 / maxScrubSpeed;
|
const double unity = 1.0 / maxScrubSpeed;
|
||||||
@ -115,14 +118,16 @@ namespace {
|
|||||||
const double extreme = std::max(1.0, maxScrubSpeed * ARBITRARY_MULTIPLIER);
|
const double extreme = std::max(1.0, maxScrubSpeed * ARBITRARY_MULTIPLIER);
|
||||||
|
|
||||||
// Width of visible track area, in time terms:
|
// Width of visible track area, in time terms:
|
||||||
const double halfScreen = screen / 2.0;
|
auto partScreen = screen * TracksPrefs::GetPinnedHeadPositionPreference();
|
||||||
const double origin = viewInfo.h + halfScreen;
|
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
|
// The snapping zone is this fraction of screen, on each side of the
|
||||||
// center line:
|
// center line:
|
||||||
const double snap = 0.05;
|
const double snap = 0.05;
|
||||||
const double fraction =
|
const double fraction = (partScreen <= 0.0) ? 0.0 :
|
||||||
std::max(snap, std::min(1.0, fabs(timeAtMouse - origin) / halfScreen));
|
std::max(snap, std::min(1.0, fabs(timeAtMouse - origin) / partScreen));
|
||||||
|
|
||||||
double result = 1.0 + ((fraction - snap) / (1.0 - snap)) * (extreme - 1.0);
|
double result = 1.0 + ((fraction - snap) / (1.0 - snap)) * (extreme - 1.0);
|
||||||
if (timeAtMouse < origin)
|
if (timeAtMouse < origin)
|
||||||
@ -343,7 +348,9 @@ bool Scrubber::MaybeStartScrubbing(wxCoord xx)
|
|||||||
if (mDragging && mSmoothScrollingScrub) {
|
if (mDragging && mSmoothScrollingScrub) {
|
||||||
auto delta = time0 - time1;
|
auto delta = time0 - time1;
|
||||||
time0 = std::max(0.0, std::min(maxTime,
|
time0 = std::max(0.0, std::min(maxTime,
|
||||||
(viewInfo.h + mProject->GetScreenEndTime()) / 2
|
viewInfo.h +
|
||||||
|
(mProject->GetScreenEndTime() - viewInfo.h)
|
||||||
|
* TracksPrefs::GetPinnedHeadPositionPreference()
|
||||||
));
|
));
|
||||||
time1 = time0 + delta;
|
time1 = time0 + delta;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user