Editor.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. virtual void closeEvent( QCloseEvent * _ce );
  45. protected slots:
  46. virtual void play() {}
  47. virtual void record() {}
  48. virtual void recordAccompany() {}
  49. virtual void stop() {}
  50. private slots:
  51. /// Called by pressing the space key. Plays or stops.
  52. void togglePlayStop();
  53. signals:
  54. protected:
  55. /// \brief Constructor.
  56. ///
  57. /// \param record If set true, the editor's toolbar will contain record
  58. /// buttons in addition to the play and stop buttons.
  59. Editor(bool record = false);
  60. virtual ~Editor();
  61. DropToolBar* m_toolBar;
  62. QAction* m_playAction;
  63. QAction* m_recordAction;
  64. QAction* m_recordAccompanyAction;
  65. QAction* m_stopAction;
  66. };
  67. /// Small helper class: A QToolBar that accepts and exposes drop events as signals
  68. class DropToolBar : public QToolBar
  69. {
  70. Q_OBJECT
  71. public:
  72. DropToolBar(QWidget* parent=0);
  73. signals:
  74. void dragEntered(QDragEnterEvent* event);
  75. void dropped(QDropEvent* event);
  76. protected:
  77. void dragEnterEvent(QDragEnterEvent* event);
  78. void dropEvent(QDropEvent* event);
  79. };
  80. #endif