Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
ProjectWindow Class Referencefinal

A top-level window associated with a project, and handling scrollbars and zooming. More...

#include <ProjectWindow.h>

Inheritance diagram for ProjectWindow:
[legend]
Collaboration diagram for ProjectWindow:
[legend]

Classes

class  PlaybackScroller
 
struct  PlaybackScrollerMessage
 

Public Member Functions

 ProjectWindow (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, AudacityProject &project)
 
 ~ProjectWindow () override
 
int NextWindowID ()
 
bool IsActive () override
 
bool IsIconized () const override
 
bool IsBeingDeleted () const
 
void SetIsBeingDeleted ()
 
void Reset ()
 
wxWindow * GetTrackListWindow () noexcept
 Track list window is the parent container for TrackPanel. More...
 
wxSplitterWindow * GetContainerWindow () noexcept
 Container is a parent window for both effects panel and track list windows. More...
 
wxPanel * GetTopPanel () noexcept
 Top panel contains project-related controls and tools. More...
 
void UpdateStatusWidths ()
 
PlaybackScrollerGetPlaybackScroller ()
 
void SetNormalizedWindowState (wxRect pSizeAndLocation)
 
wxRect GetNormalizedWindowState () const
 
void RedrawProject (const bool bForceWaveTracks=false)
 
void Zoom (double level)
 
void ZoomInByFactor (double ZoomFactor)
 
void ZoomOutByFactor (double ZoomFactor)
 
void ZoomBy (double multiplier)
 
void ZoomAfterImport (Track *pTrack)
 
double GetZoomOfToFit () const
 
void DoZoomFit ()
 
void ApplyUpdatedTheme ()
 
wxScrollBar & GetVerticalScrollBar ()
 
wxScrollBar & GetHorizontalScrollBar ()
 
void ScrollIntoView (double pos)
 
void ScrollIntoView (int x)
 
void OnScrollLeft ()
 
void OnScrollRight ()
 
void Rewind (bool shift)
 
void SkipEnd (bool shift)
 
void OnScrollLeftButton (wxScrollEvent &event)
 
void OnScrollRightButton (wxScrollEvent &event)
 
void FinishAutoScroll ()
 
void FixScrollbars ()
 
bool MayScrollBeyondZero () const
 
double ScrollingLowerBoundTime () const
 
double PixelWidthBeforeTime (double scrollto) const
 
void SetHorizontalThumb (double scrollto)
 
wxSize GetTPTracksUsableArea ()
 
void RefreshTPTrack (Track *pTrk, bool refreshbacking=true)
 
void TP_RedrawScrollbars () override
 
void TP_ScrollLeft () override
 
void TP_ScrollRight () override
 
void TP_ScrollWindow (double scrollto) override
 
bool TP_ScrollUpDown (int delta) override
 
void TP_HandleResize () override
 
void OnMenu (wxCommandEvent &event)
 
void OnUpdateUI (wxUpdateUIEvent &event)
 
void MacShowUndockedToolbars (bool show)
 
void OnActivate (wxActivateEvent &event)
 
void OnMouseEvent (wxMouseEvent &event)
 
void OnIconize (wxIconizeEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void HandleResize ()
 
void UpdateLayout ()
 
void OnShow (wxShowEvent &event)
 
void OnMove (wxMoveEvent &event)
 
void DoScroll ()
 
void OnScroll (wxScrollEvent &event)
 
void OnToolBarUpdate (wxCommandEvent &event)
 
void OnUndoPushedModified ()
 
void OnUndoRedo ()
 
void OnUndoReset ()
 
- Public Member Functions inherited from ProjectWindowBase
 ProjectWindowBase (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, AudacityProject &project)
 
 ~ProjectWindowBase () override
 
std::shared_ptr< AudacityProjectFindProject ()
 
std::shared_ptr< const AudacityProjectFindProject () const
 
- Public Member Functions inherited from TrackPanelListener
 TrackPanelListener ()
 
virtual ~TrackPanelListener ()
 
virtual void TP_RedrawScrollbars ()=0
 
virtual void TP_ScrollLeft ()=0
 
virtual void TP_ScrollRight ()=0
 
virtual void TP_ScrollWindow (double scrollto)=0
 
virtual bool TP_ScrollUpDown (int delta)=0
 
virtual void TP_HandleResize ()=0
 
- Public Member Functions inherited from PrefsListener
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Public Member Functions inherited from Observer::Publisher< ProjectWindowDestroyedMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static ProjectWindowGet (AudacityProject &project)
 
static const ProjectWindowGet (const AudacityProject &project)
 
static ProjectWindowFind (AudacityProject *pProject)
 
static const ProjectWindowFind (const AudacityProject *pProject)
 
static void OnResetWindow (const CommandContext &context)
 
- Static Public Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 

Public Attributes

bool mbInitializingScrollbar { false }
 

Private Member Functions

void OnThemeChange (struct ThemeChangeMessage)
 
void UpdatePrefs () override
 

Private Attributes

wxRect mNormalizedWindowState
 
wxPanel * mTopPanel {}
 
wxSplitterWindow * mContainerWindow
 
wxWindow * mTrackListWindow {}
 
wxScrollBar * mHsbar {}
 
wxScrollBar * mVsbar {}
 
int mNextWindowID {}
 
bool mAutoScrolling { false }
 
bool mActive { true }
 
bool mIconized { false }
 
bool mShownOnce { false }
 
bool mIsDeleting { false }
 
Observer::Subscription mUndoSubscription
 
Observer::Subscription mThemeChangeSubscription
 
std::unique_ptr< PlaybackScrollermPlaybackScroller
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< ProjectWindowDestroyedMessage >
using message_type = ProjectWindowDestroyedMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const ProjectWindowDestroyedMessage &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Attributes inherited from Observer::Publisher< ProjectWindowDestroyedMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
- Protected Member Functions inherited from Observer::Publisher< ProjectWindowDestroyedMessage >
CallbackReturn Publish (const ProjectWindowDestroyedMessage &message)
 Send a message to connected callbacks. More...
 
- Protected Attributes inherited from ProjectWindowBase
std::weak_ptr< AudacityProjectmwProject
 

Detailed Description

A top-level window associated with a project, and handling scrollbars and zooming.

Definition at line 36 of file ProjectWindow.h.

Constructor & Destructor Documentation

◆ ProjectWindow()

ProjectWindow::ProjectWindow ( wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos,
const wxSize &  size,
AudacityProject project 
)
explicit

Definition at line 599 of file ProjectWindow.cpp.

602 : ProjectWindowBase{ parent, id, pos, size, project }
603{
605
606 constexpr auto EffectsPanelMaxWidth { 500 };
607 constexpr auto TrackPanelMinWidth { 250 };
608
609 // Two sub-windows need to be made before Init(),
610 // so that this constructor can complete, and then TrackPanel and
611 // AdornedRulerPanel can retrieve those windows from this in their
612 // factory functions
613
614 // PRL: this panel groups the top tool dock and the ruler into one
615 // tab cycle.
616 // Must create it with non-default width equal to the main window width,
617 // or else the device toolbar doesn't make initial widths of the choice
618 // controls correct.
620 this, wxID_ANY, wxDefaultPosition,
621 wxSize{ this->GetSize().GetWidth(), -1 }
622 };
623 mTopPanel->SetLabel( "Top Panel" );// Not localised
624 mTopPanel->SetLayoutDirection(wxLayout_LeftToRight);
625 mTopPanel->SetAutoLayout(true);
626#ifdef EXPERIMENTAL_DA2
627 mTopPanel->SetBackgroundColour(theTheme.Colour( clrMedium ));
628#endif
629
630 auto container = safenew wxSplitterWindow(this, wxID_ANY,
631 wxDefaultPosition,
632 wxDefaultSize,
633 wxNO_BORDER | wxSP_LIVE_UPDATE | wxSP_THIN_SASH);
634 container->Bind(wxEVT_SPLITTER_DOUBLECLICKED, [](wxSplitterEvent& event){
635 //"The default behaviour is to unsplit the window"
636 event.Veto();//do noting instead
637 });
638 container->Bind(wxEVT_SPLITTER_SASH_POS_CHANGING, [=](wxSplitterEvent& event){
639 if(event.GetSashPosition() > EffectsPanelMaxWidth)
640 //Prevents left panel from expanding further
641 event.SetSashPosition(-1);
642 });
643 mContainerWindow = container;
644
646 wxDefaultPosition,
647 wxDefaultSize,
648 wxNO_BORDER);
649 mTrackListWindow->SetMinSize({TrackPanelMinWidth, -1});
650 mTrackListWindow->SetSizer( safenew wxBoxSizer(wxVERTICAL) );
651 mTrackListWindow->SetLabel("Main Panel");// Not localized.
652 mTrackListWindow->SetLayoutDirection(wxLayout_LeftToRight);
653
655
656#ifdef EXPERIMENTAL_DA2
657 mTrackListWindow->SetBackgroundColour(theTheme.Colour( clrMedium ));
658#endif
659
660 mPlaybackScroller = std::make_unique<PlaybackScroller>( &project );
661
662 // PRL: Old comments below. No longer observing the ordering that it
663 // recommends. ProjectWindow::OnActivate puts the focus directly into
664 // the TrackPanel, which avoids the problems.
665 // LLL: When Audacity starts or becomes active after returning from
666 // another application, the first window that can accept focus
667 // will be given the focus even if we try to SetFocus(). By
668 // creating the scrollbars after the TrackPanel, we resolve
669 // several focus problems.
670
671 mHsbar = safenew ScrollBar(mTrackListWindow, HSBarID, wxSB_HORIZONTAL);
672 mVsbar = safenew ScrollBar(mTrackListWindow, VSBarID, wxSB_VERTICAL);
673#if wxUSE_ACCESSIBILITY
674 // so that name can be set on a standard control
675 mHsbar->SetAccessible(safenew WindowAccessible(mHsbar));
676 mVsbar->SetAccessible(safenew WindowAccessible(mVsbar));
677#endif
678 mHsbar->SetLayoutDirection(wxLayout_LeftToRight);
679 mHsbar->SetName(_("Horizontal Scrollbar"));
680 mVsbar->SetName(_("Vertical Scrollbar"));
681
683 .Subscribe([this](UndoRedoMessage message){
684 switch (message.type) {
685 case UndoRedoMessage::Pushed:
686 case UndoRedoMessage::Modified:
687 return OnUndoPushedModified();
688 case UndoRedoMessage::UndoOrRedo:
689 return OnUndoRedo();
690 case UndoRedoMessage::Reset:
691 return OnUndoReset();
692 default:
693 return;
694 }
695 });
696
699}
#define _(s)
Definition: Internat.h:75
#define safenew
Definition: MemoryX.h:10
@ VSBarID
@ HSBarID
@ NextID
THEME_API Theme theTheme
Definition: Theme.cpp:82
int id
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
A top-level window associated with a project.
wxScrollBar * mHsbar
wxSplitterWindow * mContainerWindow
wxPanel * mTopPanel
Observer::Subscription mThemeChangeSubscription
std::unique_ptr< PlaybackScroller > mPlaybackScroller
void OnThemeChange(struct ThemeChangeMessage)
Observer::Subscription mUndoSubscription
wxScrollBar * mVsbar
wxWindow * mTrackListWindow
wxColour & Colour(int iIndex)
static UndoManager & Get(AudacityProject &project)
Definition: UndoManager.cpp:67
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
Type of message published by UndoManager.
Definition: UndoManager.h:61
enum UndoRedoMessage::Type type

