Audacity  2.3.1
Classes | Enumerations | Functions | Variables
Project.cpp File Reference

Implements AudacityProject, DropTarget, and FileObject.F. More...

#include "Audacity.h"
#include "Project.h"
#include <stdio.h>
#include <iostream>
#include <wx/wxprec.h>
#include <wx/apptrait.h>
#include <wx/defs.h>
#include <wx/app.h>
#include <wx/dc.h>
#include <wx/dcmemory.h>
#include <wx/dnd.h>
#include <wx/docview.h>
#include <wx/event.h>
#include <wx/ffile.h>
#include <wx/filedlg.h>
#include <wx/filefn.h>
#include <wx/filename.h>
#include <wx/intl.h>
#include <wx/log.h>
#include <wx/menu.h>
#include <wx/notebook.h>
#include <wx/progdlg.h>
#include <wx/scrolbar.h>
#include <wx/sizer.h>
#include <wx/statusbr.h>
#include <wx/string.h>
#include <wx/textfile.h>
#include <wx/timer.h>
#include <wx/display.h>
#include "AdornedRulerPanel.h"
#include "AudacityException.h"
#include "FreqWindow.h"
#include "effects/Contrast.h"
#include "AutoRecovery.h"
#include "AudacityApp.h"
#include "AColor.h"
#include "AudioIO.h"
#include "BatchProcessDialog.h"
#include "Dependencies.h"
#include "Diags.h"
#include "HistoryWindow.h"
#include "InconsistencyException.h"
#include "MixerBoard.h"
#include "Internat.h"
#include "import/Import.h"
#include "LabelTrack.h"
#include "Legacy.h"
#include "LyricsWindow.h"
#include "Menus.h"
#include "Mix.h"
#include "NoteTrack.h"
#include "Prefs.h"
#include "Sequence.h"
#include "Snap.h"
#include "Tags.h"
#include "TimeTrack.h"
#include "TrackPanel.h"
#include "WaveTrack.h"
#include "DirManager.h"
#include "commands/CommandManager.h"
#include "effects/Effect.h"
#include "prefs/PrefsDialog.h"
#include "widgets/LinkingHtmlWindow.h"
#include "widgets/ASlider.h"
#include "widgets/ErrorDialog.h"
#include "widgets/Warning.h"
#include "xml/XMLFileReader.h"
#include "PlatformCompatibility.h"
#include "Experimental.h"
#include "export/Export.h"
#include "FileNames.h"
#include "BlockFile.h"
#include "ondemand/ODManager.h"
#include "ondemand/ODTask.h"
#include "ondemand/ODComputeSummaryTask.h"
#include "ModuleManager.h"
#include "Theme.h"
#include "AllThemeResources.h"
#include "FileDialog.h"
#include "UndoManager.h"
#include "toolbars/ToolManager.h"
#include "toolbars/ControlToolBar.h"
#include "toolbars/DeviceToolBar.h"
#include "toolbars/EditToolBar.h"
#include "toolbars/MeterToolBar.h"
#include "toolbars/MixerToolBar.h"
#include "toolbars/ScrubbingToolBar.h"
#include "toolbars/SelectionBar.h"
#include "toolbars/SpectralSelectionBar.h"
#include "toolbars/ToolsToolBar.h"
#include "toolbars/TranscriptionToolBar.h"
#include "tracks/ui/BackgroundCell.h"
#include "tracks/ui/EditCursorOverlay.h"
#include "tracks/ui/PlayIndicatorOverlay.h"
#include "tracks/ui/Scrubbing.h"
#include "commands/ScriptCommandRelay.h"
#include "commands/CommandTargets.h"
#include "commands/Command.h"
#include "commands/CommandType.h"
#include "commands/CommandContext.h"
#include "prefs/QualityPrefs.h"
#include "prefs/TracksPrefs.h"
#include "../images/AudacityLogoAlpha.xpm"

Go to the source code of this file.

Classes

class  VarSetter< T >
 
class  ScrollBar
 
class  TitleRestorer
 

Enumerations

enum  { FirstID = 1000, HSBarID, VSBarID, TrackPanelID }
 

Functions

 DEFINE_EVENT_TYPE (EVT_CAPTURE_KEY)
 Custom events. More...
 
static void SetActiveProject (AudacityProject *project)
 
AUDACITY_DLL_API AudacityProjectGetActiveProject ()
 
AudacityProjectCreateNewAudacityProject ()
 
