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 MODULATOREDITOR_H
27 #define MODULATOREDITOR_H
28 
29 #include <QWidget>
30 #include "idlist.h"
31 #include "attribute.h"
32 
33 namespace Ui {
34 class ModulatorEditor;
35 }
36 
37 class ModulatorEditor : public QWidget
38 {
39     Q_OBJECT
40 
41 public:
42     explicit ModulatorEditor(QWidget *parent = nullptr);
43     ~ModulatorEditor();
44 
45     void initialize(bool isPrst);
46     void setIds(IdList ids, QList<AttributeType> attributes = QList<AttributeType>());
47 
48 signals:
49     void attributesSelected(QList<AttributeType> attributes);
50     void expandedStateChanged(bool isExpanded);
51 
52 private slots:
53     void on_pushExpand_clicked();
54     void on_pushCollapse_clicked();
55     void on_listWidget_itemSelectionChanged();
56     void on_pushAdd_clicked();
57     void on_pushCopy_clicked();
58     void on_pushPaste_clicked();
59     void on_pushClone_clicked();
60     void on_pushDelete_clicked();
61     void duplicateMod(QList<int> listIndex);
62 
63 private:
64     void checkOverrides();
65     void updateInterface(QList<AttributeType> attributes, bool keepScrollPosition);
66     void updateButtons(bool withSelection);
67     QList<EltID> getSelectedModulators();
68     QList<ModulatorData> getModList(EltID id);
69     void pasteMod(EltID id, QList<ModulatorData> modulators);
70 
71     static QList<ModulatorEditor *> s_instInstances;
72     static QList<ModulatorEditor *> s_prstInstances;
73     static QList<ModulatorData> s_modulatorCopy;
74 
75     Ui::ModulatorEditor *ui;
76     EltID _currentId;
77     QColor _mixedColor;
78     bool _isPrst;
79 };
80 
81 #endif // MODULATOREDITOR_H
82