References _, ThemeBase::Colour(), UndoManager::Get(), HSBarID, mContainerWindow, mHsbar, mNextWindowID, mPlaybackScroller, mThemeChangeSubscription, mTopPanel, mTrackListWindow, mUndoSubscription, mVsbar, NextID, OnThemeChange(), safenew, Observer::Publisher< Message, NotifyAll >::Subscribe(), theTheme, UndoRedoMessage::type, and VSBarID.

Here is the call graph for this function:

◆ ~ProjectWindow()

ProjectWindow::~ProjectWindow ( )
override

Definition at line 701 of file ProjectWindow.cpp.

702{
703 // Tool manager gives us capture sometimes
704 if(HasCapture())
705 ReleaseMouse();
706}

Member Function Documentation

◆ ApplyUpdatedTheme()

void ProjectWindow::ApplyUpdatedTheme ( )

Definition at line 727 of file ProjectWindow.cpp.

728{
729 SetBackgroundColour(theTheme.Colour( clrMedium ));
730 ClearBackground();// For wxGTK.
731}

References ThemeBase::Colour(), and theTheme.

Referenced by OnThemeChange().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoScroll()

void ProjectWindow::DoScroll ( )

Definition at line 1534 of file ProjectWindow.cpp.

1535{
1536 auto pProject = FindProject();
1537 if (!pProject)
1538 return;
1539 auto &project = *pProject;
1540 auto &trackPanel = GetProjectPanel( project );
1541 auto &viewInfo = ViewInfo::Get( project );
1542 const double lowerBound = ScrollingLowerBoundTime();
1543
1544 auto width = viewInfo.GetTracksUsableWidth();
1545 viewInfo.SetBeforeScreenWidth(viewInfo.sbarH, width, lowerBound);
1546
1547
1548 if (MayScrollBeyondZero()) {
1549 enum { SCROLL_PIXEL_TOLERANCE = 10 };
1550 if (std::abs(viewInfo.TimeToPosition(0.0, 0
1551 )) < SCROLL_PIXEL_TOLERANCE) {
1552 // Snap the scrollbar to 0
1553 viewInfo.h = 0;
1554 SetHorizontalThumb(0.0);
1555 }
1556 }
1557
1558 viewInfo.vpos = mVsbar->GetThumbPosition() * viewInfo.scrollStep;
1559
1560 //mchinen: do not always set this project to be the active one.
1561 //a project may autoscroll while playing in the background
1562 //I think this is okay since OnMouseEvent has one of these.
1563 //SetActiveProject(this);
1564
1565 if (!mAutoScrolling) {
1566 trackPanel.Refresh(false);
1567 }
1568}
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
std::shared_ptr< AudacityProject > FindProject()
void SetHorizontalThumb(double scrollto)
double ScrollingLowerBoundTime() const
bool MayScrollBeyondZero() const
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:234

References ProjectWindowBase::FindProject(), ViewInfo::Get(), GetProjectPanel(), mAutoScrolling, MayScrollBeyondZero(), mVsbar, ScrollingLowerBoundTime(), and SetHorizontalThumb().

Referenced by FinishAutoScroll(), OnScroll(), OnScrollLeftButton(), OnScrollRightButton(), TP_ScrollUpDown(), and TP_ScrollWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoZoomFit()

void ProjectWindow::DoZoomFit ( )

Definition at line 1971 of file ProjectWindow.cpp.

1972{
1973 auto pProject = FindProject();
1974 if (!pProject)
1975 return;
1976 auto &project = *pProject;
1977 auto &viewInfo = ViewInfo::Get( project );
1978 auto &tracks = TrackList::Get( project );
1979 auto &window = *this;
1980
1981 const double start = viewInfo.bScrollBeyondZero
1982 ? std::min(tracks.GetStartTime(), 0.0)
1983 : 0;
1984
1985 window.Zoom( window.GetZoomOfToFit() );
1986 window.TP_ScrollWindow(start);
1987}
int min(int a, int b)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486

References ProjectWindowBase::FindProject(), ViewInfo::Get(), TrackList::Get(), and min().

Referenced by ZoomAfterImport().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Find() [1/2]

ProjectWindow * ProjectWindow::Find ( AudacityProject pProject)
static

Definition at line 563 of file ProjectWindow.cpp.

564{
565 return pProject
567 : nullptr;
568}
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
Subclass * Find(const RegisteredFactory &key)
Get a (bare) pointer to an attachment, or null, down-cast it to Subclass *; will not create on demand...
Definition: ClientData.h:333
A top-level window associated with a project, and handling scrollbars and zooming.
Definition: ProjectWindow.h:40
AttachedWindows::RegisteredFactory sProjectWindowKey

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Find(), GetAttachedWindows(), and anonymous_namespace{ProjectWindow.cpp}::sProjectWindowKey.

Referenced by Exporter::CheckMix(), ExportMP3::Export(), ExportMultipleDialog::ExportMultipleByLabel(), ExportMultipleDialog::ExportMultipleByTrack(), Find(), Exporter::GetFilename(), ScreenshotCommand::GetFrontWindow(), ProjectManager::OnStatusChange(), ProjectManager::SetStatusText(), and ScreenshotCommand::WindowFileName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Find() [2/2]

const ProjectWindow * ProjectWindow::Find ( const AudacityProject pProject)
static

Definition at line 570 of file ProjectWindow.cpp.

571{
572 return Find( const_cast< AudacityProject * >( pProject ) );
573}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static ProjectWindow * Find(AudacityProject *pProject)

References Find().

Here is the call graph for this function:

◆ FinishAutoScroll()

void ProjectWindow::FinishAutoScroll ( )

Definition at line 785 of file ProjectWindow.cpp.

786{
787 // Set a flag so we don't have to generate two update events
788 mAutoScrolling = true;
789
790 // Call our Scroll method which updates our ViewInfo variables
791 // to reflect the positions of the scrollbars
792 DoScroll();
793
794 mAutoScrolling = false;
795}

References DoScroll(), and mAutoScrolling.

Referenced by OnScrollLeft(), and OnScrollRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FixScrollbars()

void ProjectWindow::FixScrollbars ( )

Definition at line 1071 of file ProjectWindow.cpp.

