1
0
Fork 0

GUI changes contributed by Norman Vine.

This commit is contained in:
curt 1999-05-27 00:21:22 +00:00
parent 86cc2b162a
commit bf56b15f7e
2 changed files with 124 additions and 132 deletions

View file

@ -63,18 +63,9 @@
FG_USING_STD(string); FG_USING_STD(string);
// Pui hides low level access to the mouse and menu display states puFont guiFnt = 0;
// so for now we track these in case we want to know about them fntTexFont *guiFntHandle = 0;
puFont guiFnt = 0; // Our High Level Gui Font
fntTexFont *guiFntHandle = 0; // lower level access to guiFnt's Font
static int _mX = 0; // current mouse x
static int _mY = 0; // y
static int last_buttons = 0 ; // mouse button state
static int mouse_active = 0; // is mouse displayed
static int menu_on = 0; // menu displayed
// PUI objects
static puMenuBar *mainMenuBar = 0; static puMenuBar *mainMenuBar = 0;
//static puButton *hideMenuButton = 0; //static puButton *hideMenuButton = 0;
@ -90,7 +81,6 @@ static puText *YNdialogBoxMessage = 0;
static puOneShot *YNdialogBoxOkButton = 0; static puOneShot *YNdialogBoxOkButton = 0;
static puOneShot *YNdialogBoxNoButton = 0; static puOneShot *YNdialogBoxNoButton = 0;
// Accessor CallBacks for external PUI Objects
// extern void NewAltitude( puObject *cb ); // extern void NewAltitude( puObject *cb );
// extern void NewHeading( puObject *cb ); // extern void NewHeading( puObject *cb );
extern void fgAPAdjust( puObject * ); extern void fgAPAdjust( puObject * );
@ -99,6 +89,13 @@ extern void fgLatLonFormatToggle( puObject *);
/* -------------------------------------------------------------------- /* --------------------------------------------------------------------
Mouse stuff Mouse stuff
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
static int _mX = 0;
static int _mY = 0;
static int last_buttons = 0 ;
static int mouse_active = 0;
static int menu_on = 0;
void guiMotionFunc ( int x, int y ) void guiMotionFunc ( int x, int y )
{ {
_mX = x; _mX = x;
@ -155,11 +152,6 @@ static inline void TurnCursorOff( void )
#endif #endif
} }
// If the gui isn't active try to hide the mouse
// an if the qui requested show the mouse
// this can get confused if it rerequesting the gui object
// should resync things.
// see PUI macros in gui.hxx for normal use
void maybeToggleMouse( void ) void maybeToggleMouse( void )
{ {
static int first_time = ~0; static int first_time = ~0;
@ -216,26 +208,25 @@ void mkDialog (char *txt)
} }
// Repair any damage done to the Panel by other Gui Items // Repair any damage done to the Panel by other Gui Items
// see PUI macros in gui.hxx for use
void guiFixPanel( void ) void guiFixPanel( void )
{ {
int toggle_pause; int toggle_pause;
if ( current_options.get_panel_status() ) { if ( current_options.get_panel_status() ) {
FGView *v = &current_view; FGView *v = &current_view;
FGTime *t = FGTime::cur_time_params; FGTime *t = FGTime::cur_time_params;
if( (toggle_pause = !t->getPause()) ) if( (toggle_pause = !t->getPause()) )
t->togglePauseMode(); t->togglePauseMode();
// this seems to be the only way to do this :-( // this seems to be the only way to do this :-(
// problem is the viewport has been mucked with // problem is the viewport has been mucked with
xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) ); xglViewport(0, 0 , (GLint)(v->winWidth), (GLint)(v->winHeight) );
FGPanel::OurPanel->ReInit(0, 0, 1024, 768); FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
if(toggle_pause) if(toggle_pause)
t->togglePauseMode(); t->togglePauseMode();
} }
} }
@ -243,13 +234,13 @@ void guiFixPanel( void )
void guiToggleMenu(void) void guiToggleMenu(void)
{ {
if( menu_on ) { if( menu_on ) {
// printf("Hiding Menu\n"); // printf("Hiding Menu\n");
mainMenuBar->hide (); mainMenuBar->hide ();
TurnCursorOff(); TurnCursorOff();
} else { } else {
// printf("Showing Menu\n"); // printf("Showing Menu\n");
mainMenuBar->reveal(); mainMenuBar->reveal();
TurnCursorOn(); TurnCursorOn();
} }
menu_on = ~menu_on; menu_on = ~menu_on;
} }
@ -277,11 +268,10 @@ void hideMenuCb (puObject *cb)
guiToggleMenu(); guiToggleMenu();
} }
// This is the accessor function
void goodBye(puObject *) void goodBye(puObject *)
{ {
// FG_LOG( FG_INPUT, FG_ALERT, // FG_LOG( FG_INPUT, FG_ALERT,
// "Program exiting normally at user request." ); // "Program exiting normally at user request." );
cout << "Program exiting normally at user request." << endl; cout << "Program exiting normally at user request." << endl;
// if(gps_bug) // if(gps_bug)
@ -298,13 +288,15 @@ void goAwayCb (puObject *me)
void mkDialogInit (void) void mkDialogInit (void)
{ {
// printf("mkDialogInit\n"); // printf("mkDialogInit\n");
dialogBox = new puDialogBox (150, 50); int x = (current_options.get_xsize()/2 - 400/2);
int y = (current_options.get_ysize()/2 - 100/2);
dialogBox = new puDialogBox (x, y); // 150, 50
{ {
dialogFrame = new puFrame (0,0,400, 100); dialogFrame = new puFrame (0,0,400,100);
dialogBoxMessage = new puText (10, 70); dialogBoxMessage = new puText (10, 70);
dialogBoxMessage -> setLabel (""); dialogBoxMessage -> setLabel ("");
dialogBoxOkButton = new puOneShot (180, 10, 240, 50); dialogBoxOkButton = new puOneShot (180, 10, 240, 50);
} }
FG_FINALIZE_PUI_DIALOG( dialogBox ); FG_FINALIZE_PUI_DIALOG( dialogBox );
} }
@ -321,26 +313,30 @@ void goAwayYesNoCb(puObject *me)
void ConfirmExitDialogInit(void) void ConfirmExitDialogInit(void)
{ {
// printf("ConfirmExitDialogInit\n"); // printf("ConfirmExitDialogInit\n");
string Msg("Really Quit"); string Msg("Really Quit");
// int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2; // int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2;
int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), Msg.c_str() )/2; int len = 200 - puGetStringWidth( puGetDefaultLabelFont(), Msg.c_str() )/2;
YNdialogBox = new puDialogBox (150, 50); int x = (current_options.get_xsize()/2 - 400/2);
int y = (current_options.get_ysize()/2 - 100/2);
YNdialogBox = new puDialogBox (x, y); // 150, 50
// YNdialogBox = new puDialogBox (150, 50);
{ {
YNdialogFrame = new puFrame (0,0,400, 100); YNdialogFrame = new puFrame (0,0,400, 100);
YNdialogBoxMessage = new puText (len, 70); YNdialogBoxMessage = new puText (len, 70);
YNdialogBoxMessage -> setLabel (Msg.c_str()); YNdialogBoxMessage -> setLabel (Msg.c_str());
YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50); YNdialogBoxOkButton = new puOneShot (100, 10, 160, 50);
YNdialogBoxOkButton -> setLegend ("OK"); YNdialogBoxOkButton -> setLegend ("OK");
YNdialogBoxOkButton -> setCallback (goodBye); YNdialogBoxOkButton -> setCallback (goodBye);
YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50); YNdialogBoxNoButton = new puOneShot (240, 10, 300, 50);
YNdialogBoxNoButton -> setLegend ("NO"); YNdialogBoxNoButton -> setLegend ("NO");
// YNdialogBoxNoButton -> makeReturnDefault (TRUE ); // YNdialogBoxNoButton -> makeReturnDefault (TRUE );
YNdialogBoxNoButton -> setCallback (goAwayYesNoCb); YNdialogBoxNoButton -> setCallback (goAwayYesNoCb);
} }
FG_FINALIZE_PUI_DIALOG( YNdialogBox ); FG_FINALIZE_PUI_DIALOG( YNdialogBox );
} }
@ -357,8 +353,8 @@ void helpCb (puObject *)
#if defined(FX) && !defined(WIN32) #if defined(FX) && !defined(WIN32)
# if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW) # if defined(XMESA_FX_FULLSCREEN) && defined(XMESA_FX_WINDOW)
if ( global_fullscreen ) { if ( global_fullscreen ) {
global_fullscreen = false; global_fullscreen = false;
XMesaSetFXmode( XMESA_FX_WINDOW ); XMesaSetFXmode( XMESA_FX_WINDOW );
} }
# endif # endif
#endif #endif
@ -407,7 +403,7 @@ void AptDialog_OK (puObject *)
FGTime *t = FGTime::cur_time_params; FGTime *t = FGTime::cur_time_params;
int PauseMode = t->getPause(); int PauseMode = t->getPause();
if(!PauseMode) if(!PauseMode)
t->togglePauseMode(); t->togglePauseMode();
char *s; char *s;
AptDialogInput->getValue(&s); AptDialogInput->getValue(&s);
@ -416,29 +412,29 @@ void AptDialog_OK (puObject *)
AptDialog_Cancel( NULL ); AptDialog_Cancel( NULL );
if ( AptId.length() ) { if ( AptId.length() ) {
// set initial position from airport id // set initial position from airport id
fgAIRPORTS airports; fgAIRPORTS airports;
fgAIRPORT a; fgAIRPORT a;
FG_LOG( FG_GENERAL, FG_INFO, FG_LOG( FG_GENERAL, FG_INFO,
"Attempting to set starting position from airport code " "Attempting to set starting position from airport code "
<< s ); << s );
airports.load("apt_simple"); airports.load("apt_simple");
if ( airports.search( AptId, &a ) ) if ( airports.search( AptId, &a ) )
{ {
current_options.set_airport_id( AptId.c_str() ); current_options.set_airport_id( AptId.c_str() );
BusyCursor(0); BusyCursor(0);
fgReInitSubsystems(); fgReInitSubsystems();
BusyCursor(1); BusyCursor(1);
} else { } else {
AptId += " not in database."; AptId += " not in database.";
mkDialog(AptId.c_str()); mkDialog(AptId.c_str());
} }
} }
if( PauseMode != t->getPause() ) if( PauseMode != t->getPause() )
t->togglePauseMode(); t->togglePauseMode();
} }
void AptDialog_Reset(puObject *) void AptDialog_Reset(puObject *)
@ -447,8 +443,6 @@ void AptDialog_Reset(puObject *)
AptDialogInput->setCursor( 0 ) ; AptDialogInput->setCursor( 0 ) ;
} }
// This is the accessor function
void NewAirport(puObject *cb) void NewAirport(puObject *cb)
{ {
string AptLabel("Enter New Airport ID"); string AptLabel("Enter New Airport ID");
@ -465,35 +459,35 @@ static void NewAirportInit(void)
cout << "NewAirportInit" << endl; cout << "NewAirportInit" << endl;
string AptLabel("Enter New Airport ID"); string AptLabel("Enter New Airport ID");
// int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2; // int len = 350/2 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel )/2;
int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel.c_str() )/2; int len = 150 - puGetStringWidth( puGetDefaultLabelFont(), AptLabel.c_str() )/2;
AptDialog = new puDialogBox (150, 50); AptDialog = new puDialogBox (150, 50);
{ {
AptDialogFrame = new puFrame (0,0,350, 150); AptDialogFrame = new puFrame (0,0,350, 150);
AptDialogMessage = new puText (len, 110); AptDialogMessage = new puText (len, 110);
AptDialogInput = new puInput ( 50, 70, 300, 100 ); AptDialogInput = new puInput ( 50, 70, 300, 100 );
AptDialogOkButton = new puOneShot (50, 10, 110, 50); AptDialogOkButton = new puOneShot (50, 10, 110, 50);
AptDialogOkButton -> setLegend ("OK"); AptDialogOkButton -> setLegend ("OK");
AptDialogOkButton -> setCallback (AptDialog_OK); AptDialogOkButton -> setCallback (AptDialog_OK);
AptDialogCancelButton = new puOneShot (140, 10, 210, 50); AptDialogCancelButton = new puOneShot (140, 10, 210, 50);
AptDialogCancelButton -> setLegend ("Cancel"); AptDialogCancelButton -> setLegend ("Cancel");
AptDialogCancelButton -> setCallback (AptDialog_Cancel); AptDialogCancelButton -> setCallback (AptDialog_Cancel);
AptDialogResetButton = new puOneShot (240, 10, 300, 50); AptDialogResetButton = new puOneShot (240, 10, 300, 50);
AptDialogResetButton -> setLegend ("Reset"); AptDialogResetButton -> setLegend ("Reset");
AptDialogResetButton -> setCallback (AptDialog_Reset); AptDialogResetButton -> setCallback (AptDialog_Reset);
} }
FG_FINALIZE_PUI_DIALOG( AptDialog ); FG_FINALIZE_PUI_DIALOG( AptDialog );
} }
/* ----------------------------------------------------------------------- /* -----------------------------------------------------------------------
The menu stuff The menu stuff
---------------------------------------------------------------------*/ ---------------------------------------------------------------------*/
char *fileSubmenu [] = { char *fileSubmenu [] = {
"Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL }; "Exit", "Close", "---------", "Print", "---------", "Save", "Reset", NULL };
puCallback fileSubmenuCb [] = { puCallback fileSubmenuCb [] = {
@ -547,7 +541,7 @@ void guiInit()
// Install our fast fonts // Install our fast fonts
string fntpath = current_options.get_fg_root() + "/Fonts/" + string fntpath = current_options.get_fg_root() + "/Fonts/" +
"typewriter" + ".txf"; "typewriter" + ".txf";
guiFntHandle = new fntTexFont ; guiFntHandle = new fntTexFont ;
guiFntHandle -> load ( fntpath.c_str() ) ; guiFntHandle -> load ( fntpath.c_str() ) ;
puFont GuiFont ( guiFntHandle, 15 ) ; puFont GuiFont ( guiFntHandle, 15 ) ;
@ -555,26 +549,26 @@ void guiInit()
guiFnt = puGetDefaultLabelFont(); guiFnt = puGetDefaultLabelFont();
if ( current_options.get_mouse_pointer() == 0 ) { if ( current_options.get_mouse_pointer() == 0 ) {
// no preference specified for mouse pointer, attempt to autodetect... // no preference specified for mouse pointer, attempt to autodetect...
// Determine if we need to render the cursor, or if the windowing // Determine if we need to render the cursor, or if the windowing
// system will do it. First test if we are rendering with glide. // system will do it. First test if we are rendering with glide.
if ( strstr ( general.get_glRenderer(), "Glide" ) ) { if ( strstr ( general.get_glRenderer(), "Glide" ) ) {
// Test for the MESA_GLX_FX env variable // Test for the MESA_GLX_FX env variable
if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) { if ( (mesa_win_state = getenv( "MESA_GLX_FX" )) != NULL) {
// test if we are fullscreen mesa/glide // test if we are fullscreen mesa/glide
if ( (mesa_win_state[0] == 'f') || if ( (mesa_win_state[0] == 'f') ||
(mesa_win_state[0] == 'F') ) { (mesa_win_state[0] == 'F') ) {
puShowCursor (); puShowCursor ();
} }
} }
} }
mouse_active = ~mouse_active; mouse_active = ~mouse_active;
} else if ( current_options.get_mouse_pointer() == 1 ) { } else if ( current_options.get_mouse_pointer() == 1 ) {
// don't show pointer // don't show pointer
} else if ( current_options.get_mouse_pointer() == 2 ) { } else if ( current_options.get_mouse_pointer() == 2 ) {
// force showing pointer // force showing pointer
puShowCursor(); puShowCursor();
mouse_active = ~mouse_active; mouse_active = ~mouse_active;
} }
// Set up our Dialog Boxes // Set up our Dialog Boxes

View file

@ -50,7 +50,6 @@ extern fntTexFont *guiFntHandle;
// Activate Dialog Box // Activate Dialog Box
#define FG_PUSH_PUI_DIALOG( X ) \ #define FG_PUSH_PUI_DIALOG( X ) \
maybeToggleMouse(); \ maybeToggleMouse(); \
puPushGroup( (X) ) ; \
puPushLiveInterface( (X) ) ; \ puPushLiveInterface( (X) ) ; \
( X )->reveal() ( X )->reveal()
@ -58,7 +57,6 @@ extern fntTexFont *guiFntHandle;
#define FG_POP_PUI_DIALOG( X ) \ #define FG_POP_PUI_DIALOG( X ) \
(X)->hide(); \ (X)->hide(); \
puPopLiveInterface(); \ puPopLiveInterface(); \
puPopGroup(); \
guiFixPanel(); \ guiFixPanel(); \
maybeToggleMouse(); maybeToggleMouse();