]> git.mxchange.org Git - flightgear.git/blobdiff - src/Cockpit/panel.cxx
toggle fullscreen: also adapt GUI plane when resizing
[flightgear.git] / src / Cockpit / panel.cxx
index ff13176e2fa88db2e3035541a5c385e2352cc24b..3fbc1994b4a63c9b82d829c1ebbffc6bcff83147 100644 (file)
 
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
-#include <Main/viewmgr.hxx>
+#include <Viewer/viewmgr.hxx>
+#include <Viewer/viewer.hxx>
 #include <Time/light.hxx>
 #include <GUI/FGFontCache.hxx> 
-#include <Main/viewer.hxx>
 #include <Instrumentation/dclgps.hxx>
 
 #define WIN_X 0
@@ -73,6 +73,9 @@
 // my hardware/driver requires many more.
 #define POFF_UNITS 8
 
+const double MOUSE_ACTION_REPEAT_DELAY = 0.5; // 500msec initial delay
+const double MOUSE_ACTION_REPEAT_INTERVAL = 0.1; // 10Hz repeat rate
+
 using std::map;
 
 ////////////////////////////////////////////////////////////////////////
@@ -90,28 +93,6 @@ get_aspect_adjust (int xsize, int ysize)
   float real_aspect = float(xsize) / float(ysize);
   return (real_aspect / ideal_aspect);
 }
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Global functions.
-////////////////////////////////////////////////////////////////////////
-
-bool
-fgPanelVisible ()
-{
-     const FGPanel* current = globals->get_current_panel();
-     if (current == 0)
-       return false;
-     if (current->getVisibility() == 0)
-       return false;
-     if (globals->get_viewmgr()->get_current() != 0)
-       return false;
-     if (current->getAutohide() && globals->get_current_view()->getHeadingOffset_deg() * SGD_DEGREES_TO_RADIANS != 0)
-       return false;
-     return true;
-}
-
 \f
 ////////////////////////////////////////////////////////////////////////
 // Implementation of FGTextureManager.
@@ -198,8 +179,6 @@ FGPanel::FGPanel ()
   : _mouseDown(false),
     _mouseInstrument(0),
     _width(WIN_W), _height(int(WIN_H * 0.5768 + 1)),
- //   _view_height(int(WIN_H * 0.4232)),
-    _visibility(fgGetNode("/sim/panel/visibility", true)),
     _x_offset(fgGetNode("/sim/panel/x-offset", true)),
     _y_offset(fgGetNode("/sim/panel/y-offset", true)),
     _jitter(fgGetNode("/sim/panel/jitter", true)),
@@ -207,6 +186,7 @@ FGPanel::FGPanel ()
     _xsize_node(fgGetNode("/sim/startup/xsize", true)),
     _ysize_node(fgGetNode("/sim/startup/ysize", true)),
     _enable_depth_test(false),
+    _autohide(true),
     _drawPanelHotspots("/sim/panel-hotspots")
 {
 }
@@ -235,44 +215,6 @@ FGPanel::addInstrument (FGPanelInstrument * instrument)
   _instruments.push_back(instrument);
 }
 
-
-/**
- * Initialize the panel.
- */
-void
-FGPanel::init ()
-{
-}
-
-
-/**
- * Bind panel properties.
- */
-void
-FGPanel::bind ()
-{
-  fgSetArchivable("/sim/panel/visibility");
-  fgSetArchivable("/sim/panel/x-offset");
-  fgSetArchivable("/sim/panel/y-offset");
-  fgSetArchivable("/sim/panel/jitter");
-}
-
-
-/**
- * Unbind panel properties.
- */
-void
-FGPanel::unbind ()
-{
-}
-
-
-void
-FGPanel::update (double /* dt */)
-{
-  updateMouseDelay();
-}
-
 double
 FGPanel::getAspectScale() const
 {
@@ -293,15 +235,18 @@ FGPanel::getAspectScale() const
  * fgUpdate3DPanels().  This functionality needs to move into the
  * input subsystem.  Counting a tick every two frames is clumsy...
  */
-void FGPanel::updateMouseDelay()
-{
-    if (_mouseDown) {
-        _mouseDelay--;
-        if (_mouseDelay < 0) {
-            _mouseInstrument->doMouseAction(_mouseButton, 0, _mouseX, _mouseY);
-            _mouseDelay = 2;
-        }
-    }
+void FGPanel::updateMouseDelay(double dt)
+{
+  if (!_mouseDown) {
+    return;
+  }
+
+  _mouseActionRepeat -= dt;
+  while (_mouseActionRepeat < 0.0) {
+    _mouseActionRepeat += MOUSE_ACTION_REPEAT_INTERVAL;
+    _mouseInstrument->doMouseAction(_mouseButton, 0, _mouseX, _mouseY);
+    
+  }
 }
 
 void
@@ -477,6 +422,9 @@ FGPanel::draw(osg::State& state)
     for ( unsigned int i = 0; i < _instruments.size(); i++ )
       _instruments[i]->drawHotspots(state);
 
+  // disable drawing of panel extents for the 2.8 release, since it
+  // confused use of hot-spot drawing in tutorials.
+#ifdef DRAW_PANEL_EXTENTS
     glColor3f(0, 1, 1);
 
     int x0, y0, x1, y1;
@@ -488,7 +436,7 @@ FGPanel::draw(osg::State& state)
     glVertex2f(x1, y1);
     glVertex2f(x0, y1);
     glEnd();
-
+#endif
     
     glPopAttrib();
 
@@ -500,26 +448,6 @@ FGPanel::draw(osg::State& state)
   }
 }
 
-/**
- * Set the panel's visibility.
- */
-void
-FGPanel::setVisibility (bool visibility)
-{
-  _visibility->setBoolValue( visibility );
-}
-
-
-/**
- * Return true if the panel is visible.
- */
-bool
-FGPanel::getVisibility () const
-{
-  return _visibility->getBoolValue();
-}
-
-
 /**
  * Set the panel's background texture.
  */
@@ -595,7 +523,7 @@ FGPanel::doLocalMouseAction(int button, int updown, int x, int y)
     int ih = inst->getHeight() / 2;
     if (x >= ix - iw && x < ix + iw && y >= iy - ih && y < iy + ih) {
       _mouseDown = true;
-      _mouseDelay = 20;
+      _mouseActionRepeat = MOUSE_ACTION_REPEAT_DELAY;
       _mouseInstrument = inst;
       _mouseButton = button;
       _mouseX = x - ix;