ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

window.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/stark/ui/window.h"
00024 
00025 #include "engines/stark/gfx/driver.h"
00026 #include "engines/stark/services/services.h"
00027 #include "engines/stark/ui/cursor.h"
00028 
00029 namespace Stark {
00030 
00031 Window::Window(Gfx::Driver *gfx, Cursor *cursor) :
00032         _gfx(gfx),
00033         _cursor(cursor),
00034         _visible(false) {
00035 }
00036 
00037 Window::~Window() {
00038 }
00039 
00040 void Window::handleGameLoop() {
00041     if (!_visible) {
00042         return;
00043     }
00044 
00045     onGameLoop();
00046 }
00047 
00048 void Window::render() {
00049     if (!_visible) {
00050         return;
00051     }
00052 
00053     _gfx->setViewport(_position);
00054 
00055     onRender();
00056 }
00057 
00058 Graphics::Surface *Window::getScreenshot() const {
00059     if (!_visible) {
00060         return nullptr;
00061     }
00062 
00063     _gfx->setViewport(_position);
00064     return _gfx->getViewportScreenshot();
00065 }
00066 
00067 bool Window::isMouseInside() const {
00068     if (!_visible) {
00069         return false;
00070     }
00071 
00072     Common::Point mousePos = _cursor->getMousePosition();
00073     return _position.contains(mousePos);
00074 }
00075 
00076 bool Window::isVisible() const {
00077     return _visible;
00078 }
00079 
00080 Common::Point Window::getRelativeMousePosition() const {
00081     Common::Point mousePos = _cursor->getMousePosition();
00082     return mousePos - Common::Point(_position.left, _position.top);
00083 }
00084 
00085 void Window::handleMouseMove() {
00086     if (!_visible) {
00087         return;
00088     }
00089 
00090     if (isMouseInside()) {
00091         onMouseMove(getRelativeMousePosition());
00092     }
00093 }
00094 
00095 void Window::handleClick() {
00096     if (!_visible) {
00097         return;
00098     }
00099 
00100     if (isMouseInside()) {
00101         onClick(getRelativeMousePosition());
00102     }
00103 }
00104 
00105 void Window::handleRightClick() {
00106     if (!_visible) {
00107         return;
00108     }
00109 
00110     if (isMouseInside()) {
00111         onRightClick(getRelativeMousePosition());
00112     }
00113 }
00114 
00115 void Window::handleDoubleClick() {
00116     if (!_visible) {
00117         return;
00118     }
00119 
00120     if (isMouseInside()) {
00121         onDoubleClick(getRelativeMousePosition());
00122     }
00123 }
00124 
00125 } // End of namespace Stark


Generated on Sat Jul 13 2019 05:01:14 for ResidualVM by doxygen 1.7.1
curved edge   curved edge