dynDrawer.h 2.5 KB

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