1 /* 2 SPDX-FileCopyrightText: 2009-2010 Graeme Gott <graeme@gottcode.org> 3 4 SPDX-License-Identifier: GPL-3.0-or-later 5 */ 6 7 #ifndef TANGLET_VIEW_H 8 #define TANGLET_VIEW_H 9 10 #include <QGraphicsView> 11 12 /** 13 * @brief The View class displays the game area. 14 */ 15 class View : public QGraphicsView 16 { 17 Q_OBJECT 18 19 public: 20 /** 21 * Constructs a view instance. 22 * @param scene the game area to display 23 * @param parent the widget that owns the view 24 */ 25 explicit View(QGraphicsScene* scene, QWidget* parent = nullptr); 26 27 signals: 28 /** 29 * Emitted when the player clicks on the view. 30 */ 31 void mousePressed(); 32 33 protected: 34 /** 35 * Override to detect player clicking on the view. 36 * @param event the details of the mouse press event 37 */ 38 void mousePressEvent(QMouseEvent* event) override; 39 40 /** 41 * Override to always zoom and recenter view when resized. 42 * @param event the details of the resize event 43 */ 44 void resizeEvent(QResizeEvent* event) override; 45 }; 46 47 #endif // TANGLET_VIEW_H 48