noteEditor.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 <QUrl>
  21. #include <QWidget>
  22. #include "Utils.h"
  23. #include "ui/Config.h"
  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. Q_OBJECT
  38. friend class qtauEdController;
  39. friend class qtauDynDrawer;
  40. public:
  41. qtauNoteEditor(QWidget *parent = 0);
  42. ~qtauNoteEditor();
  43. void configure(const SNoteSetup &newSetup);
  44. void deleteSelected();
  45. void setVOffset(int voff);
  46. void setHOffset(int hoff);
  47. QPoint scrollTo(const QRect &r);
  48. void setRMBScrollEnabled(bool e) { _state.rmbScrollEnabled = e; }
  49. void setEditingEnabled(bool e) { _state.editingEnabled = e; }
  50. void setGridSnapEnabled(bool e) { _state.gridSnapEnabled = e; }
  51. void doPhonemeTransformation();
  52. struct selectionRange getSelectionRange();
  53. QVector<quint64> getSelection();
  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. void selectionChanged(void);
  75. public slots:
  76. void onEvent(qtauEvent *e);
  77. void lazyUpdate(); // use this instead of update() - Qt is drawing much
  78. // faster than display updates
  79. void setPlaybackPosition(int pos);
  80. protected:
  81. void paintEvent(QPaintEvent *event);
  82. void resizeEvent(QResizeEvent *event);
  83. void mouseDoubleClickEvent(QMouseEvent *event);
  84. void mouseMoveEvent(QMouseEvent *event);
  85. void mousePressEvent(QMouseEvent *event);
  86. void mouseReleaseEvent(QMouseEvent *event);
  87. void wheelEvent(QWheelEvent *event);
  88. SNoteSetup _setup;
  89. qne::editorState _state;
  90. qne::editorNotes _notes;
  91. QPixmap *_labelCache;
  92. QPixmap *_bgCache;
  93. void recalcNoteRects();
  94. void updateBGCache();
  95. int _lastUpdate;
  96. bool _delayingUpdate;
  97. bool _updateCalled;
  98. int _posPulses;
  99. int _playLine;
  100. qtauEdController *_ctrl;
  101. qtauEdController
  102. *_lastCtrl; // they keep getting input after changing somehow :/
  103. void changeController(qtauEdController *c);
  104. void rmbScrollHappened(const QPoint &delta, const QPoint &origOff);
  105. void eventHappened(qtauEvent *e);
  106. };
  107. #endif // NOTEEDITOR_H