StepRecorderWidget.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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(TimePos currentPosition);
  43. void setMargins(const QMargins &qm);
  44. void setBottomMargin(const int marginBottom);
  45. QMargins margins();
  46. //API used by StepRecorder
  47. void setStepsLength(TimePos stepsLength);
  48. void setStartPosition(TimePos pos);
  49. void setEndPosition(TimePos pos);
  50. void showHint();
  51. private:
  52. void paintEvent(QPaintEvent * pe) override;
  53. int xCoordOfTick(int tick);
  54. void drawVerLine(QPainter* painter, int x, const QColor& color, int top, int bottom);
  55. void drawVerLine(QPainter* painter, const TimePos& pos, const QColor& color, int top, int bottom);
  56. void updateBoundaries();
  57. TimePos m_stepsLength;
  58. TimePos m_curStepStartPos;
  59. TimePos m_curStepEndPos;
  60. int m_ppb; // pixels per bar
  61. TimePos m_currentPosition; // current position showed by on PianoRoll
  62. QColor m_colorLineStart;
  63. QColor m_colorLineEnd;
  64. // boundaries within piano roll window
  65. int m_top;
  66. int m_bottom;
  67. int m_left;
  68. int m_right;
  69. const int m_marginTop;
  70. int m_marginBottom; // not const since can change on resize of edit-note area
  71. const int m_marginLeft;
  72. const int m_marginRight;
  73. signals:
  74. void positionChanged(const TimePos & t);
  75. } ;
  76. #endif //STEP_RECOREDER_WIDGET_H