// 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;
////////////////////////////////////////////////////////////////////////
void
-FGPanel::update (double /* dt */)
+FGPanel::update (double dt)
{
- updateMouseDelay();
+ updateMouseDelay(dt);
}
double
* 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
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;
//void update (osg::State& state);
//virtual void update (osg::State& state, GLfloat winx, GLfloat winw, GLfloat winy, GLfloat winh);
- virtual void updateMouseDelay();
+ virtual void updateMouseDelay(double dt);
// transfer pointer ownership!!!
virtual void addInstrument (FGPanelInstrument * instrument);
mutable bool _mouseDown;
mutable int _mouseButton, _mouseX, _mouseY;
- mutable int _mouseDelay;
+ double _mouseActionRepeat;
+
mutable FGPanelInstrument * _mouseInstrument;
typedef std::vector<FGPanelInstrument *> instrument_list_type;
int _width;
picked.x(), picked.y());
}
- virtual void update(double /* dt */)
+ virtual void update(double dt)
{
- panel->getPanel()->updateMouseDelay();
+ panel->getPanel()->updateMouseDelay(dt);
}
virtual void buttonReleased(void)