LinkedModelGroupViews.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * LinkedModelGroupViews.h - views for groups of linkable models
  3. *
  4. * Copyright (c) 2019-2019 Johannes Lorenz <j.git$$$lorenz-ho.me, $$$=@>
  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 LINKEDMODELGROUPVIEWS_H
  25. #define LINKEDMODELGROUPVIEWS_H
  26. #include <QGroupBox>
  27. /**
  28. @file LinkedModelGroupViews.h
  29. See Lv2ViewBase.h for example usage
  30. */
  31. //! View for one processor, LinkedModelGroupsViewBase contains 2
  32. //! of those for mono plugins
  33. class LinkedModelGroupViewBase : public QGroupBox
  34. {
  35. public:
  36. //! @param colNum numbers of columns for the controls
  37. //! (link LEDs not counted)
  38. LinkedModelGroupViewBase(QWidget *parent, bool isLinking,
  39. int colNum, int curProc, int nProc, const QString &name = QString());
  40. ~LinkedModelGroupViewBase();
  41. //! Reconnect models if model changed
  42. void modelChanged(class LinkedModelGroup *linkedModelGroup);
  43. protected:
  44. //! Add a control to this widget
  45. void addControl(class ControlBase *ctrl);
  46. private:
  47. void makeAllGridCellsEqualSized();
  48. int m_colNum; //!< column number in surrounding grid in Lv2ViewBase
  49. bool m_isLinking;
  50. class QGridLayout* m_grid;
  51. QVector<class ControlBase*> m_controls;
  52. QVector<class LedCheckBox*> m_leds;
  53. };
  54. //! Base class for view for one plugin with linkable models.
  55. //! Provides a global channel link LED.
  56. class LinkedModelGroupsViewBase
  57. {
  58. protected:
  59. //! @param pluginWidget A child class which inherits QWidget
  60. LinkedModelGroupsViewBase(class LinkedModelGroups *ctrlBase);
  61. ~LinkedModelGroupsViewBase();
  62. //! Reconnect models if model changed; to be called by child virtuals
  63. void modelChanged(class LinkedModelGroups* ctrlBase);
  64. //! Access to the global multi channel link LED
  65. LedCheckBox* globalLinkLed() { return m_multiChannelLink; }
  66. private:
  67. //! The base class must return the adressed group view
  68. virtual LinkedModelGroupViewBase* getGroupView(std::size_t idx) = 0;
  69. class LedCheckBox *m_multiChannelLink = nullptr;
  70. };
  71. #endif // LINKEDMODELGROUPVIEWS_H