]> git.mxchange.org Git - flightgear.git/commitdiff
- modified PanelAction to use FGBinding, like keyboard and joystick
authorcurt <curt>
Fri, 27 Jul 2001 21:59:53 +0000 (21:59 +0000)
committercurt <curt>
Fri, 27 Jul 2001 21:59:53 +0000 (21:59 +0000)
  events
- removed all classes derived from PanelAction (no longer needed)

src/Cockpit/panel.cxx
src/Cockpit/panel.hxx

index dca6cfdff95b3382478ba7ffdfe1f5d3cc909b23..c844d74972359d22c800937539be4b799bd866e4 100644 (file)
@@ -273,7 +273,8 @@ FGPanel::update (GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh)
   glMatrixMode(GL_PROJECTION);
   glPushMatrix();
   glLoadIdentity();
-  gluOrtho2D(winx, winx + winw, winy, winy + winh);
+  gluOrtho2D(winx, winx + winw, winy, winy + winh); /* right side up */
+  // gluOrtho2D(winx + winw, winx, winy + winh, winy); /* up side down */
 
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
@@ -450,81 +451,19 @@ FGPanelAction::~FGPanelAction ()
 {
 }
 
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGAdjustAction.
-////////////////////////////////////////////////////////////////////////
-
-FGAdjustAction::FGAdjustAction (int button, int x, int y, int w, int h,
-                               SGPropertyNode * node, float increment, 
-                               float min, float max, bool wrap)
-  : FGPanelAction(button, x, y, w, h),
-    _node(node), _increment(increment), _min(min), _max(max), _wrap(wrap)
-{
-}
-
-FGAdjustAction::~FGAdjustAction ()
-{
-}
-
-void
-FGAdjustAction::doAction ()
-{
-  float val = _node->getFloatValue();
-  val += _increment;
-  if (val < _min) {
-    val = (_wrap ? _max : _min);
-  } else if (val > _max) {
-    val = (_wrap ? _min : _max);
-  }
-  _node->setDoubleValue(val);
-}
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGSwapAction.
-////////////////////////////////////////////////////////////////////////
-
-FGSwapAction::FGSwapAction (int button, int x, int y, int w, int h,
-                           SGPropertyNode * node1, SGPropertyNode * node2)
-  : FGPanelAction(button, x, y, w, h), _node1(node1), _node2(node2)
-{
-}
-
-FGSwapAction::~FGSwapAction ()
-{
-}
-
 void
-FGSwapAction::doAction ()
-{
-  float val = _node1->getFloatValue();
-  _node1->setDoubleValue(_node2->getFloatValue());
-  _node2->setDoubleValue(val);
-}
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Implementation of FGToggleAction.
-////////////////////////////////////////////////////////////////////////
-
-FGToggleAction::FGToggleAction (int button, int x, int y, int w, int h,
-                               SGPropertyNode * node)
-  : FGPanelAction(button, x, y, w, h), _node(node)
-{
-}
-
-FGToggleAction::~FGToggleAction ()
+FGPanelAction::addBinding (const FGBinding &binding)
 {
+  _bindings.push_back(binding);
 }
 
 void
-FGToggleAction::doAction ()
+FGPanelAction::doAction ()
 {
-  _node->setBoolValue(!(_node->getBoolValue()));
+  int nBindings = _bindings.size();
+  for (int i = 0; i < nBindings; i++) {
+    _bindings[i].fire();
+  }
 }
 
 
index 1aa28d6952f8320375114603d1dd7b74bb1a8127..70a311de68e86501e740f6b0417db2a273360895 100644 (file)
@@ -49,6 +49,8 @@
 
 #include <Main/fgfs.hxx>
 
+#include <Input/input.hxx>
+
 SG_USING_STD(vector);
 SG_USING_STD(map);
 
@@ -215,6 +217,7 @@ public:
   virtual int getHeight () const { return _h; }
 
                                // Setters.
+  virtual void addBinding (const FGBinding &binding);
   virtual void setButton (int button) { _button = button; }
   virtual void setX (int x) { _x = x; }
   virtual void setY (int y) { _y = y; }
@@ -232,84 +235,17 @@ public:
   }
 
                                // Perform the action.
-  virtual void doAction () = 0;
+  virtual void doAction ();
 
 private:
+  typedef vector<FGBinding> binding_list_t;
+
   int _button;
   int _x;
   int _y;
   int _w;
   int _h;
-};
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Adjustment action.
-//
-// This is an action to increase or decrease an FGFS value by a certain
-// increment within a certain range.  If the wrap flag is true, the
-// value will wrap around if it goes below min or above max; otherwise,
-// it will simply stop at min or max.
-////////////////////////////////////////////////////////////////////////
-
-class FGAdjustAction : public FGPanelAction
-{
-public:
-  FGAdjustAction (int button, int x, int y, int w, int h,
-                 SGPropertyNode * node, float increment,
-                 float min, float max, bool wrap=false);
-  virtual ~FGAdjustAction ();
-  virtual void doAction ();
-
-private:
-  SGPropertyNode * _node;
-  float _increment;
-  float _min;
-  float _max;
-  bool _wrap;
-};
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Swap action.
-//
-// This is an action to swap two values.  It's currently used in the
-// navigation radios.
-////////////////////////////////////////////////////////////////////////
-
-class FGSwapAction : public FGPanelAction
-{
-public:
-  FGSwapAction (int button, int x, int y, int w, int h,
-               SGPropertyNode * node1, SGPropertyNode * node2);
-  virtual ~FGSwapAction ();
-  virtual void doAction ();
-
-private:
-  SGPropertyNode * _node1;
-  SGPropertyNode * _node2;
-};
-
-
-\f
-////////////////////////////////////////////////////////////////////////
-// Toggle action.
-//
-// This is an action to toggle a boolean value.
-////////////////////////////////////////////////////////////////////////
-
-class FGToggleAction : public FGPanelAction
-{
-public:
-  FGToggleAction (int button, int x, int y, int w, int h,
-                 SGPropertyNode * node);
-  virtual ~FGToggleAction ();
-  virtual void doAction ();
-
-private:
-  SGPropertyNode * _node;
+  binding_list_t _bindings;
 };