dynDrawer.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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 DYNDRAWER_H
  19. #define DYNDRAWER_H
  20. #include "Utils.h"
  21. #include <QLabel>
  22. class QPixmap;
  23. class qtauNoteEditor;
  24. class DynamicsModel;
  25. class QTextEdit;
  26. class qtauDynLabel : public QLabel {
  27. Q_OBJECT
  28. public:
  29. explicit qtauDynLabel(const QString &txt = "", QWidget *parent = 0);
  30. ~qtauDynLabel();
  31. typedef enum { off = 0, front, back } EState;
  32. EState state();
  33. void setState(EState s);
  34. signals:
  35. void leftClicked();
  36. void rightClicked();
  37. protected:
  38. void mousePressEvent(QMouseEvent *event);
  39. EState _state;
  40. };
  41. //----------------------------------------------
  42. class qtauDynDrawer : public QWidget {
  43. Q_OBJECT
  44. public:
  45. qtauDynDrawer(qtauNoteEditor *qne, QWidget *parent = 0);
  46. ~qtauDynDrawer();
  47. void setOffset(int off);
  48. void configure(const SNoteSetup &newSetup);
  49. signals:
  50. void scrolled(int delta);
  51. void zoomed(int delta);
  52. public slots:
  53. void onRepaintDynDrawer(void);
  54. protected:
  55. void paintEvent(QPaintEvent *event);
  56. void resizeEvent(QResizeEvent *event);
  57. void mouseDoubleClickEvent(QMouseEvent *event);
  58. void mouseMoveEvent(QMouseEvent *event);
  59. void mousePressEvent(QMouseEvent *event);
  60. void mouseReleaseEvent(QMouseEvent *event);
  61. void wheelEvent(QWheelEvent *event);
  62. //void keyPressEvent(QKeyEvent *event);
  63. int _offset;
  64. qtauNoteEditor *_editor;
  65. SNoteSetup _ns;
  66. bool _velSelected = true;
  67. QPoint _absFirstClickPos;
  68. bool _mousePressed = false;
  69. int _hSt;
  70. int _h;
  71. int _notePos;
  72. uint64_t _noteUnderCursor;
  73. float _velocity;
  74. DynamicsModel* _dyn=nullptr;
  75. QTextEdit* _edit=nullptr;
  76. QPixmap *_bgCache;
  77. void updateCache();
  78. };
  79. #endif // DYNDRAWER_H