Adjust cursor-setting code, for better compatibility with Cocoa-Viewer (OSG patch still required, unfortunately)
This commit is contained in:
parent
1692bc749e
commit
c4c5cc850b
1 changed files with 17 additions and 14 deletions
|
@ -45,6 +45,7 @@
|
||||||
#include <osg/View>
|
#include <osg/View>
|
||||||
#include <osgViewer/ViewerEventHandlers>
|
#include <osgViewer/ViewerEventHandlers>
|
||||||
#include <osgViewer/Viewer>
|
#include <osgViewer/Viewer>
|
||||||
|
#include <osgViewer/GraphicsWindow>
|
||||||
|
|
||||||
#include <Scenery/scenery.hxx>
|
#include <Scenery/scenery.hxx>
|
||||||
#include "fg_os.hxx"
|
#include "fg_os.hxx"
|
||||||
|
@ -313,24 +314,23 @@ void fgOSFullScreen()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setMouseCursor(osg::Camera* camera, int cursor)
|
static void setMouseCursor(osgViewer::GraphicsWindow* gw, int cursor)
|
||||||
{
|
{
|
||||||
if (!camera)
|
if (!gw) {
|
||||||
return;
|
|
||||||
osg::GraphicsContext* gc = camera->getGraphicsContext();
|
|
||||||
if (!gc)
|
|
||||||
return;
|
|
||||||
osgViewer::GraphicsWindow* gw;
|
|
||||||
gw = dynamic_cast<osgViewer::GraphicsWindow*>(gc);
|
|
||||||
if (!gw)
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
osgViewer::GraphicsWindow::MouseCursor mouseCursor;
|
osgViewer::GraphicsWindow::MouseCursor mouseCursor;
|
||||||
mouseCursor = osgViewer::GraphicsWindow::InheritCursor;
|
mouseCursor = osgViewer::GraphicsWindow::InheritCursor;
|
||||||
if (cursor == MOUSE_CURSOR_NONE)
|
if (cursor == MOUSE_CURSOR_NONE)
|
||||||
mouseCursor = osgViewer::GraphicsWindow::NoCursor;
|
mouseCursor = osgViewer::GraphicsWindow::NoCursor;
|
||||||
else if(cursor == MOUSE_CURSOR_POINTER)
|
else if(cursor == MOUSE_CURSOR_POINTER)
|
||||||
|
#ifdef SG_MAC
|
||||||
|
// osgViewer-Cocoa lacks RightArrowCursor, use Left
|
||||||
|
mouseCursor = osgViewer::GraphicsWindow::LeftArrowCursor;
|
||||||
|
#else
|
||||||
mouseCursor = osgViewer::GraphicsWindow::RightArrowCursor;
|
mouseCursor = osgViewer::GraphicsWindow::RightArrowCursor;
|
||||||
|
#endif
|
||||||
else if(cursor == MOUSE_CURSOR_WAIT)
|
else if(cursor == MOUSE_CURSOR_WAIT)
|
||||||
mouseCursor = osgViewer::GraphicsWindow::WaitCursor;
|
mouseCursor = osgViewer::GraphicsWindow::WaitCursor;
|
||||||
else if(cursor == MOUSE_CURSOR_CROSSHAIR)
|
else if(cursor == MOUSE_CURSOR_CROSSHAIR)
|
||||||
|
@ -362,9 +362,12 @@ static int _cursor = -1;
|
||||||
void fgSetMouseCursor(int cursor)
|
void fgSetMouseCursor(int cursor)
|
||||||
{
|
{
|
||||||
_cursor = cursor;
|
_cursor = cursor;
|
||||||
setMouseCursor(viewer->getCamera(), cursor);
|
|
||||||
for (unsigned i = 0; i < viewer->getNumSlaves(); ++i)
|
std::vector<osgViewer::GraphicsWindow*> windows;
|
||||||
setMouseCursor(viewer->getSlave(i)._camera.get(), cursor);
|
viewer->getWindows(windows);
|
||||||
|
BOOST_FOREACH(osgViewer::GraphicsWindow* gw, windows) {
|
||||||
|
setMouseCursor(gw, cursor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int fgGetMouseCursor()
|
int fgGetMouseCursor()
|
||||||
|
|
Loading…
Add table
Reference in a new issue