StepRecorderWidget.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * StepRecorderWidget.h - widget that provide gui markers for step recording
  3. *
  4. * This file is part of LMMS - https://lmms.io
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of"the GNU General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public
  17. * License along with this program (see COPYING); if not, write to the
  18. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  19. * Boston, MA 02110-1301 USA.
  20. *
  21. */
  22. #ifndef STEP_RECOREDER_WIDGET_H
  23. #define STEP_RECOREDER_WIDGET_H
  24. #include "lmms_basics.h"
  25. #include "Note.h"
  26. #include <QWidget>
  27. #include <QColor>
  28. #include <QPainter>
  29. class StepRecorderWidget : public QWidget
  30. {
  31. Q_OBJECT
  32. public:
  33. StepRecorderWidget(
  34. QWidget * parent,
  35. const int ppb,
  36. const int marginTop,
  37. const int marginBottom,
  38. const int marginLeft,
  39. const int marginRight);
  40. //API used by PianoRoll
  41. void setPixelsPerBar(int ppb);
  42. void setCurrentPosition(MidiTime currentPosition);
  43. void setBottomMargin(const int marginBottom);
  44. //API used by StepRecorder
  45. void setStepsLength(MidiTime stepsLength);
  46. void setStartPosition(MidiTime pos);
  47. void setEndPosition(MidiTime pos);
  48. void showHint();
  49. private:
  50. void paintEvent(QPaintEvent * pe) override;
  51. int xCoordOfTick(int tick);
  52. void drawVerLine(QPainter* painter, int x, const QColor& color, int top, int bottom);
  53. void drawVerLine(QPainter* painter, const MidiTime& pos, const QColor& color, int top, int bottom);
  54. void updateBoundaries();
  55. MidiTime m_stepsLength;
  56. MidiTime m_curStepStartPos;
  57. MidiTime m_curStepEndPos;
  58. int m_ppb; // pixels per bar
  59. MidiTime m_currentPosition; // current position showed by on PianoRoll
  60. QColor m_colorLineStart;
  61. QColor m_colorLineEnd;
  62. // boundaries within piano roll window
  63. int m_top;
  64. int m_bottom;
  65. int m_left;
  66. int m_right;
  67. const int m_marginTop;
  68. int m_marginBottom; // not const since can change on resize of edit-note area
  69. const int m_marginLeft;
  70. const int m_marginRight;
  71. signals:
  72. void positionChanged(const MidiTime & t);
  73. } ;
  74. #endif //STEP_RECOREDER_WIDGET_H