Controls.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 Control
  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 class AutomatableModelView* modelView() = 0;
  48. virtual ~Control();
  49. };
  50. class KnobControl : public Control
  51. {
  52. class Knob* m_knob;
  53. public:
  54. void setText(const QString& text) override;
  55. QWidget* topWidget() override;
  56. void setModel(AutomatableModel* model) override;
  57. FloatModel* model() override;
  58. class AutomatableModelView* modelView() override;
  59. KnobControl(QWidget* parent = nullptr);
  60. ~KnobControl() override;
  61. };
  62. class ComboControl : public Control
  63. {
  64. QWidget* m_widget;
  65. class ComboBox* m_combo;
  66. class QLabel* m_label;
  67. public:
  68. void setText(const QString& text) override;
  69. QWidget* topWidget() override { return m_widget; }
  70. void setModel(AutomatableModel* model) override;
  71. ComboBoxModel* model() override;
  72. class AutomatableModelView* modelView() override;
  73. ComboControl(QWidget* parent = nullptr);
  74. ~ComboControl() override;
  75. };
  76. class LcdControl : public Control
  77. {
  78. class LcdSpinBox* m_lcd;
  79. public:
  80. void setText(const QString& text) override;
  81. QWidget* topWidget() override;
  82. void setModel(AutomatableModel* model) override;
  83. IntModel* model() override;
  84. class AutomatableModelView* modelView() override;
  85. LcdControl(int numDigits, QWidget* parent = nullptr);
  86. ~LcdControl() override;
  87. };
  88. class CheckControl : public Control
  89. {
  90. QWidget* m_widget;
  91. class LedCheckBox* m_checkBox;
  92. QLabel* m_label;
  93. public:
  94. void setText(const QString& text) override;
  95. QWidget* topWidget() override;
  96. void setModel(AutomatableModel* model) override;
  97. BoolModel *model() override;
  98. class AutomatableModelView* modelView() override;
  99. CheckControl(QWidget* parent = nullptr);
  100. ~CheckControl() override;
  101. };
  102. #endif // CONTROLS_H