1072{
1073 auto pProject = FindProject();
1074 if (!pProject)
1075 return;
1076 auto &project = *pProject;
1077 auto &tracks = TrackList::Get( project );
1078 auto &trackPanel = GetProjectPanel( project );
1079 auto &viewInfo = ViewInfo::Get( project );
1080
1081 bool refresh = false;
1082 bool rescroll = false;
1083
1084 int totalHeight = TrackView::GetTotalHeight( tracks ) + 32;
1085
1086 auto panelWidth = viewInfo.GetTracksUsableWidth();
1087 auto panelHeight = viewInfo.GetHeight();
1088
1089 // (From Debian...at least I think this is the change corresponding
1090 // to this comment)
1091 //
1092 // (2.) GTK critical warning "IA__gtk_range_set_range: assertion
1093 // 'min < max' failed" because of negative numbers as result of window
1094 // size checking. Added a sanity check that straightens up the numbers
1095 // in edge cases.
1096 if (panelWidth < 0) {
1097 panelWidth = 0;
1098 }
1099 if (panelHeight < 0) {
1100 panelHeight = 0;
1101 }
1102
1103 auto LastTime = std::numeric_limits<double>::lowest();
1104 for (const Track *track : tracks) {
1105 // Iterate over pending changed tracks if present.
1106 track = track->SubstitutePendingChangedTrack().get();
1107 LastTime = std::max( LastTime, track->GetEndTime() );
1108 }
1109 LastTime =
1110 std::max(LastTime, viewInfo.selectedRegion.t1());
1111
1112 const double screen =
1113 viewInfo.GetScreenEndTime() - viewInfo.h;
1114 const double halfScreen = screen / 2.0;
1115
1116 // If we can scroll beyond zero,
1117 // Add 1/2 of a screen of blank space to the end
1118 // and another 1/2 screen before the beginning
1119 // so that any point within the union of the selection and the track duration
1120 // may be scrolled to the midline.
1121 // May add even more to the end, so that you can always scroll the starting time to zero.
1122 const double lowerBound = ScrollingLowerBoundTime();
1123 const double additional = MayScrollBeyondZero()
1124 ? -lowerBound + std::max(halfScreen, screen - LastTime)
1125 : screen / 4.0;
1126
1127 viewInfo.total = LastTime + additional;
1128
1129 // Don't remove time from total that's still on the screen
1130 viewInfo.total = std::max(viewInfo.total, viewInfo.h + screen);
1131
1132 if (viewInfo.h < lowerBound) {
1133 viewInfo.h = lowerBound;
1134 rescroll = true;
1135 }
1136
1137 viewInfo.sbarTotal = (wxInt64) (viewInfo.GetTotalWidth());
1138 viewInfo.sbarScreen = (wxInt64)(panelWidth);
1139 viewInfo.sbarH = (wxInt64) (viewInfo.GetBeforeScreenWidth());
1140
1141 // PRL: Can someone else find a more elegant solution to bug 812, than
1142 // introducing this boolean member variable?
1143 // Setting mVSbar earlier, int HandlXMLTag, didn't succeed in restoring
1144 // the vertical scrollbar to its saved position. So defer that till now.
1145 // mbInitializingScrollbar should be true only at the start of the life
1146 // of an AudacityProject reopened from disk.
1148 viewInfo.vpos = mVsbar->GetThumbPosition() * viewInfo.scrollStep;
1149 }
1151
1152 if (viewInfo.vpos >= totalHeight)
1153 viewInfo.vpos = totalHeight - 1;
1154 if (viewInfo.vpos < 0)
1155 viewInfo.vpos = 0;
1156
1157 bool oldhstate;
1158 bool oldvstate;
1159 bool newhstate =
1160 (viewInfo.GetScreenEndTime() - viewInfo.h) < viewInfo.total;
1161 bool newvstate = panelHeight < totalHeight;
1162
1163#ifdef __WXGTK__
1164 oldhstate = mHsbar->IsShown();
1165 oldvstate = mVsbar->IsShown();
1166 mHsbar->Show(newhstate);
1167 mVsbar->Show(panelHeight < totalHeight);
1168#else
1169 oldhstate = mHsbar->IsEnabled();
1170 oldvstate = mVsbar->IsEnabled();
1171 mHsbar->Enable(newhstate);
1172 mVsbar->Enable(panelHeight < totalHeight);
1173#endif
1174
1175 if (panelHeight >= totalHeight && viewInfo.vpos != 0) {
1176 viewInfo.vpos = 0;
1177
1178 refresh = true;
1179 rescroll = false;
1180 }
1181 if (!newhstate && viewInfo.sbarH != 0) {
1182 viewInfo.sbarH = 0;
1183
1184 refresh = true;
1185 rescroll = false;
1186 }
1187
1188 // wxScrollbar only supports int values but we need a greater range, so
1189 // we scale the scrollbar coordinates on demand. We only do this if we
1190 // would exceed the int range, so we can always use the maximum resolution
1191 // available.
1192
1193 // Don't use the full 2^31 max int range but a bit less, so rounding
1194 // errors in calculations do not overflow max int
1195 wxInt64 maxScrollbarRange = (wxInt64)(2147483647 * 0.999);
1196 if (viewInfo.sbarTotal > maxScrollbarRange)
1197 viewInfo.sbarScale = ((double)maxScrollbarRange) / viewInfo.sbarTotal;
1198 else
1199 viewInfo.sbarScale = 1.0; // use maximum resolution
1200
1201 {
1202 int scaledSbarH = (int)(viewInfo.sbarH * viewInfo.sbarScale);
1203 int scaledSbarScreen = (int)(viewInfo.sbarScreen * viewInfo.sbarScale);
1204 int scaledSbarTotal = (int)(viewInfo.sbarTotal * viewInfo.sbarScale);
1205 const int offset =
1206 (int)(floor(0.5 + viewInfo.sbarScale * PixelWidthBeforeTime(0.0)));
1207
1208 mHsbar->SetScrollbar(scaledSbarH + offset, scaledSbarScreen, scaledSbarTotal,
1209 scaledSbarScreen, TRUE);
1210 }
1211
1212 // Vertical scrollbar
1213 mVsbar->SetScrollbar(viewInfo.vpos / viewInfo.scrollStep,
1214 panelHeight / viewInfo.scrollStep,
1215 totalHeight / viewInfo.scrollStep,
1216 panelHeight / viewInfo.scrollStep, TRUE);
1217
1218 if (refresh || (rescroll &&
1219 (viewInfo.GetScreenEndTime() - viewInfo.h) < viewInfo.total)) {
1220 trackPanel.Refresh(false);
1221 }
1222
1223 MenuManager::Get( project ).UpdateMenus();
1224
1225 if (oldhstate != newhstate || oldvstate != newvstate) {
1226 UpdateLayout();
1227 }
1228}
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:69
void UpdateMenus(bool checkActive=true)
Definition: Menus.cpp:575
double PixelWidthBeforeTime(double scrollto) const
bool mbInitializingScrollbar
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:225
static int GetTotalHeight(const TrackList &list)
Definition: TrackView.cpp:47

References ProjectWindowBase::FindProject(), ViewInfo::Get(), TrackList::Get(), MenuManager::Get(), GetProjectPanel(), TrackView::GetTotalHeight(), MayScrollBeyondZero(), mbInitializingScrollbar, mHsbar, mVsbar, PixelWidthBeforeTime(), ScrollingLowerBoundTime(), UpdateLayout(), and MenuManager::UpdateMenus().

Referenced by HandleResize(), InitProjectWindow(), TP_RedrawScrollbars(), Zoom(), and ZoomBy().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [1/2]

ProjectWindow & ProjectWindow::Get ( AudacityProject project)
static

Definition at line 553 of file ProjectWindow.cpp.

554{
556}
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309

References ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), GetAttachedWindows(), and anonymous_namespace{ProjectWindow.cpp}::sProjectWindowKey.

Referenced by ProjectSelectionManager::AS_SetSnapTo(), anonymous_namespace{TrackMenus.cpp}::DoAlign(), CommandDispatch::DoAudacityCommand(), anonymous_namespace{SelectMenus.cpp}::DoBoundaryMove(), anonymous_namespace{ClipMenus.cpp}::DoClipLeftOrRight(), anonymous_namespace{ClipMenus.cpp}::DoCursorClipBoundary(), LOFImportFileHandle::doDurationAndScrollOffset(), LabelTrackView::DoEditLabels(), EffectUI::DoEffect(), anonymous_namespace{FileMenus.cpp}::DoImport(), DoImportMIDI(), LabelTrackView::DoKeyDown(), anonymous_namespace{TrackMenus.cpp}::DoMixAndRender(), anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), anonymous_namespace{TrackMenus.cpp}::DoPanTracks(), anonymous_namespace{EditMenus.cpp}::DoPasteNothingSelected(), anonymous_namespace{EditMenus.cpp}::DoPasteText(), TrackUtilities::DoRemoveTrack(), anonymous_namespace{ClipMenus.cpp}::DoSelectClip(), Get(), GetNextWindowPlacement(), anonymous_namespace{ViewMenus.cpp}::GetZoomOfPreset(), anonymous_namespace{ViewMenus.cpp}::GetZoomOfSelection(), RealtimeEffectPanel::HidePanel(), LabelTrackView::KeyDown(), cloud::ShareAudioToolbar::MakeShareAudioButton(), MixerBoard::MixerBoard(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), anonymous_namespace{TrackMenus.cpp}::MuteTracks(), ProjectManager::New(), anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame(), anonymous_namespace{BatchProcessDialog.cpp}::OnApplyMacroDirectlyByName(), ApplyMacroDialog::OnApplyToFiles(), MixerTrackCluster::OnButton_Mute(), MixerTrackCluster::OnButton_Solo(), anonymous_namespace{FileMenus.cpp}::OnClose(), ProjectManager::OnCloseWindow(), ViewActions::Handler::OnCollapseAllTracks(), SelectActions::Handler::OnCursorSelEnd(), SelectActions::Handler::OnCursorSelStart(), SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), anonymous_namespace{EditMenus.cpp}::OnCut(), anonymous_namespace{EditMenus.cpp}::OnDelete(), anonymous_namespace{EditMenus.cpp}::OnDisjoin(), anonymous_namespace{EditMenus.cpp}::OnDuplicate(), AudacityApp::OnExceptionInMainLoop(), ViewActions::Handler::OnExpandAllTracks(), ControlToolBar::OnFF(), ViewActions::Handler::OnGoSelEnd(), ViewActions::Handler::OnGoSelStart(), anonymous_namespace{FileMenus.cpp}::OnImportLabels(), anonymous_namespace{EditMenus.cpp}::OnJoin(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewStereoTrack(), anonymous_namespace{TimeTrackMenuItems.cpp}::OnNewTimeTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::OnNewWaveTrack(), anonymous_namespace{EditMenus.cpp}::OnPaste(), CommandHandler::OnReceiveCommand(), ProjectManager::OnReconnectionFailure(), anonymous_namespace{EditMenus.cpp}::OnRedo(), anonymous_namespace{TrackMenus.cpp}::OnResample(), OnResetWindow(), ControlToolBar::OnRewind(), LabelDialog::OnSelectCell(), SelectActions::Handler::OnSelectionRestore(), SelectActions::Handler::OnSelToEnd(), SelectActions::Handler::OnSelToStart(), ScreenshotBigDialog::OnShortTracks(), anonymous_namespace{EditMenus.cpp}::OnSplitCut(), anonymous_namespace{EditMenus.cpp}::OnSplitDelete(), anonymous_namespace{EditMenus.cpp}::OnSplitNew(), ProjectWindow::PlaybackScroller::OnTimer(), PlayIndicatorOverlay::OnTimer(), SelectHandle::TimerHandler::OnTimer(), TrackPanel::OnTimer(), anonymous_namespace{TimerRecordDialog.cpp}::OnTimerRecord(), ToolsToolBar::OnToolChanged(), anonymous_namespace{EditMenus.cpp}::OnTrim(), anonymous_namespace{EditMenus.cpp}::OnUndo(), ViewActions::Handler::OnZoomFit(), ViewActions::Handler::OnZoomFitV(), ViewActions::Handler::OnZoomIn(), ViewActions::Handler::OnZoomNormal(), ViewActions::Handler::OnZoomOut(), ViewActions::Handler::OnZoomSel(), ViewActions::Handler::OnZoomToggle(), ProjectFileManager::OpenFile(), ProjectManager::OpenProject(), ProjectFileManager::OpenProjectFile(), PlayIndicatorOverlay::PlayIndicatorOverlay(), ProjectManager::ProjectManager(), ProjectManager::SaveWindowSize(), ScrubbingOverlay::ScrubbingOverlay(), ScrubForwarder::ScrubForwarder(), anonymous_namespace{SelectMenus.cpp}::SeekWhenAudioInactive(), RealtimeEffectStateUI::Show(), RealtimeEffectPanel::ShowPanel(), ScreenshotBigDialog::SizeTracks(), ProjectSelectionManager::SnapSelection(), ControlToolBar::StartScrolling(), ControlToolBar::StartScrollingIfPreferred(), ControlToolBar::StopScrolling(), SelectHandle::TimerHandler::TimerHandler(), ScreenshotBigDialog::TimeZoom(), and TrackPanel::TrackPanel().

Here is the call graph for this function:

◆ Get() [2/2]

const ProjectWindow & ProjectWindow::Get ( const AudacityProject project)
static

Definition at line 558 of file ProjectWindow.cpp.

559{
560 return Get( const_cast< AudacityProject & >( project ) );
561}
static ProjectWindow & Get(AudacityProject &project)

References Get().

Here is the call graph for this function:

◆ GetContainerWindow()

wxSplitterWindow * ProjectWindow::GetContainerWindow ( )
noexcept

Container is a parent window for both effects panel and track list windows.

Returns
Pointer to a container window (not null)

Definition at line 1304 of file ProjectWindow.cpp.

1305{
1306 return mContainerWindow;
1307}

References mContainerWindow.

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetHorizontalScrollBar()

wxScrollBar & ProjectWindow::GetHorizontalScrollBar ( )
inline

Definition at line 139 of file ProjectWindow.h.

139{ return *mHsbar; }

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetNormalizedWindowState()

wxRect ProjectWindow::GetNormalizedWindowState ( ) const
inline

Definition at line 122 of file ProjectWindow.h.

122{ return mNormalizedWindowState; }
wxRect mNormalizedWindowState

Referenced by ProjectManager::SaveWindowSize().

Here is the caller graph for this function:

◆ GetPlaybackScroller()

PlaybackScroller & ProjectWindow::GetPlaybackScroller ( )
inline

Definition at line 119 of file ProjectWindow.h.

119{ return *mPlaybackScroller; }

Referenced by MixerBoard::MixerBoard(), PlayIndicatorOverlay::PlayIndicatorOverlay(), ScrubbingOverlay::ScrubbingOverlay(), ControlToolBar::StartScrolling(), ControlToolBar::StartScrollingIfPreferred(), ControlToolBar::StopScrolling(), and SelectHandle::TimerHandler::TimerHandler().

Here is the caller graph for this function:

◆ GetTopPanel()

wxPanel * ProjectWindow::GetTopPanel ( )
noexcept

Top panel contains project-related controls and tools.

Returns
Pointer to a top panel window (not null)

Definition at line 1309 of file ProjectWindow.cpp.

1310{
1311 return mTopPanel;
1312}

References mTopPanel.

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetTPTracksUsableArea()

wxSize ProjectWindow::GetTPTracksUsableArea ( )

◆ GetTrackListWindow()

wxWindow * ProjectWindow::GetTrackListWindow ( )
noexcept

Track list window is the parent container for TrackPanel.

Returns
Pointer to a track list window (not null)

Definition at line 1299 of file ProjectWindow.cpp.

1300{
1301 return mTrackListWindow;
1302}

References mTrackListWindow.

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetVerticalScrollBar()

wxScrollBar & ProjectWindow::GetVerticalScrollBar ( )
inline

Definition at line 138 of file ProjectWindow.h.

138{ return *mVsbar; }

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetZoomOfToFit()

double ProjectWindow::GetZoomOfToFit ( ) const

Definition at line 1948 of file ProjectWindow.cpp.

1949{
1950 auto pProject = FindProject();
1951 if (!pProject)
1952 return 1.0;
1953 auto &project = *pProject;
1954 auto &tracks = TrackList::Get( project );
1955 auto &viewInfo = ViewInfo::Get( project );
1956
1957 const double end = tracks.GetEndTime();
1958 const double start = viewInfo.bScrollBeyondZero
1959 ? std::min( tracks.GetStartTime(), 0.0)
1960 : 0;
1961 const double len = end - start;
1962
1963 if (len <= 0.0)
1964 return viewInfo.GetZoom();
1965
1966 auto w = viewInfo.GetTracksUsableWidth();
1967 w -= 10;
1968 return w/len;
1969}
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), ProjectWindowBase::FindProject(), ViewInfo::Get(), TrackList::Get(), and min().

