1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef PSP_IMAGE_VIEWER_H
24 #define PSP_IMAGE_VIEWER_H
25 
26 class InputHandler;
27 
28 class ImageViewer : public DisplayClient {
29 public:
30 	enum Event {
31 		EVENT_NONE = -1,
32 		EVENT_HIDE = 0,
33 		EVENT_SHOW = 1,
34 		EVENT_ZOOM_IN,
35 		EVENT_ZOOM_OUT,
36 		EVENT_MOVE_LEFT,
37 		EVENT_MOVE_UP,
38 		EVENT_MOVE_RIGHT,
39 		EVENT_MOVE_DOWN,
40 		EVENT_MOVE_STOP,
41 		EVENT_NEXT_IMAGE,
42 		EVENT_LAST_IMAGE,
43 	};
44 
45 private:
46 	Buffer *_buffer;
47 	Palette *_palette;
48 	GuRenderer *_renderer;
49 	bool _visible;
50 	bool _dirty;
51 	bool _init;
52 	uint32 _imageNum;	// current image number
53 	float _zoomFactor;	// how much we're zooming in/out on the image
54 	float _visibleHeight, _visibleWidth;
55 	float _centerX, _centerY;
56 	Event _movement;
57 
58 	InputHandler *_inputHandler;
59 	DisplayManager *_displayManager;
60 
61 	void setFullScreenImageParams();
62 	void loadNextImage();
63 	void loadLastImage();
64 	void setViewerButtons(bool active);
65 	void setConstantRendererOptions();
66 	void moveImageX(float val);
67 	void moveImageY(float val);
68 	bool load(int imageNum);
69 	void unload();
70 	void runLoop(); // to get total pausing we have to do our own loop
71 
72 	void setZoom(float value);
73 	void setOffsetParams();
74 	void modifyZoom(bool up);	// up or down
75 	void setVisible(bool visible);
76 
77 public:
78 
ImageViewer()79 	ImageViewer() : _buffer(0), _palette(0), _visible(false),
80 					_dirty(false), _init(false), _imageNum(0),
81 					_zoomFactor(0.0f), _visibleHeight(0.0f), _visibleWidth(0.0f),
82 					_centerX(0.0f), _centerY(0.0f), _movement(EVENT_MOVE_STOP),
83 					_inputHandler(0), _displayManager(0) {}
~ImageViewer()84 	~ImageViewer() { unload(); }	// deallocate images
85 	bool load();
86 	void render();
isVisible()87 	bool isVisible() { return _visible; }
isDirty()88 	bool isDirty() { return _dirty; }
setDirty()89 	void setDirty() { _dirty = true; }
setClean()90 	void setClean() { if (!_visible) // otherwise we want to keep rendering
91 							_dirty = false;
92 	}
93 	void resetOnEngineDone();
94 
95 	void handleEvent(uint32 event);
96 
97 	// pointer setters
setInputHandler(InputHandler * inputHandler)98 	void setInputHandler(InputHandler *inputHandler) { _inputHandler = inputHandler; }
setDisplayManager(DisplayManager * displayManager)99 	void setDisplayManager(DisplayManager *displayManager) { _displayManager = displayManager; }
100 };
101 
102 #endif /* PSP_IMAGE_VIEWER_H */
103