void RedrawAllProjects ()
 
void RefreshCursorForAllProjects ()
 
AUDACITY_DLL_API void CloseAllProjects ()
 
void GetDefaultWindowRect (wxRect *defRect)
 
bool IsWindowAccessible (wxRect *requestedRect)
 
int ScreenContaining (wxRect &r)
 
bool CornersOnScreen (wxRect &r)
 
void GetNextWindowPlacement (wxRect *nextRect, bool *pMaximized, bool *pIconized)
 
static wxString CreateUniqueName ()
 
static wxString gsLegacyFileWarning ()
 

Variables

const int sbarSpaceWidth = 15
 
const int sbarControlWidth = 15
 
const int sbarExtraLen = 0
 
const int sbarHjump = 30
 
static int gAudacityOffsetInc = 0
 
static int gAudacityPosInc = 0
 
static AudacityProjectgActiveProject
 
AProjectArray gAudacityProjects
 

Detailed Description

Implements AudacityProject, DropTarget, and FileObject.F.

Definition in file Project.cpp.

Enumeration Type Documentation

anonymous enum
Enumerator
FirstID 
HSBarID 
VSBarID 
TrackPanelID 

Definition at line 948 of file Project.cpp.

948  {
949  FirstID = 1000,
950 
951  // Window controls
952 
953  HSBarID,
954  VSBarID,
956 };

Function Documentation

AUDACITY_DLL_API void CloseAllProjects ( )

Definition at line 614 of file Project.cpp.

References gAudacityOffsetInc, gAudacityPosInc, and gAudacityProjects.

615 {
616  size_t len = gAudacityProjects.size();
617  for (size_t i = 0; i < len; i++)
618  gAudacityProjects[i]->Close();
619 
620  //Set the Offset and Position increments to 0
621  gAudacityOffsetInc = 0;
622  gAudacityPosInc = 0;
623 }
static int gAudacityOffsetInc
Definition: Project.cpp:301
AProjectArray gAudacityProjects
Definition: Project.cpp:306
static int gAudacityPosInc
Definition: Project.cpp:302
bool CornersOnScreen ( wxRect &  r)

Definition at line 711 of file Project.cpp.

Referenced by GetNextWindowPlacement().

711  {
712  if( wxDisplay::GetFromPoint( r.GetTopLeft() ) == wxNOT_FOUND) return false;
713  if( wxDisplay::GetFromPoint( r.GetBottomRight() ) == wxNOT_FOUND) return false;
714  return true;
715 }
AudacityProject* CreateNewAudacityProject ( )

Definition at line 552 of file Project.cpp.

References ModuleManager::Dispatch(), gAudacityProjects, gAudioIO, ModuleManager::Get(), GetNextWindowPlacement(), ProjectInitialized, safenew, SetActiveProject(), and AudioIO::SetListener().

Referenced by FileActions::DoImportMIDI(), AudacityProject::OnCloseWindow(), AudacityApp::OnInit(), AudacityApp::OnMenuNew(), FileActions::Handler::OnNew(), and AudacityProject::OpenProject().

553 {
554  wxRect wndRect;
555  bool bMaximized = false;
556  bool bIconized = false;
557  GetNextWindowPlacement(&wndRect, &bMaximized, &bIconized);
558 
559  // Create and show a NEW project
560  // Use a non-default deleter in the smart pointer!
561  gAudacityProjects.push_back( AProjectHolder {
563  nullptr, -1,
564  wxDefaultPosition,
565  wxSize(wndRect.width, wndRect.height)
566  ),
568  } );
569  const auto p = gAudacityProjects.back().get();
570 
571  // wxGTK3 seems to need to require creating the window using default position
572  // and then manually positioning it.
573  p->SetPosition(wndRect.GetPosition());
574 
575  if(bMaximized) {
576  p->Maximize(true);
577  }
578  else if (bIconized) {
579  // if the user close down and iconized state we could start back up and iconized state
580  // p->Iconize(TRUE);
581  }
582 
583  //Initialise the Listener
584  gAudioIO->SetListener(p);
585 
586  //Set the NEW project as active:
587  SetActiveProject(p);
588 
589  // Okay, GetActiveProject() is ready. Now we can get its CommandManager,
590  // and add the shortcut keys to the tooltips.
591  p->GetToolManager()->RegenerateTooltips();
592 
594 
595  p->Show(true);
596 
597  return p;
598 }
void GetNextWindowPlacement(wxRect *nextRect, bool *pMaximized, bool *pIconized)
Definition: Project.cpp:721
static ModuleManager & Get()
AProjectArray gAudacityProjects
Definition: Project.cpp:306
std::shared_ptr< AudacityProject > AProjectHolder
Definition: Project.h:116
#define safenew
Definition: Audacity.h:230
int Dispatch(ModuleDispatchTypes type)
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:174
A deleter class to supply the second template parameter of unique_ptr for classes like wxWindow that ...
Definition: MemoryX.h:353
AudioIO * gAudioIO
Definition: AudioIO.cpp:491
void SetListener(AudioIOListener *listener)
Definition: AudioIO.cpp:4131
static void SetActiveProject(AudacityProject *project)
Definition: Project.cpp:316
static wxString CreateUniqueName ( )
static

