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 ()
 
void OnProjectTitleChange (ProjectFileIOMessage)
 
- 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
 
Observer::Subscription mTitleChangeSubcription
 
Observer::Subscription mSnappingChangedSubscription
 
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 37 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 601 of file ProjectWindow.cpp.

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

References _, ThemeBase::Colour(), ProjectFileIO::Get(), UndoManager::Get(), ProjectSnap::Get(), HSBarID, mContainerWindow, mHsbar, mNextWindowID, mPlaybackScroller, mSnappingChangedSubscription, mThemeChangeSubscription, mTitleChangeSubcription, mTopPanel, mTrackListWindow, mUndoSubscription, mVsbar, NextID, OnProjectTitleChange(), OnThemeChange(), ProjectTitleChange, RedrawProject(), 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 713 of file ProjectWindow.cpp.

714{
715 // Tool manager gives us capture sometimes
716 if(HasCapture())
717 ReleaseMouse();
718}

Member Function Documentation

◆ ApplyUpdatedTheme()

void ProjectWindow::ApplyUpdatedTheme ( )

Definition at line 739 of file ProjectWindow.cpp.

740{
741 SetBackgroundColour(theTheme.Colour( clrMedium ));
742 ClearBackground();// For wxGTK.
743}

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 1561 of file ProjectWindow.cpp.

1562{
1563 auto pProject = FindProject();
1564 if (!pProject)
1565 return;
1566 auto &project = *pProject;
1567 auto &trackPanel = GetProjectPanel( project );
1568 auto &viewInfo = ViewInfo::Get( project );
1569 const double lowerBound = ScrollingLowerBoundTime();
1570
1571 auto width = viewInfo.GetTracksUsableWidth();
1572 viewInfo.SetBeforeScreenWidth(viewInfo.sbarH, width, lowerBound);
1573
1574
1575 if (MayScrollBeyondZero()) {
1576 enum { SCROLL_PIXEL_TOLERANCE = 10 };
1577 if (std::abs(viewInfo.TimeToPosition(0.0, 0
1578 )) < SCROLL_PIXEL_TOLERANCE) {
1579 // Snap the scrollbar to 0
1580 viewInfo.h = 0;
1581 SetHorizontalThumb(0.0);
1582 }
1583 }
1584
1585 viewInfo.vpos = mVsbar->GetThumbPosition() * viewInfo.scrollStep;
1586
1587 //mchinen: do not always set this project to be the active one.
1588 //a project may autoscroll while playing in the background
1589 //I think this is okay since OnMouseEvent has one of these.
1590 //SetActiveProject(this);
1591
1592 if (!mAutoScrolling) {
1593 trackPanel.Refresh(false);
1594 }
1595}
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:235

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 1998 of file ProjectWindow.cpp.

1999{
2000 auto pProject = FindProject();
2001 if (!pProject)
2002 return;
2003 auto &project = *pProject;
2004 auto &viewInfo = ViewInfo::Get( project );
2005 auto &tracks = TrackList::Get( project );
2006 auto &window = *this;
2007
2008 const double start = viewInfo.bScrollBeyondZero
2009 ? std::min(tracks.GetStartTime(), 0.0)
2010 : 0;
2011
2012 window.Zoom( window.GetZoomOfToFit() );
2013 window.TP_ScrollWindow(start);
2014}
int min(int a, int b)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:385

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 565 of file ProjectWindow.cpp.

566{
567 return pProject
569 : nullptr;
570}
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:41
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 572 of file ProjectWindow.cpp.

573{
574 return Find( const_cast< AudacityProject * >( pProject ) );
575}
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 797 of file ProjectWindow.cpp.

798{
799 // Set a flag so we don't have to generate two update events
800 mAutoScrolling = true;
801
802 // Call our Scroll method which updates our ViewInfo variables
803 // to reflect the positions of the scrollbars
804 DoScroll();
805
806 mAutoScrolling = false;
807}

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 1083 of file ProjectWindow.cpp.

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

556{
558}
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 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(), 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 560 of file ProjectWindow.cpp.

561{
562 return Get( const_cast< AudacityProject & >( project ) );
563}
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 1316 of file ProjectWindow.cpp.

1317{
1318 return mContainerWindow;
1319}

References mContainerWindow.

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetHorizontalScrollBar()

wxScrollBar & ProjectWindow::GetHorizontalScrollBar ( )
inline

Definition at line 140 of file ProjectWindow.h.

140{ return *mHsbar; }

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetNormalizedWindowState()

wxRect ProjectWindow::GetNormalizedWindowState ( ) const
inline

Definition at line 123 of file ProjectWindow.h.

123{ return mNormalizedWindowState; }
wxRect mNormalizedWindowState

Referenced by ProjectManager::SaveWindowSize().

Here is the caller graph for this function:

◆ GetPlaybackScroller()

PlaybackScroller & ProjectWindow::GetPlaybackScroller ( )
inline

Definition at line 120 of file ProjectWindow.h.

