Major overhaul to the menu system, by John Fay

git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@167 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
puggles 2003-08-27 19:02:36 +00:00
parent a9a67dc3b5
commit 355b9327a9
4 changed files with 20 additions and 33 deletions

View File

@ -76,6 +76,7 @@ SFG_State fgState = { { -1, -1, FALSE }, /* Position */
{ NULL, NULL }, /* Timers */
NULL, /* IdleCallback */
FALSE, /* BuildingAMenu */
0, /* ActiveMenus */
NULL, /* MenuStateCallback */
NULL, /* MenuStatusCallback */
{ 640, 480, TRUE }, /* GameModeSize */

View File

@ -236,6 +236,7 @@ struct tagSFG_State
FGCBidle IdleCallback; /* The global idle callback */
GLboolean BuildingAMenu; /* True if we are presently making a menu */
int ActiveMenus; /* Number of currently active menus */
FGCBmenuState MenuStateCallback; /* Menu callbacks are global */
FGCBmenuStatus MenuStatusCallback;

View File

@ -659,7 +659,7 @@ void FGAPIENTRY glutMainLoopEvent( void )
/*
* Let's make the window redraw as a result of the mouse motion.
*/
window->State.Redisplay = TRUE ;
if ( window->IsMenu ) window->State.Redisplay = TRUE ;
break;
}
@ -778,11 +778,6 @@ void FGAPIENTRY glutMainLoopEvent( void )
if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
}
/*
* Let's make the window redraw as a result of the mouse click and menu activity.
*/
window->State.Redisplay = TRUE ;
break ;
}
@ -791,11 +786,6 @@ void FGAPIENTRY glutMainLoopEvent( void )
*/
if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
{
/*
* Let's make the window redraw as a result of the mouse click.
*/
window->State.Redisplay = TRUE ;
/*
* Set the current window
*/
@ -814,11 +804,11 @@ void FGAPIENTRY glutMainLoopEvent( void )
*/
if( fgStructure.Window->Callbacks.Mouse == NULL )
break;
/*
* Set the current window
*/
fgSetWindow ( window );
fgSetWindow( window );
/*
* Remember the current modifiers state
@ -1014,8 +1004,9 @@ void FGAPIENTRY glutMainLoopEvent( void )
/*
* No messages in the queue, which means we are idling...
* Don't call this if there is a menu active
*/
if( fgState.IdleCallback != NULL )
if( ( fgState.IdleCallback != NULL ) && ( fgState.ActiveMenus == 0 ) )
fgState.IdleCallback();
/*
@ -1060,8 +1051,9 @@ void FGAPIENTRY glutMainLoopEvent( void )
/*
* No messages in the queue, which means we are idling...
* Don't call this if there is a menu active
*/
if( fgState.IdleCallback != NULL )
if( ( fgState.IdleCallback != NULL ) && ( fgState.ActiveMenus == 0 ) )
fgState.IdleCallback();
/*
@ -1388,12 +1380,12 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
/*
* Fallback if there's an active menu hooked to this window
*/
if( window->ActiveMenu != NULL )
if ( window->ActiveMenu != NULL )
{
/*
* Let's make the window redraw as a result of the mouse motion.
*/
window->State.Redisplay = TRUE ;
if ( window->IsMenu ) window->State.Redisplay = TRUE ;
break;
}
@ -1530,11 +1522,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
if ( pressed == TRUE ) fgDeactivateMenu ( window->ActiveMenu->ParentWindow ) ;
}
/*
* Let's make the window redraw as a result of the mouse click and menu activity.
*/
if ( ! window->IsMenu ) window->State.Redisplay = TRUE ;
break ;
}
@ -1543,11 +1530,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
*/
if ( ( window->Menu[ button ] != NULL ) && ( pressed == TRUE ) )
{
/*
* Let's make the window redraw as a result of the mouse click.
*/
window->State.Redisplay = TRUE ;
/*
* Set the current window
*/
@ -1567,6 +1549,11 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
if( fgStructure.Window->Callbacks.Mouse == NULL )
break;
/*
* Set the current window
*/
fgSetWindow( window );
/*
* Remember the current modifiers state.
*/
@ -1575,11 +1562,6 @@ LRESULT CALLBACK fgWindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPara
( ( (GetKeyState( VK_LCONTROL ) < 0 ) || ( GetKeyState( VK_RCONTROL ) < 0 )) ? GLUT_ACTIVE_CTRL : 0 ) |
( ( (GetKeyState( VK_LMENU ) < 0 ) || ( GetKeyState( VK_RMENU ) < 0 )) ? GLUT_ACTIVE_ALT : 0 );
/*
* Set the current window
*/
fgSetWindow ( window );
/*
* Finally execute the mouse callback
*/

View File

@ -195,7 +195,7 @@ static GLboolean fghCheckMenuStatus( SFG_Window* window, SFG_Menu* menu )
fgSetWindow ( menuEntry->SubMenu->Window ) ;
glutPositionWindow ( menuEntry->SubMenu->X, menuEntry->SubMenu->Y ) ;
glutReshapeWindow ( menuEntry->SubMenu->Width, menuEntry->SubMenu->Height ) ;
glutPopWindow () ;
glutPopWindow () ;
glutShowWindow () ;
menuEntry->SubMenu->Window->ActiveMenu = menuEntry->SubMenu ;
fgSetWindow ( current_window ) ;
@ -466,6 +466,7 @@ void fgActivateMenu( SFG_Window* window, int button )
*/
window->ActiveMenu = menu;
menu->IsActive = TRUE ;
fgState.ActiveMenus ++ ;
/*
* Set up the initial menu position now:
@ -578,6 +579,8 @@ void fgDeactivateMenu( SFG_Window *window )
menu->ParentWindow->ActiveMenu = NULL ;
menu->IsActive = FALSE ;
fgState.ActiveMenus -- ;
/*
* Hide all submenu windows, and the root menu's window.
*/