1 /*!
2 * @file screen.cpp
3 * @brief Implementation of the Screen base class
4 *
5 *
6 * Copyright 2009 - 2017 <qmidiarp-devel@lists.sourceforge.net>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21 * MA 02110-1301, USA.
22 *
23 */
24
25 #include "screen.h"
26
27
Screen(QWidget * parent)28 Screen::Screen(QWidget* parent) : QWidget (parent)
29 {
30 mouseX = 0;
31 mouseY = 0;
32 currentIndex = 0;
33 grooveTick = 0;
34 grooveVelocity = 0;
35 grooveLength = 0;
36 isMuted = false;
37 needsRedraw = false;
38 recordMode = false;
39 w = QWidget::width();
40 h = QWidget::height();
41 mouseW = 0;
42 }
43
updateDraw()44 void Screen::updateDraw()
45 {
46 if (!needsRedraw) return;
47 needsRedraw = false;
48 update();
49 }
50
setMuted(bool on)51 void Screen::setMuted(bool on)
52 {
53 isMuted = on;
54 needsRedraw = true;
55 }
56
mouseMoveEvent(QMouseEvent * event)57 void Screen::mouseMoveEvent(QMouseEvent *event)
58 {
59 emitMouseEvent(event, 0);
60 }
61
mousePressEvent(QMouseEvent * event)62 void Screen::mousePressEvent(QMouseEvent *event)
63 {
64 emitMouseEvent(event, 1);
65 }
66
mouseReleaseEvent(QMouseEvent * event)67 void Screen::mouseReleaseEvent(QMouseEvent *event)
68 {
69 emitMouseEvent(event, 2);
70 }
71
wheelEvent(QWheelEvent * event)72 void Screen::wheelEvent(QWheelEvent *event)
73 {
74 mouseW = event->delta();
75 emit mouseWheel(mouseW / 120);
76 event->accept();
77 }
78
setRecordMode(bool on)79 void Screen::setRecordMode(bool on)
80 {
81 recordMode = on;
82 }
83
newGrooveValues(int tick,int vel,int length)84 void Screen::newGrooveValues(int tick, int vel, int length)
85 {
86 grooveTick = tick;
87 grooveVelocity = vel;
88 grooveLength = length;
89 needsRedraw = true;
90 }
91
sizeHint() const92 QSize Screen::sizeHint() const
93 {
94 return QSize(SCR_MIN_W, SCR_MIN_H);
95 }
96
sizePolicy() const97 QSizePolicy Screen::sizePolicy() const
98 {
99 return QSizePolicy(QSizePolicy::MinimumExpanding,
100 QSizePolicy::MinimumExpanding);
101 }
102