Editor.h 2.5 KB

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