1 /* TIATracker, (c) 2016 Andre "Kylearan" Wichmann.
2  * Website: https://bitbucket.org/kylearan/tiatracker
3  * Email: andre.wichmann@gmx.de
4  * See the file "license.txt" for information on usage and redistribution
5  * of this file.
6  */
7 
8 #ifndef INSTRUMENTSELECTOR_H
9 #define INSTRUMENTSELECTOR_H
10 
11 #include <QObject>
12 #include <QWidget>
13 #include <QFont>
14 #include "track/track.h"
15 #include "pianokeyboard.h"
16 
17 
18 class InstrumentSelector : public QWidget
19 {
20     Q_OBJECT
21 public:
22     explicit InstrumentSelector(QWidget *parent = 0);
23     ~InstrumentSelector();
24 
25     void initSelector();
26 
27     void registerTrack(Track::Track *newTrack);
28     void registerPianoKeyboard(PianoKeyboard *pNewKeyboard);
29 
30     int getSelectedInstrument();
31     void setSelectedInstrument(int index);
32 
33     QSize sizeHint() const;
34 
35 signals:
36     void setWaveform(TiaSound::Distortion dist);
37     void setUsePitchGuide(bool use);
38 
39 public slots:
40     void keyShortcut(bool);
41 
42 protected:
43     void paintEvent(QPaintEvent *) Q_DECL_OVERRIDE;
44 
45 private:
46     static const int horizontalMargin = 10;
47     static const int verticalMargin = 10;
48     static const int buttonHorizontalMargin = 6;
49     static const int buttonVerticalMargin = 1;
50     static const int insPercMargin = 8;
51     static const int fontSize = 12;
52     static const int minWidth = 176;
53 
54 
55     Track::Track *pTrack = nullptr;
56     PianoKeyboard *pKeyboard = nullptr;
57 
58     void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE;
59 
60     QFont font{"Helvetica"};
61     int widgetHeight;
62     int fontHeight;
63     int buttonWidth;
64     int buttonHeight;
65 
66     int selected = 0;
67 
68     QList<QAction *> shortcutActions{};
69     void updateNewSelectedInstrument();
70 };
71 
72 #endif // INSTRUMENTSELECTOR_H
73