1
0
Fork 0

- modified PanelAction to use FGBinding, like keyboard and joystick

events
- removed all classes derived from PanelAction (no longer needed)
This commit is contained in:
curt 2001-07-27 21:59:53 +00:00
parent 6d1c383814
commit 0f156c7280
2 changed files with 16 additions and 141 deletions

View 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 ()
{
}
////////////////////////////////////////////////////////////////////////
// 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
FGPanelAction::addBinding (const FGBinding &binding)
{
_bindings.push_back(binding);
}
void
FGAdjustAction::doAction ()
FGPanelAction::doAction ()
{
float val = _node->getFloatValue();
val += _increment;
if (val < _min) {
val = (_wrap ? _max : _min);
} else if (val > _max) {
val = (_wrap ? _min : _max);
int nBindings = _bindings.size();
for (int i = 0; i < nBindings; i++) {
_bindings[i].fire();
}
_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 ()
{
}
void
FGToggleAction::doAction ()
{
_node->setBoolValue(!(_node->getBoolValue()));
}

View 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;
};
////////////////////////////////////////////////////////////////////////
// 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;
};