diff options
author | Matthew Hoops | 2011-09-18 15:48:31 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-09-18 15:48:31 -0400 |
commit | 8f6e6030999e7263062461eaf6e0fe378a3892ba (patch) | |
tree | c057fd4ad7f7b1e027c0548bdd12a17b5a368949 /engines | |
parent | 1390db1df12a8a853deca62df2e11a899c111fcf (diff) | |
download | scummvm-rg350-8f6e6030999e7263062461eaf6e0fe378a3892ba.tar.gz scummvm-rg350-8f6e6030999e7263062461eaf6e0fe378a3892ba.tar.bz2 scummvm-rg350-8f6e6030999e7263062461eaf6e0fe378a3892ba.zip |
PEGASUS: Add the Tracker class
Diffstat (limited to 'engines')
-rwxr-xr-x | engines/pegasus/input.cpp | 27 | ||||
-rwxr-xr-x | engines/pegasus/input.h | 35 |
2 files changed, 62 insertions, 0 deletions
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp index 37f9945634..9ef369eb60 100755 --- a/engines/pegasus/input.cpp +++ b/engines/pegasus/input.cpp @@ -267,4 +267,31 @@ bool InputHandler::wantsCursor() { return false; } +Tracker *Tracker::_currentTracker = 0; + +void Tracker::handleInput(const Input &input, const Hotspot *) { + if (stopTrackingInput(input)) + stopTracking(input); + else if (isTracking()) + continueTracking(input); +} + +void Tracker::startTracking(const Input &) { + if (!isTracking()) { + _savedHandler = InputHandler::setInputHandler(this); + _currentTracker = this; + } +} + +void Tracker::stopTracking(const Input &) { + if (isTracking()) { + _currentTracker = NULL; + InputHandler::setInputHandler(_savedHandler); + } +} + +bool Tracker::isClickInput(const Input &input, const Hotspot *hotspot) { + return !isTracking() && InputHandler::isClickInput(input, hotspot); +} + } // End of namespace Pegasus diff --git a/engines/pegasus/input.h b/engines/pegasus/input.h index 432ff8098b..4da0418a53 100755 --- a/engines/pegasus/input.h +++ b/engines/pegasus/input.h @@ -414,6 +414,41 @@ protected: bool _allowInput; }; + +/* + + Tracker implements "dragging". A Tracker can receive a startTracking message, + which causes it to be the current tracker, as well as setting it up as the current + input handler. In addition, only one tracker can be tracking at a time, and no + other handler can be set up as the current handler until the track finishes. By + default, there is no next input handler for a Tracker, but this behavior can be + overridden if desired. + +*/ + +class Tracker : public InputHandler { +public: + Tracker() : InputHandler(0) {} + virtual ~Tracker(); + + virtual void handleInput(const Input &, const Hotspot *); + virtual bool stopTrackingInput(const Input &) { return false; } + + virtual void startTracking(const Input &); + virtual void stopTracking(const Input &); + virtual void continueTracking(const Input &) {} + + bool isTracking() { return this == _currentTracker; } + bool isClickInput(const Input &, const Hotspot *); + + bool releaseInputFocus() { return !isTracking(); } + +protected: + static Tracker *_currentTracker; + + InputHandler *_savedHandler; +}; + } // End of namespace Pegasus #endif |