Definition at line 883 of file Project.cpp.

Referenced by AudacityProject::AutoSave().

884 {
885  static int count = 0;
886  return wxDateTime::Now().Format(wxT("%Y-%m-%d %H-%M-%S")) +
887  wxString::Format(wxT(" N-%i"), ++count);
888 }
DEFINE_EVENT_TYPE ( EVT_CAPTURE_KEY  )

Custom events.

AUDACITY_DLL_API AudacityProject* GetActiveProject ( )

Definition at line 311 of file Project.cpp.

References gActiveProject.

Referenced by LongMessageDialog::AcceptText(), AudacityCommand::Apply(), Effect::Apply(), MacroCommands::ApplyCommand(), MacroCommands::ApplyCommandInBatchMode(), MacroCommands::ApplyEffectCommand(), SetTrackVisualsCommand::ApplyInner(), MacroCommands::ApplyMacro(), MacroCommands::ApplySpecialCommand(), TrackSelectHandle::CalculateRearrangingThresholds(), ControlToolBar::CancelRecording(), ControlToolBar::CanStopAudioStream(), AudacityProject::CaptureKeyboard(), LabelTrack::Char(), TimeTrack::Clear(), WaveformPrefs::Commit(), KeyConfigPrefs::Commit(), ControlToolBar::CommitRecording(), ContrastDialog::ContrastDialog(), LabelTrack::DoCaptureKey(), ControlToolBar::DoRecord(), TransportActions::DoTogglePinnedHead(), Effect::Effect(), EffectUIHost::EffectUIHost(), DeviceToolBar::EnableDisableButtons(), ScrubbingToolBar::EnableDisableButtons(), TranscriptionToolBar::EnableDisableButtons(), ControlToolBar::EnableDisableButtons(), ExecCommand(), TimerRecordDialog::ExecutePostRecordActions(), CommandManagerEventMonitor::FilterEvent(), CommandManager::FilterKeyEvent(), EditToolBar::ForAllButtons(), FreqWindow::FreqWindow(), TrackInfo::GainSlider(), CommandManager::GetCategories(), ContrastDialog::GetDB(), MacroCommands::GetEndTime(), AudacityProject::GetKeyboardCaptureHandler(), CommandContext::GetProject(), TranscriptionToolBar::GetSamples(), Effect::GetSelectionFormat(), CommandManager::HandleCommandEntry(), CommandManager::HandleMenuID(), CommandManager::HandleTextualCommand(), IdleHandler(), Importer::Import(), EffectScienFilter::Init(), NyquistEffect::Init(), EffectEqualization::Init(), TrackMenuTable::InitMenu(), WaveColorMenuTable::InitMenu(), FormatMenuTable::InitMenu(), RateMenuTable::InitMenu(), WaveTrackMenuTable::InitMenu(), MacroCommands::IsMono(), Track::IsSyncLockSelected(), ControlToolBar::IsTransportingPinned(), LabelTrack::KeyDown(), AudacityApp::MRUOpen(), ApplyMacroDialog::OnApplyToFiles(), TimerRecordDialog::OnAutoExportPathButton_Click(), TimerRecordDialog::OnAutoSavePathButton_Click(), ScrubbingToolBar::OnButton(), EditToolBar::OnButton(), NoteTrackMenuTable::OnChangeOctave(), LabelTrack::OnChar(), LabelTrack::OnContextMenu(), AudacityApp::OnExceptionInMainLoop(), ContrastDialog::OnExport(), ControlToolBar::OnFF(), QuickFixDialog::OnFix(), FormatMenuTable::OnFormatChange(), ContrastDialog::OnGetBackground(), ContrastDialog::OnGetForeground(), Exporter::OnHelp(), AudacityApp::OnKeyDown(), LabelTrack::OnKeyDown(), ControlToolBar::OnKeyEvent(), LyricsPanel::OnKeyEvent(), MixerBoardFrame::OnKeyEvent(), WaveTrackMenuTable::OnMergeStereo(), MeterPanel::OnMouse(), HighlightTextCtrl::OnMouseEvent(), AButton::OnMouseEvent(), LWSlider::OnMouseEvent(), TrackMenuTable::OnMoveTrack(), TimerRecordDialog::OnOK(), ControlToolBar::OnPause(), ControlToolBar::OnPlay(), MeterPanel::OnPreferences(), CommandHandler::OnReceiveCommand(), ControlToolBar::OnRecord(), ControlToolBar::OnRewind(), LabelDialog::OnSelectCell(), WaveTrackMenuTable::OnSetDisplay(), TrackMenuTable::OnSetName(), TimeTrackMenuTable::OnSetTimeTrackRange(), MultiDialog::OnShowLog(), WaveTrackMenuTable::OnSpectrogramSettings(), SpectrumVRulerMenuTable::OnSpectrumScaleType(), WaveTrackMenuTable::OnSplitStereo(), WaveTrackMenuTable::OnSplitStereoMono(), ControlToolBar::OnStop(), WaveTrackMenuTable::OnSwapChannels(), AudacityApp::OnTimer(), TimeTrackMenuTable::OnTimeTrackLin(), TimeTrackMenuTable::OnTimeTrackLog(), TimeTrackMenuTable::OnTimeTrackLogInt(), ScreenFrame::OnUIUpdate(), WaveColorMenuTable::OnWaveColorChange(), WaveformVRulerMenuTable::OnWaveformScaleType(), WaveTrackVRulerMenuTable::OnZoom(), TrackInfo::PanSlider(), TimeTrack::Paste(), TranscriptionToolBar::PlayAtSpeed(), ControlToolBar::PlayCurrentRegion(), ControlToolBar::PlayPlayRegion(), KeyConfigPrefs::Populate(), EffectToneGen::PopulateOrExchange(), TimerRecordDialog::PopulateOrExchange(), EffectEqualization::PopulateOrExchange(), TrackSelectHandle::Preview(), SpectrumPrefs::Preview(), Generator::Process(), NyquistEffect::Process(), EffectTruncSilence::ProcessIndependently(), EffectStereoToMono::ProcessOne(), EffectEqualization::ProcessOne(), Effect::ProcessTrack(), ScrubbingToolBar::RegenerateTooltips(), TrackSelectHandle::Release(), AudacityProject::ReleaseKeyboard(), SpectrumPrefs::Rollback(), TimerRecordDialog::RunWaitDialog(), EffectToneGen::SetAutomationParameters(), ToolBar::SetButtonToolTip(), CommandImplementation::SetParameter(), ControlToolBar::SetPlay(), RateMenuTable::SetRate(), ContrastDialog::SetStartAndEndTime(), ControlToolBar::SetupCutPreviewTracks(), SelectHandle::SetUseSnap(), ZoomInfo::SetZoom(), LabelTrack::ShowContextMenu(), HelpSystem::ShowHelp(), SnapManager::Snap(), SnapManager::SnapManager(), WaveTrackMenuTable::SplitStereo(), ODManager::Start(), MeterPanel::StartMonitoring(), AudioIO::StartPortAudioStream(), ControlToolBar::StartScrolling(), ControlToolBar::StartScrollingIfPreferred(), ControlToolBar::StateForStatusBar(), ControlToolBar::StopPlaying(), ControlToolBar::StopScrolling(), WaveTrack::SyncLockAdjust(), Scrubber::Thunk(), MuteButtonHandle::Tip(), CloseButtonHandle::Tip(), SoloButtonHandle::Tip(), MenuButtonHandle::Tip(), LyricsPanel::Update(), MenuManager::UpdateMenus(), MacrosWindow::UpdateMenus(), AButton::UpdateStatus(), TrackInfo::VelocitySlider(), WaveTrack::WaveTrack(), and MacroCommands::WriteMp3File().

