From 0f156c72809fc76e44ecaf79174c480465058360 Mon Sep 17 00:00:00 2001 From: curt Date: Fri, 27 Jul 2001 21:59:53 +0000 Subject: [PATCH] - modified PanelAction to use FGBinding, like keyboard and joystick events - removed all classes derived from PanelAction (no longer needed) --- src/Cockpit/panel.cxx | 79 +++++-------------------------------------- src/Cockpit/panel.hxx | 78 ++++-------------------------------------- 2 files changed, 16 insertions(+), 141 deletions(-) diff --git a/src/Cockpit/panel.cxx b/src/Cockpit/panel.cxx index dca6cfdff..c844d7497 100644 --- a/src/Cockpit/panel.cxx +++ b/src/Cockpit/panel.cxx @@ -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 () { } - - -//////////////////////////////////////////////////////////////////////// -// 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); -} - - - -//////////////////////////////////////////////////////////////////////// -// 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); -} - - - -//////////////////////////////////////////////////////////////////////// -// 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(); + } } diff --git a/src/Cockpit/panel.hxx b/src/Cockpit/panel.hxx index 1aa28d695..70a311de6 100644 --- a/src/Cockpit/panel.hxx +++ b/src/Cockpit/panel.hxx @@ -49,6 +49,8 @@ #include
+#include + 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 binding_list_t; + int _button; int _x; int _y; int _w; int _h; -}; - - - -//////////////////////////////////////////////////////////////////////// -// 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; -}; - - - -//////////////////////////////////////////////////////////////////////// -// 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; -}; - - - -//////////////////////////////////////////////////////////////////////// -// 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; }; -- 2.39.5