1
//=========================================================
4
// $Id: waveedit.cpp,v 1.1 2002/01/30 14:10:09 muse Exp $
5
// (C) Copyright 2000 Werner Schweer (ws@seh.de)
6
//=========================================================
11
#include "scrollscale.h"
23
#include <qtoolbutton.h>
27
#include <qsizegrip.h>
28
#include <qscrollbar.h>
30
#include <qpushbutton.h>
31
#include <qradiobutton.h>
32
#include <qbuttongroup.h>
34
#include <qcombobox.h>
36
#include <qpopupmenu.h>
39
extern QColor readColor(Xml& xml);
41
QColor WaveEdit::bg = QColor(0xff,0xff,0xff);
43
//---------------------------------------------------------
45
//---------------------------------------------------------
47
void WaveEdit::setBg(QColor _bg)
53
//---------------------------------------------------------
55
//---------------------------------------------------------
57
void WaveEdit::closeEvent(QCloseEvent* e)
59
emit deleted((int)this);
63
//---------------------------------------------------------
65
//---------------------------------------------------------
67
WaveEdit::WaveEdit(PartList* pl)
68
: MidiEditor(1, 1, pl)
71
WavePart* part = (WavePart*)(pl->begin()->second);
74
//---------Pulldown Menu----------------------------
75
QPopupMenu* menuFile = new QPopupMenu(this);
76
menuBar()->insertItem("&File", menuFile);
77
QPopupMenu* menuFunctions = new QPopupMenu(this);
78
menuBar()->insertItem("Functions", menuFunctions);
79
menuFunctions->insertItem(tr("Normalize"), 1);
81
connect(menuFunctions, SIGNAL(activated(int)), SLOT(cmd(int)));
82
connect(menuFile, SIGNAL(activated(int)), SLOT(cmd(int)));
84
//---------ToolBar----------------------------------
85
tools = new QToolBar(this, "waveedit-tools");
86
undoRedo->addTo(tools);
88
//--------------------------------------------------
90
new TransportToolbar(this, "pr-tr-tools");
92
//--------------------------------------------------
93
// ToolBar: Solo Cursor1 Cursor2
95
tb1 = new QToolBar(this, "pianoroll-tools");
96
// tb1->setHorizontalStretchable(true);
98
tb1->setLabel(tr("weTools"));
99
solo = new QToolButton(tb1);
100
solo->setText(tr("Solo"));
101
solo->setToggleButton(true);
103
QLabel* label = new QLabel(tr("Cursor"), tb1, "Cursor");
104
label->setAlignment(AlignRight|AlignVCenter);
106
pos1 = new PosLabel(tb1);
107
pos2 = new PosLabel(tb1);
108
pos2->setSmpte(true);
110
//---------------------------------------------------
112
//---------------------------------------------------
117
view = new WaveView(this, mainw, xscale, yscale);
118
wview = view; // HACK!
121
QSizeGrip* corner = new QSizeGrip(mainw);
122
ymag = new QSlider(1, 256, 256, yscale, Vertical, mainw);
123
// time = new WTScale(&_raster, mainw, xscale);
124
time = new MTScale(&_raster, mainw, xscale, true);
125
ymag->setFixedWidth(16);
126
connect(ymag, SIGNAL(valueChanged(int)), view, SLOT(setYScale(int)));
128
hscroll = new ScrollScale(1, -32768, xscale, 10000, Horizontal, mainw, 0, true, 10000.0);
133
hscroll->setRange(s, e);
135
mainGrid->setRowStretch(0, 100);
136
mainGrid->setColStretch(0, 100);
138
mainGrid->addMultiCellWidget(time, 0, 0, 0, 1);
139
mainGrid->addMultiCellWidget(hLine(mainw), 1, 1, 0, 1);
140
mainGrid->addWidget(view, 2, 0);
141
mainGrid->addWidget(ymag, 2, 1);
142
mainGrid->addWidget(hscroll, 3, 0);
143
mainGrid->addWidget(corner, 3, 1, AlignBottom | AlignRight);
145
connect(hscroll, SIGNAL(scrollChanged(int)), view, SLOT(setXPos(int)));
146
connect(hscroll, SIGNAL(scaleChanged(int)), view, SLOT(setXMag(int)));
147
setCaption(view->getCaption());
148
connect(view, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
150
connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int)));
151
connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int)));
152
connect(time, SIGNAL(timeChanged(int)), SLOT(setTime(int)));
153
connect(view, SIGNAL(timeChanged(int)), SLOT(setTime(int)));
154
connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
157
//---------------------------------------------------------
159
//---------------------------------------------------------
161
void WaveEdit::setTime(int samplepos)
163
int tick = tempomap.samples2tick(samplepos);
164
pos1->setValue(tick);
165
pos2->setValue(tick);
166
time->setPos(3, tick, false);
169
//---------------------------------------------------------
171
//---------------------------------------------------------
173
WaveEdit::~WaveEdit()
175
undoRedo->removeFrom(tools);
178
//---------------------------------------------------------
180
//---------------------------------------------------------
182
void WaveEdit::cmd(int n)
185
case 1: printf("normalize: not implemented\n"); break;
191
//---------------------------------------------------------
193
//---------------------------------------------------------
195
void WaveEdit::readConfiguration(Xml& xml)
198
Xml::Token token = xml.parse();
199
const QString& tag = xml.s1();
202
if (tag == "bgcolor")
205
xml.unknown("WaveEdit");
208
if (tag == "waveedit")
219
//---------------------------------------------------------
221
//---------------------------------------------------------
223
void WaveEdit::writeConfiguration(int level, Xml& xml)
225
xml.tag(level++, "waveedit");
226
xml.put(level, "<bgcolor r=\"%d\" g=\"%d\" b=\"%d\"></bgcolor>",
227
bg.red(), bg.green(), bg.blue());
228
xml.tag(level, "/waveedit");
231
//---------------------------------------------------------
233
//---------------------------------------------------------
235
void WaveEdit::writeStatus(int level, Xml& xml) const
237
writePartList(level, xml);
238
xml.tag(level++, "waveedit");
239
MidiEditor::writeStatus(level, xml);
240
xml.intTag(level, "xpos", hscroll->pos());
241
xml.intTag(level, "xmag", hscroll->mag());
242
xml.intTag(level, "ymag", ymag->value());
243
xml.tag(level, "/waveedit");
246
//---------------------------------------------------------
248
//---------------------------------------------------------
250
void WaveEdit::readStatus(Xml& xml)
253
Xml::Token token = xml.parse();
254
if (token == Xml::Error || token == Xml::End)
256
QString tag = xml.s1();
259
if (tag == "midieditor")
260
MidiEditor::readStatus(xml);
261
else if (tag == "xmag")
262
hscroll->setMag(xml.parseInt());
263
else if (tag == "ymag")
264
ymag->setValue(xml.parseInt());
265
else if (tag == "xpos")
266
hscroll->setPos(xml.parseInt());
268
xml.unknown("WaveEdit");
271
if (tag == "waveedit")