312 {
313  return gActiveProject;
314 }
static AudacityProject * gActiveProject
Definition: Project.cpp:304
void GetDefaultWindowRect ( wxRect *  defRect)

Definition at line 626 of file Project.cpp.

Referenced by GetNextWindowPlacement(), and SaveWindowSize().

627 {
628  *defRect = wxGetClientDisplayRect();
629 
630  int width = 940;
631  int height = 674;
632 
633  //These conditional values assist in improving placement and size
634  //of NEW windows on different platforms.
635 #ifdef __WXGTK__
636  height += 20;
637 #endif
638 
639 #ifdef __WXMSW__
640  height += 40;
641 #endif
642 
643 #ifdef __WXMAC__
644  height += 55;
645 #endif
646 
647  // Use screen size where it is smaller than the values we would like.
648  // Otherwise use the values we would like, and centred.
649  if (width < defRect->width)
650  {
651  defRect->x = (defRect->width - width)/2;
652  defRect->width = width;
653  }
654 
655  if (height < defRect->height)
656  {
657  defRect->y = (defRect->height - height)/2;
658  // Bug 1119 workaround
659  // Small adjustment for very small Mac screens.
660  // If there is only a tiny space at the top
661  // then instead of vertical centre, align to bottom.
662  const int pixelsFormenu = 60;
663  if( defRect->y < pixelsFormenu )
664  defRect->y *=2;
665  defRect->height = height;
666  }
667 }
void GetNextWindowPlacement ( wxRect *  nextRect,
bool *  pMaximized,
bool *  pIconized 
)

