1 /***************************************************************************
2 **                                                                        **
3 **  Polyphone, a soundfont editor                                         **
4 **  Copyright (C) 2013-2020 Davy Triponney                                **
5 **                                                                        **
6 **  This program is free software: you can redistribute it and/or modify  **
7 **  it under the terms of the GNU General Public License as published by  **
8 **  the Free Software Foundation, either version 3 of the License, or     **
9 **  (at your option) any later version.                                   **
10 **                                                                        **
11 **  This program is distributed in the hope that it will be useful,       **
12 **  but WITHOUT ANY WARRANTY; without even the implied warranty of        **
13 **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the          **
14 **  GNU General Public License for more details.                          **
15 **                                                                        **
16 **  You should have received a copy of the GNU General Public License     **
17 **  along with this program. If not, see http://www.gnu.org/licenses/.    **
18 **                                                                        **
19 ****************************************************************************
20 **           Author: Davy Triponney                                       **
21 **  Website/Contact: https://www.polyphone-soundfonts.com                 **
22 **             Date: 01.01.2013                                           **
23 ***************************************************************************/
24 
25 #ifndef EDITORTOOLBAR_H
26 #define EDITORTOOLBAR_H
27 
28 #include <QToolBar>
29 #include "page.h"
30 class ToolMenu;
31 class StyledAction;
32 
33 class EditorToolBar : public QToolBar
34 {
35     Q_OBJECT
36 
37 public:
38     EditorToolBar(QWidget *parent = nullptr);
39     ~EditorToolBar();
40     void setSf2Index(int sf2index);
41     void updateActions();
42     void disable();
43     void setDisplayOptions(QList<Page::DisplayOption> displayOptions);
44 
45     static void updateRecorderButtonsState(bool isChecked);
46     static void updateKeyboardButtonsState(bool isChecked);
47 
48 public slots:
49     void onSelectionChanged(IdList ids);
50     void disableDisplayOption(QList<int> disabledOptions);
51     void selectDisplayOption(int displayOption);
52 
53 signals:
54     void displayOptionChanged(int displayOption);
55     void recorderDisplayChanged(bool isDisplayed);
56     void keyboardDisplayChanged(bool isDisplayed);
57     void selectionChanged(IdList id);
58 
59 private slots:
60     void onNewSmplClicked();
61     void onNewInstClicked();
62     void onNewInstClicked(QString name, bool linkElements);
63     void onNewPrstClicked();
64     void onNewPrstClicked(QString name, bool linkElements);
65     void onSaveClicked();
66     void onDisplayActionClicked();
67     void onRecorderActionClicked();
68     void onKeyboardActionClicked();
69     void onUndo();
70     void onRedo();
71 
72 private:
73     StyledAction * _actionAddSample;
74     StyledAction * _actionAddInstrument;
75     StyledAction * _actionAddPreset;
76     StyledAction * _actionToolBox;
77     StyledAction * _actionUndo;
78     StyledAction * _actionRedo;
79     StyledAction * _actionSave;
80     StyledAction * _actionShowRecorder;
81     StyledAction * _actionShowKeyboard;
82 
83     int _sf2Index;
84     QAction * _displayActionSeparator;
85     QList<StyledAction *> _displayActions;
86     bool _updatingDisplayOptions;
87     ToolMenu * _toolMenu;
88     IdList _currentSelection;
89 
90     static QList<EditorToolBar *> s_instances;
91     static bool s_recorderOpen;
92     static bool s_keyboardOpen;
93 };
94 
95 #endif // EDITORTOOLBAR_H
96