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();
{
}
-
-\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();
+ }
}
#include <Main/fgfs.hxx>
+#include <Input/input.hxx>
+
SG_USING_STD(vector);
SG_USING_STD(map);
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; }
}
// 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;
};