1 /***************************************************************************
2 **                                                                        **
3 **  Polyphone, a soundfont editor                                         **
4 **  Copyright (C) 2013-2020 Davy Triponney                                **
5 **                2014      Andrea Celani                                 **
6 **                                                                        **
7 **  This program is free software: you can redistribute it and/or modify  **
8 **  it under the terms of the GNU General Public License as published by  **
9 **  the Free Software Foundation, either version 3 of the License, or     **
10 **  (at your option) any later version.                                   **
11 **                                                                        **
12 **  This program is distributed in the hope that it will be useful,       **
13 **  but WITHOUT ANY WARRANTY; without even the implied warranty of        **
14 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          **
15 **  GNU General Public License for more details.                          **
16 **                                                                        **
17 **  You should have received a copy of the GNU General Public License     **
18 **  along with this program. If not, see http://www.gnu.org/licenses/.    **
19 **                                                                        **
20 ****************************************************************************
21 **           Author: Davy Triponney                                       **
22 **  Website/Contact: https://www.polyphone-soundfonts.com                 **
23 **             Date: 01.01.2013                                           **
24 ***************************************************************************/
25 
26 #ifndef MODULATORCOMBOSRC_H
27 #define MODULATORCOMBOSRC_H
28 
29 #include <QComboBox>
30 #include "basetypes.h"
31 
32 class ModulatorComboSrc : public QComboBox
33 {
34     Q_OBJECT
35 
36 public:
37     ModulatorComboSrc(QWidget* parent = nullptr);
38 
39     // Initialize the combobox
40     void initialize(EltID id, bool source1);
41     void initialize(SFModulator mod);
42 
43     // Load value
44     void loadValue();
45 
46     static QString getIndexName(quint16 iVal, bool CC);
47 
48     // Return true if the input is "no controller"
isOne()49     bool isOne() { return currentData().toString() == "0"; }
50 
51     // Get information
52     int getIndex();
53     bool isCC();
54 
55     // Keep a minimum width of 50px, regardless the content of the ComboBox
sizeHint()56     QSize sizeHint() const override        { return minimumSizeHint(); }
minimumSizeHint()57     QSize minimumSizeHint() const override { return QSize(50, QComboBox::minimumSizeHint().height()); }
58 
59 private slots:
60     void onCurrentIndexChanged(int index);
61 
62 private:
63     QList<int> getAssociatedMods(EltID id);
64     void setLink(bool enabled, QString text);
65 
66     EltID _id;
67     bool _source1;
68 };
69 
70 #endif // MODULATORCOMBOSRC_H
71