3
3
// Linux Music Editor
4
4
// $Id: wtscale.cpp,v 1.3 2004/04/11 13:03:32 wschweer Exp $
5
5
// (C) Copyright 2000 Werner Schweer (ws@seh.de)
7
// This program is free software; you can redistribute it and/or
8
// modify it under the terms of the GNU General Public License
9
// as published by the Free Software Foundation; version 2 of
10
// the License, or (at your option) any later version.
12
// This program is distributed in the hope that it will be useful,
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with this program; if not, write to the Free Software
19
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
6
21
//=========================================================
29
47
QToolTip::add(this, tr("bar scale"));
30
48
barLocator = false;
32
pos[0] = int(song->tempomap()->tick2time(song->cpos()) * sampleRate);
33
pos[1] = int(song->tempomap()->tick2time(song->lpos()) * sampleRate);
34
pos[2] = int(song->tempomap()->tick2time(song->rpos()) * sampleRate);
50
pos[0] = int(MusEGlobal::song->tempomap()->tick2time(MusEGlobal::song->cpos()) * sampleRate);
51
pos[1] = int(MusEGlobal::song->tempomap()->tick2time(MusEGlobal::song->lpos()) * sampleRate);
52
pos[2] = int(MusEGlobal::song->tempomap()->tick2time(MusEGlobal::song->rpos()) * sampleRate);
35
53
pos[3] = -1; // do not show
36
54
button = Qt::NoButton;
37
55
setMouseTracking(true);
38
connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool)));
39
connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
40
connect(song, SIGNAL(markerChanged(int)), SLOT(redraw()));
56
connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool)));
57
connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
58
connect(MusEGlobal::song, SIGNAL(markerChanged(int)), SLOT(redraw()));
41
59
setFixedHeight(28);
42
60
setBg(QColor(0xe0, 0xe0, 0xe0));
57
75
void WTScale::setPos(int idx, unsigned val, bool adjustScrollbar)
59
val = int(song->tempomap()->tick2time(val) * sampleRate);
77
val = int(MusEGlobal::song->tempomap()->tick2time(val) * sampleRate);
60
78
if (val == pos[idx])
62
80
int opos = mapx(pos[idx] == -1 ? val : pos[idx]);
103
121
void WTScale::viewMouseMoveEvent(QMouseEvent* event)
105
int x= song->tempomap()->time2tick(double(event->x())/double(sampleRate));
106
x = song->raster(x, *raster);
123
int x= MusEGlobal::song->tempomap()->time2tick(double(event->x())/double(sampleRate));
124
x = MusEGlobal::song->raster(x, *raster);
109
127
emit timeChanged(x);
154
175
p.drawLine(r.x(), y+1, r.x() + r.width(), y+1);
156
177
tr.setHeight(12);
157
MarkerList* marker = song->marker();
178
MarkerList* marker = MusEGlobal::song->marker();
158
179
for (iMarker m = marker->begin(); m != marker->end(); ++m) {
159
180
int xp = mapx(int(m->second.time() * sampleRate));
218
239
p.drawLine(xp, 0, xp, height());
221
int ctick = song->samples2tick(mapxDev(x));
242
int ctick = MusEGlobal::song->samples2tick(mapxDev(x));
222
243
int bar1, bar2, beat, tick;
223
song->tickValues(ctick, &bar1, &beat, &tick);
224
song->tickValues(song->samples2tick(mapxDev(x+w)), &bar2, &beat, &tick);
244
MusEGlobal::song->tickValues(ctick, &bar1, &beat, &tick);
245
MusEGlobal::song->tickValues(MusEGlobal::song->samples2tick(mapxDev(x+w)), &bar2, &beat, &tick);
226
247
//printf("bar %d %d-%d=%d\n", bar, ntick, stick, ntick-stick);
228
int stick = song->bar2tick(bar1, 0, 0);
249
int stick = MusEGlobal::song->bar2tick(bar1, 0, 0);
230
251
for (int bar = bar1; bar <= bar2; bar++, stick = ntick) {
231
ntick = song->bar2tick(bar+1, 0, 0);
232
int a = song->tick2samples(ntick);
233
int b = song->tick2samples(stick);
252
ntick = MusEGlobal::song->bar2tick(bar+1, 0, 0);
253
int a = MusEGlobal::song->tick2samples(ntick);
254
int b = MusEGlobal::song->tick2samples(stick);
234
255
int tpix = rmapx(a - b);
236
257
// don�t show beats if measure is this small
260
song->timesig(stick, z, n);
281
MusEGlobal::song->timesig(stick, z, n);
261
282
for (int beat = 0; beat < z; beat++) {
262
int xx = song->tick2samples(song->bar2tick(bar, beat, 0));
283
int xx = MusEGlobal::song->tick2samples(MusEGlobal::song->bar2tick(bar, beat, 0));
263
284
int xp = mapx(xx);
265
286
QRect r(xp+2, y, 0, h);