piano.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. This file is part of QTau
  3. Copyright (C) 2013-2018 Tobias "Tomoko" Platen <tplaten@posteo.de>
  4. Copyright (C) 2013 digited <https://github.com/digited>
  5. Copyright (C) 2010-2013 HAL@ShurabaP <https://github.com/haruneko>
  6. QTau is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. SPDX-License-Identifier: GPL-3.0+
  17. */
  18. #ifndef PIANO_H
  19. #define PIANO_H
  20. #include <QWidget>
  21. #include "Utils.h"
  22. #include <QDebug>
  23. class QPixmap;
  24. // write new PianoRoll that works using affine transformations and modulo 12
  25. class qtauPiano : public QWidget {
  26. Q_OBJECT
  27. public:
  28. qtauPiano(QWidget *parent = 0);
  29. ~qtauPiano();
  30. void setOffset(int voff);
  31. void configure(const SNoteSetup &newSetup);
  32. signals:
  33. void keyPressed(int keyNum);
  34. void keyReleased(int keyNum);
  35. void scrolled(int delta);
  36. void heightChanged(int newHeight);
  37. public slots:
  38. //
  39. protected:
  40. void paintEvent(QPaintEvent *event);
  41. void resizeEvent(QResizeEvent *event);
  42. void mouseDoubleClickEvent(QMouseEvent *event);
  43. void mouseMoveEvent(QMouseEvent *event);
  44. void mousePressEvent(QMouseEvent *event);
  45. void mouseReleaseEvent(QMouseEvent *event);
  46. void wheelEvent(QWheelEvent *event);
  47. // UNUSED: void onHover(bool inside);
  48. // bool eventFilter(QObject *object, QEvent *event);
  49. void initPiano(int baseOctave, int octavesNum);
  50. QPoint _offset; // graphical offset of keys, used for virtual scrolling
  51. QPixmap *_labelCache;
  52. public:
  53. //-------------------------------------------------------------
  54. typedef enum { Passive = 0, Pressed, Highlighted } pianoKeyState;
  55. protected:
  56. int _pressedKey;
  57. int _hoveredKey;
  58. SNoteSetup _ns;
  59. };
  60. #endif // PIANO_H