1
0
Fork 0

get rid of mouse.cxx and pu{Show|Hide}Cursor()

This commit is contained in:
mfranz 2008-07-27 09:39:10 +00:00
parent 46ae218672
commit b68b751fd4
9 changed files with 14 additions and 247 deletions

View file

@ -6956,21 +6956,6 @@ SOURCE=.\src\GUI\gui_local.hxx
# End Source File
# Begin Source File
SOURCE=.\src\GUI\mouse.cxx
!IF "$(CFG)" == "FlightGear - Win32 Release"
# PROP Intermediate_Dir "Release\Lib_GUI"
!ELSEIF "$(CFG)" == "FlightGear - Win32 Debug"
# PROP Intermediate_Dir "Debug\Lib_GUI"
!ENDIF
# End Source File
# Begin Source File
SOURCE=.\src\GUI\fonts.cxx
!IF "$(CFG)" == "FlightGear - Win32 Release"

View file

@ -1781,9 +1781,6 @@
<File
RelativePath="..\..\src\GUI\menubar.hxx">
</File>
<File
RelativePath="..\..\src\GUI\mouse.cxx">
</File>
<File
RelativePath="..\..\src\GUI\new_gui.cxx">
</File>

View file

@ -2922,10 +2922,6 @@
RelativePath="..\..\src\sound\morse.cxx"
>
</File>
<File
RelativePath="..\..\src\gui\mouse.cxx"
>
</File>
<File
RelativePath="..\..\src\Instrumentation\mrg.cxx"
>

View file

@ -6,7 +6,7 @@ libGUI_a_SOURCES = \
dialog.cxx dialog.hxx \
menubar.cxx menubar.hxx \
gui.cxx gui.h gui_funcs.cxx \
mouse.cxx fonts.cxx \
fonts.cxx \
AirportList.cxx AirportList.hxx \
property_list.cxx property_list.hxx \
layout.cxx layout-props.cxx layout.hxx \

View file

@ -10,7 +10,6 @@ dialog.[ch]xx XML-configurable dialog box.
gui.cxx, gui.h Top-level GUI functions (deprecated).
gui_funcs.cxx Implementation of internal GUI functions (deprecated).
menubar.[ch]xx XML-configurable menu bar.
mouse.cxx Old GUI mouse support (deprecated).
new_gui.[ch]xx Top-level for the GUI subsystem.

View file

@ -73,10 +73,4 @@ typedef struct {
} __fg_gui_fn_t;
extern const __fg_gui_fn_t __fg_gui_fn[];
// mouse.cxx
extern void guiInitMouse(int width, int height);
extern void maybeToggleMouse( void );
extern void TurnCursorOn( void );
extern void TurnCursorOff( void );
#endif // _GUI_H_

View file

