noteEditor.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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 NOTEEDITOR_H
  19. #define NOTEEDITOR_H
  20. #include "Utils.h"
  21. #include "ui/Config.h"
  22. #include <QWidget>
  23. #include <QUrl>
  24. class ISynth;
  25. class qtauEvent_NoteAddition;
  26. class qtauEvent_NoteMove;
  27. class qtauEvent_NoteResize;
  28. class qtauEvent_NoteText;
  29. class qtauEvent_NoteEffect;
  30. class QPixmap;
  31. class QLineEdit;
  32. class qtauEvent;
  33. class qtauEdController;
  34. class qtauDynDrawer;
  35. class qtauController;
  36. class qtauNoteEditor : public QWidget
  37. {
  38. Q_OBJECT
  39. friend class qtauEdController;
  40. friend class qtauDynDrawer;
  41. public:
  42. qtauNoteEditor(QWidget *parent = 0);
  43. ~qtauNoteEditor();
  44. void configure(const SNoteSetup &newSetup);
  45. void deleteSelected();
  46. void setVOffset(int voff);
  47. void setHOffset(int hoff);
  48. QPoint scrollTo (const QRect &r);
  49. void setRMBScrollEnabled(bool e) { _state.rmbScrollEnabled = e; }
  50. void setEditingEnabled (bool e) { _state.editingEnabled = e; }
  51. void setGridSnapEnabled (bool e) { _state.gridSnapEnabled = e; }
  52. void doPhonemeTransformation();
  53. struct selectionRange getSelectionRange();
  54. void reset();
  55. void setNoteColor(quint64 id,EColor color);
  56. QList<quint64> getNoteIDs();
  57. signals:
  58. void editorEvent(qtauEvent *e);
  59. void hscrolled(int delta);
  60. void vscrolled(int delta);
  61. void zoomed (int delta);
  62. void heightChanged(int newHeight);
  63. void widthChanged (int newWidth );
  64. void rmbScrolled(QPoint posDelta, QPoint origOffset);
  65. void requestsOffset(QPoint offset);
  66. // what happens in editor and is sent to session
  67. void noteAdd (qtauEvent_NoteAddition *event);
  68. void noteResize(qtauEvent_NoteResize *event);
  69. void noteMove (qtauEvent_NoteMove *event);
  70. void noteText (qtauEvent_NoteText *event);
  71. void noteEffect(qtauEvent_NoteEffect *event);
  72. void urisDropped(QList<QUrl> uris);
  73. void repaintDynDrawer(void);
  74. public slots:
  75. void onEvent(qtauEvent *e);
  76. void lazyUpdate(); // use this instead of update() - Qt is drawing much faster than display updates
  77. void setPlaybackPosition(int pos);
  78. protected:
  79. void paintEvent (QPaintEvent *event);
  80. void resizeEvent (QResizeEvent *event);
  81. void mouseDoubleClickEvent(QMouseEvent *event);
  82. void mouseMoveEvent (QMouseEvent *event);
  83. void mousePressEvent (QMouseEvent *event);
  84. void mouseReleaseEvent (QMouseEvent *event);
  85. void wheelEvent (QWheelEvent *event);
  86. SNoteSetup _setup;
  87. qne::editorState _state;
  88. qne::editorNotes _notes;
  89. QPixmap *_labelCache;
  90. QPixmap *_bgCache;
  91. void recalcNoteRects();
  92. void updateBGCache();
  93. int _lastUpdate;
  94. bool _delayingUpdate;
  95. bool _updateCalled;
  96. int _posPulses;
  97. int _playLine;
  98. qtauEdController *_ctrl;
  99. qtauEdController *_lastCtrl; // they keep getting input after changing somehow :/
  100. void changeController(qtauEdController *c);
  101. void rmbScrollHappened(const QPoint &delta, const QPoint &origOff);
  102. void eventHappened(qtauEvent *e);
  103. };
  104. #endif // NOTEEDITOR_H