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 * GetEffectsWindow () noexcept
 Effect window contains list off effects assigned to a selected track. More...
 
wxWindow * GetTrackListWindow () noexcept
 Track list window is the parent container for TrackPanel. More...
 
wxWindow * 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 ShowEffectsPanel (Track *track=nullptr, bool focus=false)
 
void HideEffectsPanel ()
 
bool IsEffectsPanelShown ()
 
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
 
AudacityProjectGetProject ()
 
const AudacityProjectGetProject () 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
 
RealtimeEffectPanelmEffectsWindow {}
 
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
 
Observer::Subscription mFocusChangeSubscription
 

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
AudacityProjectmProject
 

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

603 : ProjectWindowBase{ parent, id, pos, size, project }
604{
606
607 // Two sub-windows need to be made before Init(),
608 // so that this constructor can complete, and then TrackPanel and
609 // AdornedRulerPanel can retrieve those windows from this in their
610 // factory functions
611
612 // PRL: this panel groups the top tool dock and the ruler into one
613 // tab cycle.
614 // Must create it with non-default width equal to the main window width,
615 // or else the device toolbar doesn't make initial widths of the choice
616 // controls correct.
618 this, wxID_ANY, wxDefaultPosition,
619 wxSize{ this->GetSize().GetWidth(), -1 }
620 };
621 mTopPanel->SetLabel( "Top Panel" );// Not localised
622 mTopPanel->SetLayoutDirection(wxLayout_LeftToRight);
623 mTopPanel->SetAutoLayout(true);
624#ifdef EXPERIMENTAL_DA2
625 mTopPanel->SetBackgroundColour(theTheme.Colour( clrMedium ));
626#endif
627
628 auto container = safenew wxSplitterWindow(this, wxID_ANY,
629 wxDefaultPosition,
630 wxDefaultSize,
631 wxNO_BORDER | wxSP_LIVE_UPDATE | wxSP_THIN_SASH);
632 container->Bind(wxEVT_SPLITTER_DOUBLECLICKED, [](wxSplitterEvent& event){
633 //"The default behaviour is to unsplit the window"
634 event.Veto();//do noting instead
635 });
636 mContainerWindow = container;
637
639 wxDefaultPosition,
640 wxDefaultSize,
641 wxNO_BORDER);
642 mTrackListWindow->SetSizer( safenew wxBoxSizer(wxVERTICAL) );
643 mTrackListWindow->SetLabel("Main Panel");// Not localized.
644 mTrackListWindow->SetLayoutDirection(wxLayout_LeftToRight);
645
647
649 effectsPanel->SetName(_("Realtime effects"));
650 effectsPanel->SetBackgroundColorIndex(clrMedium);
651 effectsPanel->Hide();//initially hidden
652 effectsPanel->Bind(wxEVT_CLOSE_WINDOW, [this](wxCloseEvent&)
653 {
655 });
656 mEffectsWindow = effectsPanel;
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
703 .Subscribe([this](const TrackFocusChangeMessage& msg) {
704 if(mEffectsWindow->IsShown())
705 {
706 auto& project = GetProject();
707 auto& trackFocus = TrackFocus::Get(project);
708 ShowEffectsPanel(trackFocus.Get(), false);
709 }
710 });
711
712}
#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.
AudacityProject & mProject
wxScrollBar * mHsbar
wxSplitterWindow * mContainerWindow
RealtimeEffectPanel * mEffectsWindow
Observer::Subscription mFocusChangeSubscription
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)
Track * Get()
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(), TrackFocus::Get(), UndoManager::Get(), HideEffectsPanel(), HSBarID, mContainerWindow, mEffectsWindow, mFocusChangeSubscription, mHsbar, mNextWindowID, mPlaybackScroller, ProjectWindowBase::mProject, 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 714 of file ProjectWindow.cpp.

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

Member Function Documentation

◆ ApplyUpdatedTheme()

void ProjectWindow::ApplyUpdatedTheme ( )

Definition at line 740 of file ProjectWindow.cpp.

741{
742 auto &project = mProject;
743 SetBackgroundColour(theTheme.Colour( clrMedium ));
744 ClearBackground();// For wxGTK.
745}

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

1503{
1504 auto &project = mProject;
1505 auto &trackPanel = GetProjectPanel( project );
1506 auto &viewInfo = ViewInfo::Get( project );
1507 const double lowerBound = ScrollingLowerBoundTime();
1508
1509 auto width = viewInfo.GetTracksUsableWidth();
1510 viewInfo.SetBeforeScreenWidth(viewInfo.sbarH, width, lowerBound);
1511
1512
1513 if (MayScrollBeyondZero()) {
1514 enum { SCROLL_PIXEL_TOLERANCE = 10 };
1515 if (std::abs(viewInfo.TimeToPosition(0.0, 0
1516 )) < SCROLL_PIXEL_TOLERANCE) {
1517 // Snap the scrollbar to 0
1518 viewInfo.h = 0;
1519 SetHorizontalThumb(0.0);
1520 }
1521 }
1522
1523 viewInfo.vpos = mVsbar->GetThumbPosition() * viewInfo.scrollStep;
1524
1525 //mchinen: do not always set this project to be the active one.
1526 //a project may autoscroll while playing in the background
1527 //I think this is okay since OnMouseEvent has one of these.
1528 //SetActiveProject(this);
1529
1530 if (!mAutoScrolling) {
1531 trackPanel.Refresh(false);
1532 }
1533}
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
void SetHorizontalThumb(double scrollto)
double ScrollingLowerBoundTime() const
bool MayScrollBeyondZero() const
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References ViewInfo::Get(), GetProjectPanel(), mAutoScrolling, MayScrollBeyondZero(), ProjectWindowBase::mProject, 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 1900 of file ProjectWindow.cpp.

1901{
1902 auto &project = mProject;
1903 auto &viewInfo = ViewInfo::Get( project );
1904 auto &tracks = TrackList::Get( project );
1905 auto &window = *this;
1906
1907 const double start = viewInfo.bScrollBeyondZero
1908 ? std::min(tracks.GetStartTime(), 0.0)
1909 : 0;
1910
1911 window.Zoom( window.GetZoomOfToFit() );
1912 window.TP_ScrollWindow(start);
1913}
int min(int a, int b)
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486

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

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

