freeglut_menu.c:217,519,532: Fix menus to stay in the window (John Fay)
authorEric Sandall <sandalle@gmail.com>
Wed, 8 Oct 2003 19:17:07 +0000 (19:17 +0000)
committerEric Sandall <sandalle@gmail.com>
Wed, 8 Oct 2003 19:17:07 +0000 (19:17 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@216 7f0cb862-5218-0410-a997-914c9d46530a

ChangeLog
src/freeglut_menu.c

index a345197..a13e87f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -338,3 +338,9 @@ October 24, 2002:
 
 (111) freeglut_menu.c:328 Fix submenu triangle (John Fay)
 
+*******************************************************************************************
+* Changes on October 8, 2003
+*******************************************************************************************
+
+(112) freeglut_menu.c:217,519,532: Fix menus to stay in the window (John Fay)
+
index 3fdc342..1194908 100644 (file)
@@ -215,6 +215,14 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu )
         menuEntry->SubMenu->X = menu->X + menu->Width ;
         menuEntry->SubMenu->Y = menu->Y + menuEntry->Ordinal * FREEGLUT_MENU_HEIGHT ;
 
+        if ( menuEntry->SubMenu->X + menuEntry->SubMenu->Width > glutGet (
+GLUT_SCREEN_WIDTH ) )
+        menuEntry->SubMenu->X = menu->X - menuEntry->SubMenu->Width ;
+
+        if ( menuEntry->SubMenu->Y + menuEntry->SubMenu->Height > glutGet (
+GLUT_SCREEN_HEIGHT ) )
+        menuEntry->SubMenu->Y -=menuEntry->SubMenu->Height ;
+
         fgSetWindow ( menuEntry->SubMenu->Window ) ;
         glutPositionWindow ( menuEntry->SubMenu->X, menuEntry->SubMenu->Y ) ;
         glutReshapeWindow ( menuEntry->SubMenu->Width, menuEntry->SubMenu->Height ) ;
@@ -513,6 +521,12 @@ void fgActivateMenu( SFG_Window* window, int button )
   menu->X = window->State.MouseX + glutGet ( GLUT_WINDOW_X ) ;
   menu->Y = window->State.MouseY + glutGet ( GLUT_WINDOW_Y ) ;
 
+  if ( menu->X + menu->Width > glutGet ( GLUT_SCREEN_WIDTH ) )
+    menu->X -=menu->Width ;
+
+  if ( menu->Y + menu->Height > glutGet ( GLUT_SCREEN_HEIGHT ) )
+    menu->Y -=menu->Height ;
+
   fgSetWindow ( menu->Window ) ;
   glutPositionWindow ( menu->X, menu->Y ) ;
   glutReshapeWindow ( menu->Width, menu->Height ) ;
@@ -520,10 +534,6 @@ void fgActivateMenu( SFG_Window* window, int button )
   glutShowWindow () ;
   menu->Window->ActiveMenu = menu ;
 
-/*  if( x > ( glutGet( GLUT_WINDOW_WIDTH ) - menu->Width ) )
-    menu->X = glutGet( GLUT_WINDOW_WIDTH ) - menu->Width;
-  if( y > ( glutGet( GLUT_WINDOW_HEIGHT ) - menu->Height) )
-    menu->Y = glutGet( GLUT_WINDOW_HEIGHT ) - menu->Height; */
 }
 
 /*