Here is the call graph for this function:

◆ HandleResize()

void ProjectWindow::HandleResize ( )

Definition at line 1274 of file ProjectWindow.cpp.

1275{
1276 // Activate events can fire during window teardown, so just
1277 // ignore them.
1278 if (mIsDeleting) {
1279 return;
1280 }
1281
1282 CallAfter( [this]{
1283
1284 if (mIsDeleting)
1285 return;
1286
1287 FixScrollbars();
1288 UpdateLayout();
1289
1290 });
1291}
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:206

References BasicUI::CallAfter(), FixScrollbars(), mIsDeleting, and UpdateLayout().

Referenced by OnSize(), OnToolBarUpdate(), OnUndoRedo(), OnUndoReset(), and TP_HandleResize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsActive()

bool ProjectWindow::IsActive ( )
override

Definition at line 1646 of file ProjectWindow.cpp.

1647{
1648 return mActive;
1649}

References mActive.

◆ IsBeingDeleted()

bool ProjectWindow::IsBeingDeleted ( ) const
inline

Definition at line 62 of file ProjectWindow.h.

62{ return mIsDeleting; }

Referenced by OnActivate().

Here is the caller graph for this function:

◆ IsIconized()

bool ProjectWindow::IsIconized ( ) const
override

Definition at line 1294 of file ProjectWindow.cpp.

1295{
1296 return mIconized;
1297}

References mIconized.

Referenced by GetNextWindowPlacement(), OnMove(), and OnSize().

Here is the caller graph for this function:

◆ MacShowUndockedToolbars()

void ProjectWindow::MacShowUndockedToolbars ( bool  show)

Definition at line 1353 of file ProjectWindow.cpp.

1354{
1355 (void)show;//compiler food
1356#ifdef __WXMAC__
1357 // Save the focus so we can restore it to whatever had it before since
1358 // showing a previously hidden toolbar will cause the focus to be set to
1359 // its frame. If this is not done it will appear that activation events
1360 // aren't being sent to the project window since they are actually being
1361 // delivered to the last tool frame shown.
1362 wxWindow *focused = FindFocus();
1363
1364 // Find all the floating toolbars, and show or hide them
1365 const auto &children = GetChildren();
1366 for(const auto &child : children) {
1367 if (auto frame = dynamic_cast<ToolFrame*>(child)) {
1368 if (!show) {
1369 frame->Hide();
1370 }
1371 else if (frame->GetBar() &&
1372 frame->GetBar()->IsVisible() ) {
1373 frame->Show();
1374 }
1375 }
1376 }
1377
1378 // Restore the focus if needed
1379 if (focused) {
1380 focused->SetFocus();
1381 }
1382#endif
1383}
class ToolFrame
Definition: ToolManager.h:190

Referenced by OnIconize().

Here is the caller graph for this function:

◆ MayScrollBeyondZero()

bool ProjectWindow::MayScrollBeyondZero ( ) const

Definition at line 952 of file ProjectWindow.cpp.

