Controls.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Controls.h - labeled control widgets
  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 CONTROLS_H
  25. #define CONTROLS_H
  26. #include "Model.h"
  27. // headers only required for covariance
  28. #include "AutomatableModel.h"
  29. #include "ComboBoxModel.h"
  30. class QString;
  31. class QWidget;
  32. class AutomatableModel;
  33. /**
  34. These classes provide
  35. - a control with a text label
  36. - a type safe way to set a model
  37. (justification: setting the wrong typed model to a widget will cause
  38. hard-to-find runtime errors)
  39. */
  40. class ControlBase
  41. {
  42. public:
  43. virtual QWidget* topWidget() = 0;
  44. virtual void setText(const QString& text) = 0;
  45. virtual void setModel(AutomatableModel* model) = 0;
  46. virtual AutomatableModel* model() = 0;
  47. virtual ~ControlBase();
  48. };
  49. class KnobControl : public ControlBase
  50. {
  51. class Knob* m_knob;
  52. public:
  53. void setText(const QString& text) override;
  54. QWidget* topWidget() override;
  55. void setModel(AutomatableModel* model) override;
  56. FloatModel* model() override;
  57. KnobControl(QWidget* parent = nullptr);
  58. ~KnobControl() override;
  59. };
  60. class ComboControl : public ControlBase
  61. {
  62. QWidget* m_widget;
  63. class ComboBox* m_combo;
  64. class QLabel* m_label;
  65. public:
  66. void setText(const QString& text) override;
  67. QWidget* topWidget() override { return m_widget; }
  68. void setModel(AutomatableModel* model) override;
  69. ComboBoxModel* model() override;
  70. ComboControl(QWidget* parent = nullptr);
  71. ~ComboControl() override;
  72. };
  73. class LcdControl : public ControlBase
  74. {
  75. class LcdSpinBox* m_lcd;
  76. public:
  77. void setText(const QString& text) override;
  78. QWidget* topWidget() override;
  79. void setModel(AutomatableModel* model) override;
  80. IntModel* model() override;
  81. LcdControl(int numDigits, QWidget* parent = nullptr);
  82. ~LcdControl() override;
  83. };
  84. class CheckControl : public ControlBase
  85. {
  86. QWidget* m_widget;
  87. class LedCheckBox* m_checkBox;
  88. QLabel* m_label;
  89. public:
  90. void setText(const QString& text) override;
  91. QWidget* topWidget() override;
  92. void setModel(AutomatableModel* model) override;
  93. BoolModel *model() override;
  94. CheckControl(QWidget* parent = nullptr);
  95. ~CheckControl() override;
  96. };
  97. #endif // CONTROLS_H