Editor.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. class QAction;
  29. class DropToolBar;
  30. /// \brief Superclass for editors with a toolbar.
  31. ///
  32. /// Those editors include the Song Editor, the Automation Editor, B&B Editor,
  33. /// and the Piano Roll.
  34. class Editor : public QMainWindow
  35. {
  36. Q_OBJECT
  37. public:
  38. void setPauseIcon(bool displayPauseIcon=true);
  39. QAction *playAction() const;
  40. protected:
  41. DropToolBar * addDropToolBarToTop(QString const & windowTitle);
  42. DropToolBar * addDropToolBar(Qt::ToolBarArea whereToAdd, QString const & windowTitle);
  43. DropToolBar * addDropToolBar(QWidget * parent, Qt::ToolBarArea whereToAdd, QString const & windowTitle);
  44. void closeEvent( QCloseEvent * _ce ) override;
  45. protected slots:
  46. virtual void play() {}
  47. virtual void record() {}
  48. virtual void recordAccompany() {}
  49. virtual void toggleStepRecording() {}
  50. virtual void stop() {}
  51. private slots:
  52. /// Called by pressing the space key. Plays or stops.
  53. void togglePlayStop();
  54. signals:
  55. protected:
  56. /// \brief Constructor.
  57. ///
  58. /// \param record If set true, the editor's toolbar will contain record
  59. /// buttons in addition to the play and stop buttons.
  60. Editor(bool record = false, bool record_step = false);
  61. virtual ~Editor();
  62. DropToolBar* m_toolBar;
  63. QAction* m_playAction;
  64. QAction* m_recordAction;
  65. QAction* m_recordAccompanyAction;
  66. QAction* m_toggleStepRecordingAction;
  67. QAction* m_stopAction;
  68. };
  69. /// Small helper class: A QToolBar that accepts and exposes drop events as signals
  70. class DropToolBar : public QToolBar
  71. {
  72. Q_OBJECT
  73. public:
  74. DropToolBar(QWidget* parent=0);
  75. signals:
  76. void dragEntered(QDragEnterEvent* event);
  77. void dropped(QDropEvent* event);
  78. protected:
  79. void dragEnterEvent(QDragEnterEvent* event) override;
  80. void dropEvent(QDropEvent* event) override;
  81. };
  82. #endif