feature request: exotic automatic relocation and resizing of new project windows

1 message Options
Embed this post
Permalink
Ed Musgrove-2

feature request: exotic automatic relocation and resizing of new project windows

Reply Threaded More More options
Print post
Permalink
I have started a new e-mail subject because I do not believe that this issue
was related to the original disappearing window bug.

While this does not resolve the issue of opening too many new project
windows it may present a reasonable solution to the window cascading
behavior. When the project window's automatic resizing would cause it to be
narrower than the default window, the new project window is moved back to
the user's preferred left edge and width then moved down a bit and the test
is made to verify that it is not now too tall.

Exercising this might be a bit challenging because of the issue of opening
too many new project windows. Open a couple of new project windows; size the
youngest so that it is about seventy-five pixels narrower than the screen
right edge and about seventy-five pixels less tall than the screen lower
edge (pardon my grammar). Open four or five or new projects-- the youngest
should start marching not cascading (i.e. the y value will not change, the x
value will increment by twenty-five, the height will not change but the
width will. Grabbed the left edge of the youngest window and size it so that
it is about as wide as a default window. Open new projects until one appears
with its left edge aligned with the very oldest window -- note that has been
moved down twenty-five pixels but does not exceed the screen boundaries.

I really like this behavior.

I have attached a patch against the current head which does the following,
in the file audacity\src\Project.cpp at or near line #543, replace the
entire function:

void GetNextWindowPlacement(wxRect *nextRect, bool *bMaximized)
{
   int inc = 25;
   *bMaximized = false;
   wxRect defaultWindowRect;
   GetDefaultWindowRect(&defaultWindowRect);

   if (gAudacityProjects.IsEmpty()) {
      //Read the values from the registry, or use the defaults
      nextRect->SetX(gPrefs->Read(wxT("/Window/X"),
defaultWindowRect.GetX()));
      nextRect->SetY(gPrefs->Read(wxT("/Window/Y"),
defaultWindowRect.GetY()));
      nextRect->SetWidth(gPrefs->Read(wxT("/Window/Width"),
defaultWindowRect.GetWidth()));
      nextRect->SetHeight(gPrefs->Read(wxT("/Window/Height"),
defaultWindowRect.GetHeight()));

      gPrefs->Read(wxT("/Window/Maximized"), bMaximized);
   }
   else {
      //This code was heavily modified to deal with iconized project windows
      //Ed Musgrove 28 September 2009
      bool validWindowSize = FALSE;
      AudacityProject * validProject = NULL;
      size_t numProjects = gAudacityProjects.Count();
      for (int i = numProjects; i > 0 ; i--)
      //   read these backwards so that new project locations will increment
off the newest project window
      {
         if (!gAudacityProjects[i-1]->IsIconized()) {
             validWindowSize = TRUE;
             validProject = gAudacityProjects[i-1];
             i = 0;
         }
      }
      if (validWindowSize)
      {
         *nextRect = validProject->GetRect();
         *bMaximized = validProject->IsMaximized();
      }
      else
      {
          nextRect->SetX(gPrefs->Read(wxT("/Window/X"),
defaultWindowRect.GetX()));
          nextRect->SetY(gPrefs->Read(wxT("/Window/Y"),
defaultWindowRect.GetY()));
          nextRect->SetWidth(gPrefs->Read(wxT("/Window/Width"),
defaultWindowRect.GetWidth()));
          nextRect->SetHeight(gPrefs->Read(wxT("/Window/Height"),
defaultWindowRect.GetHeight()));
          gPrefs->Read(wxT("/Window/Maximized"), bMaximized);
      }

      //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 = wxGetClientDisplayRect();

   // We do not want to reset the increments unless the top left corner of
the new window
   //    gets too near the bottom right hand corner of the screen -- also,
make sure the
   //    window fits on the screen
   // Ed Musgrove
   // 16 October 2009
         //Have we hit the right side of the screen?
   wxPoint bottomRight = nextRect->GetBottomRight();
   if (bottomRight.x > screenRect.GetRight()) {
      int newWidth = screenRect.width - nextRect->x;
      if (newWidth < defaultWindowRect.GetWidth()) {
         // try to use as much of the user's preferred Project window state
as possible
         nextRect->SetX(gPrefs->Read(wxT("/Window/X"),
defaultWindowRect.GetX()));
         nextRect->SetWidth(gPrefs->Read(wxT("/Window/Width"),
defaultWindowRect.GetWidth()));
         nextRect->y += inc;
      }
      else {
         nextRect->width = newWidth;
      }
   }
      //Have we hit the bottom of the screen?
   if (bottomRight.y > screenRect.GetBottom()) {
      nextRect->y  -= inc;
      bottomRight = nextRect->GetBottomRight();//we will need to test again
since we have moved the window down
      if (bottomRight.y > screenRect.GetBottom()) {
         nextRect->SetHeight(screenRect.GetHeight() - nextRect->y);
      }
   }
}

--Ed




------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
audacity-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-devel

exotic.patch (5K) Download Attachment