Definition at line 721 of file Project.cpp.

References CornersOnScreen(), gAudacityProjects, GetDefaultWindowRect(), gPrefs, IsWindowAccessible(), and ScreenContaining().

Referenced by CreateNewAudacityProject(), and AudacityApp::OnInit().

722 {
723  int inc = 25;
724 
725  wxRect defaultRect;
726  GetDefaultWindowRect(&defaultRect);
727 
728  gPrefs->Read(wxT("/Window/Maximized"), pMaximized, false);
729  gPrefs->Read(wxT("/Window/Iconized"), pIconized, false);
730 
731  wxRect windowRect;
732  gPrefs->Read(wxT("/Window/X"), &windowRect.x, defaultRect.x);
733  gPrefs->Read(wxT("/Window/Y"), &windowRect.y, defaultRect.y);
734  gPrefs->Read(wxT("/Window/Width"), &windowRect.width, defaultRect.width);
735  gPrefs->Read(wxT("/Window/Height"), &windowRect.height, defaultRect.height);
736 
737  wxRect normalRect;
738  gPrefs->Read(wxT("/Window/Normal_X"), &normalRect.x, defaultRect.x);
739  gPrefs->Read(wxT("/Window/Normal_Y"), &normalRect.y, defaultRect.y);
740  gPrefs->Read(wxT("/Window/Normal_Width"), &normalRect.width, defaultRect.width);
741  gPrefs->Read(wxT("/Window/Normal_Height"), &normalRect.height, defaultRect.height);
742 
743  // Workaround 2.1.1 and earlier bug on OSX...affects only normalRect, but let's just
744  // validate for all rects and plats
745  if (normalRect.width == 0 || normalRect.height == 0) {
746  normalRect = defaultRect;
747  }
748  if (windowRect.width == 0 || windowRect.height == 0) {
749  windowRect = defaultRect;
750  }
751 
752 
753  wxRect screenRect( wxGetClientDisplayRect());
754 #if defined(__WXMAC__)
755 
756  // On OSX, the top of the window should never be less than the menu height,
757  // so something is amiss if it is
758  if (normalRect.y < screenRect.y) {
759  normalRect = defaultRect;
760  }
761  if (windowRect.y < screenRect.y) {
762  windowRect = defaultRect;
763  }
764 #endif
765 
766  // IF projects empty, THEN it's the first window.
767  // It lands where the config says it should, and can straddle screen.
768  if (gAudacityProjects.empty()) {
769  if (*pMaximized || *pIconized) {
770  *nextRect = normalRect;
771  }
772  else {
773  *nextRect = windowRect;
774  }
775  // Resize, for example if one monitor that was on is now off.
776  if (!CornersOnScreen( wxRect(*nextRect).Deflate( 32, 32 ))) {
777  *nextRect = defaultRect;
778  }
779  if (!IsWindowAccessible(nextRect)) {
780  *nextRect = defaultRect;
781  }
782  // Do not trim the first project window down.
783  // All corners are on screen (or almost so), and
784  // the rect may straddle screens.
785  return;
786  }
787 
788 
789  // ELSE a subsequent NEW window. It will NOT straddle screens.
790 
791  // We don't mind being 32 pixels off the screen in any direction.
792  // Make sure initial sizes (pretty much) fit within the display bounds
793  // We used to trim the sizes which could result in ridiculously small windows.
794  // contributing to bug 1243.
795  // Now instead if the window significantly doesn't fit the screen, we use the default
796  // window instead, which we know does.
797  if (ScreenContaining( wxRect(normalRect).Deflate( 32, 32 ))<0) {
798  normalRect = defaultRect;
799  }
800  if (ScreenContaining( wxRect(windowRect).Deflate( 32, 32 ) )<0) {
801  windowRect = defaultRect;
802  }
803 
804  bool validWindowSize = false;
805  AudacityProject * validProject = NULL;
806  size_t numProjects = gAudacityProjects.size();
807  for (int i = numProjects; i > 0 ; i--) {
808  if (!gAudacityProjects[i-1]->IsIconized()) {
809  validWindowSize = true;
810  validProject = gAudacityProjects[i-1].get();
811  break;
812  }
813  }
814  if (validWindowSize) {
815  *nextRect = validProject->GetRect();
816  *pMaximized = validProject->IsMaximized();
817  *pIconized = validProject->IsIconized();
818  // Do not straddle screens.
819  if (ScreenContaining( wxRect(*nextRect).Deflate( 32, 32 ) )<0) {
820  *nextRect = defaultRect;
821  }
822  }
823  else {
824  *nextRect = normalRect;
825  }
826 
827  //Placement depends on the increments
828  nextRect->x += inc;
829  nextRect->y += inc;
830 
831  // defaultrect is a rectangle on the first screen. It's the right fallback to
832  // use most of the time if things are not working out right with sizing.
833  // windowRect is a saved rectangle size.
834  // normalRect seems to be a substitute for windowRect when iconized or maximised.
835 
836  // Windows can say that we are off screen when actually we are not.
837  // On Windows 10 I am seeing miscalculation by about 6 pixels.
838  // To fix this we allow some sloppiness on the edge being counted as off screen.
839  // This matters most when restoring very carefully sized windows that are maximised
840  // in one dimension (height or width) but not both.
841  const int edgeSlop = 10;
842 
843  // Next four lines are getting the rectangle for the screen that contains the
844  // top left corner of nextRect (and defaulting to rect of screen 0 otherwise).
845  wxPoint p = nextRect->GetLeftTop();
846  int scr = std::max( 0, wxDisplay::GetFromPoint( p ));
847  wxDisplay d( scr );
848  screenRect = d.GetClientArea();
849 
850  // Now we (possibly) start trimming our rectangle down.
851  // Have we hit the right side of the screen?
852  wxPoint bottomRight = nextRect->GetBottomRight();
853  if (bottomRight.x > (screenRect.GetRight()+edgeSlop)) {
854  int newWidth = screenRect.GetWidth() - nextRect->GetLeft();
855  if (newWidth < defaultRect.GetWidth()) {
856  nextRect->x = windowRect.x;
857  nextRect->y = windowRect.y;
858  nextRect->width = windowRect.width;
859  }
860  else {
861  nextRect->width = newWidth;
862  }
863  }
864 
865  // Have we hit the bottom of the screen?
866  bottomRight = nextRect->GetBottomRight();
867  if (bottomRight.y > (screenRect.GetBottom()+edgeSlop)) {
868  nextRect->y -= inc;
869  bottomRight = nextRect->GetBottomRight();
870  if (bottomRight.y > (screenRect.GetBottom()+edgeSlop)) {
871  nextRect->SetBottom(screenRect.GetBottom());
872  }
873  }
874 
875  // After all that we could have a window that does not have a visible
876  // top bar. [It is unlikely, but something might have gone wrong]
877  // If so, use the safe fallback size.
878  if (!IsWindowAccessible(nextRect)) {
879  *nextRect = defaultRect;
880  }
881 }
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
AProjectArray gAudacityProjects
Definition: Project.cpp:306
int ScreenContaining(wxRect &r)
Definition: Project.cpp:696
bool IsWindowAccessible(wxRect *requestedRect)
Definition: Project.cpp:670
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:174
bool CornersOnScreen(wxRect &r)
Definition: Project.cpp:711
void GetDefaultWindowRect(wxRect *defRect)
Definition: Project.cpp:626
static wxString gsLegacyFileWarning ( )
static

