1
//=========================================================
4
// $Id: ctrlpanel.cpp,v 1.2 2002/02/08 09:56:29 muse Exp $
5
// (C) Copyright 1999 Werner Schweer (ws@seh.de)
6
//=========================================================
11
#include "ctrlpanel.h"
12
#include "ctrlcanvas.h"
15
#include <qpushbutton.h>
16
#include <qpopupmenu.h>
19
#include <qsizepolicy.h>
26
#include "midieditor.h"
29
//---------------------------------------------------------
31
//---------------------------------------------------------
33
CtrlPanel::CtrlPanel(QWidget* parent, MidiEditor* e, const char* name = 0)
34
: QWidget(parent, name)
37
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
38
QGridLayout* cgrid = new QGridLayout(this, 4, 1, 0);
40
selCtrl = new QPushButton("Sel", this, "selCtrl");
41
selCtrl->setFont(font3);
42
selCtrl->setSizePolicy(
43
QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
44
QToolTip::add(selCtrl, tr("select controller"));
46
pop = new QPopupMenu(selCtrl);
49
QPushButton* destroy = new QPushButton("x", this, "destroy");
50
destroy->setFont(font3);
51
destroy->setSizePolicy(
52
QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
53
QToolTip::add(destroy, tr("remove panel"));
56
connect(selCtrl, SIGNAL(clicked()), SLOT(ctrlPopup()));
57
connect(destroy, SIGNAL(clicked()), SIGNAL(destroyPanel()));
59
cgrid->addWidget(selCtrl, 0, 0);
60
cgrid->addWidget(destroy, 2, 0);
61
cgrid->setRowStretch(1, 50);
64
//---------------------------------------------------------
66
//---------------------------------------------------------
68
void CtrlPanel::setHeight(int h)
76
TCtrl(MidiController* mc, bool flag) {
82
//---------------------------------------------------------
84
//---------------------------------------------------------
86
void CtrlPanel::ctrlPopup()
88
//---------------------------------------------------
89
// build list of defined midi controllers
90
// check if controller exists in current parts
91
//---------------------------------------------------
93
std::list<struct TCtrl> clist;
95
for (iMidiController i = midiControllerList.begin();
96
i != midiControllerList.end(); ++i) {
97
clist.push_back(TCtrl(*i, false));
99
PartList* parts = editor->parts();
100
for (iPart ip = parts->begin(); ip != parts->end(); ++ip) {
101
EventList* el = ip->second->events();
102
for (iEvent ie = el->begin(); ie != el->end(); ++ie) {
103
MidiEvent* ev = (MidiEvent*)(ie->second);
104
if (ev->type() == MidiEvent::Ctrl7
105
|| ev->type() == MidiEvent::Ctrl14) {
106
for (std::list<struct TCtrl>::iterator i = clist.begin();
107
i != clist.end(); ++i) {
108
MidiController* ctrl = i->ctrl;
109
if (ev->cntrl() != ctrl->hnum())
120
pop->insertItem("Velocity", 1);
121
pop->insertItem("Pitch", 2);
123
for (std::list<struct TCtrl>::const_iterator i = clist.begin();
124
i != clist.end(); ++i) {
125
pop->insertItem(i->exists ? *dotIcon : QPixmap(),
129
pop->insertItem(QIconSet(*configureIcon), tr("other ..."), 3);
130
int rv = pop->exec(selCtrl->mapToGlobal(QPoint(0,0)));
134
QString s = pop->text(rv);
136
MidiController ctrl(MidiController::Velo, "Velocity");
139
emit controllerChanged(ctrl);
142
MidiController ctrl(MidiController::Pitch, "Pitch");
143
ctrl.setMinVal(-8192);
144
ctrl.setMaxVal(+8191);
145
emit controllerChanged(ctrl);
148
configMidiController();
151
for (iMidiController i = midiControllerList.begin();
152
i != midiControllerList.end(); ++i) {
153
if (s == (*i)->name()) {
154
emit controllerChanged(**i);