ScrollIntoView out of TrackPanel, into ProjectWindow
This commit is contained in:
parent
b0d03d09a2
commit
52ff705b0d
|
@ -935,6 +935,28 @@ const int sbarHjump = 30; //STM: This is how far the thumb jumps when the
|
|||
#include "AllThemeResources.h"
|
||||
#endif
|
||||
|
||||
// Make sure selection edge is in view
|
||||
void ProjectWindow::ScrollIntoView(double pos)
|
||||
{
|
||||
auto &trackPanel = TrackPanel::Get( mProject );
|
||||
auto &viewInfo = ViewInfo::Get( mProject );
|
||||
auto w = viewInfo.GetTracksUsableWidth();
|
||||
|
||||
int pixel = viewInfo.TimeToPosition(pos);
|
||||
if (pixel < 0 || pixel >= w)
|
||||
{
|
||||
TP_ScrollWindow
|
||||
(viewInfo.OffsetTimeByPixels(pos, -(w / 2)));
|
||||
trackPanel.Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectWindow::ScrollIntoView(int x)
|
||||
{
|
||||
auto &viewInfo = ViewInfo::Get( mProject );
|
||||
ScrollIntoView(viewInfo.PositionToTime(x, viewInfo.GetLeftOffset()));
|
||||
}
|
||||
|
||||
///
|
||||
/// This method handles general left-scrolling, either for drag-scrolling
|
||||
/// or when the scrollbar is clicked to the left of the thumb
|
||||
|
@ -1717,7 +1739,6 @@ void ProjectWindow::SkipEnd(bool shift)
|
|||
{
|
||||
auto &project = mProject;
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &viewInfo = ViewInfo::Get( project );
|
||||
double len = tracks.GetEndTime();
|
||||
|
||||
|
@ -1726,8 +1747,7 @@ void ProjectWindow::SkipEnd(bool shift)
|
|||
viewInfo.selectedRegion.setT0(len);
|
||||
|
||||
// Make sure the end of the track is visible
|
||||
trackPanel.ScrollIntoView(len);
|
||||
trackPanel.Refresh(false);
|
||||
ScrollIntoView(len);
|
||||
}
|
||||
|
||||
void ProjectWindow::TP_DisplaySelection()
|
||||
|
@ -1832,7 +1852,6 @@ void ProjectWindow::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
|||
void ProjectWindow::ZoomInByFactor( double ZoomFactor )
|
||||
{
|
||||
auto &project = mProject;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &viewInfo = ViewInfo::Get( project );
|
||||
|
||||
auto gAudioIO = AudioIOBase::Get();
|
||||
|
@ -1842,8 +1861,7 @@ void ProjectWindow::ZoomInByFactor( double ZoomFactor )
|
|||
ProjectAudioIO::Get( project ).GetAudioIOToken()) &&
|
||||
!gAudioIO->IsPaused()){
|
||||
ZoomBy(ZoomFactor);
|
||||
trackPanel.ScrollIntoView(gAudioIO->GetStreamTime());
|
||||
trackPanel.Refresh(false);
|
||||
ScrollIntoView(gAudioIO->GetStreamTime());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -102,6 +102,9 @@ public:
|
|||
|
||||
wxScrollBar &GetVerticalScrollBar() { return *mVsbar; }
|
||||
|
||||
void ScrollIntoView(double pos);
|
||||
void ScrollIntoView(int x);
|
||||
|
||||
void OnScrollLeft();
|
||||
void OnScrollRight();
|
||||
|
||||
|
|
|
@ -971,25 +971,6 @@ void TrackPanel::UpdateVRulerSize()
|
|||
Refresh(false);
|
||||
}
|
||||
|
||||
// Make sure selection edge is in view
|
||||
void TrackPanel::ScrollIntoView(double pos)
|
||||
{
|
||||
auto w = mViewInfo->GetTracksUsableWidth();
|
||||
|
||||
int pixel = mViewInfo->TimeToPosition(pos);
|
||||
if (pixel < 0 || pixel >= w)
|
||||
{
|
||||
mListener->TP_ScrollWindow
|
||||
(mViewInfo->OffsetTimeByPixels(pos, -(w / 2)));
|
||||
Refresh(false);
|
||||
}
|
||||
}
|
||||
|
||||
void TrackPanel::ScrollIntoView(int x)
|
||||
{
|
||||
ScrollIntoView(mViewInfo->PositionToTime(x, mViewInfo->GetLeftOffset()));
|
||||
}
|
||||
|
||||
void TrackPanel::OnTrackMenu(Track *t)
|
||||
{
|
||||
CellularPanel::DoContextMenu( t ? &TrackView::Get( *t ) : nullptr );
|
||||
|
|
|
@ -117,9 +117,6 @@ class AUDACITY_DLL_API TrackPanel final
|
|||
void HandlePageDownKey();
|
||||
AudacityProject * GetProject() const override;
|
||||
|
||||
void ScrollIntoView(double pos);
|
||||
void ScrollIntoView(int x);
|
||||
|
||||
void OnTrackMenu(Track *t = NULL);
|
||||
|
||||
void VerticalScroll( float fracPosition);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include "../ProjectHistory.h"
|
||||
#include "../ProjectSettings.h"
|
||||
#include "../TrackPanel.h"
|
||||
#include "../ProjectWindow.h"
|
||||
#include "../UndoManager.h"
|
||||
#include "../WaveClip.h"
|
||||
#include "../ViewInfo.h"
|
||||
|
@ -561,6 +562,7 @@ void DoSelectClip(AudacityProject &project, bool next)
|
|||
{
|
||||
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
std::vector<FoundClip> results;
|
||||
FindClips(project, selectedRegion.t0(),
|
||||
|
@ -573,7 +575,7 @@ void DoSelectClip(AudacityProject &project, bool next)
|
|||
double t1 = results[0].endTime;
|
||||
selectedRegion.setTimes(t0, t1);
|
||||
ProjectHistory::Get( project ).ModifyState(false);
|
||||
trackPanel.ScrollIntoView(selectedRegion.t0());
|
||||
window.ScrollIntoView(selectedRegion.t0());
|
||||
|
||||
// create and send message to screen reader
|
||||
wxString message;
|
||||
|
@ -607,6 +609,7 @@ void DoCursorClipBoundary
|
|||
{
|
||||
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
std::vector<FoundClipBoundary> results;
|
||||
FindClipBoundaries(project, next ? selectedRegion.t1() :
|
||||
|
@ -618,7 +621,7 @@ void DoCursorClipBoundary
|
|||
double time = results[0].time;
|
||||
selectedRegion.setTimes(time, time);
|
||||
ProjectHistory::Get( project ).ModifyState(false);
|
||||
trackPanel.ScrollIntoView(selectedRegion.t0());
|
||||
window.ScrollIntoView(selectedRegion.t0());
|
||||
|
||||
wxString message = ClipBoundaryMessage(results);
|
||||
trackPanel.MessageForScreenReader(message);
|
||||
|
@ -691,6 +694,7 @@ void DoClipLeftOrRight
|
|||
(AudacityProject &project, bool right, bool keyUp )
|
||||
{
|
||||
auto &undoManager = UndoManager::Get( project );
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
if (keyUp) {
|
||||
undoManager.StopConsolidating();
|
||||
|
@ -707,7 +711,7 @@ void DoClipLeftOrRight
|
|||
auto amount = DoClipMove( viewInfo, trackPanel.GetFocusedTrack(),
|
||||
tracks, isSyncLocked, right );
|
||||
|
||||
trackPanel.ScrollIntoView(selectedRegion.t0());
|
||||
window.ScrollIntoView(selectedRegion.t0());
|
||||
|
||||
if (amount != 0.0) {
|
||||
wxString message = right? _("Time shifted clips to the right") :
|
||||
|
|
|
@ -41,7 +41,6 @@ void FinishCopy
|
|||
bool DoPasteText(AudacityProject &project)
|
||||
{
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
|
@ -61,7 +60,7 @@ bool DoPasteText(AudacityProject &project)
|
|||
// Make sure caret is in view
|
||||
int x;
|
||||
if (view.CalcCursorX( project, &x )) {
|
||||
trackPanel.ScrollIntoView(x);
|
||||
window.ScrollIntoView(x);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -273,7 +273,7 @@ void MoveWhenAudioInactive
|
|||
}
|
||||
|
||||
// Make sure NEW position is in view
|
||||
trackPanel.ScrollIntoView(viewInfo.selectedRegion.t1());
|
||||
window.ScrollIntoView(viewInfo.selectedRegion.t1());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -282,9 +282,9 @@ void SeekWhenAudioInactive
|
|||
SelectionOperation operation)
|
||||
{
|
||||
auto &viewInfo = ViewInfo::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &tracks = TrackList::Get( project );
|
||||
const auto &settings = ProjectSettings::Get( project );
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
if( operation == CURSOR_MOVE )
|
||||
{
|
||||
|
@ -318,9 +318,8 @@ SelectionOperation operation)
|
|||
else
|
||||
viewInfo.selectedRegion.setT1( newT );
|
||||
|
||||
// Ensure it is visible, and refresh.
|
||||
trackPanel.ScrollIntoView(newT);
|
||||
trackPanel.Refresh(false);
|
||||
// Ensure it is visible
|
||||
window.ScrollIntoView(newT);
|
||||
}
|
||||
|
||||
// Handle small cursor and play head movements
|
||||
|
@ -381,8 +380,8 @@ void DoCursorMove(
|
|||
void DoBoundaryMove(AudacityProject &project, int step, SeekInfo &info)
|
||||
{
|
||||
auto &viewInfo = ViewInfo::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
// step is negative, then is moving left. step positive, moving right.
|
||||
// Move the left/right selection boundary, to expand the selection
|
||||
|
@ -434,9 +433,8 @@ void DoBoundaryMove(AudacityProject &project, int step, SeekInfo &info)
|
|||
else
|
||||
viewInfo.selectedRegion.setT1( newT );
|
||||
|
||||
// Ensure it is visible, and refresh.
|
||||
trackPanel.ScrollIntoView(newT);
|
||||
trackPanel.Refresh(false);
|
||||
// Ensure it is visible
|
||||
window.ScrollIntoView(newT);
|
||||
|
||||
ProjectHistory::Get( project ).ModifyState(false);
|
||||
}
|
||||
|
@ -834,31 +832,31 @@ void OnSelContractRight(const CommandContext &context)
|
|||
void OnCursorSelStart(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
selectedRegion.collapseToT0();
|
||||
ProjectHistory::Get( project ).ModifyState(false);
|
||||
trackPanel.ScrollIntoView(selectedRegion.t0());
|
||||
window.ScrollIntoView(selectedRegion.t0());
|
||||
}
|
||||
|
||||
void OnCursorSelEnd(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
selectedRegion.collapseToT1();
|
||||
ProjectHistory::Get( project ).ModifyState(false);
|
||||
trackPanel.ScrollIntoView(selectedRegion.t1());
|
||||
window.ScrollIntoView(selectedRegion.t1());
|
||||
}
|
||||
|
||||
void OnCursorTrackStart(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
double kWayOverToRight = std::numeric_limits<double>::max();
|
||||
|
||||
|
@ -876,15 +874,15 @@ void OnCursorTrackStart(const CommandContext &context)
|
|||
|
||||
selectedRegion.setTimes(minOffset, minOffset);
|
||||
ProjectHistory::Get( project ).ModifyState(false);
|
||||
trackPanel.ScrollIntoView(selectedRegion.t0());
|
||||
window.ScrollIntoView(selectedRegion.t0());
|
||||
}
|
||||
|
||||
void OnCursorTrackEnd(const CommandContext &context)
|
||||
{
|
||||
auto &project = context.project;
|
||||
auto &tracks = TrackList::Get( project );
|
||||
auto &trackPanel = TrackPanel::Get( project );
|
||||
auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
|
||||
auto &window = ProjectWindow::Get( project );
|
||||
|
||||
double kWayOverToLeft = std::numeric_limits<double>::lowest();
|
||||
|
||||
|
@ -902,7 +900,7 @@ void OnCursorTrackEnd(const CommandContext &context)
|
|||
|
||||
selectedRegion.setTimes(maxEndOffset, maxEndOffset);
|
||||
ProjectHistory::Get( project ).ModifyState(false);
|
||||
trackPanel.ScrollIntoView(selectedRegion.t1());
|
||||
window.ScrollIntoView(selectedRegion.t1());
|
||||
}
|
||||
|
||||
void OnSkipStart(const CommandContext &context)
|
||||
|
|
|
@ -173,7 +173,7 @@ void DoMoveToLabel(AudacityProject &project, bool next)
|
|||
}
|
||||
else {
|
||||
selectedRegion = label->selectedRegion;
|
||||
trackPanel.ScrollIntoView(selectedRegion.t0());
|
||||
window.ScrollIntoView(selectedRegion.t0());
|
||||
window.RedrawProject();
|
||||
}
|
||||
|
||||
|
|
|
@ -1302,7 +1302,7 @@ unsigned LabelTrackView::KeyDown(
|
|||
// Make sure caret is in view
|
||||
int x;
|
||||
if (CalcCursorX( *project, &x ))
|
||||
TrackPanel::Get( *project ).ScrollIntoView(x);
|
||||
ProjectWindow::Get( *project ).ScrollIntoView(x);
|
||||
|
||||
// If selection modified, refresh
|
||||
// Otherwise, refresh track display if the keystroke was handled
|
||||
|
|
Loading…
Reference in New Issue