ScummVM API documentation
viewport.h
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 modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NANCY_UI_VIEWPORT_H
23 #define NANCY_UI_VIEWPORT_H
24 
25 #include "engines/nancy/time.h"
26 #include "engines/nancy/video.h"
27 
28 #include "engines/nancy/renderobject.h"
29 
30 namespace Common {
31 class String;
32 }
33 
34 namespace Nancy {
35 
36 class Scene;
37 struct NancyInput;
38 
39 namespace UI {
40 
41 class Viewport : public Nancy::RenderObject {
42 public:
43  Viewport() :
44  RenderObject(6),
45  _movementLastFrame(0),
46  _edgesMask(0),
47  _currentFrame(0),
48  _videoFormat(kLargeVideoFormat),
49  _stickyCursorPos(-1, -1),
50  _panningType(kPanNone),
51  _decoder(AVFDecoder::kLoadBidirectional),
52  _autoMove(false) {}
53 
54  virtual ~Viewport() { _decoder.close(); _fullFrame.free(); }
55 
56  void init() override;
57  void handleInput(NancyInput &input);
58 
59  void loadVideo(const Common::Path &filename, uint frameNr = 0, uint verticalScroll = 0, byte panningType = kPanNone, uint16 format = 2, const Common::Path &palette = Common::Path());
60 
61  void setFrame(uint frameNr);
62  void setNextFrame();
63  void setPreviousFrame();
64 
65  void setVerticalScroll(uint scroll);
66  void scrollUp(uint delta);
67  void scrollDown(uint delta);
68 
69  uint16 getFrameCount() const { return _decoder.isVideoLoaded() ? _decoder.getFrameCount() : 0; }
70  uint16 getCurFrame() const { return _currentFrame; }
71  uint16 getCurVerticalScroll() const { return _drawSurface.getOffsetFromOwner().y; }
72  uint16 getMaxScroll() const;
73 
74  Common::Rect convertViewportToScreen(const Common::Rect &viewportRect) const;
75  Common::Rect convertScreenToViewport(const Common::Rect &viewportRect) const;
76 
77  void disableEdges(byte edges);
78  void enableEdges(byte edges);
79 
80 protected:
81  void setEdgesSize(uint16 upSize, uint16 downSize, uint16 leftSize, uint16 rightSize);
82 
83  Common::Rect _nonScrollZone;
84  byte _edgesMask;
85 
86  byte _movementLastFrame;
87  Time _nextMovementTime;
88 
89  byte _panningType;
90 
91  AVFDecoder _decoder;
92  uint16 _currentFrame;
93  uint16 _videoFormat;
94  Graphics::ManagedSurface _fullFrame;
95  Common::Rect _format1Bounds;
96  Common::Rect _format2Bounds;
97  Common::Point _stickyCursorPos;
98 
99  bool _autoMove;
100 };
101 
102 } // End of namespace UI
103 } // End of namespace Nancy
104 
105 #endif // NANCY_UI_VIEWPORT_H
Definition: managed_surface.h:51
Definition: viewport.h:41
Definition: time.h:30
Definition: rect.h:144
Definition: path.h:52
Definition: input.h:41
Definition: soundequalizerpuzzle.h:27
Definition: renderobject.h:36
Definition: algorithm.h:29
Definition: rect.h:45
Definition: video.h:41
Definition: actionmanager.h:32