953{
954 auto pProject = FindProject();
955 if (!pProject)
956 return false;
957 auto &project = *pProject;
958 auto &scrubber = Scrubber::Get( project );
959 auto &viewInfo = ViewInfo::Get( project );
960 if (viewInfo.bScrollBeyondZero)
961 return true;
962
963 if (scrubber.HasMark() ||
964 ProjectAudioIO::Get( project ).IsAudioActive()) {
965 if (mPlaybackScroller) {
966 auto mode = mPlaybackScroller->GetMode();
967 if (mode == PlaybackScroller::Mode::Pinned ||
969 return true;
970 }
971 }
972
973 return false;
974}
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:187

References ProjectWindowBase::FindProject(), ProjectAudioIO::Get(), ViewInfo::Get(), Scrubber::Get(), ProjectAudioIO::IsAudioActive(), mPlaybackScroller, ProjectWindow::PlaybackScroller::Pinned, and ProjectWindow::PlaybackScroller::Right.

Referenced by DoScroll(), FixScrollbars(), ProjectWindow::PlaybackScroller::OnTimer(), and ScrollingLowerBoundTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextWindowID()

int ProjectWindow::NextWindowID ( )

Definition at line 583 of file ProjectWindow.cpp.

584{
585 return mNextWindowID++;
586}

References mNextWindowID.

◆ OnActivate()

void ProjectWindow::OnActivate ( wxActivateEvent &  event)

Definition at line 1611 of file ProjectWindow.cpp.

1612{
1613 // Activate events can fire during window teardown, so just
1614 // ignore them.
1615 if (IsBeingDeleted()) {
1616 return;
1617 }
1618
1619 auto pProject = FindProject();
1620 if (!pProject)
1621 return;
1622 auto &project = *pProject;
1623
1624 mActive = event.GetActive();
1625
1626 // Under Windows, focus can be "lost" when returning to
1627 // Audacity from a different application.
1628 //
1629 // This was observed by minimizing all windows using WINDOWS+M and
1630 // then ALT+TAB to return to Audacity. Focus will be given to the
1631 // project window frame which is not at all useful.
1632 //
1633 // So, we use ToolManager's observation of focus changes in a wxEventFilter.
1634 // Then, when we receive the
1635 // activate event, we restore that focus to the child or the track
1636 // panel if no child had the focus (which probably should never happen).
1637 if (mActive) {
1638 auto &toolManager = ToolManager::Get( project );
1639 SetActiveProject( &project );
1640 if ( ! toolManager.RestoreFocus() )
1641 GetProjectPanel( project ).SetFocus();
1642 }
1643 event.Skip();
1644}
void SetActiveProject(AudacityProject *project)
bool IsBeingDeleted() const
Definition: ProjectWindow.h:62
static ToolManager & Get(AudacityProject &project)

References ProjectWindowBase::FindProject(), ToolManager::Get(), GetProjectPanel(), IsBeingDeleted(), mActive, and SetActiveProject().

Here is the call graph for this function:

◆ OnIconize()

void ProjectWindow::OnIconize ( wxIconizeEvent &  event)

Definition at line 1385 of file ProjectWindow.cpp.

1386{
1387 //JKC: On Iconizing we get called twice. Don't know
1388 // why but it does no harm.
1389 // Should we be returning true/false rather than
1390 // void return? I don't know.
1391 mIconized = event.IsIconized();
1392
1393#if defined(__WXMAC__)
1394 // Readdresses bug 1431 since a crash could occur when restoring iconized
1395 // floating toolbars due to recursion (bug 2411).
1397 if( !mIconized )
1398 {
1399 Raise();
1400 }
1401#endif
1402
1403 // VisibileProjectCount seems to be just a counter for debugging.
1404 // It's not used outside this function.
1405 auto VisibleProjectCount = std::count_if(
1407 []( const AllProjects::value_type &ptr ){
1408 return !GetProjectFrame( *ptr ).IsIconized();
1409 }
1410 );
1411 event.Skip();
1412
1413 // This step is to fix part of Bug 2040, where the BackingPanel
1414 // size was not restored after we leave Iconized state.
1415
1416 // Queue up a resize event using OnShow so that we
1417 // refresh the track panel. But skip this, if we're iconized.
1418 if( mIconized )
1419 return;
1420 wxShowEvent Evt;
1421 OnShow( Evt );
1422}
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
const_iterator end() const
Definition: Project.cpp:27
Container::value_type value_type
Definition: Project.h:57
const_iterator begin() const
Definition: Project.cpp:22
void OnShow(wxShowEvent &event)
void MacShowUndockedToolbars(bool show)

References AllProjects::begin(), AllProjects::end(), GetProjectFrame(), MacShowUndockedToolbars(), mIconized, and OnShow().

Here is the call graph for this function:

◆ OnMenu()

void ProjectWindow::OnMenu ( wxCommandEvent &  event)

Definition at line 1570 of file ProjectWindow.cpp.

1571{
1572#ifdef __WXMSW__
1573 // Bug 1642: We can arrive here with bogus menu IDs, which we
1574 // proceed to process. So if bogus, don't.
1575 // The bogus menu IDs are probably generated by controls on the TrackPanel,
1576 // such as the Project Rate.
1577 // 17000 is the magic number at which we start our menu.
1578 // This code would probably NOT be OK on Mac, since we assign
1579 // some specific ID numbers.
1580 if( event.GetId() < 17000){
1581 event.Skip();
1582 return;
1583 }
1584#endif
1585 auto pProject = FindProject();
1586 if (!pProject)
1587 return;
1588 auto &project = *pProject;
1589 auto &commandManager = CommandManager::Get( project );
1590 bool handled = commandManager.HandleMenuID( project,
1591 event.GetId(), MenuManager::Get( project ).GetUpdateFlags(),
1592 false);
1593
1594 if (handled)
1595 event.Skip(false);
1596 else{
1597 event.ResumePropagation( 999 );
1598 event.Skip(true);
1599 }
1600}
static CommandManager & Get(AudacityProject &project)
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:533

References ProjectWindowBase::FindProject(), CommandManager::Get(), MenuManager::Get(), and MenuManager::GetUpdateFlags().

Here is the call graph for this function:

◆ OnMouseEvent()

void ProjectWindow::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1651 of file ProjectWindow.cpp.

1652{
1653 auto pProject = FindProject();
1654 if (!pProject)
1655 return;
1656 auto &project = *pProject;
1657 if (event.ButtonDown())
1658 SetActiveProject( &project );
1659}

References ProjectWindowBase::FindProject(), and SetActiveProject().

Here is the call graph for this function:

◆ OnMove()

void ProjectWindow::OnMove ( wxMoveEvent &  event)

Definition at line 1424 of file ProjectWindow.cpp.

1425{
1426 if (!this->IsMaximized() && !this->IsIconized())
1427 SetNormalizedWindowState(this->GetRect());
1428 event.Skip();
1429}
void SetNormalizedWindowState(wxRect pSizeAndLocation)
bool IsIconized() const override

References IsIconized(), and SetNormalizedWindowState().

Here is the call graph for this function:

◆ OnResetWindow()

void ProjectWindow::OnResetWindow ( const CommandContext context)
static

Definition at line 575 of file ProjectWindow.cpp.

576{
577 auto& project = context.project;
578 auto& window = ProjectWindow::Get(project);
579
580 window.Reset();
581}
AudacityProject & project

References Get(), and CommandContext::project.

Referenced by anonymous_namespace{PluginMenus.cpp}::OnResetConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScroll()

void ProjectWindow::OnScroll ( wxScrollEvent &  event)

Definition at line 1513 of file ProjectWindow.cpp.

1514{
1515 auto pProject = FindProject();
1516 if (!pProject)
1517 return;
1518 auto &project = *pProject;
1519 auto &viewInfo = ViewInfo::Get( project );
1520 const wxInt64 offset = PixelWidthBeforeTime(0.0);
1521 viewInfo.sbarH =
1522 (wxInt64)(mHsbar->GetThumbPosition() / viewInfo.sbarScale) - offset;
1523 DoScroll();
1524
1525#ifndef __WXMAC__
1526 // Bug2179
1527 // This keeps the time ruler in sync with horizontal scrolling, without
1528 // making an undesirable compilation dependency of this source file on
1529 // the ruler
1530 wxTheApp->ProcessIdle();
1531#endif
1532}

References DoScroll(), ProjectWindowBase::FindProject(), ViewInfo::Get(), mHsbar, and PixelWidthBeforeTime().

Here is the call graph for this function:

◆ OnScrollLeft()

void ProjectWindow::OnScrollLeft ( )

This method handles general left-scrolling, either for drag-scrolling or when the scrollbar is clicked to the left of the thumb

Definition at line 849 of file ProjectWindow.cpp.

850{
851 auto pProject = FindProject();
852 if (!pProject)
853 return;
854 auto &project = *pProject;
855 auto &viewInfo = ViewInfo::Get( project );
856 wxInt64 pos = mHsbar->GetThumbPosition();
857 // move at least one scroll increment
858 pos -= wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
859 pos = wxMax(pos, 0);
860 viewInfo.sbarH -= sbarHjump;
861 viewInfo.sbarH = std::max(viewInfo.sbarH,
862 -(wxInt64) PixelWidthBeforeTime(0.0));
863
864
865 if (pos != mHsbar->GetThumbPosition()) {
866 mHsbar->SetThumbPosition((int)pos);
868 }
869}
const int sbarHjump
void FinishAutoScroll()

References ProjectWindowBase::FindProject(), FinishAutoScroll(), ViewInfo::Get(), mHsbar, PixelWidthBeforeTime(), and sbarHjump.

Referenced by TP_ScrollLeft().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScrollLeftButton()

void ProjectWindow::OnScrollLeftButton ( wxScrollEvent &  event)

This handles the event when the left direction button on the scrollbar is depressed

Definition at line 903 of file ProjectWindow.cpp.

904{
905 auto pProject = FindProject();
906 if (!pProject)
907 return;
908 auto &project = *pProject;
909 auto &viewInfo = ViewInfo::Get( project );
910 wxInt64 pos = mHsbar->GetThumbPosition();
911 // move at least one scroll increment
912 pos -= wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
913 pos = wxMax(pos, 0);
914 viewInfo.sbarH -= sbarHjump;
915 viewInfo.sbarH = std::max(viewInfo.sbarH,
916 - (wxInt64) PixelWidthBeforeTime(0.0));
917
918 if (pos != mHsbar->GetThumbPosition()) {
919 mHsbar->SetThumbPosition((int)pos);
920 DoScroll();
921 }
922}

References DoScroll(), ProjectWindowBase::FindProject(), ViewInfo::Get(), mHsbar, PixelWidthBeforeTime(), and sbarHjump.

Here is the call graph for this function:

◆ OnScrollRight()

void ProjectWindow::OnScrollRight ( )

This method handles general right-scrolling, either for drag-scrolling or when the scrollbar is clicked to the right of the thumb

Definition at line 875 of file ProjectWindow.cpp.

876{
877 auto pProject = FindProject();
878 if (!pProject)
879 return;
880 auto &project = *pProject;
881 auto &viewInfo = ViewInfo::Get( project );
882 wxInt64 pos = mHsbar->GetThumbPosition();
883 // move at least one scroll increment
884 // use wxInt64 for calculation to prevent temporary overflow
885 pos += wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
886 wxInt64 max = mHsbar->GetRange() - mHsbar->GetThumbSize();
887 pos = wxMin(pos, max);
888 viewInfo.sbarH += sbarHjump;
889 viewInfo.sbarH = std::min(viewInfo.sbarH,
890 viewInfo.sbarTotal
891 - (wxInt64) PixelWidthBeforeTime(0.0) - viewInfo.sbarScreen);
892
893 if (pos != mHsbar->GetThumbPosition()) {
894 mHsbar->SetThumbPosition((int)pos);
896 }
897}

References ProjectWindowBase::FindProject(), FinishAutoScroll(), ViewInfo::Get(), mHsbar, min(), PixelWidthBeforeTime(), and sbarHjump.

Referenced by TP_ScrollRight().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnScrollRightButton()

void ProjectWindow::OnScrollRightButton ( wxScrollEvent &  event)

This handles the event when the right direction button on the scrollbar is depressed

Definition at line 927 of file ProjectWindow.cpp.

928{
929 auto pProject = FindProject();
930 if (!pProject)
931 return;
932 auto &project = *pProject;
933 auto &viewInfo = ViewInfo::Get( project );
934 wxInt64 pos = mHsbar->GetThumbPosition();
935 // move at least one scroll increment
936 // use wxInt64 for calculation to prevent temporary overflow
937 pos += wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
938 wxInt64 max = mHsbar->GetRange() - mHsbar->GetThumbSize();
939 pos = wxMin(pos, max);
940 viewInfo.sbarH += sbarHjump;
941 viewInfo.sbarH = std::min(viewInfo.sbarH,
942 viewInfo.sbarTotal
943 - (wxInt64) PixelWidthBeforeTime(0.0) - viewInfo.sbarScreen);
944
945 if (pos != mHsbar->GetThumbPosition()) {
946 mHsbar->SetThumbPosition((int)pos);
947 DoScroll();
948 }
949}

References DoScroll(), ProjectWindowBase::FindProject(), ViewInfo::Get(), mHsbar, min(), PixelWidthBeforeTime(), and sbarHjump.

Here is the call graph for this function:

◆ OnShow()

void ProjectWindow::OnShow ( wxShowEvent &  event)

Definition at line 1449 of file ProjectWindow.cpp.

1450{
1451 // Remember that the window has been shown at least once
1452 mShownOnce = true;
1453
1454 // (From Debian...see also TrackPanel::OnTimer and AudacityTimer::Notify)
1455 //
1456 // Description: Workaround for wxWidgets bug: Reentry in clipboard
1457 // The wxWidgets bug http://trac.wxwidgets.org/ticket/16636 prevents
1458 // us from doing clipboard operations in wxShowEvent and wxTimerEvent
1459 // processing because those event could possibly be processed during
1460 // the (not sufficiently protected) Yield() of a first clipboard
1461 // operation, causing reentry. Audacity had a workaround in place
1462 // for this problem (the class "CaptureEvents"), which however isn't
1463 // applicable with wxWidgets 3.0 because it's based on changing the
1464 // gdk event handler, a change that would be overridden by wxWidgets's
1465 // own gdk event handler change.
1466 // Instead, as a NEW workaround, specifically protect those processings
1467 // of wxShowEvent and wxTimerEvent that try to do clipboard operations
1468 // from being executed within Yield(). This is done by delaying their
1469 // execution by posting pure wxWidgets events - which are never executed
1470 // during Yield().
1471 // Author: Martin Stegh fer <[email protected]>
1472 // Bug-Debian: https://bugs.debian.org/765341
1473
1474 // the actual creation/showing of the window).
1475 // Post the event instead of calling OnSize(..) directly. This ensures that
1476 // this is a pure wxWidgets event (no GDK event behind it) and that it
1477 // therefore isn't processed within the YieldFor(..) of the clipboard
1478 // operations (workaround for Debian bug #765341).
1479 // QueueEvent() will take ownership of the event
1480 GetEventHandler()->QueueEvent(safenew wxSizeEvent(GetSize()));
1481
1482 // Further processing by default handlers
1483 event.Skip();
1484}

References mShownOnce, and safenew.

Referenced by OnIconize().

Here is the caller graph for this function:

◆ OnSize()

void ProjectWindow::OnSize ( wxSizeEvent &  event)

Definition at line 1431 of file ProjectWindow.cpp.

1432{
1433 // (From Debian)
1434 //
1435 // (3.) GTK critical warning "IA__gdk_window_get_origin: assertion
1436 // 'GDK_IS_WINDOW (window)' failed": Received events of type wxSizeEvent
1437 // on the main project window cause calls to "ClientToScreen" - which is
1438 // not available until the window is first shown. So the class has to
1439 // keep track of wxShowEvent events and inhibit those actions until the
1440 // window is first shown.
1441 if (mShownOnce) {
1442 HandleResize();
1443 if (!this->IsMaximized() && !this->IsIconized())
1444 SetNormalizedWindowState(this->GetRect());
1445 }
1446 event.Skip();
1447}

References HandleResize(), IsIconized(), mShownOnce, and SetNormalizedWindowState().

Here is the call graph for this function:

◆ OnThemeChange()

void ProjectWindow::OnThemeChange ( struct ThemeChangeMessage  message)
private

Definition at line 762 of file ProjectWindow.cpp.

763{
764 auto pProject = FindProject();
765 if (!pProject)
766 return;
767 auto &project = *pProject;
768
769 if (message.appearance)
770 return;
771 this->ApplyUpdatedTheme();
772 auto &toolManager = ToolManager::Get( project );
773 toolManager.ForEach([](auto pToolBar){
774 if( pToolBar )
775 pToolBar->ReCreateButtons();
776 });
777}
void ApplyUpdatedTheme()
std::optional< PreferredSystemAppearance > appearance
Definition: Theme.h:112

References ThemeChangeMessage::appearance, ApplyUpdatedTheme(), ProjectWindowBase::FindProject(), and ToolManager::Get().

Referenced by ProjectWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnToolBarUpdate()

void ProjectWindow::OnToolBarUpdate ( wxCommandEvent &  event)

A toolbar has been updated, so handle it like a sizing event.

Definition at line 1489 of file ProjectWindow.cpp.

1490{
1491 HandleResize();
1492
1493 event.Skip(false); /* No need to propagate any further */
1494}

References HandleResize().

Here is the call graph for this function:

◆ OnUndoPushedModified()

void ProjectWindow::OnUndoPushedModified ( )

Definition at line 1496 of file ProjectWindow.cpp.

1497{
1498 RedrawProject();
1499}
void RedrawProject(const bool bForceWaveTracks=false)

References RedrawProject().

Here is the call graph for this function:

◆ OnUndoRedo()

void ProjectWindow::OnUndoRedo ( )

Definition at line 1501 of file ProjectWindow.cpp.

1502{
1503 HandleResize();
1504 RedrawProject();
1505}

References HandleResize(), and RedrawProject().

Here is the call graph for this function:

◆ OnUndoReset()

void ProjectWindow::OnUndoReset ( )

Definition at line 1507 of file ProjectWindow.cpp.

1508{
1509 HandleResize();
1510 // RedrawProject(); // Should we do this here too?
1511}

References HandleResize().

Here is the call graph for this function:

◆ OnUpdateUI()

void ProjectWindow::OnUpdateUI ( wxUpdateUIEvent &  event)

Definition at line 1602 of file ProjectWindow.cpp.

1603{
1604 auto pProject = FindProject();
1605 if (!pProject)
1606 return;
1607 auto &project = *pProject;
1608 MenuManager::Get( project ).UpdateMenus();
1609}

References ProjectWindowBase::FindProject(), MenuManager::Get(), and MenuManager::UpdateMenus().

Here is the call graph for this function:

◆ PixelWidthBeforeTime()

double ProjectWindow::PixelWidthBeforeTime ( double  scrollto) const

Definition at line 992 of file ProjectWindow.cpp.

993{
994 auto pProject = FindProject();
995 if (!pProject)
996 return 0;
997 auto &project = *pProject;
998 auto &viewInfo = ViewInfo::Get( project );
999 const double lowerBound = ScrollingLowerBoundTime();
1000 return
1001 // Ignoring fisheye is correct here
1002 viewInfo.TimeRangeToPixelWidth(scrollto - lowerBound);
1003}

References ProjectWindowBase::FindProject(), ViewInfo::Get(), and ScrollingLowerBoundTime().

Referenced by FixScrollbars(), OnScroll(), OnScrollLeft(), OnScrollLeftButton(), OnScrollRight(), OnScrollRightButton(), and SetHorizontalThumb().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RedrawProject()

void ProjectWindow::RedrawProject ( const bool  bForceWaveTracks = false)

Definition at line 733 of file ProjectWindow.cpp.

734{
735 auto pThis = wxWeakRef<ProjectWindow>(this);
736 CallAfter( [pThis, bForceWaveTracks]{
737
738 if (!pThis)
739 return;
740 if (pThis->IsBeingDeleted())
741 return;
742
743 auto pProject = pThis->FindProject();
744 if (!pProject)
745 return;
746
747 auto &project = *pProject;
748 auto &tracks = TrackList::Get( project );
749 auto &trackPanel = GetProjectPanel( project );
750 pThis->FixScrollbars();
751 if (bForceWaveTracks)
752 {
753 for ( auto pWaveTrack : tracks.Any< WaveTrack >() )
754 for (const auto &clip: pWaveTrack->GetClips())
755 clip->MarkChanged();
756 }
757 trackPanel.Refresh(false);
758
759 });
760}
A Track that contains audio waveform data.
Definition: WaveTrack.h:57

References BasicUI::CallAfter(), TrackList::Get(), and GetProjectPanel().

Referenced by MixerTrackCluster::OnButton_Mute(), MixerTrackCluster::OnButton_Solo(), AudacityApp::OnExceptionInMainLoop(), CommandHandler::OnReceiveCommand(), LabelDialog::OnSelectCell(), ScreenshotBigDialog::OnShortTracks(), ToolsToolBar::OnToolChanged(), OnUndoPushedModified(), OnUndoRedo(), and ScreenshotBigDialog::SizeTracks().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RefreshTPTrack()

void ProjectWindow::RefreshTPTrack ( Track pTrk,
bool  refreshbacking = true 
)

◆ Reset()

void ProjectWindow::Reset ( )

Definition at line 1314 of file ProjectWindow.cpp.

1315{
1316 wxRect defaultRect;
1317 GetDefaultWindowRect(&defaultRect);
1318
1319 SetSize(defaultRect.width, defaultRect.height);
1320}
void GetDefaultWindowRect(wxRect *defRect)

References GetDefaultWindowRect().

Here is the call graph for this function:

◆ Rewind()

void ProjectWindow::Rewind ( bool  shift)

Definition at line 1725 of file ProjectWindow.cpp.

1726{
1727 auto pProject = FindProject();
1728 if (!pProject)
1729 return;
1730 auto &project = *pProject;
1731 auto &viewInfo = ViewInfo::Get( project );
1732 viewInfo.selectedRegion.setT0(0, false);
1733 if (!shift)
1734 viewInfo.selectedRegion.setT1(0);
1735
1736 TP_ScrollWindow(0);
1737}
void TP_ScrollWindow(double scrollto) override

References ProjectWindowBase::FindProject(), ViewInfo::Get(), and TP_ScrollWindow().

Referenced by ControlToolBar::OnRewind().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScrollingLowerBoundTime()

double ProjectWindow::ScrollingLowerBoundTime ( ) const

Definition at line 976 of file ProjectWindow.cpp.

977{
978 auto pProject = FindProject();
979 if (!pProject)
980 return 0;
981 auto &project = *pProject;
982 auto &tracks = TrackList::Get( project );
983 auto &viewInfo = ViewInfo::Get( project );
984 if (!MayScrollBeyondZero())
985 return 0;
986 const double screen = viewInfo.GetScreenEndTime() - viewInfo.h;
987 return std::min(tracks.GetStartTime(), -screen);
988}

References ProjectWindowBase::FindProject(), ViewInfo::Get(), TrackList::Get(), MayScrollBeyondZero(), and min().

Referenced by DoScroll(), FixScrollbars(), and PixelWidthBeforeTime().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScrollIntoView() [1/2]

void ProjectWindow::ScrollIntoView ( double  pos)

Definition at line 816 of file ProjectWindow.cpp.

817{
818 auto pProject = FindProject();
819 if (!pProject)
820 return;
821 auto &project = *pProject;
822 auto &trackPanel = GetProjectPanel( project );
823 auto &viewInfo = ViewInfo::Get( project );
824 auto w = viewInfo.GetTracksUsableWidth();
825
826 int pixel = viewInfo.TimeToPosition(pos);
827 if (pixel < 0 || pixel >= w)
828 {
830 (viewInfo.OffsetTimeByPixels(pos, -(w / 2)));
831 trackPanel.Refresh(false);
832 }
833}

References ProjectWindowBase::FindProject(), ViewInfo::Get(), GetProjectPanel(), and TP_ScrollWindow().

Referenced by LabelTrackView::DoKeyDown(), LabelTrackView::KeyDown(), ScrollIntoView(), SkipEnd(), and ZoomInByFactor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ScrollIntoView() [2/2]

void ProjectWindow::ScrollIntoView ( int  x)

Definition at line 835 of file ProjectWindow.cpp.

836{
837 auto pProject = FindProject();
838 if (!pProject)
839 return;
840 auto &project = *pProject;
841 auto &viewInfo = ViewInfo::Get( project );
842 ScrollIntoView(viewInfo.PositionToTime(x, viewInfo.GetLeftOffset()));
843}
void ScrollIntoView(double pos)

References ProjectWindowBase::FindProject(), ViewInfo::Get(), and ScrollIntoView().

Here is the call graph for this function:

◆ SetHorizontalThumb()

void ProjectWindow::SetHorizontalThumb ( double  scrollto)

Definition at line 1005 of file ProjectWindow.cpp.

1006{
1007 auto pProject = FindProject();
1008 if (!pProject)
1009 return;
1010 auto &project = *pProject;
1011 auto &viewInfo = ViewInfo::Get( project );
1012 const auto unscaled = PixelWidthBeforeTime(scrollto);
1013 const int max = mHsbar->GetRange() - mHsbar->GetThumbSize();
1014 const int pos =
1015 std::min(max,
1016 std::max(0,
1017 (int)(floor(0.5 + unscaled * viewInfo.sbarScale))));
1018 mHsbar->SetThumbPosition(pos);
1019 viewInfo.sbarH = floor(0.5 + unscaled - PixelWidthBeforeTime(0.0));
1020 viewInfo.sbarH = std::max(viewInfo.sbarH,
1021 - (wxInt64) PixelWidthBeforeTime(0.0));
1022 viewInfo.sbarH = std::min(viewInfo.sbarH,
1023 viewInfo.sbarTotal
1024 - (wxInt64) PixelWidthBeforeTime(0.0) - viewInfo.sbarScreen);
1025}

References ProjectWindowBase::FindProject(), ViewInfo::Get(), mHsbar, min(), and PixelWidthBeforeTime().

Referenced by DoScroll(), and TP_ScrollWindow().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetIsBeingDeleted()

void ProjectWindow::SetIsBeingDeleted ( )
inline

Definition at line 63 of file ProjectWindow.h.

63{ mIsDeleting = true; }

◆ SetNormalizedWindowState()

void ProjectWindow::SetNormalizedWindowState ( wxRect  pSizeAndLocation)
inline

Definition at line 121 of file ProjectWindow.h.

121{ mNormalizedWindowState = pSizeAndLocation; }

Referenced by OnMove(), and OnSize().

Here is the caller graph for this function:

◆ SkipEnd()

void ProjectWindow::SkipEnd ( bool  shift)

Definition at line 1748 of file ProjectWindow.cpp.

1749{
1750 auto pProject = FindProject();
1751 if (!pProject)
1752 return;
1753 auto &project = *pProject;
1754 auto &tracks = TrackList::Get( project );
1755 auto &viewInfo = ViewInfo::Get( project );
1756 double len = tracks.GetEndTime();
1757
1758 viewInfo.selectedRegion.setT1(len, false);
1759 if (!shift)
1760 viewInfo.selectedRegion.setT0(len);
1761
1762 // Make sure the end of the track is visible
1763 ScrollIntoView(len);
1764}

References ProjectWindowBase::FindProject(), ViewInfo::Get(), TrackList::Get(), and ScrollIntoView().

Referenced by ControlToolBar::OnFF().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TP_HandleResize()

void ProjectWindow::TP_HandleResize ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1784 of file ProjectWindow.cpp.

1785{
1786 HandleResize();
1787}

References HandleResize().

Here is the call graph for this function:

◆ TP_RedrawScrollbars()

void ProjectWindow::TP_RedrawScrollbars ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1779 of file ProjectWindow.cpp.

1780{
1781 FixScrollbars();
1782}

References FixScrollbars().

Here is the call graph for this function:

◆ TP_ScrollLeft()

void ProjectWindow::TP_ScrollLeft ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1767 of file ProjectWindow.cpp.

1768{
1769 OnScrollLeft();
1770}

References OnScrollLeft().

Here is the call graph for this function:

◆ TP_ScrollRight()

void ProjectWindow::TP_ScrollRight ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1773 of file ProjectWindow.cpp.

1774{
1775 OnScrollRight();
1776}

References OnScrollRight().

Here is the call graph for this function:

◆ TP_ScrollUpDown()

bool ProjectWindow::TP_ScrollUpDown ( int  delta)
overridevirtual

Implements TrackPanelListener.

Definition at line 1045 of file ProjectWindow.cpp.

1046{
1047 int oldPos = mVsbar->GetThumbPosition();
1048 int pos = oldPos + delta;
1049 int max = mVsbar->GetRange() - mVsbar->GetThumbSize();
1050
1051 // Can be negative in case of only one track
1052 if (max < 0)
1053 max = 0;
1054
1055 if (pos > max)
1056 pos = max;
1057 else if (pos < 0)
1058 pos = 0;
1059
1060 if (pos != oldPos)
1061 {
1062 mVsbar->SetThumbPosition(pos);
1063
1064 DoScroll();
1065 return true;
1066 }
1067 else
1068 return false;
1069}

References DoScroll(), and mVsbar.

Here is the call graph for this function:

◆ TP_ScrollWindow()

void ProjectWindow::TP_ScrollWindow ( double  scrollto)
overridevirtual

Implements TrackPanelListener.

Definition at line 1031 of file ProjectWindow.cpp.

1032{
1033 SetHorizontalThumb(scrollto);
1034
1035 // Call our Scroll method which updates our ViewInfo variables
1036 // to reflect the positions of the scrollbars
1037 DoScroll();
1038}

References DoScroll(), and SetHorizontalThumb().

Referenced by LOFImportFileHandle::doDurationAndScrollOffset(), Rewind(), ScrollIntoView(), Zoom(), ZoomInByFactor(), and ZoomOutByFactor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdateLayout()

void ProjectWindow::UpdateLayout ( )

Definition at line 1230 of file ProjectWindow.cpp.

1231{
1232 auto pProject = FindProject();
1233 if (!pProject)
1234 return;
1235 auto &project = *pProject;
1236 auto &trackPanel = GetProjectPanel( project );
1237 auto &toolManager = ToolManager::Get( project );
1238
1239 // 1. Layout panel, to get widths of the docks.
1240 Layout();
1241 // 2. Layout toolbars to pack the toolbars correctly in docks which
1242 // are now the correct width.
1243 toolManager.LayoutToolBars();
1244 // 3. Layout panel, to resize docks, in particular reducing the height
1245 // of any empty docks, or increasing the height of docks that need it.
1246 Layout();
1247
1248 // Bug 2455
1249 // The commented out code below is to calculate a nice minimum size for
1250 // the window. However on Ubuntu when the window is minimised it leads to
1251 // an insanely tall window.
1252 // Using a fixed min size fixes that.
1253 // However there is still something strange when minimised, as once
1254 // UpdateLayout is called once, when minimised, it gets called repeatedly.
1255#if 0
1256 // Retrieve size of this projects window
1257 wxSize mainsz = GetSize();
1258
1259 // Retrieve position of the track panel to use as the size of the top
1260 // third of the window
1261 wxPoint tppos = ClientToScreen(trackPanel.GetParent()->GetPosition());
1262
1263 // Retrieve position of bottom dock to use as the size of the bottom
1264 // third of the window
1265 wxPoint sbpos = ClientToScreen(toolManager.GetBotDock()->GetPosition());
1266
1267 // The "+ 50" is the minimum height of the TrackPanel
1268 SetMinSize( wxSize(250, (mainsz.y - sbpos.y) + tppos.y + 50));
1269#endif
1270 SetMinSize( wxSize(250, 250));
1271 SetMaxSize( wxSize(20000, 20000));
1272}

References ProjectWindowBase::FindProject(), ToolManager::Get(), and GetProjectPanel().

Referenced by FixScrollbars(), and HandleResize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UpdatePrefs()

void ProjectWindow::UpdatePrefs ( )
overrideprivatevirtual

Implements PrefsListener.

Definition at line 779 of file ProjectWindow.cpp.

780{
781 // Update status bar widths in case of language change
783}
void UpdateStatusWidths()

References UpdateStatusWidths().

Here is the call graph for this function:

◆ UpdateStatusWidths()

void ProjectWindow::UpdateStatusWidths ( )

Definition at line 1322 of file ProjectWindow.cpp.

1323{
1324 auto pProject = FindProject();
1325 if (!pProject)
1326 return;
1327 auto &project = *pProject;
1328 enum { nWidths = nStatusBarFields + 1 };
1329 int widths[ nWidths ]{ 0 };
1330 widths[ rateStatusBarField ] = 150;
1331 const auto statusBar = GetStatusBar();
1332 const auto &functions = ProjectStatus::GetStatusWidthFunctions();
1333 // Start from 1 not 0
1334 // Specifying a first column always of width 0 was needed for reasons
1335 // I forget now
1336 for ( int ii = 1; ii <= nStatusBarFields; ++ii ) {
1337 int &width = widths[ ii ];
1338 for ( const auto &function : functions ) {
1339 auto results =
1340 function( project, static_cast< StatusBarField >( ii ) );
1341 for ( const auto &string : results.first ) {
1342 int w;
1343 statusBar->GetTextExtent(string.Translation(), &w, nullptr);
1344 width = std::max<int>( width, w + results.second );
1345 }
1346 }
1347 }
1348 // The main status field is not fixed width
1349 widths[ mainStatusBarField ] = -1;
1350 statusBar->SetStatusWidths( nWidths, widths );
1351}
StatusBarField
Definition: ProjectStatus.h:24
@ mainStatusBarField
Definition: ProjectStatus.h:26
@ nStatusBarFields
Definition: ProjectStatus.h:29
@ rateStatusBarField
Definition: ProjectStatus.h:27
static const StatusWidthFunctions & GetStatusWidthFunctions()

References ProjectWindowBase::FindProject(), ProjectStatus::GetStatusWidthFunctions(), mainStatusBarField, nStatusBarFields, and rateStatusBarField.

Referenced by InitProjectWindow(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Zoom()

void ProjectWindow::Zoom ( double  level)

Definition at line 1684 of file ProjectWindow.cpp.

1685{
1686 auto pProject = FindProject();
1687 if (!pProject)
1688 return;
1689 auto &project = *pProject;
1690 auto &viewInfo = ViewInfo::Get( project );
1691 viewInfo.SetZoom(level);
1692 FixScrollbars();
1693 // See if we can center the selection on screen, and have it actually fit.
1694 // tOnLeft is the amount of time we would need before the selection left edge to center it.
1695 float t0 = viewInfo.selectedRegion.t0();
1696 float t1 = viewInfo.selectedRegion.t1();
1697 float tAvailable = viewInfo.GetScreenEndTime() - viewInfo.h;
1698 float tOnLeft = (tAvailable - t0 + t1)/2.0;
1699 // Bug 1292 (Enh) is effectively a request to do this scrolling of the selection into view.
1700 // If tOnLeft is positive, then we have room for the selection, so scroll to it.
1701 if( tOnLeft >=0 )
1702 TP_ScrollWindow( t0-tOnLeft);
1703}

References ProjectWindowBase::FindProject(), FixScrollbars(), ViewInfo::Get(), and TP_ScrollWindow().

Here is the call graph for this function:

◆ ZoomAfterImport()

void ProjectWindow::ZoomAfterImport ( Track pTrack)

Definition at line 1661 of file ProjectWindow.cpp.

1662{
1663 auto pProject = FindProject();
1664 if (!pProject)
1665 return;
1666 auto &project = *pProject;
1667 auto &tracks = TrackList::Get( project );
1668 auto &trackPanel = GetProjectPanel( project );
1669
1670 DoZoomFit();
1671
1672 trackPanel.SetFocus();
1673 if (!pTrack)
1674 pTrack = *tracks.Selected().begin();
1675 if (!pTrack)
1676 pTrack = *tracks.Any().begin();
1677 if (pTrack) {
1678 TrackFocus::Get(project).Set(pTrack);
1679 pTrack->EnsureVisible();
1680 }
1681}
Track * Get()
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:97
bool Any() const
Definition: Track.cpp:399

References Track::Any(), DoZoomFit(), Track::EnsureVisible(), ProjectWindowBase::FindProject(), TrackFocus::Get(), TrackList::Get(), and GetProjectPanel().

Referenced by DoImportMIDI(), ApplyMacroDialog::OnApplyToFiles(), and ProjectFileManager::OpenFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZoomBy()

void ProjectWindow::ZoomBy ( double  multiplier)

Definition at line 1706 of file ProjectWindow.cpp.

1707{
1708 auto pProject = FindProject();
1709 if (!pProject)
1710 return;
1711 auto &project = *pProject;
1712 auto &viewInfo = ViewInfo::Get( project );
1713 viewInfo.ZoomBy(multiplier);
1714 FixScrollbars();
1715}

References ProjectWindowBase::FindProject(), FixScrollbars(), and ViewInfo::Get().

Referenced by LOFImportFileHandle::doDurationAndScrollOffset(), ZoomInByFactor(), and ZoomOutByFactor().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ZoomInByFactor()

void ProjectWindow::ZoomInByFactor ( double  ZoomFactor)

Definition at line 1845 of file ProjectWindow.cpp.

1846{
1847 auto pProject = FindProject();
1848 if (!pProject)
1849 return;
1850 auto &project = *pProject;
1851 auto &viewInfo = ViewInfo::Get( project );
1852
1853 auto gAudioIO = AudioIO::Get();
1854 // LLL: Handling positioning differently when audio is
1855 // actively playing. Don't do this if paused.
1856 if (gAudioIO->IsStreamActive(
1857 ProjectAudioIO::Get( project ).GetAudioIOToken()) &&
1858 !gAudioIO->IsPaused()){
1859 ZoomBy(ZoomFactor);
1860 ScrollIntoView(gAudioIO->GetStreamTime());
1861 return;
1862 }
1863
1864 // DMM: Here's my attempt to get logical zooming behavior
1865 // when there's a selection that's currently at least
1866 // partially on-screen
1867
1868 const double endTime = viewInfo.GetScreenEndTime();
1869 const double duration = endTime - viewInfo.h;
1870
1871 bool selectionIsOnscreen =
1872 (viewInfo.selectedRegion.t0() < endTime) &&
1873 (viewInfo.selectedRegion.t1() >= viewInfo.h);
1874
1875 bool selectionFillsScreen =
1876 (viewInfo.selectedRegion.t0() < viewInfo.h) &&
1877 (viewInfo.selectedRegion.t1() > endTime);
1878
1879 if (selectionIsOnscreen && !selectionFillsScreen) {
1880 // Start with the center of the selection
1881 double selCenter = (viewInfo.selectedRegion.t0() +
1882 viewInfo.selectedRegion.t1()) / 2;
1883
1884 // If the selection center is off-screen, pick the
1885 // center of the part that is on-screen.
1886 if (selCenter < viewInfo.h)
1887 selCenter = viewInfo.h +
1888 (viewInfo.selectedRegion.t1() - viewInfo.h) / 2;
1889 if (selCenter > endTime)
1890 selCenter = endTime -
1891 (endTime - viewInfo.selectedRegion.t0()) / 2;
1892
1893 // Zoom in
1894 ZoomBy(ZoomFactor);
1895 const double newDuration =
1896 viewInfo.GetScreenEndTime() - viewInfo.h;
1897
1898 // Recenter on selCenter
1899 TP_ScrollWindow(selCenter - newDuration / 2);
1900 return;
1901 }
1902
1903
1904 double origLeft = viewInfo.h;
1905 double origWidth = duration;
1906 ZoomBy(ZoomFactor);
1907
1908 const double newDuration =
1909 viewInfo.GetScreenEndTime() - viewInfo.h;
1910 double newh = origLeft + (origWidth - newDuration) / 2;
1911
1912 // MM: Commented this out because it was confusing users
1913 /*
1914 // make sure that the *right-hand* end of the selection is
1915 // no further *left* than 1/3 of the way across the screen
1916 if (viewInfo.selectedRegion.t1() < newh + viewInfo.screen / 3)
1917 newh = viewInfo.selectedRegion.t1() - viewInfo.screen / 3;
1918
1919 // make sure that the *left-hand* end of the selection is
1920 // no further *right* than 2/3 of the way across the screen
1921 if (viewInfo.selectedRegion.t0() > newh + viewInfo.screen * 2 / 3)
1922 newh = viewInfo.selectedRegion.t0() - viewInfo.screen * 2 / 3;
1923 */
1924
1925 TP_ScrollWindow(newh);
1926}
static AudioIO * Get()
Definition: AudioIO.cpp:147
int GetAudioIOToken() const
void ZoomBy(double multiplier)

References ProjectWindowBase::FindProject(), AudioIO::Get(), ProjectAudioIO::Get(), ViewInfo::Get(), ProjectAudioIO::GetAudioIOToken(), ScrollIntoView(), TP_ScrollWindow(), and ZoomBy().

Here is the call graph for this function:

◆ ZoomOutByFactor()

void ProjectWindow::ZoomOutByFactor ( double  ZoomFactor)

Definition at line 1928 of file ProjectWindow.cpp.

1929{
1930 auto pProject = FindProject();
1931 if (!pProject)
1932 return;
1933 auto &project = *pProject;
1934 auto &viewInfo = ViewInfo::Get( project );
1935
1936 //Zoom() may change these, so record original values:
1937 const double origLeft = viewInfo.h;
1938 const double origWidth = viewInfo.GetScreenEndTime() - origLeft;
1939
1940 ZoomBy(ZoomFactor);
1941 const double newWidth = viewInfo.GetScreenEndTime() - viewInfo.h;
1942
1943 const double newh = origLeft + (origWidth - newWidth) / 2;
1944 // newh = (newh > 0) ? newh : 0;
1945 TP_ScrollWindow(newh);
1946}

References ProjectWindowBase::FindProject(), ViewInfo::Get(), TP_ScrollWindow(), and ZoomBy().

Here is the call graph for this function:

Member Data Documentation

◆ mActive

bool ProjectWindow::mActive { true }
private

Definition at line 220 of file ProjectWindow.h.

Referenced by IsActive(), and OnActivate().

◆ mAutoScrolling

bool ProjectWindow::mAutoScrolling { false }
private

Definition at line 219 of file ProjectWindow.h.

Referenced by DoScroll(), and FinishAutoScroll().

◆ mbInitializingScrollbar

bool ProjectWindow::mbInitializingScrollbar { false }

Definition at line 205 of file ProjectWindow.h.

Referenced by FixScrollbars().

◆ mContainerWindow

wxSplitterWindow* ProjectWindow::mContainerWindow
private

Definition at line 211 of file ProjectWindow.h.

Referenced by GetContainerWindow(), and ProjectWindow().

◆ mHsbar

wxScrollBar* ProjectWindow::mHsbar {}
private

◆ mIconized

bool ProjectWindow::mIconized { false }
private

Definition at line 221 of file ProjectWindow.h.

Referenced by IsIconized(), and OnIconize().

◆ mIsDeleting

bool ProjectWindow::mIsDeleting { false }
private

Definition at line 226 of file ProjectWindow.h.

Referenced by HandleResize().

◆ mNextWindowID

int ProjectWindow::mNextWindowID {}
private

Definition at line 217 of file ProjectWindow.h.

Referenced by NextWindowID(), and ProjectWindow().

◆ mNormalizedWindowState

wxRect ProjectWindow::mNormalizedWindowState
private

Definition at line 208 of file ProjectWindow.h.

◆ mPlaybackScroller

std::unique_ptr<PlaybackScroller> ProjectWindow::mPlaybackScroller
private

Definition at line 232 of file ProjectWindow.h.

Referenced by MayScrollBeyondZero(), and ProjectWindow().

◆ mShownOnce

bool ProjectWindow::mShownOnce { false }
private

Definition at line 222 of file ProjectWindow.h.

Referenced by OnShow(), and OnSize().

◆ mThemeChangeSubscription

Observer::Subscription ProjectWindow::mThemeChangeSubscription
private

Definition at line 231 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mTopPanel

wxPanel* ProjectWindow::mTopPanel {}
private

Definition at line 210 of file ProjectWindow.h.

Referenced by GetTopPanel(), and ProjectWindow().

◆ mTrackListWindow

wxWindow* ProjectWindow::mTrackListWindow {}
private

Definition at line 212 of file ProjectWindow.h.

Referenced by GetTrackListWindow(), and ProjectWindow().

◆ mUndoSubscription

Observer::Subscription ProjectWindow::mUndoSubscription
private

Definition at line 230 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mVsbar

wxScrollBar* ProjectWindow::mVsbar {}
private

Definition at line 215 of file ProjectWindow.h.

Referenced by DoScroll(), FixScrollbars(), ProjectWindow(), and TP_ScrollUpDown().


The documentation for this class was generated from the following files: