diff options
author | Yotam Barnoy | 2010-10-14 22:33:32 +0000 |
---|---|---|
committer | Yotam Barnoy | 2010-10-14 22:33:32 +0000 |
commit | 6fc10aeeac5551d9402456e4f1e4df7c9bb2ab2c (patch) | |
tree | 6a0b5ae654e9de7340269646f2e11d1ff0039d76 | |
parent | 06c2b6bace8af0ddcbaff9a032c0f6eabddd22e8 (diff) | |
download | scummvm-rg350-6fc10aeeac5551d9402456e4f1e4df7c9bb2ab2c.tar.gz scummvm-rg350-6fc10aeeac5551d9402456e4f1e4df7c9bb2ab2c.tar.bz2 scummvm-rg350-6fc10aeeac5551d9402456e4f1e4df7c9bb2ab2c.zip |
PSP: made image in viewer movable by pushing nub continuously
svn-id: r53462
-rw-r--r-- | backends/platform/psp/image_viewer.cpp | 31 | ||||
-rw-r--r-- | backends/platform/psp/image_viewer.h | 38 | ||||
-rw-r--r-- | backends/platform/psp/input.cpp | 8 |
3 files changed, 50 insertions, 27 deletions
diff --git a/backends/platform/psp/image_viewer.cpp b/backends/platform/psp/image_viewer.cpp index e3fb786774..f3bcd988a2 100644 --- a/backends/platform/psp/image_viewer.cpp +++ b/backends/platform/psp/image_viewer.cpp @@ -159,6 +159,7 @@ void ImageViewer::loadNextImage() { if (!load(_imageNum)) // we failed, so reload the current image setVisible(false); // just hide } + setDirty(); } void ImageViewer::loadLastImage() { @@ -167,6 +168,7 @@ void ImageViewer::loadLastImage() { if (!load(_imageNum)) setVisible(false); // we can't even show the old image so hide } + setDirty(); } void ImageViewer::setFullScreenImageParams() { @@ -188,7 +190,24 @@ void ImageViewer::setFullScreenImageParams() { void ImageViewer::render() { assert(_buffer); assert(_renderer); - + + // move the image slightly. Note that we count on the renderer's timing + switch (_movement) { + case EVENT_MOVE_LEFT: + moveImageX(-2); + break; + case EVENT_MOVE_UP: + moveImageY(-2); + break; + case EVENT_MOVE_RIGHT: + moveImageX(2); + break; + case EVENT_MOVE_DOWN: + moveImageY(2); + break; + default: + break; + } _renderer->render(); } @@ -239,6 +258,7 @@ void ImageViewer::setOffsetParams() { int offsetY = _centerY - (int)(_visibleHeight * 0.5f); _renderer->setOffsetOnScreen(offsetX, offsetY); + setDirty(); } // Handler events coming in from the inputHandler @@ -260,16 +280,11 @@ void ImageViewer::handleEvent(uint32 event) { modifyZoom(false); break; case EVENT_MOVE_LEFT: - moveImageX(-5); - break; case EVENT_MOVE_UP: - moveImageY(-5); - break; case EVENT_MOVE_RIGHT: - moveImageX(5); - break; case EVENT_MOVE_DOWN: - moveImageY(5); + case EVENT_MOVE_STOP: + _movement = (Event)event; break; case EVENT_NEXT_IMAGE: loadNextImage(); diff --git a/backends/platform/psp/image_viewer.h b/backends/platform/psp/image_viewer.h index 2242ab198a..0e24ea496d 100644 --- a/backends/platform/psp/image_viewer.h +++ b/backends/platform/psp/image_viewer.h @@ -29,6 +29,22 @@ class InputHandler; class ImageViewer : public DisplayClient { +public: + enum Event { + EVENT_NONE = -1, + EVENT_HIDE = 0, + EVENT_SHOW = 1, + EVENT_ZOOM_IN, + EVENT_ZOOM_OUT, + EVENT_MOVE_LEFT, + EVENT_MOVE_UP, + EVENT_MOVE_RIGHT, + EVENT_MOVE_DOWN, + EVENT_MOVE_STOP, + EVENT_NEXT_IMAGE, + EVENT_LAST_IMAGE, + }; + private: Buffer *_buffer; Palette *_palette; @@ -40,6 +56,7 @@ private: float _zoomFactor; // how much we're zooming in/out on the image float _visibleHeight, _visibleWidth; float _centerX, _centerY; + Event _movement; InputHandler *_inputHandler; @@ -59,29 +76,20 @@ private: void setVisible(bool visible); public: - enum Events { - EVENT_HIDE = 0, - EVENT_SHOW = 1, - EVENT_ZOOM_IN, - EVENT_ZOOM_OUT, - EVENT_MOVE_LEFT, - EVENT_MOVE_UP, - EVENT_MOVE_RIGHT, - EVENT_MOVE_DOWN, - EVENT_NEXT_IMAGE, - EVENT_LAST_IMAGE, - }; - ImageViewer() : _buffer(0), _palette(0), _visible(false), _dirty(false), _init(false), _imageNum(0), + ImageViewer() : _buffer(0), _palette(0), _visible(false), + _dirty(false), _init(false), _imageNum(0), _zoomFactor(0.0f), _visibleHeight(0.0f), _visibleWidth(0.0f), - _centerX(0.0f), _centerY(0.0f) {} + _centerX(0.0f), _centerY(0.0f), _movement(EVENT_MOVE_STOP) {} ~ImageViewer() { unload(); } // deallocate images bool load(); void render(); bool isVisible() { return _visible; } bool isDirty() { return _dirty; } void setDirty() { _dirty = true; } - void setClean() { _dirty = false; } + void setClean() { if (_movement == EVENT_MOVE_STOP) // otherwise we want to keep rendering + _dirty = false; + } void resetOnEngineDone(); void handleEvent(uint32 event); diff --git a/backends/platform/psp/input.cpp b/backends/platform/psp/input.cpp index ba599cdac2..0dad31e5ae 100644 --- a/backends/platform/psp/input.cpp +++ b/backends/platform/psp/input.cpp @@ -561,13 +561,13 @@ void InputHandler::setButtonsForImageViewer() { //Nub _nub.getPad().clearButtons(); _nub.getPad().getButton(ButtonPad::BTN_UP, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_UP, - PSP_EVENT_NONE, false); + PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); _nub.getPad().getButton(ButtonPad::BTN_DOWN, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_DOWN, - PSP_EVENT_NONE, false); + PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); _nub.getPad().getButton(ButtonPad::BTN_LEFT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_LEFT, - PSP_EVENT_NONE, false); + PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); _nub.getPad().getButton(ButtonPad::BTN_RIGHT, UNSHIFTED).setPspEvent(PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_RIGHT, - PSP_EVENT_NONE, false); + PSP_EVENT_IMAGE_VIEWER, ImageViewer::EVENT_MOVE_STOP); } |