1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
//=========================================================
// MusE
// Linux Music Editor
// $Id: ctrledit.cpp,v 1.4.2.2 2009/02/02 21:38:00 terminator356 Exp $
// (C) Copyright 1999 Werner Schweer (ws@seh.de)
//=========================================================
#include <stdio.h>
#include "ctrledit.h"
#include "ctrlcanvas.h"
#include "midieditor.h"
#include "xml.h"
#include "vscale.h"
#include "ctrlpanel.h"
#include "globals.h"
#include "midiport.h"
#include "instruments/minstrument.h"
#include "gconfig.h"
#include <QHBoxLayout>
//---------------------------------------------------------
// setTool
//---------------------------------------------------------
void CtrlEdit::setTool(int t)
{
canvas->setTool(t);
}
//---------------------------------------------------------
// CtrlEdit
//---------------------------------------------------------
CtrlEdit::CtrlEdit(QWidget* parent, MidiEditor* e, int xmag,
bool expand, const char* name) : QWidget(parent)
{
setObjectName(name);
setAttribute(Qt::WA_DeleteOnClose);
QHBoxLayout* hbox = new QHBoxLayout;
panel = new CtrlPanel(0, e, "panel");
canvas = new CtrlCanvas(e, 0, xmag, "ctrlcanvas", panel);
QWidget* vscale = new VScale;
hbox->setContentsMargins(0, 0, 0, 0);
hbox->setSpacing (0);
canvas->setOrigin(-(config.division/4), 0);
canvas->setMinimumHeight(50);
panel->setFixedWidth(CTRL_PANEL_FIXED_WIDTH);
hbox->addWidget(panel, expand ? 100 : 0, Qt::AlignRight);
hbox->addWidget(canvas, 100);
hbox->addWidget(vscale, 0);
setLayout(hbox);
connect(panel, SIGNAL(destroyPanel()), SLOT(destroy()));
connect(panel, SIGNAL(controllerChanged(int)), canvas, SLOT(setController(int)));
connect(canvas, SIGNAL(xposChanged(unsigned)), SIGNAL(timeChanged(unsigned)));
connect(canvas, SIGNAL(yposChanged(int)), SIGNAL(yposChanged(int)));
}
//---------------------------------------------------------
// writeStatus
//---------------------------------------------------------
void CtrlEdit::writeStatus(int level, Xml& xml)
{
if (canvas->controller()) {
xml.tag(level++, "ctrledit");
xml.strTag(level, "ctrl", canvas->controller()->name());
xml.tag(level, "/ctrledit");
}
}
//---------------------------------------------------------
// readStatus
//---------------------------------------------------------
void CtrlEdit::readStatus(Xml& xml)
{
for (;;) {
Xml::Token token = xml.parse();
const QString& tag = xml.s1();
switch (token) {
case Xml::Error:
case Xml::End:
return;
case Xml::TagStart:
if (tag == "ctrl") {
QString name = xml.parse1();
int portno = canvas->track()->outPort();
MidiPort* port = &midiPorts[portno];
MidiInstrument* instr = port->instrument();
MidiControllerList* mcl = instr->controller();
for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) {
if (ci->second->name() == name) {
canvas->setController(ci->second->num());
break;
}
}
}
else
xml.unknown("CtrlEdit");
break;
case Xml::TagEnd:
if (tag == "ctrledit")
return;
default:
break;
}
}
}
//---------------------------------------------------------
// destroy
//---------------------------------------------------------
void CtrlEdit::destroy()
{
emit destroyedCtrl(this);
close(); // close and destroy widget
}
//---------------------------------------------------------
// setCanvasWidth
//---------------------------------------------------------
void CtrlEdit::setCanvasWidth(int w)
{
canvas->setFixedWidth(w);
}
|