Definition at line 2932 of file Project.cpp.

References _().

Referenced by AudacityProject::HandleXMLTag(), and AudacityProject::WarnOfLegacyFile().

2932  { return
2933 _("This file was saved by Audacity version %s. The format has changed. \
2934 \n\nAudacity can try to open and save this file, but saving it in this \
2935 \nversion will then prevent any 1.2 or earlier version opening it. \
2936 \n\nAudacity might corrupt the file in opening it, so you should \
2937 back it up first. \
2938 \n\nOpen this file now?");
2939 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
bool IsWindowAccessible ( wxRect *  requestedRect)

Definition at line 670 of file Project.cpp.

References monitor.

Referenced by GetNextWindowPlacement().

671 {
672  wxDisplay display;
673  wxRect targetTitleRect(requestedRect->GetLeftTop(), requestedRect->GetBottomRight());
674  // Hackery to approximate a window top bar size from a window size.
675  // and exclude the open/close and borders.
676  targetTitleRect.x += 15;
677  targetTitleRect.width -= 100;
678  if (targetTitleRect.width < 165) targetTitleRect.width = 165;
679  targetTitleRect.height = 15;
680  int targetBottom = targetTitleRect.GetBottom();
681  int targetRight = targetTitleRect.GetRight();
682  // This looks like overkill to check each and every pixel in the ranges.
683  // and decide that if any is visible on screen we are OK.
684  for (int i = targetTitleRect.GetLeft(); i < targetRight; i++) {
685  for (int j = targetTitleRect.GetTop(); j < targetBottom; j++) {
686  int monitor = display.GetFromPoint(wxPoint(i, j));
687  if (monitor != wxNOT_FOUND) {
688  return TRUE;
689  }
690  }
691  }
692  return FALSE;
693 }
CommandManagerEventMonitor monitor
void RedrawAllProjects ( )

Definition at line 600 of file Project.cpp.

References gAudacityProjects.

Referenced by ToolsToolBar::OnTool().

601 {
602  size_t len = gAudacityProjects.size();
603  for (size_t i = 0; i < len; i++)
604  gAudacityProjects[i]->RedrawProject();
605 }
AProjectArray gAudacityProjects
Definition: Project.cpp:306
void RefreshCursorForAllProjects ( )

Definition at line 607 of file Project.cpp.

References gAudacityProjects.

Referenced by ToolsToolBar::SetCurrentTool().

608 {
609  size_t len = gAudacityProjects.size();
610  for (size_t i = 0; i < len; i++)
611  gAudacityProjects[i]->RefreshCursor();
612 }
AProjectArray gAudacityProjects
Definition: Project.cpp:306
int ScreenContaining ( wxRect &  r)

Definition at line 696 of file Project.cpp.

Referenced by GetNextWindowPlacement().

696  {
697  unsigned int n = wxDisplay::GetCount();
698  for(unsigned int i = 0;i<n;i++){
699  wxDisplay d(i);
700  wxRect scr = d.GetClientArea();
701  if( scr.Contains( r ) )
702  return (int)i;
703  }
704  return -1;
705 }
void SetActiveProject ( AudacityProject project)
static

Definition at line 316 of file Project.cpp.

References gActiveProject.

Referenced by CreateNewAudacityProject(), AudacityProject::OnActivate(), AudacityProject::OnCloseWindow(), and AudacityProject::OnMouseEvent().

317 {
318  gActiveProject = project;
319  wxTheApp->SetTopWindow(project);
320 }
static AudacityProject * gActiveProject
Definition: Project.cpp:304

Variable Documentation

AudacityProject* gActiveProject
static

Definition at line 304 of file Project.cpp.

Referenced by GetActiveProject(), AudacityProject::OnCloseWindow(), and SetActiveProject().

int gAudacityOffsetInc = 0
static

Definition at line 301 of file Project.cpp.

Referenced by CloseAllProjects().

int gAudacityPosInc = 0
static

Definition at line 302 of file Project.cpp.

Referenced by CloseAllProjects().

AProjectArray gAudacityProjects
const int sbarControlWidth = 15

Definition at line 204 of file Project.cpp.

const int sbarExtraLen = 0

Definition at line 205 of file Project.cpp.

const int sbarHjump = 30
const int sbarSpaceWidth = 15

Definition at line 203 of file Project.cpp.