Editor.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * Editor.h - declaration of Editor class
  3. *
  4. * Copyright (c) 2014 Lukas W <lukaswhl/at/gmail.com>
  5. *
  6. * This file is part of LMMS - https://lmms.io
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2 of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public
  19. * License along with this program (see COPYING); if not, write to the
  20. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301 USA.
  22. *
  23. */
  24. #ifndef EDITOR_COMMON_H
  25. #define EDITOR_COMMON_H
  26. #include <QMainWindow>
  27. #include <QToolBar>
  28. static const int Quantizations[] = {
  29. 1, 2, 4, 8, 16, 32, 64,
  30. 3, 6, 12, 24, 48, 96, 192
  31. };
  32. class QAction;
  33. class DropToolBar;
  34. /// \brief Superclass for editors with a toolbar.
  35. ///
  36. /// Those editors include the Song Editor, the Automation Editor, B&B Editor,
  37. /// and the Piano Roll.
  38. class Editor : public QMainWindow
  39. {
  40. Q_OBJECT
  41. public:
  42. void setPauseIcon(bool displayPauseIcon=true);
  43. QAction *playAction() const;
  44. protected:
  45. DropToolBar * addDropToolBarToTop(QString const & windowTitle);
  46. DropToolBar * addDropToolBar(Qt::ToolBarArea whereToAdd, QString const & windowTitle);
  47. DropToolBar * addDropToolBar(QWidget * parent, Qt::ToolBarArea whereToAdd, QString const & windowTitle);
  48. void closeEvent( QCloseEvent * _ce ) override;
  49. protected slots:
  50. virtual void play() {}
  51. virtual void record() {}
  52. virtual void recordAccompany() {}
  53. virtual void toggleStepRecording() {}
  54. virtual void stop() {}
  55. private slots:
  56. /// Called by pressing the space key. Plays or stops.
  57. void togglePlayStop();
  58. /// Called by pressing shift+space. Toggles pause state.
  59. void togglePause();
  60. void toggleMaximize();
  61. signals:
  62. protected:
  63. /// \brief Constructor.
  64. ///
  65. /// \param record If set true, the editor's toolbar will contain record
  66. /// buttons in addition to the play and stop buttons.
  67. Editor(bool record = false, bool record_step = false);
  68. virtual ~Editor();
  69. DropToolBar* m_toolBar;
  70. QAction* m_playAction;
  71. QAction* m_recordAction;
  72. QAction* m_recordAccompanyAction;
  73. QAction* m_toggleStepRecordingAction;
  74. QAction* m_stopAction;
  75. };
  76. /// Small helper class: A QToolBar that accepts and exposes drop events as signals
  77. class DropToolBar : public QToolBar
  78. {
  79. Q_OBJECT
  80. public:
  81. DropToolBar(QWidget* parent=0);
  82. signals:
  83. void dragEntered(QDragEnterEvent* event);
  84. void dropped(QDropEvent* event);
  85. protected:
  86. void dragEnterEvent(QDragEnterEvent* event) override;
  87. void dropEvent(QDropEvent* event) override;
  88. };
  89. #endif