Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv28403

Modified Files:
        Project.cpp AudacityApp.cpp 
Log Message:
Save window position on exit and use for first project on startup.

Index: Project.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.cpp,v
retrieving revision 1.318
retrieving revision 1.319
diff -u -d -r1.318 -r1.319
--- Project.cpp 28 Jul 2007 08:15:41 -0000      1.318
+++ Project.cpp 30 Jul 2007 05:29:17 -0000      1.319
@@ -380,19 +380,13 @@
 // BG: The default size and position of the first window
 void GetDefaultWindowRect(wxRect *defRect)
 {
-   //the point that a new window should open at.
-   defRect->x = 10;
-   defRect->y = 10;
+   *defRect = wxGetClientDisplayRect();
 
    defRect->width = 600;
    defRect->height = 400;
 
    //These conditional values assist in improving placement and size
    //of new windows on different platforms.
-#ifdef __WXMAC__
-   defRect->y += 50;
-#endif
-
 #ifdef __WXGTK__
    defRect->height += 20;
 #endif
@@ -407,84 +401,68 @@
 void GetNextWindowPlacement(wxRect *nextRect, bool *bMaximized)
 {
    wxRect defWndRect;
+   int inc = 25;
 
    GetDefaultWindowRect(&defWndRect);
 
    *bMaximized = false;
 
-   if(gAudacityProjects.IsEmpty())
-   {
+   if (gAudacityProjects.IsEmpty()) {
       //Read the values from the registry, or use the defaults
+      nextRect->SetX(gPrefs->Read(wxT("/Window/X"), defWndRect.GetX()));
+      nextRect->SetY(gPrefs->Read(wxT("/Window/Y"), defWndRect.GetY()));
       nextRect->SetWidth(gPrefs->Read(wxT("/Window/Width"), 
defWndRect.GetWidth()));
       nextRect->SetHeight(gPrefs->Read(wxT("/Window/Height"), 
defWndRect.GetHeight()));
 
       gPrefs->Read(wxT("/Window/Maximized"), bMaximized);
    }
-   else
-   {
+   else {
       //Base the values on the previous Window
       *nextRect = gAudacityProjects[gAudacityProjects.GetCount()-1]->GetRect();
 
       *bMaximized = 
gAudacityProjects[gAudacityProjects.GetCount()-1]->IsMaximized();
-   }
-
-   nextRect->x = defWndRect.x;
-   nextRect->y = defWndRect.y;
 
-   //Placement depends on the increments
-   nextRect->x += (gAudacityPosInc * 25) + (gAudacityOffsetInc * 25);
-   nextRect->y += gAudacityPosInc * 25;
+      //Placement depends on the increments
+      nextRect->x += inc;
+      nextRect->y += inc;
+   }
 
    //Make sure that the Window will be completely visible
 
    //Get the size of the screen
-   wxRect screenRect;
-   wxClientDisplayRect(&screenRect.x, &screenRect.y, &screenRect.width, 
&screenRect.height);
+   wxRect screenRect = wxGetClientDisplayRect();
 
    //First check if we need to reset the increments
 
    //Have we hit the bottom of the screen?
-   if( (nextRect->y+nextRect->height > screenRect.y+screenRect.height) )
-   {
-      //Reset Position increment
-      gAudacityPosInc = 0;
-
-      //Increment Offset increment
-      gAudacityOffsetInc++;
-
+   if (nextRect->GetBottom() > screenRect.GetBottom()) {
       //Recalculate the position on the screen
-      nextRect->x = defWndRect.x;
+      nextRect->x = defWndRect.x + gAudacityOffsetInc;
       nextRect->y = defWndRect.y;
 
-      nextRect->x += (gAudacityPosInc * 25) + (gAudacityOffsetInc * 25);
-      nextRect->y += gAudacityPosInc * 25;
+      //Increment Offset increment
+      gAudacityOffsetInc += inc;
    }
 
    //Have we hit the right side of the screen?
-   if( (nextRect->x+nextRect->width > screenRect.x+screenRect.width) )
-   {
-      //Reset both Position and Offset increments
-      gAudacityPosInc = 0;
+   if (nextRect->GetRight() > screenRect.GetRight()) {
+      //Reset Offset increments
       gAudacityOffsetInc = 0;
 
       //Recalculate the position on the screen
       nextRect->x = defWndRect.x;
       nextRect->y = defWndRect.y;
-      //No need to compute the offset and position, just use the defaults
+      //No need to compute the offset, just use the default
    }
 
    //Next check if the screen is too small for the default Audacity width and 
height
    //Uses both comparisons from above
-   if( (nextRect->x+nextRect->width > screenRect.x+screenRect.width) ||
-       (nextRect->y+nextRect->height > screenRect.y+screenRect.height) )
-   {
+   if ((nextRect->GetRight() > screenRect.GetRight()) ||
+      (nextRect->GetBottom() > screenRect.GetBottom())) {
       //Resize the Audacity window to fit in the screen
       nextRect->width = screenRect.width-nextRect->x;
       nextRect->height = screenRect.height-nextRect->y;
    }
-
-   //Increment Position increment
-   gAudacityPosInc++;
 }
 
 wxString CreateUniqueName()

Index: AudacityApp.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/AudacityApp.cpp,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -d -r1.177 -r1.178
--- AudacityApp.cpp     28 Jul 2007 07:21:53 -0000      1.177
+++ AudacityApp.cpp     30 Jul 2007 05:29:17 -0000      1.178
@@ -201,10 +201,12 @@
    {
       // BG: Save size of Window 0.
       if (!gAudacityProjects[0]->IsIconized()) {
-         wxSize wndSize = gAudacityProjects[0]->GetSize();
+         wxRect r = gAudacityProjects[0]->GetRect();
          bool wndMaximized = gAudacityProjects[0]->IsMaximized();
-         gPrefs->Write(wxT("/Window/Width"), wndSize.GetWidth());
-         gPrefs->Write(wxT("/Window/Height"), wndSize.GetHeight());
+         gPrefs->Write(wxT("/Window/X"), r.GetX());
+         gPrefs->Write(wxT("/Window/Y"), r.GetY());
+         gPrefs->Write(wxT("/Window/Width"), r.GetWidth());
+         gPrefs->Write(wxT("/Window/Height"), r.GetHeight());
          gPrefs->Write(wxT("/Window/Maximized"), wndMaximized);   
       }
    }


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to