120{ 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 1321 of file ProjectWindow.cpp.

1322{
1323 return mTopPanel;
1324}

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 1311 of file ProjectWindow.cpp.

1312{
1313 return mTrackListWindow;
1314}

References mTrackListWindow.

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetVerticalScrollBar()

wxScrollBar & ProjectWindow::GetVerticalScrollBar ( )
inline

Definition at line 139 of file ProjectWindow.h.

139{ return *mVsbar; }

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetZoomOfToFit()

double ProjectWindow::GetZoomOfToFit ( ) const

Definition at line 1975 of file ProjectWindow.cpp.

1976{
1977 auto pProject = FindProject();
1978 if (!pProject)
1979 return 1.0;
1980 auto &project = *pProject;
1981 auto &tracks = TrackList::Get( project );
1982 auto &viewInfo = ViewInfo::Get( project );
1983
1984 const double end = tracks.GetEndTime();
1985 const double start = viewInfo.bScrollBeyondZero
1986 ? std::min( tracks.GetStartTime(), 0.0)
1987 : 0;
1988 const double len = end - start;
1989
1990 if (len <= 0.0)
1991 return viewInfo.GetZoom();
1992
1993 auto w = viewInfo.GetTracksUsableWidth();
1994 w -= 10;
1995 return w/len;
1996}
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 1286 of file ProjectWindow.cpp.

1287{
1288 // Activate events can fire during window teardown, so just
1289 // ignore them.
1290 if (mIsDeleting) {
1291 return;
1292 }
1293
1294 CallAfter( [this]{
1295
1296 if (mIsDeleting)
1297 return;
1298
1299 FixScrollbars();
1300 UpdateLayout();
1301
1302 });
1303}
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:208

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 1673 of file ProjectWindow.cpp.

1674{
1675 return mActive;
1676}

References mActive.

◆ IsBeingDeleted()

bool ProjectWindow::IsBeingDeleted ( ) const
inline

Definition at line 63 of file ProjectWindow.h.

63{ return mIsDeleting; }

Referenced by OnActivate().

Here is the caller graph for this function:

◆ IsIconized()

bool ProjectWindow::IsIconized ( ) const
override

Definition at line 1306 of file ProjectWindow.cpp.

1307{
1308 return mIconized;
1309}

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 1365 of file ProjectWindow.cpp.

1366{
1367 (void)show;//compiler food
1368#ifdef __WXMAC__
1369 // Save the focus so we can restore it to whatever had it before since
1370 // showing a previously hidden toolbar will cause the focus to be set to
1371 // its frame. If this is not done it will appear that activation events
1372 // aren't being sent to the project window since they are actually being
1373 // delivered to the last tool frame shown.
1374 wxWindow *focused = FindFocus();
1375
1376 // Find all the floating toolbars, and show or hide them
1377 const auto &children = GetChildren();
1378 for(const auto &child : children) {
1379 if (auto frame = dynamic_cast<ToolFrame*>(child)) {
1380 if (!show) {
1381 frame->Hide();
1382 }
1383 else if (frame->GetBar() &&
1384 frame->GetBar()->IsVisible() ) {
1385 frame->Show();
1386 }
1387 }
1388 }
1389
1390 // Restore the focus if needed
1391 if (focused) {
1392 focused->SetFocus();
1393 }
1394#endif
1395}
class ToolFrame
Definition: ToolManager.h:190
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
Definition: BasicUI.h:343

References BasicUI::FindFocus().

Referenced by OnIconize().

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

◆ MayScrollBeyondZero()

bool ProjectWindow::MayScrollBeyondZero ( ) const

Definition at line 964 of file ProjectWindow.cpp.

965{
966 auto pProject = FindProject();
967 if (!pProject)
968 return false;
969 auto &project = *pProject;
970 auto &scrubber = Scrubber::Get( project );
971 auto &viewInfo = ViewInfo::Get( project );
972 if (viewInfo.bScrollBeyondZero)
973 return true;
974
975 if (scrubber.HasMark() ||
976 ProjectAudioIO::Get( project ).IsAudioActive()) {
977 if (mPlaybackScroller) {
978 auto mode = mPlaybackScroller->GetMode();
979 if (mode == PlaybackScroller::Mode::Pinned ||
981 return true;
982 }
983 }
984
985 return false;
986}
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 585 of file ProjectWindow.cpp.

586{
587 return mNextWindowID++;
588}

References mNextWindowID.

◆ OnActivate()

void ProjectWindow::OnActivate ( wxActivateEvent &  event)

Definition at line 1638 of file ProjectWindow.cpp.

1639{
1640 // Activate events can fire during window teardown, so just
1641 // ignore them.
1642 if (IsBeingDeleted()) {
1643 return;
1644 }
1645
1646 auto pProject = FindProject();
1647 if (!pProject)
1648 return;
1649 auto &project = *pProject;
1650
1651 mActive = event.GetActive();
1652
1653 // Under Windows, focus can be "lost" when returning to
1654 // Audacity from a different application.
1655 //
1656 // This was observed by minimizing all windows using WINDOWS+M and
1657 // then ALT+TAB to return to Audacity. Focus will be given to the
1658 // project window frame which is not at all useful.
1659 //
1660 // So, we use ToolManager's observation of focus changes in a wxEventFilter.
1661 // Then, when we receive the
1662 // activate event, we restore that focus to the child or the track
1663 // panel if no child had the focus (which probably should never happen).
1664 if (mActive) {
1665 auto &toolManager = ToolManager::Get( project );
1666 SetActiveProject( &project );
1667 if ( ! toolManager.RestoreFocus() )
1668 GetProjectPanel( project ).SetFocus();
1669 }
1670 event.Skip();
1671}
void SetActiveProject(AudacityProject *project)
bool IsBeingDeleted() const
Definition: ProjectWindow.h:63
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 1397 of file ProjectWindow.cpp.

1398{
1399 //JKC: On Iconizing we get called twice. Don't know
1400 // why but it does no harm.
1401 // Should we be returning true/false rather than
1402 // void return? I don't know.
1403 mIconized = event.IsIconized();
1404
1405#if defined(__WXMAC__)
1406 // Readdresses bug 1431 since a crash could occur when restoring iconized
1407 // floating toolbars due to recursion (bug 2411).
1409 if( !mIconized )
1410 {
1411 Raise();
1412 }
1413#endif
1414
1415 // VisibileProjectCount seems to be just a counter for debugging.
1416 // It's not used outside this function.
1417 auto VisibleProjectCount = std::count_if(
1419 []( const AllProjects::value_type &ptr ){
1420 return !GetProjectFrame( *ptr ).IsIconized();
1421 }
1422 );
1423 event.Skip();
1424
1425 // This step is to fix part of Bug 2040, where the BackingPanel
1426 // size was not restored after we leave Iconized state.
1427
1428 // Queue up a resize event using OnShow so that we
1429 // refresh the track panel. But skip this, if we're iconized.
1430 if( mIconized )
1431 return;
1432 wxShowEvent Evt;
1433 OnShow( Evt );
1434}
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 1597 of file ProjectWindow.cpp.

1598{
1599#ifdef __WXMSW__
1600 // Bug 1642: We can arrive here with bogus menu IDs, which we
1601 // proceed to process. So if bogus, don't.
1602 // The bogus menu IDs are probably generated by controls on the TrackPanel,
1603 // such as the Project Rate.
1604 // 17000 is the magic number at which we start our menu.
1605 // This code would probably NOT be OK on Mac, since we assign
1606 // some specific ID numbers.
1607 if( event.GetId() < 17000){
1608 event.Skip();
1609 return;
1610 }
1611#endif
1612 auto pProject = FindProject();
1613 if (!pProject)
1614 return;
1615 auto &project = *pProject;
1616 auto &commandManager = CommandManager::Get( project );
1617 bool handled = commandManager.HandleMenuID( project,
1618 event.GetId(), MenuManager::Get( project ).GetUpdateFlags(),
1619 false);
1620
1621 if (handled)
1622 event.Skip(false);
1623 else{
1624 event.ResumePropagation( 999 );
1625 event.Skip(true);
1626 }
1627}
static CommandManager & Get(AudacityProject &project)
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:539

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 1678 of file ProjectWindow.cpp.

1679{
1680 auto pProject = FindProject();
1681 if (!pProject)
1682 return;
1683 auto &project = *pProject;
1684 if (event.ButtonDown())
1685 SetActiveProject( &project );
1686}

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

Here is the call graph for this function:

◆ OnMove()

void ProjectWindow::OnMove ( wxMoveEvent &  event)

Definition at line 1436 of file ProjectWindow.cpp.

1437{
1438 if (!this->IsMaximized() && !this->IsIconized())
1439 SetNormalizedWindowState(this->GetRect());
1440 event.Skip();
1441}
void SetNormalizedWindowState(wxRect pSizeAndLocation)
bool IsIconized() const override

References IsIconized(), and SetNormalizedWindowState().

Here is the call graph for this function:

◆ OnProjectTitleChange()

void ProjectWindow::OnProjectTitleChange ( ProjectFileIOMessage  message)

Definition at line 1525 of file ProjectWindow.cpp.

1526{
1528 auto pProject = FindProject();
1529 if (!pProject)
1530 return;
1531 auto &project = *pProject;
1532 const auto &name = ProjectFileIO::Get(project).GetProjectTitle();
1533 if (name != GetTitle()) {
1534 SetTitle(name);
1535 SetName(name); // to make the nvda screen reader read the correct title
1536 }
1537 }
1538}
const TranslatableString name
Definition: Distortion.cpp:76
const wxString & GetProjectTitle() const
Definition: ProjectFileIO.h:79

References ProjectWindowBase::FindProject(), ProjectFileIO::Get(), ProjectFileIO::GetProjectTitle(), name, and ProjectTitleChange.

Referenced by ProjectWindow().

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

◆ OnResetWindow()

void ProjectWindow::OnResetWindow ( const CommandContext context)
static

Definition at line 577 of file ProjectWindow.cpp.

578{
579 auto& project = context.project;
580 auto& window = ProjectWindow::Get(project);
581
582 window.Reset();
583}
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 1540 of file ProjectWindow.cpp.

1541{
1542 auto pProject = FindProject();
1543 if (!pProject)
1544 return;
1545 auto &project = *pProject;
1546 auto &viewInfo = ViewInfo::Get( project );
1547 const wxInt64 offset = PixelWidthBeforeTime(0.0);
1548 viewInfo.sbarH =
1549 (wxInt64)(mHsbar->GetThumbPosition() / viewInfo.sbarScale) - offset;
1550 DoScroll();
1551
1552#ifndef __WXMAC__
1553 // Bug2179
1554 // This keeps the time ruler in sync with horizontal scrolling, without
1555 // making an undesirable compilation dependency of this source file on
1556 // the ruler
1557 wxTheApp->ProcessIdle();
1558#endif
1559}

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 861 of file ProjectWindow.cpp.

862{
863 auto pProject = FindProject();
864 if (!pProject)
865 return;
866 auto &project = *pProject;
867 auto &viewInfo = ViewInfo::Get( project );
868 wxInt64 pos = mHsbar->GetThumbPosition();
869 // move at least one scroll increment
870 pos -= wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
871 pos = wxMax(pos, 0);
872 viewInfo.sbarH -= sbarHjump;
873 viewInfo.sbarH = std::max(viewInfo.sbarH,
874 -(wxInt64) PixelWidthBeforeTime(0.0));
875
876
877 if (pos != mHsbar->GetThumbPosition()) {
878 mHsbar->SetThumbPosition((int)pos);
880 }
881}
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 915 of file ProjectWindow.cpp.

916{
917 auto pProject = FindProject();
918 if (!pProject)
919 return;
920 auto &project = *pProject;
921 auto &viewInfo = ViewInfo::Get( project );
922 wxInt64 pos = mHsbar->GetThumbPosition();
923 // move at least one scroll increment
924 pos -= wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
925 pos = wxMax(pos, 0);
926 viewInfo.sbarH -= sbarHjump;
927 viewInfo.sbarH = std::max(viewInfo.sbarH,
928 - (wxInt64) PixelWidthBeforeTime(0.0));
929
930 if (pos != mHsbar->GetThumbPosition()) {
931 mHsbar->SetThumbPosition((int)pos);
932 DoScroll();
933 }
934}

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 887 of file ProjectWindow.cpp.

888{
889 auto pProject = FindProject();
890 if (!pProject)
891 return;
892 auto &project = *pProject;
893 auto &viewInfo = ViewInfo::Get( project );
894 wxInt64 pos = mHsbar->GetThumbPosition();
895 // move at least one scroll increment
896 // use wxInt64 for calculation to prevent temporary overflow
897 pos += wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
898 wxInt64 max = mHsbar->GetRange() - mHsbar->GetThumbSize();
899 pos = wxMin(pos, max);
900 viewInfo.sbarH += sbarHjump;
901 viewInfo.sbarH = std::min(viewInfo.sbarH,
902 viewInfo.sbarTotal
903 - (wxInt64) PixelWidthBeforeTime(0.0) - viewInfo.sbarScreen);
904
905 if (pos != mHsbar->GetThumbPosition()) {
906 mHsbar->SetThumbPosition((int)pos);
908 }
909}

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 939 of file ProjectWindow.cpp.

940{
941 auto pProject = FindProject();
942 if (!pProject)
943 return;
944 auto &project = *pProject;
945 auto &viewInfo = ViewInfo::Get( project );
946 wxInt64 pos = mHsbar->GetThumbPosition();
947 // move at least one scroll increment
948 // use wxInt64 for calculation to prevent temporary overflow
949 pos += wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
950 wxInt64 max = mHsbar->GetRange() - mHsbar->GetThumbSize();
951 pos = wxMin(pos, max);
952 viewInfo.sbarH += sbarHjump;
953 viewInfo.sbarH = std::min(viewInfo.sbarH,
954 viewInfo.sbarTotal
955 - (wxInt64) PixelWidthBeforeTime(0.0) - viewInfo.sbarScreen);
956
957 if (pos != mHsbar->GetThumbPosition()) {
958 mHsbar->SetThumbPosition((int)pos);
959 DoScroll();
960 }
961}

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 1461 of file ProjectWindow.cpp.

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

References mShownOnce, and safenew.

Referenced by OnIconize().

Here is the caller graph for this function:

◆ OnSize()

void ProjectWindow::OnSize ( wxSizeEvent &  event)

Definition at line 1443 of file ProjectWindow.cpp.

1444{
1445 // (From Debian)
1446 //
1447 // (3.) GTK critical warning "IA__gdk_window_get_origin: assertion
1448 // 'GDK_IS_WINDOW (window)' failed": Received events of type wxSizeEvent
1449 // on the main project window cause calls to "ClientToScreen" - which is
1450 // not available until the window is first shown. So the class has to
1451 // keep track of wxShowEvent events and inhibit those actions until the
1452 // window is first shown.
1453 if (mShownOnce) {
1454 HandleResize();
1455 if (!this->IsMaximized() && !this->IsIconized())
1456 SetNormalizedWindowState(this->GetRect());
1457 }
1458 event.Skip();
1459}

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 774 of file ProjectWindow.cpp.

775{
776 auto pProject = FindProject();
777 if (!pProject)
778 return;
779 auto &project = *pProject;
780
781 if (message.appearance)
782 return;
783 this->ApplyUpdatedTheme();
784 auto &toolManager = ToolManager::Get( project );
785 toolManager.ForEach([](auto pToolBar){
786 if( pToolBar )
787 pToolBar->ReCreateButtons();
788 });
789}
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 1501 of file ProjectWindow.cpp.

1502{
1503 HandleResize();
1504
1505 event.Skip(false); /* No need to propagate any further */
1506}

References HandleResize().

Here is the call graph for this function:

◆ OnUndoPushedModified()

void ProjectWindow::OnUndoPushedModified ( )

Definition at line 1508 of file ProjectWindow.cpp.

1509{
1510 RedrawProject();
1511}

References RedrawProject().

Here is the call graph for this function:

◆ OnUndoRedo()

void ProjectWindow::OnUndoRedo ( )

Definition at line 1513 of file ProjectWindow.cpp.

1514{
1515 HandleResize();
1516 RedrawProject();
1517}

References HandleResize(), and RedrawProject().

Here is the call graph for this function:

◆ OnUndoReset()

void ProjectWindow::OnUndoReset ( )

Definition at line 1519 of file ProjectWindow.cpp.

1520{
1521 HandleResize();
1522 // RedrawProject(); // Should we do this here too?
1523}

References HandleResize().

Here is the call graph for this function:

◆ OnUpdateUI()

void ProjectWindow::OnUpdateUI ( wxUpdateUIEvent &  event)

Definition at line 1629 of file ProjectWindow.cpp.

1630{
1631 auto pProject = FindProject();
1632 if (!pProject)
1633 return;
1634 auto &project = *pProject;
1635 MenuManager::Get( project ).UpdateMenus();
1636}

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 1004 of file ProjectWindow.cpp.

1005{
1006 auto pProject = FindProject();
1007 if (!pProject)
1008 return 0;
1009 auto &project = *pProject;
1010 auto &viewInfo = ViewInfo::Get( project );
1011 const double lowerBound = ScrollingLowerBoundTime();
1012 return
1013 // Ignoring fisheye is correct here
1014 viewInfo.TimeRangeToPixelWidth(scrollto - lowerBound);
1015}

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 745 of file ProjectWindow.cpp.

746{
747 auto pThis = wxWeakRef<ProjectWindow>(this);
748 CallAfter( [pThis, bForceWaveTracks]{
749
750 if (!pThis)
751 return;
752 if (pThis->IsBeingDeleted())
753 return;
754
755 auto pProject = pThis->FindProject();
756 if (!pProject)
757 return;
758
759 auto &project = *pProject;
760 auto &tracks = TrackList::Get( project );
761 auto &trackPanel = GetProjectPanel( project );
762 pThis->FixScrollbars();
763 if (bForceWaveTracks)
764 {
765 for ( auto pWaveTrack : tracks.Any< WaveTrack >() )
766 for (const auto &clip: pWaveTrack->GetClips())
767 clip->MarkChanged();
768 }
769 trackPanel.Refresh(false);
770
771 });
772}
A Track that contains audio waveform data.
Definition: WaveTrack.h:51

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(), ProjectWindow(), 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 1326 of file ProjectWindow.cpp.

1327{
1328 wxRect defaultRect;
1329 GetDefaultWindowRect(&defaultRect);
1330
1331 SetSize(defaultRect.width, defaultRect.height);
1332}
void GetDefaultWindowRect(wxRect *defRect)

References GetDefaultWindowRect().

Here is the call graph for this function:

◆ Rewind()

void ProjectWindow::Rewind ( bool  shift)

Definition at line 1752 of file ProjectWindow.cpp.

1753{
1754 auto pProject = FindProject();
1755 if (!pProject)
1756 return;
1757 auto &project = *pProject;
1758 auto &viewInfo = ViewInfo::Get( project );
1759 viewInfo.selectedRegion.setT0(0, false);
1760 if (!shift)
1761 viewInfo.selectedRegion.setT1(0);
1762
1763 TP_ScrollWindow(0);
1764}
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 988 of file ProjectWindow.cpp.

989{
990 auto pProject = FindProject();
991 if (!pProject)
992 return 0;
993 auto &project = *pProject;
994 auto &tracks = TrackList::Get( project );
995 auto &viewInfo = ViewInfo::Get( project );
996 if (!MayScrollBeyondZero())
997 return 0;
998 const double screen = viewInfo.GetScreenEndTime() - viewInfo.h;
999 return std::min(tracks.GetStartTime(), -screen);
1000}

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 828 of file ProjectWindow.cpp.

829{
830 auto pProject = FindProject();
831 if (!pProject)
832 return;
833 auto &project = *pProject;
834 auto &trackPanel = GetProjectPanel( project );
835 auto &viewInfo = ViewInfo::Get( project );
836 auto w = viewInfo.GetTracksUsableWidth();
837
838 int pixel = viewInfo.TimeToPosition(pos);
839 if (pixel < 0 || pixel >= w)
840 {
842 (viewInfo.OffsetTimeByPixels(pos, -(w / 2)));
843 trackPanel.Refresh(false);
844 }
845}

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 847 of file ProjectWindow.cpp.

848{
849 auto pProject = FindProject();
850 if (!pProject)
851 return;
852 auto &project = *pProject;
853 auto &viewInfo = ViewInfo::Get( project );
854 ScrollIntoView(viewInfo.PositionToTime(x, viewInfo.GetLeftOffset()));
855}
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 1017 of file ProjectWindow.cpp.

1018{
1019 auto pProject = FindProject();
1020 if (!pProject)
1021 return;
1022 auto &project = *pProject;
1023 auto &viewInfo = ViewInfo::Get( project );
1024 const auto unscaled = PixelWidthBeforeTime(scrollto);
1025 const int max = mHsbar->GetRange() - mHsbar->GetThumbSize();
1026 const int pos =
1027 std::min(max,
1028 std::max(0,
1029 (int)(floor(0.5 + unscaled * viewInfo.sbarScale))));
1030 mHsbar->SetThumbPosition(pos);
1031 viewInfo.sbarH = floor(0.5 + unscaled - PixelWidthBeforeTime(0.0));
1032 viewInfo.sbarH = std::max(viewInfo.sbarH,
1033 - (wxInt64) PixelWidthBeforeTime(0.0));
1034 viewInfo.sbarH = std::min(viewInfo.sbarH,
1035 viewInfo.sbarTotal
1036 - (wxInt64) PixelWidthBeforeTime(0.0) - viewInfo.sbarScreen);
1037}

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 64 of file ProjectWindow.h.

64{ mIsDeleting = true; }

◆ SetNormalizedWindowState()

void ProjectWindow::SetNormalizedWindowState ( wxRect  pSizeAndLocation)
inline

Definition at line 122 of file ProjectWindow.h.

122{ mNormalizedWindowState = pSizeAndLocation; }

Referenced by OnMove(), and OnSize().

Here is the caller graph for this function:

◆ SkipEnd()

void ProjectWindow::SkipEnd ( bool  shift)

Definition at line 1775 of file ProjectWindow.cpp.

1776{
1777 auto pProject = FindProject();
1778 if (!pProject)
1779 return;
1780 auto &project = *pProject;
1781 auto &tracks = TrackList::Get( project );
1782 auto &viewInfo = ViewInfo::Get( project );
1783 double len = tracks.GetEndTime();
1784
1785 viewInfo.selectedRegion.setT1(len, false);
1786 if (!shift)
1787 viewInfo.selectedRegion.setT0(len);
1788
1789 // Make sure the end of the track is visible
1790 ScrollIntoView(len);
1791}

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 1811 of file ProjectWindow.cpp.

1812{
1813 HandleResize();
1814}

References HandleResize().

Here is the call graph for this function:

◆ TP_RedrawScrollbars()

void ProjectWindow::TP_RedrawScrollbars ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1806 of file ProjectWindow.cpp.

1807{
1808 FixScrollbars();
1809}

References FixScrollbars().

Here is the call graph for this function:

◆ TP_ScrollLeft()

void ProjectWindow::TP_ScrollLeft ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1794 of file ProjectWindow.cpp.

1795{
1796 OnScrollLeft();
1797}

References OnScrollLeft().

Here is the call graph for this function:

◆ TP_ScrollRight()

void ProjectWindow::TP_ScrollRight ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1800 of file ProjectWindow.cpp.

1801{
1802 OnScrollRight();
1803}

References OnScrollRight().

Here is the call graph for this function:

◆ TP_ScrollUpDown()

bool ProjectWindow::TP_ScrollUpDown ( int  delta)
overridevirtual

Implements TrackPanelListener.

Definition at line 1057 of file ProjectWindow.cpp.

1058{
1059 int oldPos = mVsbar->GetThumbPosition();
1060 int pos = oldPos + delta;
1061 int max = mVsbar->GetRange() - mVsbar->GetThumbSize();
1062
1063 // Can be negative in case of only one track
1064 if (max < 0)
1065 max = 0;
1066
1067 if (pos > max)
1068 pos = max;
1069 else if (pos < 0)
1070 pos = 0;
1071
1072 if (pos != oldPos)
1073 {
1074 mVsbar->SetThumbPosition(pos);
1075
1076 DoScroll();
1077 return true;
1078 }
1079 else
1080 return false;
1081}

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 1043 of file ProjectWindow.cpp.

1044{
1045 SetHorizontalThumb(scrollto);
1046
1047 // Call our Scroll method which updates our ViewInfo variables
1048 // to reflect the positions of the scrollbars
1049 DoScroll();
1050}

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 1242 of file ProjectWindow.cpp.

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

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 791 of file ProjectWindow.cpp.

792{
793 // Update status bar widths in case of language change
795}
void UpdateStatusWidths()

References UpdateStatusWidths().

Here is the call graph for this function:

◆ UpdateStatusWidths()

void ProjectWindow::UpdateStatusWidths ( )

Definition at line 1334 of file ProjectWindow.cpp.

1335{
1336 auto pProject = FindProject();
1337 if (!pProject)
1338 return;
1339 auto &project = *pProject;
1340 enum { nWidths = nStatusBarFields + 1 };
1341 int widths[ nWidths ]{ 0 };
1342 widths[ rateStatusBarField ] = 150;
1343 const auto statusBar = GetStatusBar();
1344 const auto &functions = ProjectStatus::GetStatusWidthFunctions();
1345 // Start from 1 not 0
1346 // Specifying a first column always of width 0 was needed for reasons
1347 // I forget now
1348 for ( int ii = 1; ii <= nStatusBarFields; ++ii ) {
1349 int &width = widths[ ii ];
1350 for ( const auto &function : functions ) {
1351 auto results =
1352 function( project, static_cast< StatusBarField >( ii ) );
1353 for ( const auto &string : results.first ) {
1354 int w;
1355 statusBar->GetTextExtent(string.Translation(), &w, nullptr);
1356 width = std::max<int>( width, w + results.second );
1357 }
1358 }
1359 }
1360 // The main status field is not fixed width
1361 widths[ mainStatusBarField ] = -1;
1362 statusBar->SetStatusWidths( nWidths, widths );
1363}
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 1711 of file ProjectWindow.cpp.

1712{
1713 auto pProject = FindProject();
1714 if (!pProject)
1715 return;
1716 auto &project = *pProject;
1717 auto &viewInfo = ViewInfo::Get( project );
1718 viewInfo.SetZoom(level);
1719 FixScrollbars();
1720 // See if we can center the selection on screen, and have it actually fit.
1721 // tOnLeft is the amount of time we would need before the selection left edge to center it.
1722 float t0 = viewInfo.selectedRegion.t0();
1723 float t1 = viewInfo.selectedRegion.t1();
1724 float tAvailable = viewInfo.GetScreenEndTime() - viewInfo.h;
1725 float tOnLeft = (tAvailable - t0 + t1)/2.0;
1726 // Bug 1292 (Enh) is effectively a request to do this scrolling of the selection into view.
1727 // If tOnLeft is positive, then we have room for the selection, so scroll to it.
1728 if( tOnLeft >=0 )
1729 TP_ScrollWindow( t0-tOnLeft);
1730}

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 1688 of file ProjectWindow.cpp.

1689{
1690 auto pProject = FindProject();
1691 if (!pProject)
1692 return;
1693 auto &project = *pProject;
1694 auto &tracks = TrackList::Get( project );
1695 auto &trackPanel = GetProjectPanel( project );
1696
1697 DoZoomFit();
1698
1699 trackPanel.SetFocus();
1700 if (!pTrack)
1701 pTrack = *tracks.Selected().begin();
1702 if (!pTrack)
1703 pTrack = *tracks.Any().begin();
1704 if (pTrack) {
1705 TrackFocus::Get(project).Set(pTrack);
1706 pTrack->EnsureVisible();
1707 }
1708}
Track * Get()
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:98
bool Any() const
Definition: Track.cpp:299

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 1733 of file ProjectWindow.cpp.

1734{
1735 auto pProject = FindProject();
1736 if (!pProject)
1737 return;
1738 auto &project = *pProject;
1739 auto &viewInfo = ViewInfo::Get( project );
1740 viewInfo.ZoomBy(multiplier);
1741 FixScrollbars();
1742}

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 1872 of file ProjectWindow.cpp.

1873{
1874 auto pProject = FindProject();
1875 if (!pProject)
1876 return;
1877 auto &project = *pProject;
1878 auto &viewInfo = ViewInfo::Get( project );
1879
1880 auto gAudioIO = AudioIO::Get();
1881 // LLL: Handling positioning differently when audio is
1882 // actively playing. Don't do this if paused.
1883 if (gAudioIO->IsStreamActive(
1884 ProjectAudioIO::Get( project ).GetAudioIOToken()) &&
1885 !gAudioIO->IsPaused()){
1886 ZoomBy(ZoomFactor);
1887 ScrollIntoView(gAudioIO->GetStreamTime());
1888 return;
1889 }
1890
1891 // DMM: Here's my attempt to get logical zooming behavior
1892 // when there's a selection that's currently at least
1893 // partially on-screen
1894
1895 const double endTime = viewInfo.GetScreenEndTime();
1896 const double duration = endTime - viewInfo.h;
1897
1898 bool selectionIsOnscreen =
1899 (viewInfo.selectedRegion.t0() < endTime) &&
1900 (viewInfo.selectedRegion.t1() >= viewInfo.h);
1901
1902 bool selectionFillsScreen =
1903 (viewInfo.selectedRegion.t0() < viewInfo.h) &&
1904 (viewInfo.selectedRegion.t1() > endTime);
1905
1906 if (selectionIsOnscreen && !selectionFillsScreen) {
1907 // Start with the center of the selection
1908 double selCenter = (viewInfo.selectedRegion.t0() +
1909 viewInfo.selectedRegion.t1()) / 2;
1910
1911 // If the selection center is off-screen, pick the
1912 // center of the part that is on-screen.
1913 if (selCenter < viewInfo.h)
1914 selCenter = viewInfo.h +
1915 (viewInfo.selectedRegion.t1() - viewInfo.h) / 2;
1916 if (selCenter > endTime)
1917 selCenter = endTime -
1918 (endTime - viewInfo.selectedRegion.t0()) / 2;
1919
1920 // Zoom in
1921 ZoomBy(ZoomFactor);
1922 const double newDuration =
1923 viewInfo.GetScreenEndTime() - viewInfo.h;
1924
1925 // Recenter on selCenter
1926 TP_ScrollWindow(selCenter - newDuration / 2);
1927 return;
1928 }
1929
1930
1931 double origLeft = viewInfo.h;
1932 double origWidth = duration;
1933 ZoomBy(ZoomFactor);
1934
1935 const double newDuration =
1936 viewInfo.GetScreenEndTime() - viewInfo.h;
1937 double newh = origLeft + (origWidth - newDuration) / 2;
1938
1939 // MM: Commented this out because it was confusing users
1940 /*
1941 // make sure that the *right-hand* end of the selection is
1942 // no further *left* than 1/3 of the way across the screen
1943 if (viewInfo.selectedRegion.t1() < newh + viewInfo.screen / 3)
1944 newh = viewInfo.selectedRegion.t1() - viewInfo.screen / 3;
1945
1946 // make sure that the *left-hand* end of the selection is
1947 // no further *right* than 2/3 of the way across the screen
1948 if (viewInfo.selectedRegion.t0() > newh + viewInfo.screen * 2 / 3)
1949 newh = viewInfo.selectedRegion.t0() - viewInfo.screen * 2 / 3;
1950 */
1951
1952 TP_ScrollWindow(newh);
1953}
static AudioIO * Get()
Definition: AudioIO.cpp:126
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 1955 of file ProjectWindow.cpp.

1956{
1957 auto pProject = FindProject();
1958 if (!pProject)
1959 return;
1960 auto &project = *pProject;
1961 auto &viewInfo = ViewInfo::Get( project );
1962
1963 //Zoom() may change these, so record original values:
1964 const double origLeft = viewInfo.h;
1965 const double origWidth = viewInfo.GetScreenEndTime() - origLeft;
1966
1967 ZoomBy(ZoomFactor);
1968 const double newWidth = viewInfo.GetScreenEndTime() - viewInfo.h;
1969
1970 const double newh = origLeft + (origWidth - newWidth) / 2;
1971 // newh = (newh > 0) ? newh : 0;
1972 TP_ScrollWindow(newh);
1973}

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 222 of file ProjectWindow.h.

Referenced by IsActive(), and OnActivate().

◆ mAutoScrolling

bool ProjectWindow::mAutoScrolling { false }
private

Definition at line 221 of file ProjectWindow.h.

Referenced by DoScroll(), and FinishAutoScroll().

◆ mbInitializingScrollbar

bool ProjectWindow::mbInitializingScrollbar { false }

Definition at line 207 of file ProjectWindow.h.

Referenced by FixScrollbars().

◆ mContainerWindow

wxSplitterWindow* ProjectWindow::mContainerWindow
private

Definition at line 213 of file ProjectWindow.h.

Referenced by GetContainerWindow(), and ProjectWindow().

◆ mHsbar

wxScrollBar* ProjectWindow::mHsbar {}
private

◆ mIconized

bool ProjectWindow::mIconized { false }
private

Definition at line 223 of file ProjectWindow.h.

Referenced by IsIconized(), and OnIconize().

◆ mIsDeleting

bool ProjectWindow::mIsDeleting { false }
private

Definition at line 228 of file ProjectWindow.h.

Referenced by HandleResize().

◆ mNextWindowID

int ProjectWindow::mNextWindowID {}
private

Definition at line 219 of file ProjectWindow.h.

Referenced by NextWindowID(), and ProjectWindow().

◆ mNormalizedWindowState

wxRect ProjectWindow::mNormalizedWindowState
private

Definition at line 210 of file ProjectWindow.h.

◆ mPlaybackScroller

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

Definition at line 237 of file ProjectWindow.h.

Referenced by MayScrollBeyondZero(), and ProjectWindow().

◆ mShownOnce

bool ProjectWindow::mShownOnce { false }
private

Definition at line 224 of file ProjectWindow.h.

Referenced by OnShow(), and OnSize().

◆ mSnappingChangedSubscription

Observer::Subscription ProjectWindow::mSnappingChangedSubscription
private

Definition at line 235 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mThemeChangeSubscription

Observer::Subscription ProjectWindow::mThemeChangeSubscription
private

Definition at line 233 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mTitleChangeSubcription

Observer::Subscription ProjectWindow::mTitleChangeSubcription
private

Definition at line 234 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mTopPanel

wxPanel* ProjectWindow::mTopPanel {}
private

Definition at line 212 of file ProjectWindow.h.

Referenced by GetTopPanel(), and ProjectWindow().

◆ mTrackListWindow

wxWindow* ProjectWindow::mTrackListWindow {}
private

Definition at line 214 of file ProjectWindow.h.

Referenced by GetTrackListWindow(), and ProjectWindow().

◆ mUndoSubscription

Observer::Subscription ProjectWindow::mUndoSubscription
private

Definition at line 232 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mVsbar

wxScrollBar* ProjectWindow::mVsbar {}
private

Definition at line 217 of file ProjectWindow.h.

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


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