@ -40,9 +40,10 @@
#include <fstream>
#include <string>
#include <cstring>
#include <sstream>
#include <stdlib.h>
#include <string.h>
// for help call back
#ifdef WIN32
@ -52,22 +53,11 @@
# endif
#endif
#include <sstream>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/screen/screen-dump.hxx>
#include <Include/general.hxx>
#include <Aircraft/aircraft.hxx>
#include <Aircraft/controls.hxx>
#include <Airports/simple.hxx>
#include <Cockpit/panel.hxx>
#include <FDM/flight.hxx>
#include <Main/main.hxx>
#include <Main/fg_init.hxx>
#include <Main/fg_io.hxx>
#include <Main/globals.hxx>
#include <Main/fg_props.hxx>
#include <Main/renderer.hxx>
@ -81,8 +71,7 @@
#include "gui.h"
SG_USING_STD(string);
SG_USING_STD(cout);
using std::string;
#if defined( TR_HIRES_SNAP)
@ -230,7 +219,6 @@ void fgHiResDump()
{
FILE *f;
string message;
bool show_pu_cursor = false;
bool menu_status = fgGetBool("/sim/menubar/visibility");
char *filename = new char [24];
static int count = 1;
@ -244,11 +232,8 @@ void fgHiResDump()
}
fgSetBool("/sim/menubar/visibility", false);
TurnCursorOff();
if ( !puCursorIsHidden() ) {
show_pu_cursor = true;
puHideCursor();
}
int mouse = fgGetMouseCursor();
fgSetMouseCursor(MOUSE_CURSOR_NONE);
FGRenderer *renderer = globals->get_renderer();
// renderer->init();
@ -415,11 +400,7 @@ void fgHiResDump()
delete [] filename;
if ( show_pu_cursor ) {
puShowCursor();
}
TurnCursorOn();
fgSetMouseCursor(mouse);
fgSetBool("/sim/menubar/visibility", menu_status);
if ( !freeze ) {
@ -469,12 +450,8 @@ GLubyte *hiResScreenCapture( int multiplier )
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined(__MINGW32__)
// win32 print screen function
void printScreen () {
bool show_pu_cursor = false;
TurnCursorOff();
if ( !puCursorIsHidden() ) {
show_pu_cursor = true;
puHideCursor();
}
int mouse = fgGetMouseCursor();
fgSetMouseCursor(MOUSE_CURSOR_NONE);
CGlPrinter p( CGlPrinter::PRINT_BITMAP );
int cur_width = fgGetInt("/sim/startup/xsize");
@ -482,10 +459,7 @@ void printScreen () {
p.Begin( "FlightGear", cur_width*3, cur_height*3 );
p.End( hiResScreenCapture(3) );
if ( show_pu_cursor ) {
puShowCursor();
}
TurnCursorOn();
fgSetMouseCursor(mouse);
}
#endif // #ifdef WIN32
@ -502,7 +476,6 @@ void fgHiResDumpWrapper () {
// do a screen snap shot
bool fgDumpSnapShot () {
bool show_pu_cursor = false;
static SGConstPropertyNode_ptr master_freeze = fgGetNode("/sim/freeze/master");
bool freeze = master_freeze->getBoolValue();
@ -510,11 +483,9 @@ bool fgDumpSnapShot () {
fgSetBool("/sim/freeze/master", true);
}
TurnCursorOff();
if ( !puCursorIsHidden() ) {
show_pu_cursor = true;
puHideCursor();
}
int mouse = fgGetMouseCursor();
fgSetMouseCursor(MOUSE_CURSOR_NONE);
fgSetBool("/sim/signals/screenshot", true);
FGRenderer *renderer = globals->get_renderer();
@ -555,11 +526,7 @@ bool fgDumpSnapShot () {
fgSetString("/sim/paths/screenshot-last", path.c_str());
fgSetBool("/sim/signals/screenshot", false);
if ( show_pu_cursor ) {
puShowCursor();
}
TurnCursorOn();
fgSetMouseCursor(mouse);
if ( !freeze ) {
fgSetBool("/sim/freeze/master", false);

View file

@ -1,169 +0,0 @@
/**************************************************************************
* gui.cxx
*
* Written 1998 by Durk Talsma, started Juni, 1998. For the flight gear
* project.
*
* Additional mouse supported added by David Megginson, 1999.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* $Id$
**************************************************************************/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <simgear/compiler.h>
#ifdef HAVE_WINDOWS_H
# include <windows.h>
#endif
#include <Main/fg_os.hxx>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <simgear/constants.h>
#include <simgear/debug/logstream.hxx>
#include <simgear/misc/sg_path.hxx>
#include <Include/general.hxx>
#include <Aircraft/aircraft.hxx>
#include <Aircraft/controls.hxx>
#include <Airports/simple.hxx>
#include <Cockpit/panel.hxx>
#include <FDM/flight.hxx>
#include <Main/fg_init.hxx>
#include <Main/fg_props.hxx>
#include <Main/viewmgr.hxx>
#include "gui.h"
SG_USING_STD(string);
SG_USING_STD(cout);
/* --------------------------------------------------------------------
Mouse stuff
---------------------------------------------------------------------*/
#if defined(WIN32) || defined(__CYGWIN32__)
#define WIN32_CURSOR_TWEAKS
// uncomment this for cursor to turn off when menu is disabled
// #define WIN32_CURSOR_TWEAKS_OFF
#elif (GLUT_API_VERSION >= 4 || GLUT_XLIB_IMPLEMENTATION >= 9)
#define X_CURSOR_TWEAKS
#endif
static int mouse_active = 0;
static int MOUSE_XSIZE = 0;
static int MOUSE_YSIZE = 0;
typedef enum {
MOUSE_POINTER,
MOUSE_YOKE,
MOUSE_VIEW
} MouseMode;
/* --------------------------------------------------------------------
Support for mouse as control yoke (david@megginson.com)
- right button toggles between pointer and yoke
- horizontal drag with no buttons moves ailerons
- vertical drag with no buttons moves elevators
- horizontal drag with left button moves brakes (left=on)
- vertical drag with left button moves throttle (up=more)
- horizontal drag with middle button moves rudder
- vertical drag with middle button moves trim
For the *_sensitivity variables, a lower number means more sensitive.
TODO: figure out how to keep pointer from leaving window in yoke mode.
TODO: add thresholds and null zones
TODO: sensitivity should be configurable at user option.
TODO: allow differential braking (this will be useful if FlightGear
ever supports tail-draggers like the DC-3)
---------------------------------------------------------------------*/
MouseMode mouse_mode = MOUSE_POINTER;
void guiInitMouse(int width, int height)
{
MOUSE_XSIZE = width;
MOUSE_YSIZE = height;
}
void TurnCursorOn( void )
{
mouse_active = ~0;
#if defined(WIN32)
switch (mouse_mode) {
case MOUSE_POINTER:
fgSetMouseCursor(MOUSE_CURSOR_POINTER);
break;
case MOUSE_YOKE:
fgSetMouseCursor(MOUSE_CURSOR_CROSSHAIR);
break;
case MOUSE_VIEW:
fgSetMouseCursor(MOUSE_CURSOR_LEFTRIGHT);
break;
}
#endif
#if defined(X_CURSOR_TWEAKS)
fgWarpMouse( MOUSE_XSIZE/2, MOUSE_YSIZE/2 );
#endif
}
void TurnCursorOff( void )
{
mouse_active = 0;
#if defined(WIN32_CURSOR_TWEAKS)
fgSetMouseCursor(MOUSE_CURSOR_NONE);
#elif defined(X_CURSOR_TWEAKS)
fgWarpMouse( MOUSE_XSIZE, MOUSE_YSIZE );
#endif
}
void maybeToggleMouse( void )
{
#if defined(WIN32_CURSOR_TWEAKS_OFF)
static int first_time = ~0;
static int mouse_changed = 0;
if ( first_time ) {
if(!mouse_active) {
mouse_changed = ~mouse_changed;
TurnCursorOn();
}
} else {
if( mouse_mode != MOUSE_POINTER )
return;
if( mouse_changed ) {
mouse_changed = ~mouse_changed;
if(mouse_active) {
TurnCursorOff();
}
}
}
first_time = ~first_time;
#endif // #ifdef WIN32
}

View file

@ -833,8 +833,6 @@ FGRenderer::resize( int width, int height ) {
if (height != lastheight)
fgSetInt("/sim/startup/ysize", lastheight = height);
guiInitMouse(width, height);
// for all views
FGViewMgr *viewmgr = globals->get_viewmgr();
if (viewmgr) {