565{
566 return pProject
568 : nullptr;
569}
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 571 of file ProjectWindow.cpp.

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

References Find().

Here is the call graph for this function:

◆ FinishAutoScroll()

void ProjectWindow::FinishAutoScroll ( )

Definition at line 793 of file ProjectWindow.cpp.

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

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

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

555{
557}
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(), EffectsButtonHandle::CommitChanges(), anonymous_namespace{TrackMenus.cpp}::DoAlign(), MacroCommands::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{PluginMenus.cpp}::DoManageRealtimeEffectsSidePanel(), 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(), LabelTrackView::KeyDown(), cloud::ShareAudioToolbar::MakeShareAudioButton(), MixerBoard::MixerBoard(), anonymous_namespace{SelectMenus.cpp}::MoveWhenAudioInactive(), TrackActions::Handler::MuteTracks(), ProjectManager::New(), anonymous_namespace{NavigationMenus.cpp}::NextOrPrevFrame(), PluginActions::Handler::OnApplyMacroDirectlyByName(), ApplyMacroDialog::OnApplyToFiles(), MixerTrackCluster::OnButton_Mute(), MixerTrackCluster::OnButton_Solo(), FileActions::Handler::OnClose(), ProjectManager::OnCloseWindow(), ViewActions::Handler::OnCollapseAllTracks(), SelectActions::Handler::OnCursorSelEnd(), SelectActions::Handler::OnCursorSelStart(), SelectActions::Handler::OnCursorTrackEnd(), SelectActions::Handler::OnCursorTrackStart(), EditActions::Handler::OnCut(), EditActions::Handler::OnDelete(), EditActions::Handler::OnDisjoin(), EditActions::Handler::OnDuplicate(), AudacityApp::OnExceptionInMainLoop(), ViewActions::Handler::OnExpandAllTracks(), ControlToolBar::OnFF(), ViewActions::Handler::OnGoSelEnd(), ViewActions::Handler::OnGoSelStart(), FileActions::Handler::OnImportLabels(), EditActions::Handler::OnJoin(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewStereoTrack(), anonymous_namespace{TimeTrackMenuItems.cpp}::Handler::OnNewTimeTrack(), anonymous_namespace{WaveTrackMenuItems.cpp}::Handler::OnNewWaveTrack(), EditActions::Handler::OnPaste(), CommandHandler::OnReceiveCommand(), ProjectManager::OnReconnectionFailure(), EditActions::Handler::OnRedo(), TrackActions::Handler::OnResample(), OnResetWindow(), ControlToolBar::OnRewind(), LabelDialog::OnSelectCell(), SelectActions::Handler::OnSelectionRestore(), SelectActions::Handler::OnSelToEnd(), SelectActions::Handler::OnSelToStart(), ScreenshotBigDialog::OnShortTracks(), EditActions::Handler::OnSplitCut(), EditActions::Handler::OnSplitDelete(), EditActions::Handler::OnSplitNew(), ProjectWindow::PlaybackScroller::OnTimer(), PlayIndicatorOverlay::OnTimer(), SelectHandle::TimerHandler::OnTimer(), TrackPanel::OnTimer(), TransportActions::Handler::OnTimerRecord(), ToolsToolBar::OnToolChanged(), EditActions::Handler::OnTrim(), EditActions::Handler::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(), 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 559 of file ProjectWindow.cpp.

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

References Get().

Here is the call graph for this function:

◆ GetContainerWindow()

wxWindow * 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 1279 of file ProjectWindow.cpp.

1280{
1281 return mContainerWindow;
1282}

References mContainerWindow.

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetEffectsWindow()

wxWindow * ProjectWindow::GetEffectsWindow ( )
noexcept

Effect window contains list off effects assigned to a selected track.

Returns
Pointer to an effects side-panel window (not null)

Definition at line 1269 of file ProjectWindow.cpp.

1270{
1271 return mEffectsWindow;
1272}

References mEffectsWindow.

◆ GetHorizontalScrollBar()

wxScrollBar & ProjectWindow::GetHorizontalScrollBar ( )
inline

Definition at line 149 of file ProjectWindow.h.

149{ return *mHsbar; }

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetNormalizedWindowState()

wxRect ProjectWindow::GetNormalizedWindowState ( ) const
inline

Definition at line 128 of file ProjectWindow.h.

128{ return mNormalizedWindowState; }
wxRect mNormalizedWindowState

Referenced by ProjectManager::SaveWindowSize().

Here is the caller graph for this function:

◆ GetPlaybackScroller()

PlaybackScroller & ProjectWindow::GetPlaybackScroller ( )
inline

Definition at line 125 of file ProjectWindow.h.

125{ 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 1284 of file ProjectWindow.cpp.

1285{
1286 return mTopPanel;
1287}

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

1275{
1276 return mTrackListWindow;
1277}

References mTrackListWindow.

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetVerticalScrollBar()

wxScrollBar & ProjectWindow::GetVerticalScrollBar ( )
inline

Definition at line 148 of file ProjectWindow.h.

148{ return *mVsbar; }

Referenced by InitProjectWindow().

Here is the caller graph for this function:

◆ GetZoomOfToFit()

double ProjectWindow::GetZoomOfToFit ( ) const

Definition at line 1880 of file ProjectWindow.cpp.

1881{
1882 auto &project = mProject;
1883 auto &tracks = TrackList::Get( project );
1884 auto &viewInfo = ViewInfo::Get( project );
1885
1886 const double end = tracks.GetEndTime();
1887 const double start = viewInfo.bScrollBeyondZero
1888 ? std::min( tracks.GetStartTime(), 0.0)
1889 : 0;
1890 const double len = end - start;
1891
1892 if (len <= 0.0)
1893 return viewInfo.GetZoom();
1894
1895 auto w = viewInfo.GetTracksUsableWidth();
1896 w -= 10;
1897 return w/len;
1898}
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

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

Here is the call graph for this function:

◆ HandleResize()

void ProjectWindow::HandleResize ( )

Definition at line 1244 of file ProjectWindow.cpp.

1245{
1246 // Activate events can fire during window teardown, so just
1247 // ignore them.
1248 if (mIsDeleting) {
1249 return;
1250 }
1251
1252 CallAfter( [this]{
1253
1254 if (mIsDeleting)
1255 return;
1256
1257 FixScrollbars();
1258 UpdateLayout();
1259
1260 });
1261}
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:

◆ HideEffectsPanel()

void ProjectWindow::HideEffectsPanel ( )

Definition at line 1940 of file ProjectWindow.cpp.

1941{
1942 wxWindowUpdateLocker freeze(this);
1943
1944 if(mContainerWindow->GetWindow2() == nullptr)
1945 //only effects panel is present, restore split positions before removing effects panel
1946 //Workaround: ::Replace and ::Initialize do not work here...
1948
1950 mTrackListWindow->SetFocus();
1951 Layout();
1952}

References mContainerWindow, mEffectsWindow, and mTrackListWindow.

Referenced by ProjectWindow().

Here is the caller graph for this function:

◆ IsActive()

bool ProjectWindow::IsActive ( )
override

Definition at line 1602 of file ProjectWindow.cpp.

1603{
1604 return mActive;
1605}

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:

◆ IsEffectsPanelShown()

bool ProjectWindow::IsEffectsPanelShown ( )

Definition at line 1954 of file ProjectWindow.cpp.

1955{
1956 return mEffectsWindow->IsShown();
1957}

References mEffectsWindow.

◆ IsIconized()

bool ProjectWindow::IsIconized ( ) const
override

Definition at line 1264 of file ProjectWindow.cpp.

1265{
1266 return mIconized;
1267}

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

1325{
1326 (void)show;//compiler food
1327#ifdef __WXMAC__
1328 // Save the focus so we can restore it to whatever had it before since
1329 // showing a previously hidden toolbar will cause the focus to be set to
1330 // its frame. If this is not done it will appear that activation events
1331 // aren't being sent to the project window since they are actually being
1332 // delivered to the last tool frame shown.
1333 wxWindow *focused = FindFocus();
1334
1335 // Find all the floating toolbars, and show or hide them
1336 const auto &children = GetChildren();
1337 for(const auto &child : children) {
1338 if (auto frame = dynamic_cast<ToolFrame*>(child)) {
1339 if (!show) {
1340 frame->Hide();
1341 }
1342 else if (frame->GetBar() &&
1343 frame->GetBar()->IsVisible() ) {
1344 frame->Show();
1345 }
1346 }
1347 }
1348
1349 // Restore the focus if needed
1350 if (focused) {
1351 focused->SetFocus();
1352 }
1353#endif
1354}
class ToolFrame
Definition: ToolManager.h:168

Referenced by OnIconize().

Here is the caller graph for this function:

◆ MayScrollBeyondZero()

bool ProjectWindow::MayScrollBeyondZero ( ) const

Definition at line 940 of file ProjectWindow.cpp.

941{
942 auto &project = mProject;
943 auto &scrubber = Scrubber::Get( project );
944 auto &viewInfo = ViewInfo::Get( project );
945 if (viewInfo.bScrollBeyondZero)
946 return true;
947
948 if (scrubber.HasMark() ||
949 ProjectAudioIO::Get( project ).IsAudioActive()) {
950 if (mPlaybackScroller) {
951 auto mode = mPlaybackScroller->GetMode();
952 if (mode == PlaybackScroller::Mode::Pinned ||
954 return true;
955 }
956 }
957
958 return false;
959}
bool IsAudioActive() const
static ProjectAudioIO & Get(AudacityProject &project)
static Scrubber & Get(AudacityProject &project)
Definition: Scrubbing.cpp:187

References ViewInfo::Get(), ProjectAudioIO::Get(), Scrubber::Get(), ProjectAudioIO::IsAudioActive(), mPlaybackScroller, ProjectWindowBase::mProject, 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 584 of file ProjectWindow.cpp.

585{
586 return mNextWindowID++;
587}

References mNextWindowID.

◆ OnActivate()

void ProjectWindow::OnActivate ( wxActivateEvent &  event)

Definition at line 1570 of file ProjectWindow.cpp.

1571{
1572 // Activate events can fire during window teardown, so just
1573 // ignore them.
1574 if (IsBeingDeleted()) {
1575 return;
1576 }
1577
1578 auto &project = mProject;
1579
1580 mActive = event.GetActive();
1581
1582 // Under Windows, focus can be "lost" when returning to
1583 // Audacity from a different application.
1584 //
1585 // This was observed by minimizing all windows using WINDOWS+M and
1586 // then ALT+TAB to return to Audacity. Focus will be given to the
1587 // project window frame which is not at all useful.
1588 //
1589 // So, we use ToolManager's observation of focus changes in a wxEventFilter.
1590 // Then, when we receive the
1591 // activate event, we restore that focus to the child or the track
1592 // panel if no child had the focus (which probably should never happen).
1593 if (mActive) {
1594 auto &toolManager = ToolManager::Get( project );
1595 SetActiveProject( &project );
1596 if ( ! toolManager.RestoreFocus() )
1597 GetProjectPanel( project ).SetFocus();
1598 }
1599 event.Skip();
1600}
void SetActiveProject(AudacityProject *project)
bool IsBeingDeleted() const
Definition: ProjectWindow.h:62
static ToolManager & Get(AudacityProject &project)

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

Here is the call graph for this function:

◆ OnIconize()

void ProjectWindow::OnIconize ( wxIconizeEvent &  event)

Definition at line 1356 of file ProjectWindow.cpp.

1357{
1358 //JKC: On Iconizing we get called twice. Don't know
1359 // why but it does no harm.
1360 // Should we be returning true/false rather than
1361 // void return? I don't know.
1362 mIconized = event.IsIconized();
1363
1364#if defined(__WXMAC__)
1365 // Readdresses bug 1431 since a crash could occur when restoring iconized
1366 // floating toolbars due to recursion (bug 2411).
1368 if( !mIconized )
1369 {
1370 Raise();
1371 }
1372#endif
1373
1374 // VisibileProjectCount seems to be just a counter for debugging.
1375 // It's not used outside this function.
1376 auto VisibleProjectCount = std::count_if(
1378 []( const AllProjects::value_type &ptr ){
1379 return !GetProjectFrame( *ptr ).IsIconized();
1380 }
1381 );
1382 event.Skip();
1383
1384 // This step is to fix part of Bug 2040, where the BackingPanel
1385 // size was not restored after we leave Iconized state.
1386
1387 // Queue up a resize event using OnShow so that we
1388 // refresh the track panel. But skip this, if we're iconized.
1389 if( mIconized )
1390 return;
1391 wxShowEvent Evt;
1392 OnShow( Evt );
1393}
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:56
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 1535 of file ProjectWindow.cpp.

1536{
1537#ifdef __WXMSW__
1538 // Bug 1642: We can arrive here with bogus menu IDs, which we
1539 // proceed to process. So if bogus, don't.
1540 // The bogus menu IDs are probably generated by controls on the TrackPanel,
1541 // such as the Project Rate.
1542 // 17000 is the magic number at which we start our menu.
1543 // This code would probably NOT be OK on Mac, since we assign
1544 // some specific ID numbers.
1545 if( event.GetId() < 17000){
1546 event.Skip();
1547 return;
1548 }
1549#endif
1550 auto &project = mProject;
1551 auto &commandManager = CommandManager::Get( project );
1552 bool handled = commandManager.HandleMenuID( GetProject(),
1553 event.GetId(), MenuManager::Get( project ).GetUpdateFlags(),
1554 false);
1555
1556 if (handled)
1557 event.Skip(false);
1558 else{
1559 event.ResumePropagation( 999 );
1560 event.Skip(true);
1561 }
1562}
static CommandManager & Get(AudacityProject &project)
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:553
AudacityProject & GetProject()

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

Here is the call graph for this function:

◆ OnMouseEvent()

void ProjectWindow::OnMouseEvent ( wxMouseEvent &  event)

Definition at line 1607 of file ProjectWindow.cpp.

1608{
1609 auto &project = mProject;
1610 if (event.ButtonDown())
1611 SetActiveProject( &project );
1612}

References ProjectWindowBase::mProject, and SetActiveProject().

Here is the call graph for this function:

◆ OnMove()

void ProjectWindow::OnMove ( wxMoveEvent &  event)

Definition at line 1395 of file ProjectWindow.cpp.

1396{
1397 if (!this->IsMaximized() && !this->IsIconized())
1398 SetNormalizedWindowState(this->GetRect());
1399 event.Skip();
1400}
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 576 of file ProjectWindow.cpp.

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

References Get(), and CommandContext::project.

Referenced by PluginActions::Handler::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 1484 of file ProjectWindow.cpp.

1485{
1486 auto &project = mProject;
1487 auto &viewInfo = ViewInfo::Get( project );
1488 const wxInt64 offset = PixelWidthBeforeTime(0.0);
1489 viewInfo.sbarH =
1490 (wxInt64)(mHsbar->GetThumbPosition() / viewInfo.sbarScale) - offset;
1491 DoScroll();
1492
1493#ifndef __WXMAC__
1494 // Bug2179
1495 // This keeps the time ruler in sync with horizontal scrolling, without
1496 // making an undesirable compilation dependency of this source file on
1497 // the ruler
1498 wxTheApp->ProcessIdle();
1499#endif
1500}

References DoScroll(), ViewInfo::Get(), mHsbar, ProjectWindowBase::mProject, 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 &project = mProject;
852 auto &viewInfo = ViewInfo::Get( project );
853 wxInt64 pos = mHsbar->GetThumbPosition();
854 // move at least one scroll increment
855 pos -= wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
856 pos = wxMax(pos, 0);
857 viewInfo.sbarH -= sbarHjump;
858 viewInfo.sbarH = std::max(viewInfo.sbarH,
859 -(wxInt64) PixelWidthBeforeTime(0.0));
860
861
862 if (pos != mHsbar->GetThumbPosition()) {
863 mHsbar->SetThumbPosition((int)pos);
865 }
866}
const int sbarHjump
void FinishAutoScroll()

References FinishAutoScroll(), ViewInfo::Get(), mHsbar, ProjectWindowBase::mProject, 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 897 of file ProjectWindow.cpp.

898{
899 auto &project = mProject;
900 auto &viewInfo = ViewInfo::Get( project );
901 wxInt64 pos = mHsbar->GetThumbPosition();
902 // move at least one scroll increment
903 pos -= wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
904 pos = wxMax(pos, 0);
905 viewInfo.sbarH -= sbarHjump;
906 viewInfo.sbarH = std::max(viewInfo.sbarH,
907 - (wxInt64) PixelWidthBeforeTime(0.0));
908
909 if (pos != mHsbar->GetThumbPosition()) {
910 mHsbar->SetThumbPosition((int)pos);
911 DoScroll();
912 }
913}

References DoScroll(), ViewInfo::Get(), mHsbar, ProjectWindowBase::mProject, 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 872 of file ProjectWindow.cpp.

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

References FinishAutoScroll(), ViewInfo::Get(), mHsbar, min(), ProjectWindowBase::mProject, 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 918 of file ProjectWindow.cpp.

919{
920 auto &project = mProject;
921 auto &viewInfo = ViewInfo::Get( project );
922 wxInt64 pos = mHsbar->GetThumbPosition();
923 // move at least one scroll increment
924 // use wxInt64 for calculation to prevent temporary overflow
925 pos += wxMax((wxInt64)(sbarHjump * viewInfo.sbarScale), 1);
926 wxInt64 max = mHsbar->GetRange() - mHsbar->GetThumbSize();
927 pos = wxMin(pos, max);
928 viewInfo.sbarH += sbarHjump;
929 viewInfo.sbarH = std::min(viewInfo.sbarH,
930 viewInfo.sbarTotal
931 - (wxInt64) PixelWidthBeforeTime(0.0) - viewInfo.sbarScreen);
932
933 if (pos != mHsbar->GetThumbPosition()) {
934 mHsbar->SetThumbPosition((int)pos);
935 DoScroll();
936 }
937}

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

Here is the call graph for this function:

◆ OnShow()

void ProjectWindow::OnShow ( wxShowEvent &  event)

Definition at line 1420 of file ProjectWindow.cpp.

1421{
1422 // Remember that the window has been shown at least once
1423 mShownOnce = true;
1424
1425 // (From Debian...see also TrackPanel::OnTimer and AudacityTimer::Notify)
1426 //
1427 // Description: Workaround for wxWidgets bug: Reentry in clipboard
1428 // The wxWidgets bug http://trac.wxwidgets.org/ticket/16636 prevents
1429 // us from doing clipboard operations in wxShowEvent and wxTimerEvent
1430 // processing because those event could possibly be processed during
1431 // the (not sufficiently protected) Yield() of a first clipboard
1432 // operation, causing reentry. Audacity had a workaround in place
1433 // for this problem (the class "CaptureEvents"), which however isn't
1434 // applicable with wxWidgets 3.0 because it's based on changing the
1435 // gdk event handler, a change that would be overridden by wxWidgets's
1436 // own gdk event handler change.
1437 // Instead, as a NEW workaround, specifically protect those processings
1438 // of wxShowEvent and wxTimerEvent that try to do clipboard operations
1439 // from being executed within Yield(). This is done by delaying their
1440 // execution by posting pure wxWidgets events - which are never executed
1441 // during Yield().
1442 // Author: Martin Stegh fer <[email protected]>
1443 // Bug-Debian: https://bugs.debian.org/765341
1444
1445 // the actual creation/showing of the window).
1446 // Post the event instead of calling OnSize(..) directly. This ensures that
1447 // this is a pure wxWidgets event (no GDK event behind it) and that it
1448 // therefore isn't processed within the YieldFor(..) of the clipboard
1449 // operations (workaround for Debian bug #765341).
1450 // QueueEvent() will take ownership of the event
1451 GetEventHandler()->QueueEvent(safenew wxSizeEvent(GetSize()));
1452
1453 // Further processing by default handlers
1454 event.Skip();
1455}

References mShownOnce, and safenew.

Referenced by OnIconize().

Here is the caller graph for this function:

◆ OnSize()

void ProjectWindow::OnSize ( wxSizeEvent &  event)

Definition at line 1402 of file ProjectWindow.cpp.

1403{
1404 // (From Debian)
1405 //
1406 // (3.) GTK critical warning "IA__gdk_window_get_origin: assertion
1407 // 'GDK_IS_WINDOW (window)' failed": Received events of type wxSizeEvent
1408 // on the main project window cause calls to "ClientToScreen" - which is
1409 // not available until the window is first shown. So the class has to
1410 // keep track of wxShowEvent events and inhibit those actions until the
1411 // window is first shown.
1412 if (mShownOnce) {
1413 HandleResize();
1414 if (!this->IsMaximized() && !this->IsIconized())
1415 SetNormalizedWindowState(this->GetRect());
1416 }
1417 event.Skip();
1418}

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

773{
774 if (message.appearance)
775 return;
776 auto &project = mProject;
777 this->ApplyUpdatedTheme();
778 auto &toolManager = ToolManager::Get( project );
779 for( int ii = 0; ii < ToolBarCount; ++ii )
780 {
781 ToolBar *pToolBar = toolManager.GetToolBar(ii);
782 if( pToolBar )
783 pToolBar->ReCreateButtons();
784 }
785}
@ ToolBarCount
Definition: ToolBar.h:90
void ApplyUpdatedTheme()
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:101
virtual void ReCreateButtons()
Definition: ToolBar.cpp:516
std::optional< PreferredSystemAppearance > appearance
Definition: Theme.h:112

References ThemeChangeMessage::appearance, ApplyUpdatedTheme(), ToolManager::Get(), ProjectWindowBase::mProject, ToolBar::ReCreateButtons(), and ToolBarCount.

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

1461{
1462 HandleResize();
1463
1464 event.Skip(false); /* No need to propagate any further */
1465}

References HandleResize().

Here is the call graph for this function:

◆ OnUndoPushedModified()

void ProjectWindow::OnUndoPushedModified ( )

Definition at line 1467 of file ProjectWindow.cpp.

1468{
1469 RedrawProject();
1470}
void RedrawProject(const bool bForceWaveTracks=false)

References RedrawProject().

Here is the call graph for this function:

◆ OnUndoRedo()

void ProjectWindow::OnUndoRedo ( )

Definition at line 1472 of file ProjectWindow.cpp.

1473{
1474 HandleResize();
1475 RedrawProject();
1476}

References HandleResize(), and RedrawProject().

Here is the call graph for this function:

◆ OnUndoReset()

void ProjectWindow::OnUndoReset ( )

Definition at line 1478 of file ProjectWindow.cpp.

1479{
1480 HandleResize();
1481 // RedrawProject(); // Should we do this here too?
1482}

References HandleResize().

Here is the call graph for this function:

◆ OnUpdateUI()

void ProjectWindow::OnUpdateUI ( wxUpdateUIEvent &  event)

Definition at line 1564 of file ProjectWindow.cpp.

1565{
1566 auto &project = mProject;
1567 MenuManager::Get( project ).UpdateMenus();
1568}

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

Here is the call graph for this function:

◆ PixelWidthBeforeTime()

double ProjectWindow::PixelWidthBeforeTime ( double  scrollto) const

Definition at line 974 of file ProjectWindow.cpp.

975{
976 auto &project = mProject;
977 auto &viewInfo = ViewInfo::Get( project );
978 const double lowerBound = ScrollingLowerBoundTime();
979 return
980 // Ignoring fisheye is correct here
981 viewInfo.TimeRangeToPixelWidth(scrollto - lowerBound);
982}

References ViewInfo::Get(), ProjectWindowBase::mProject, 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 747 of file ProjectWindow.cpp.

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

References BasicUI::CallAfter(), for(), 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 1289 of file ProjectWindow.cpp.

1290{
1291 wxRect defaultRect;
1292 GetDefaultWindowRect(&defaultRect);
1293
1294 SetSize(defaultRect.width, defaultRect.height);
1295}
void GetDefaultWindowRect(wxRect *defRect)

References GetDefaultWindowRect().

Here is the call graph for this function:

◆ Rewind()

void ProjectWindow::Rewind ( bool  shift)

Definition at line 1669 of file ProjectWindow.cpp.

1670{
1671 auto &project = mProject;
1672 auto &viewInfo = ViewInfo::Get( project );
1673 viewInfo.selectedRegion.setT0(0, false);
1674 if (!shift)
1675 viewInfo.selectedRegion.setT1(0);
1676
1677 TP_ScrollWindow(0);
1678}
void TP_ScrollWindow(double scrollto) override

References ViewInfo::Get(), ProjectWindowBase::mProject, 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 961 of file ProjectWindow.cpp.

962{
963 auto &project = mProject;
964 auto &tracks = TrackList::Get( project );
965 auto &viewInfo = ViewInfo::Get( project );
966 if (!MayScrollBeyondZero())
967 return 0;
968 const double screen = viewInfo.GetScreenEndTime() - viewInfo.h;
969 return std::min(tracks.GetStartTime(), -screen);
970}

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

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

825{
826 auto &trackPanel = GetProjectPanel( mProject );
827 auto &viewInfo = ViewInfo::Get( mProject );
828 auto w = viewInfo.GetTracksUsableWidth();
829
830 int pixel = viewInfo.TimeToPosition(pos);
831 if (pixel < 0 || pixel >= w)
832 {
834 (viewInfo.OffsetTimeByPixels(pos, -(w / 2)));
835 trackPanel.Refresh(false);
836 }
837}

References ViewInfo::Get(), GetProjectPanel(), ProjectWindowBase::mProject, 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 839 of file ProjectWindow.cpp.

840{
841 auto &viewInfo = ViewInfo::Get( mProject );
842 ScrollIntoView(viewInfo.PositionToTime(x, viewInfo.GetLeftOffset()));
843}
void ScrollIntoView(double pos)

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

Here is the call graph for this function:

◆ SetHorizontalThumb()

void ProjectWindow::SetHorizontalThumb ( double  scrollto)

Definition at line 984 of file ProjectWindow.cpp.

985{
986 auto &project = mProject;
987 auto &viewInfo = ViewInfo::Get( project );
988 const auto unscaled = PixelWidthBeforeTime(scrollto);
989 const int max = mHsbar->GetRange() - mHsbar->GetThumbSize();
990 const int pos =
991 std::min(max,
992 std::max(0,
993 (int)(floor(0.5 + unscaled * viewInfo.sbarScale))));
994 mHsbar->SetThumbPosition(pos);
995 viewInfo.sbarH = floor(0.5 + unscaled - PixelWidthBeforeTime(0.0));
996 viewInfo.sbarH = std::max(viewInfo.sbarH,
997 - (wxInt64) PixelWidthBeforeTime(0.0));
998 viewInfo.sbarH = std::min(viewInfo.sbarH,
999 viewInfo.sbarTotal
1000 - (wxInt64) PixelWidthBeforeTime(0.0) - viewInfo.sbarScreen);
1001}

References ViewInfo::Get(), mHsbar, min(), ProjectWindowBase::mProject, 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 127 of file ProjectWindow.h.

127{ mNormalizedWindowState = pSizeAndLocation; }

Referenced by OnMove(), and OnSize().

Here is the caller graph for this function:

◆ ShowEffectsPanel()

void ProjectWindow::ShowEffectsPanel ( Track track = nullptr,
bool  focus = false 
)

Definition at line 1915 of file ProjectWindow.cpp.

1916{
1917 if(track == nullptr)
1918 {
1920 return;
1921 }
1922
1923 wxWindowUpdateLocker freeze(this);
1924
1925 mEffectsWindow->SetTrack(track->shared_from_this());
1926
1927 if(mContainerWindow->GetWindow1() != mEffectsWindow)
1928 {
1929 //Restore previous effects window size
1930 mContainerWindow->SplitVertically(
1933 mEffectsWindow->GetSize().GetWidth());
1934 }
1935 if(focus)
1937 Layout();
1938}
void SetTrack(const std::shared_ptr< Track > &track)
Shows effects from the effect stack of the track.

References mContainerWindow, mEffectsWindow, mTrackListWindow, RealtimeEffectPanel::ResetTrack(), RealtimeEffectPanel::SetFocus(), and RealtimeEffectPanel::SetTrack().

Referenced by EffectsButtonHandle::CommitChanges().

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

◆ SkipEnd()

void ProjectWindow::SkipEnd ( bool  shift)

Definition at line 1689 of file ProjectWindow.cpp.

1690{
1691 auto &project = mProject;
1692 auto &tracks = TrackList::Get( project );
1693 auto &viewInfo = ViewInfo::Get( project );
1694 double len = tracks.GetEndTime();
1695
1696 viewInfo.selectedRegion.setT1(len, false);
1697 if (!shift)
1698 viewInfo.selectedRegion.setT0(len);
1699
1700 // Make sure the end of the track is visible
1701 ScrollIntoView(len);
1702}

References ViewInfo::Get(), TrackList::Get(), ProjectWindowBase::mProject, 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 1722 of file ProjectWindow.cpp.

1723{
1724 HandleResize();
1725}

References HandleResize().

Here is the call graph for this function:

◆ TP_RedrawScrollbars()

void ProjectWindow::TP_RedrawScrollbars ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1717 of file ProjectWindow.cpp.

1718{
1719 FixScrollbars();
1720}

References FixScrollbars().

Here is the call graph for this function:

◆ TP_ScrollLeft()

void ProjectWindow::TP_ScrollLeft ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1705 of file ProjectWindow.cpp.

1706{
1707 OnScrollLeft();
1708}

References OnScrollLeft().

Here is the call graph for this function:

◆ TP_ScrollRight()

void ProjectWindow::TP_ScrollRight ( )
overridevirtual

Implements TrackPanelListener.

Definition at line 1711 of file ProjectWindow.cpp.

1712{
1713 OnScrollRight();
1714}

References OnScrollRight().

Here is the call graph for this function:

◆ TP_ScrollUpDown()

bool ProjectWindow::TP_ScrollUpDown ( int  delta)
overridevirtual

Implements TrackPanelListener.

Definition at line 1021 of file ProjectWindow.cpp.

1022{
1023 int oldPos = mVsbar->GetThumbPosition();
1024 int pos = oldPos + delta;
1025 int max = mVsbar->GetRange() - mVsbar->GetThumbSize();
1026
1027 // Can be negative in case of only one track
1028 if (max < 0)
1029 max = 0;
1030
1031 if (pos > max)
1032 pos = max;
1033 else if (pos < 0)
1034 pos = 0;
1035
1036 if (pos != oldPos)
1037 {
1038 mVsbar->SetThumbPosition(pos);
1039
1040 DoScroll();
1041 return true;
1042 }
1043 else
1044 return false;
1045}

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

1008{
1009 SetHorizontalThumb(scrollto);
1010
1011 // Call our Scroll method which updates our ViewInfo variables
1012 // to reflect the positions of the scrollbars
1013 DoScroll();
1014}

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

1204{
1205 auto &project = mProject;
1206 auto &trackPanel = GetProjectPanel( project );
1207 auto &toolManager = ToolManager::Get( project );
1208
1209 // 1. Layout panel, to get widths of the docks.
1210 Layout();
1211 // 2. Layout toolbars to pack the toolbars correctly in docks which
1212 // are now the correct width.
1213 toolManager.LayoutToolBars();
1214 // 3. Layout panel, to resize docks, in particular reducing the height
1215 // of any empty docks, or increasing the height of docks that need it.
1216 Layout();
1217
1218 // Bug 2455
1219 // The commented out code below is to calculate a nice minimum size for
1220 // the window. However on Ubuntu when the window is minimised it leads to
1221 // an insanely tall window.
1222 // Using a fixed min size fixes that.
1223 // However there is still something strange when minimised, as once
1224 // UpdateLayout is called once, when minimised, it gets called repeatedly.
1225#if 0
1226 // Retrieve size of this projects window
1227 wxSize mainsz = GetSize();
1228
1229 // Retrieve position of the track panel to use as the size of the top
1230 // third of the window
1231 wxPoint tppos = ClientToScreen(trackPanel.GetParent()->GetPosition());
1232
1233 // Retrieve position of bottom dock to use as the size of the bottom
1234 // third of the window
1235 wxPoint sbpos = ClientToScreen(toolManager.GetBotDock()->GetPosition());
1236
1237 // The "+ 50" is the minimum height of the TrackPanel
1238 SetMinSize( wxSize(250, (mainsz.y - sbpos.y) + tppos.y + 50));
1239#endif
1240 SetMinSize( wxSize(250, 250));
1241 SetMaxSize( wxSize(20000, 20000));
1242}

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

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

788{
789 // Update status bar widths in case of language change
791}
void UpdateStatusWidths()

References UpdateStatusWidths().

Here is the call graph for this function:

◆ UpdateStatusWidths()

void ProjectWindow::UpdateStatusWidths ( )

Definition at line 1297 of file ProjectWindow.cpp.

1298{
1299 enum { nWidths = nStatusBarFields + 1 };
1300 int widths[ nWidths ]{ 0 };
1301 widths[ rateStatusBarField ] = 150;
1302 const auto statusBar = GetStatusBar();
1303 const auto &functions = ProjectStatus::GetStatusWidthFunctions();
1304 // Start from 1 not 0
1305 // Specifying a first column always of width 0 was needed for reasons
1306 // I forget now
1307 for ( int ii = 1; ii <= nStatusBarFields; ++ii ) {
1308 int &width = widths[ ii ];
1309 for ( const auto &function : functions ) {
1310 auto results =
1311 function( mProject, static_cast< StatusBarField >( ii ) );
1312 for ( const auto &string : results.first ) {
1313 int w;
1314 statusBar->GetTextExtent(string.Translation(), &w, nullptr);
1315 width = std::max<int>( width, w + results.second );
1316 }
1317 }
1318 }
1319 // The main status field is not fixed width
1320 widths[ mainStatusBarField ] = -1;
1321 statusBar->SetStatusWidths( nWidths, widths );
1322}
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 ProjectStatus::GetStatusWidthFunctions(), mainStatusBarField, ProjectWindowBase::mProject, 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 1634 of file ProjectWindow.cpp.

1635{
1636 auto &project = mProject;
1637 auto &viewInfo = ViewInfo::Get( project );
1638 viewInfo.SetZoom(level);
1639 FixScrollbars();
1640 // See if we can center the selection on screen, and have it actually fit.
1641 // tOnLeft is the amount of time we would need before the selection left edge to center it.
1642 float t0 = viewInfo.selectedRegion.t0();
1643 float t1 = viewInfo.selectedRegion.t1();
1644 float tAvailable = viewInfo.GetScreenEndTime() - viewInfo.h;
1645 float tOnLeft = (tAvailable - t0 + t1)/2.0;
1646 // Bug 1292 (Enh) is effectively a request to do this scrolling of the selection into view.
1647 // If tOnLeft is positive, then we have room for the selection, so scroll to it.
1648 if( tOnLeft >=0 )
1649 TP_ScrollWindow( t0-tOnLeft);
1650}

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

Here is the call graph for this function:

◆ ZoomAfterImport()

void ProjectWindow::ZoomAfterImport ( Track pTrack)

Definition at line 1614 of file ProjectWindow.cpp.

1615{
1616 auto &project = mProject;
1617 auto &tracks = TrackList::Get( project );
1618 auto &trackPanel = GetProjectPanel( project );
1619
1620 DoZoomFit();
1621
1622 trackPanel.SetFocus();
1623 if (!pTrack)
1624 pTrack = *tracks.Selected().begin();
1625 if (!pTrack)
1626 pTrack = *tracks.Any().begin();
1627 if (pTrack) {
1628 TrackFocus::Get(project).Set(pTrack);
1629 pTrack->EnsureVisible();
1630 }
1631}
void EnsureVisible(bool modifyState=false)
Definition: Track.cpp:97
bool Any() const
Definition: Track.cpp:399

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

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

1654{
1655 auto &project = mProject;
1656 auto &viewInfo = ViewInfo::Get( project );
1657 viewInfo.ZoomBy(multiplier);
1658 FixScrollbars();
1659}

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

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

1784{
1785 auto &project = mProject;
1786 auto &viewInfo = ViewInfo::Get( project );
1787
1788 auto gAudioIO = AudioIO::Get();
1789 // LLL: Handling positioning differently when audio is
1790 // actively playing. Don't do this if paused.
1791 if (gAudioIO->IsStreamActive(
1792 ProjectAudioIO::Get( project ).GetAudioIOToken()) &&
1793 !gAudioIO->IsPaused()){
1794 ZoomBy(ZoomFactor);
1795 ScrollIntoView(gAudioIO->GetStreamTime());
1796 return;
1797 }
1798
1799 // DMM: Here's my attempt to get logical zooming behavior
1800 // when there's a selection that's currently at least
1801 // partially on-screen
1802
1803 const double endTime = viewInfo.GetScreenEndTime();
1804 const double duration = endTime - viewInfo.h;
1805
1806 bool selectionIsOnscreen =
1807 (viewInfo.selectedRegion.t0() < endTime) &&
1808 (viewInfo.selectedRegion.t1() >= viewInfo.h);
1809
1810 bool selectionFillsScreen =
1811 (viewInfo.selectedRegion.t0() < viewInfo.h) &&
1812 (viewInfo.selectedRegion.t1() > endTime);
1813
1814 if (selectionIsOnscreen && !selectionFillsScreen) {
1815 // Start with the center of the selection
1816 double selCenter = (viewInfo.selectedRegion.t0() +
1817 viewInfo.selectedRegion.t1()) / 2;
1818
1819 // If the selection center is off-screen, pick the
1820 // center of the part that is on-screen.
1821 if (selCenter < viewInfo.h)
1822 selCenter = viewInfo.h +
1823 (viewInfo.selectedRegion.t1() - viewInfo.h) / 2;
1824 if (selCenter > endTime)
1825 selCenter = endTime -
1826 (endTime - viewInfo.selectedRegion.t0()) / 2;
1827
1828 // Zoom in
1829 ZoomBy(ZoomFactor);
1830 const double newDuration =
1831 viewInfo.GetScreenEndTime() - viewInfo.h;
1832
1833 // Recenter on selCenter
1834 TP_ScrollWindow(selCenter - newDuration / 2);
1835 return;
1836 }
1837
1838
1839 double origLeft = viewInfo.h;
1840 double origWidth = duration;
1841 ZoomBy(ZoomFactor);
1842
1843 const double newDuration =
1844 viewInfo.GetScreenEndTime() - viewInfo.h;
1845 double newh = origLeft + (origWidth - newDuration) / 2;
1846
1847 // MM: Commented this out because it was confusing users
1848 /*
1849 // make sure that the *right-hand* end of the selection is
1850 // no further *left* than 1/3 of the way across the screen
1851 if (viewInfo.selectedRegion.t1() < newh + viewInfo.screen / 3)
1852 newh = viewInfo.selectedRegion.t1() - viewInfo.screen / 3;
1853
1854 // make sure that the *left-hand* end of the selection is
1855 // no further *right* than 2/3 of the way across the screen
1856 if (viewInfo.selectedRegion.t0() > newh + viewInfo.screen * 2 / 3)
1857 newh = viewInfo.selectedRegion.t0() - viewInfo.screen * 2 / 3;
1858 */
1859
1860 TP_ScrollWindow(newh);
1861}
static AudioIO * Get()
Definition: AudioIO.cpp:133
int GetAudioIOToken() const
void ZoomBy(double multiplier)

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

Here is the call graph for this function:

◆ ZoomOutByFactor()

void ProjectWindow::ZoomOutByFactor ( double  ZoomFactor)

Definition at line 1863 of file ProjectWindow.cpp.

1864{
1865 auto &project = mProject;
1866 auto &viewInfo = ViewInfo::Get( project );
1867
1868 //Zoom() may change these, so record original values:
1869 const double origLeft = viewInfo.h;
1870 const double origWidth = viewInfo.GetScreenEndTime() - origLeft;
1871
1872 ZoomBy(ZoomFactor);
1873 const double newWidth = viewInfo.GetScreenEndTime() - viewInfo.h;
1874
1875 const double newh = origLeft + (origWidth - newWidth) / 2;
1876 // newh = (newh > 0) ? newh : 0;
1877 TP_ScrollWindow(newh);
1878}

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

Here is the call graph for this function:

Member Data Documentation

◆ mActive

bool ProjectWindow::mActive { true }
private

Definition at line 231 of file ProjectWindow.h.

Referenced by IsActive(), and OnActivate().

◆ mAutoScrolling

bool ProjectWindow::mAutoScrolling { false }
private

Definition at line 230 of file ProjectWindow.h.

Referenced by DoScroll(), and FinishAutoScroll().

◆ mbInitializingScrollbar

bool ProjectWindow::mbInitializingScrollbar { false }

Definition at line 215 of file ProjectWindow.h.

Referenced by FixScrollbars().

◆ mContainerWindow

wxSplitterWindow* ProjectWindow::mContainerWindow
private

◆ mEffectsWindow

RealtimeEffectPanel* ProjectWindow::mEffectsWindow {}
private

◆ mFocusChangeSubscription

Observer::Subscription ProjectWindow::mFocusChangeSubscription
private

Definition at line 245 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mHsbar

wxScrollBar* ProjectWindow::mHsbar {}
private

◆ mIconized

bool ProjectWindow::mIconized { false }
private

Definition at line 232 of file ProjectWindow.h.

Referenced by IsIconized(), and OnIconize().

◆ mIsDeleting

bool ProjectWindow::mIsDeleting { false }
private

Definition at line 237 of file ProjectWindow.h.

Referenced by HandleResize().

◆ mNextWindowID

int ProjectWindow::mNextWindowID {}
private

Definition at line 228 of file ProjectWindow.h.

Referenced by NextWindowID(), and ProjectWindow().

◆ mNormalizedWindowState

wxRect ProjectWindow::mNormalizedWindowState
private

Definition at line 218 of file ProjectWindow.h.

◆ mPlaybackScroller

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

Definition at line 243 of file ProjectWindow.h.

Referenced by MayScrollBeyondZero(), and ProjectWindow().

◆ mShownOnce

bool ProjectWindow::mShownOnce { false }
private

Definition at line 233 of file ProjectWindow.h.

Referenced by OnShow(), and OnSize().

◆ mThemeChangeSubscription

Observer::Subscription ProjectWindow::mThemeChangeSubscription
private

Definition at line 242 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mTopPanel

wxPanel* ProjectWindow::mTopPanel {}
private

Definition at line 220 of file ProjectWindow.h.

Referenced by GetTopPanel(), and ProjectWindow().

◆ mTrackListWindow

wxWindow* ProjectWindow::mTrackListWindow {}
private

◆ mUndoSubscription

Observer::Subscription ProjectWindow::mUndoSubscription
private

Definition at line 241 of file ProjectWindow.h.

Referenced by ProjectWindow().

◆ mVsbar

wxScrollBar* ProjectWindow::mVsbar {}
private

Definition at line 226 of file ProjectWindow.h.

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


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