2018-07-09 18:05:31 +00:00
|
|
|
#ifndef AMUSE_KEYBOARD_WIDGET_HPP
|
|
|
|
#define AMUSE_KEYBOARD_WIDGET_HPP
|
|
|
|
|
|
|
|
#include <QWidget>
|
2018-07-18 07:39:26 +00:00
|
|
|
#include <QSvgWidget>
|
|
|
|
#include "StatusBarWidget.hpp"
|
|
|
|
|
|
|
|
class KeyboardWidget;
|
|
|
|
|
|
|
|
class KeyboardOctave : public QSvgWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
int m_octave;
|
|
|
|
QRectF m_natural[7];
|
|
|
|
QRectF m_sharp[5];
|
|
|
|
QTransform m_widgetToSvg;
|
|
|
|
public:
|
|
|
|
explicit KeyboardOctave(int octave, const QString& svgPath, QWidget* parent = Q_NULLPTR);
|
|
|
|
int getOctave() const { return m_octave; }
|
|
|
|
int getKey(const QPoint& localPos) const;
|
|
|
|
void resizeEvent(QResizeEvent *event);
|
|
|
|
};
|
2018-07-09 18:05:31 +00:00
|
|
|
|
|
|
|
class KeyboardWidget : public QWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2018-07-18 07:39:26 +00:00
|
|
|
KeyboardOctave* m_widgets[11];
|
|
|
|
StatusBarFocus* m_statusFocus = nullptr;
|
|
|
|
int m_lastOctave = -1;
|
|
|
|
int m_lastKey = -1;
|
|
|
|
bool m_holding = false;
|
|
|
|
|
|
|
|
std::pair<int, int> _getOctaveAndKey(QMouseEvent* event) const;
|
|
|
|
void _startKey(int octave, int key);
|
|
|
|
void _stopKey();
|
|
|
|
void _moveOnKey(int octave, int key);
|
|
|
|
void _pressOnKey(int octave, int key);
|
|
|
|
|
2018-07-09 18:05:31 +00:00
|
|
|
public:
|
|
|
|
explicit KeyboardWidget(QWidget* parent = Q_NULLPTR);
|
2018-07-18 07:39:26 +00:00
|
|
|
void setStatusFocus(StatusBarFocus* statusFocus) { m_statusFocus = statusFocus; }
|
|
|
|
|
|
|
|
void mouseMoveEvent(QMouseEvent* event);
|
|
|
|
void mousePressEvent(QMouseEvent* event);
|
|
|
|
void mouseReleaseEvent(QMouseEvent* event);
|
|
|
|
void enterEvent(QEvent* event);
|
|
|
|
void leaveEvent(QEvent* event);
|
2018-07-22 03:45:47 +00:00
|
|
|
void wheelEvent(QWheelEvent *event);
|
2018-07-18 07:39:26 +00:00
|
|
|
void showEvent(QShowEvent *event);
|
2018-07-09 18:05:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //AMUSE_KEYBOARD_WIDGET_HPP
|