Repository navigation
Expand file tree
/
Copy pathPatternView.cpp
More file actions
698 lines (627 loc) · 25.3 KB
/
Copy pathPatternView.cpp
File metadata and controls
698 lines (627 loc) · 25.3 KB
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
#include <QDebug>
#include <bb/cascades/Image>
#include <bb/cascades/ImagePaint>
#include <bb/cascades/Container>
#include <bb/cascades/Color>
#include <bb/cascades/ImageView>
#include <bb/cascades/DockLayout>
#include <bb/cascades/AbsoluteLayout>
#include <bb/cascades/AbsoluteLayoutProperties>
#include <bb/cascades/StackLayout>
#include "PatternView.hpp"
#include "SongFormat.hpp"
using namespace bb::cascades;
template<>
int InstanceCounter<PatternView>::s_count;
template<>
int InstanceCounter<PatternView>::s_maxCount;
const int PatternView::m_charsPerChannel = 14;
const int PatternView::m_indent = 3;
const int PatternView::m_fontScale = 2;
const int PatternView::m_fontWidth = 6;
const int PatternView::m_fontHeight = 8;
#define MAKE_RGBA(R,G,B,A) ((A << 24) + (B << 16) + (G << 8) + (R << 0))
static const unsigned int rownumber_foreground_color = MAKE_RGBA(0x00, 0x00, 0x00, 0xff);
static const unsigned int line_foreground_color = MAKE_RGBA(0x00, 0x00, 0x00, 0xff);
static const unsigned int note_active_foreground_color = MAKE_RGBA(0x00, 0x06, 0x7A, 0xff);
static const unsigned int instrument_active_foreground_color = MAKE_RGBA(0x0b, 0x63, 0x63, 0xff);
static const unsigned int volume_foreground_color = MAKE_RGBA(0x0c, 0xc6, 0xff, 0xff);
static const unsigned int effect_foreground_color = MAKE_RGBA(0x2b, 0x96, 0x07, 0xff);
static const unsigned int idle_foreground_color = MAKE_RGBA(0xB0, 0xB0, 0xB0, 0xff);
static const unsigned int rownumber_background_color = MAKE_RGBA(0x00, 0x00, 0x00, 0x00);
static const unsigned int active_background_color = MAKE_RGBA(0x00, 0x00, 0x00, 0x00);
static const unsigned int muted_background_color = MAKE_RGBA(0x90, 0x90, 0x90, 0xff);
static const unsigned int fill_color = MAKE_RGBA(0x00, 0x00, 0x00, 0x00);
#undef MAKE_RGBA
static const unsigned char NOTE_NONE = 0;
static const unsigned char NOTE_MIN = 1;
static const unsigned char NOTE_MAX = 120;
static const unsigned char NOTE_KEYOFF = 0xff;
static const unsigned char NOTE_NOTECUT = 0xfe;
static const unsigned char NOTE_FADE = 0xfd;
static const unsigned char NOTE_PC = 0xfc;
static const unsigned char NOTE_PCS = 0xfb;
static const char * NoteNames[NOTE_MAX] = {
"C-0", "C#0", "D-0", "D#0", "E-0", "F-0", "F#0", "G-0", "G#0", "A-0", "A#0", "B-0", // [00..11]
"C-1", "C#1", "D-1", "D#1", "E-1", "F-1", "F#1", "G-1", "G#1", "A-1", "A#1", "B-1", // [12..23]
"C-2", "C#2", "D-2", "D#2", "E-2", "F-2", "F#2", "G-2", "G#2", "A-2", "A#2", "B-2", // [24..35]
"C-3", "C#3", "D-3", "D#3", "E-3", "F-3", "F#3", "G-3", "G#3", "A-3", "A#3", "B-3", // [36..47]
"C-4", "C#4", "D-4", "D#4", "E-4", "F-4", "F#4", "G-4", "G#4", "A-4", "A#4", "B-4", // [48..59]
"C-5", "C#5", "D-5", "D#5", "E-5", "F-5", "F#5", "G-5", "G#5", "A-5", "A#5", "B-5", // [60..71]
"C-6", "C#6", "D-6", "D#6", "E-6", "F-6", "F#6", "G-6", "G#6", "A-6", "A#6", "B-6", // [72..83]
"C-7", "C#7", "D-7", "D#7", "E-7", "F-7", "F#7", "G-7", "G#7", "A-7", "A#7", "B-7", // [84..95]
"C-8", "C#8", "D-8", "D#8", "E-8", "F-8", "F#8", "G-8", "G#8", "A-8", "A#8", "B-8", // [96..107]
"C-9", "C#9", "D-9", "D#9", "E-9", "F-9", "F#9", "G-9", "G#9", "A-9", "A#9", "B-9", // [108..119]
};
enum VolumeCommands
{
VOLCMD_NONE = 0,
VOLCMD_VOLUME = 1,
VOLCMD_PANNING = 2,
VOLCMD_VOLSLIDEUP = 3,
VOLCMD_VOLSLIDEDOWN = 4,
VOLCMD_FINEVOLUP = 5,
VOLCMD_FINEVOLDOWN = 6,
VOLCMD_VIBRATOSPEED = 7,
VOLCMD_VIBRATODEPTH = 8,
VOLCMD_PANSLIDELEFT = 9,
VOLCMD_PANSLIDERIGHT = 10,
VOLCMD_TONEPORTAMENTO = 11,
VOLCMD_PORTAUP = 12,
VOLCMD_PORTADOWN = 13,
VOLCMD_DELAYCUT = 14, //currently unused
VOLCMD_OFFSET = 15, //rewbs.volOff
MAX_VOLCMDS = 16
};
enum EffectCommands
{
CMD_NONE = 0,
CMD_ARPEGGIO = 1,
CMD_PORTAMENTOUP = 2,
CMD_PORTAMENTODOWN = 3,
CMD_TONEPORTAMENTO = 4,
CMD_VIBRATO = 5,
CMD_TONEPORTAVOL = 6,
CMD_VIBRATOVOL = 7,
CMD_TREMOLO = 8,
CMD_PANNING8 = 9,
CMD_OFFSET = 10,
CMD_VOLUMESLIDE = 11,
CMD_POSITIONJUMP = 12,
CMD_VOLUME = 13,
CMD_PATTERNBREAK = 14,
CMD_RETRIG = 15,
CMD_SPEED = 16,
CMD_TEMPO = 17,
CMD_TREMOR = 18,
CMD_MODCMDEX = 19,
CMD_S3MCMDEX = 20,
CMD_CHANNELVOLUME = 21,
CMD_CHANNELVOLSLIDE = 22,
CMD_GLOBALVOLUME = 23,
CMD_GLOBALVOLSLIDE = 24,
CMD_KEYOFF = 25,
CMD_FINEVIBRATO = 26,
CMD_PANBRELLO = 27,
CMD_XFINEPORTAUPDOWN = 28,
CMD_PANNINGSLIDE = 29,
CMD_SETENVPOSITION = 30,
CMD_MIDI = 31,
CMD_SMOOTHMIDI = 32, //rewbs.smoothVST
CMD_DELAYCUT = 33,
CMD_XPARAM = 34, // -> CODE#0010 -> DESC="add extended parameter mechanism to pattern effects" -! NEW_FEATURE#0010
CMD_NOTESLIDEUP = 35, // IMF Gxy / PTM Jxy (Slide y notes up every ticks)
CMD_NOTESLIDEDOWN = 36, // IMF Hxy / PTM Kxy (Slide y notes down every ticks)
CMD_NOTESLIDEUPRETRIG = 37, // PTM Lxy (Slide y notes up every ticks + retrigger note)
CMD_NOTESLIDEDOWNRETRIG = 38, // PTM Mxy (Slide y notes down every ticks + retrigger note)
CMD_REVERSEOFFSET = 39, // PTM Nxx Revert sample + offset
MAX_EFFECTS = 40
};
static const char * VolumeNames = " vpcdabuhlrgfe?o";
static const char * EffectNames[2] = {
" 0123456789ABCDRFFTE???GHK?YXPLZ\\?#?????",
" JFEGHLKRXODB?CQATI?SMNVW?UY?P?Z\\?#?????"
};
PatternView::PatternView(Container *parent)
: CustomControl(parent),
m_rootContainer(NULL),
m_cursor(NULL),
m_patternImage(NULL),
m_song(NULL),
m_canvas(NULL),
m_touchHandler(NULL),
m_firstChannel(0),
m_numVisibleChannels(4)
{
setRoot(NULL);
}
void PatternView::createPatternView() {
if(m_song == NULL || !m_song->songLoaded()) {
m_cursor = NULL;
m_patternImage = NULL;
m_touchHandler = NULL;
if(m_rootContainer != NULL) {
m_rootContainer->removeAll();
m_rootContainer->setParent(NULL);
delete m_rootContainer;
m_rootContainer = NULL;
}
if(m_canvas != NULL) {
m_canvas->setParent(0);
delete m_canvas;
m_canvas = NULL;
}
} else {
if(m_rootContainer == NULL)
{
m_cursor = NULL;
m_patternImage = NULL;
m_touchHandler = NULL;
m_rootContainer = Container::create().background(Color::Transparent)
.horizontal(HorizontalAlignment::Center)
.implicitLayoutAnimations(false)
.top(0)
.topMargin(0)
.bottom(0)
.bottomMargin(0)
.left(0)
.leftMargin(0)
.right(0)
.rightMargin(0)
.layout(AbsoluteLayout::create());
setRoot(m_rootContainer);
}
updateCanvas();
if(m_canvas != NULL)
{
if(m_patternImage == NULL)
{
m_patternImage = ImageView::create()
.topMargin(0)
.bottomMargin(0)
.leftMargin(0)
.rightMargin(0)
.loadEffect(ImageViewLoadEffect::None)
.implicitLayoutAnimations(false)
.scalingMethod(ScalingMethod::AspectFill)
.layoutProperties(AbsoluteLayoutProperties::create().x(0).y(0));
m_touchHandler = new TouchHandler(m_patternImage);
bool rc;
rc = QObject::connect(m_patternImage, SIGNAL(touch(bb::cascades::TouchEvent*)),
m_touchHandler, SLOT(handle(bb::cascades::TouchEvent*)));
Q_ASSERT(rc);
rc = QObject::connect(m_touchHandler, SIGNAL(tap(int, int)),
this, SLOT(onPatternTap(int, int)));
Q_ASSERT(rc);
Q_UNUSED(rc);
m_rootContainer->add(m_patternImage);
}
const int preferredWidth = (m_indent + m_charsPerChannel * std::min(m_song->channels(), visibleChannels())) * m_fontWidth * m_fontScale;
const int preferredHeight = m_fontHeight * m_fontScale;
if(m_cursor == NULL)
{
m_cursor = Container::create().background(Color::fromRGBA(0, 1.0, 0, 0.5))
.horizontal(HorizontalAlignment::Fill)
.implicitLayoutAnimations(false)
.top(m_fontHeight)
.bottom(m_fontHeight)
.topMargin(0)
.bottomMargin(0)
.leftMargin(0)
.rightMargin(0)
.preferredWidth(preferredWidth)
.preferredHeight(preferredHeight)
.layoutProperties(AbsoluteLayoutProperties::create().x(0).y(0));
m_rootContainer->add(m_cursor);
}
else
{
m_cursor->setPreferredSize(preferredWidth, preferredHeight);
}
m_patternImage->setImage(m_canvas->image());
}
else
{
m_cursor = NULL;
m_patternImage = NULL;
m_touchHandler = NULL;
if(m_rootContainer != NULL)
{
setRoot(NULL);
m_rootContainer->removeAll();
m_rootContainer->setParent(NULL);
delete m_rootContainer;
m_rootContainer = NULL;
}
}
}
}
void PatternView::updateCanvas() {
const int channels = m_song->channels();
int lastChannel = m_firstChannel + visibleChannels();
if(lastChannel > channels) {
lastChannel = channels;
}
int rows = 0;
const int pattern = m_song->currentPattern();
ModPlugNote* data = m_song->getPattern(pattern, &rows);
const int scaledFontWidth = m_fontWidth << (m_fontScale - 1);
const int scaledFontHeight = m_fontHeight << (m_fontScale - 1);
const int width = m_indent * scaledFontWidth +
(lastChannel - m_firstChannel) * scaledFontWidth * m_charsPerChannel; // 16 chars per channel
const int height = (rows + 2) * scaledFontHeight;
if(data == NULL || rows <= 0 || rows > 128 || channels <= 0)
{
if(m_canvas != NULL)
{
m_canvas->setParent(0);
delete m_canvas;
m_canvas = NULL;
}
}
else
{
if(m_canvas != NULL)
{
if(m_canvas->width() != width ||
m_canvas->height() != height)
{
m_canvas->setParent(0);
delete m_canvas;
m_canvas = NULL;
}
}
if(m_canvas == NULL)
{
m_canvas = new Canvas(width, height, this);
}
m_canvas->fill(fill_color);
char buffer[16];
for(int row = 0; row < rows; ++row)
{
buffer[0] = ((row / 10) % 10) + '0';
buffer[1] = (row % 10) + '0';
buffer[2] = 0;
m_canvas->print(0,
(row + 2) * scaledFontHeight,
rownumber_foreground_color,
rownumber_background_color,
m_fontScale,
buffer);
for(int channel = m_firstChannel; channel < lastChannel; ++channel)
{
unsigned int foreground_color = idle_foreground_color;
unsigned int background_color = m_song->isChannelMuted(channel) ?
muted_background_color :
active_background_color;
const ModPlugNote &cell = data[row * channels + channel];
const int offset_x = (channel - m_firstChannel) * m_charsPerChannel * scaledFontWidth + m_indent * scaledFontWidth;
const int offset_y = (row + 2) * scaledFontHeight;
// Note
buffer[0] = buffer[1] = buffer[2] = '.';
buffer[3] = ' ';
buffer[4] = 0;
switch(cell.Note)
{
case NOTE_NONE:
break;
case NOTE_KEYOFF:
buffer[0] = buffer[1] = buffer[2] = '=';
foreground_color = note_active_foreground_color;
break;
case NOTE_NOTECUT:
buffer[0] = buffer[1] = buffer[2] = '^';
foreground_color = note_active_foreground_color;
break;
case NOTE_FADE:
buffer[0] = buffer[1] = buffer[2] = '~';
foreground_color = note_active_foreground_color;
break;
case NOTE_PC:
buffer[0] = 'P';
buffer[1] = 'C';
buffer[2] = ' ';
foreground_color = note_active_foreground_color;
break;
case NOTE_PCS:
buffer[0] = 'P';
buffer[1] = 'C';
buffer[2] = 'S';
foreground_color = note_active_foreground_color;
break;
default:
if(cell.Note >= NOTE_MIN && cell.Note <= NOTE_MAX)
{
const char * noteString = NoteNames[cell.Note - NOTE_MIN];
buffer[0] = noteString[0];
buffer[1] = noteString[1];
buffer[2] = noteString[2];
foreground_color = note_active_foreground_color;
}
break;
}
m_canvas->print(offset_x,
offset_y,
foreground_color,
background_color,
m_fontScale,
buffer);
// Instrument
buffer[0] = buffer[1] = '.';
buffer[2] = 0;
if(cell.Instrument != 0)
{
buffer[0] = (cell.Instrument / 10) + '0';
buffer[1] = (cell.Instrument % 10) + '0';
foreground_color = instrument_active_foreground_color;
}
else
{
foreground_color = idle_foreground_color;
}
m_canvas->print(offset_x + 4 * scaledFontWidth,
offset_y,
foreground_color,
background_color,
m_fontScale,
buffer);
// Volume
buffer[0] = ' ';
buffer[1] = buffer[2] = '.';
buffer[3] = ' ';
buffer[4] = 0;
foreground_color = idle_foreground_color;
if(cell.Note == NOTE_PC || cell.Note == NOTE_PCS) {
unsigned volume = (cell.VolumeEffect << 8) + cell.Volume;
buffer[1] = (volume / 10) + '0';
buffer[2] = (volume % 10) + '0';
foreground_color = volume_foreground_color;
}
else
{
if(cell.VolumeEffect != VOLCMD_NONE && cell.Volume <= 99)
{
unsigned volcmd = cell.VolumeEffect;
char x;
if(volcmd >= MAX_VOLCMDS)
{
x = '?';
}
else
{
x = VolumeNames[volcmd];
}
buffer[0] = x;
buffer[1] = (cell.Volume / 10) + '0';
buffer[2] = (cell.Volume % 10) + '0';
foreground_color = volume_foreground_color;
}
else
{
foreground_color = idle_foreground_color;
}
}
m_canvas->print(offset_x + 6 * scaledFontWidth,
offset_y,
foreground_color,
background_color,
m_fontScale,
buffer);
// Effect
buffer[0] = buffer[1] = buffer[2] = '.';
buffer[3] = 0;
foreground_color = idle_foreground_color;
if(cell.Note == NOTE_PC || cell.Note == NOTE_PCS)
{
snprintf(buffer, sizeof(buffer), "%03u", (cell.Effect << 8) + cell.Parameter);
foreground_color = effect_foreground_color;
}
else
{
char effect = '?';
if(cell.Effect != CMD_NONE)
{
if(cell.Effect >= MAX_EFFECTS)
{
effect = '?';
}
else {
switch(m_song->formatId())
{
case SongFormat::FORMAT_MOD:
case SongFormat::FORMAT_XM:
effect = EffectNames[0][cell.Effect];
break;
case SongFormat::FORMAT_S3M:
case SongFormat::FORMAT_IT:
effect = EffectNames[1][cell.Effect];
break;
default:
effect = EffectNames[0][cell.Effect];
break;
}
}
buffer[0] = effect;
foreground_color = effect_foreground_color;
}
else
{
buffer[0] = '.';
}
if(cell.Parameter != 0)
{
sprintf(&buffer[1], "%02X", cell.Parameter);
foreground_color = effect_foreground_color;
}
else
{
if(effect == '?')
{
buffer[1] = buffer[2] = '.';
}
else
{
buffer[1] = buffer[2] = '0';
}
if(foreground_color != effect_foreground_color)
{
foreground_color = idle_foreground_color;
}
}
}
m_canvas->print(offset_x + 10 * scaledFontWidth,
offset_y,
foreground_color,
background_color,
m_fontScale,
buffer);
}
}
m_canvas->hline(0,
m_canvas->width(),
scaledFontHeight + (scaledFontHeight >> 1),
line_foreground_color);
m_canvas->hline(0,
m_canvas->width(),
scaledFontHeight + (scaledFontHeight >> 1) - 4,
line_foreground_color);
for(int channel = m_firstChannel; channel < lastChannel; ++channel)
{
m_canvas->vline(((channel - m_firstChannel) * m_charsPerChannel + m_indent) * scaledFontWidth - (scaledFontWidth >> 1),
0,
m_canvas->height(),
line_foreground_color);
if(m_song->isChannelMuted(channel)) {
strcpy(buffer, "Muted");
} else {
snprintf(buffer, sizeof(buffer), "Channel %d", channel + 1);
}
m_canvas->print(((channel - m_firstChannel) * m_charsPerChannel + m_indent + 2) * scaledFontWidth,
0,
line_foreground_color,
active_background_color,
m_fontScale,
buffer);
}
}
}
QVariant PatternView::song() const {
return QVariant::fromValue(m_song);
}
void PatternView::setSong(QVariant value) {
SongModule * song = qobject_cast<SongModule*>(value.value<QObject*>());
if(song != m_song) {
m_song = song;
emit songChanged();
bool rc;
if(m_song != NULL)
{
rc = QObject::connect(m_song, SIGNAL(songLoadedChanged()),
this, SLOT(onSongLoadedChanged()));
Q_ASSERT(rc);
rc = QObject::connect(m_song, SIGNAL(channelsChanged()),
this, SLOT(onChannelsChanged()));
Q_ASSERT(rc);
rc = QObject::connect(m_song, SIGNAL(currentPatternChanged()),
this, SLOT(onCurrentPatternChanged()));
Q_ASSERT(rc);
rc = QObject::connect(m_song, SIGNAL(currentRowChanged()),
this, SLOT(onCurrentRowChanged()));
Q_ASSERT(rc);
Q_UNUSED(rc);
}
createPatternView();
}
emit previousChannelEnabledChanged();
emit nextChannelEnabledChanged();
}
void PatternView::onSongLoadedChanged() {
createPatternView();
emit previousChannelEnabledChanged();
emit nextChannelEnabledChanged();
}
void PatternView::onChannelsChanged() {
createPatternView();
emit previousChannelEnabledChanged();
emit nextChannelEnabledChanged();
}
void PatternView::onCurrentRowChanged() {
if(m_cursor != NULL && m_song != NULL) {
int row = m_song->currentRow();
if(row < 0) {
row = 0;
}
AbsoluteLayoutProperties * p = qobject_cast<AbsoluteLayoutProperties*>(m_cursor->layoutProperties());
p->setPositionY((row + 2) * m_fontHeight * m_fontScale);
}
}
void PatternView::onCurrentPatternChanged() {
createPatternView();
}
void PatternView::onPatternTap(int x, int y) {
Q_UNUSED(y)
if(m_song != NULL) {
const int channel_width = m_canvas->width() / visibleChannels();
const int channel = x / channel_width + m_firstChannel;
m_song->muteChannel(channel, !m_song->isChannelMuted(channel));
if(m_patternImage != NULL) {
updateCanvas();
if(m_canvas != NULL) {
m_patternImage->setImage(m_canvas->image());
}
}
}
}
void PatternView::previousChannel() {
if(previousChannelEnabled()) {
setFirstChannel(firstChannel() - 1);
}
}
void PatternView::nextChannel() {
if(nextChannelEnabled()) {
setFirstChannel(firstChannel() + 1);
}
}
int PatternView::visibleChannels() const {
return m_numVisibleChannels;
}
void PatternView::setVisibleChannels(int value) {
if(value < 0) {
value = 0;
}
if(value != m_numVisibleChannels) {
m_numVisibleChannels = value;
createPatternView();
emit visibleChannelsChanged();
emit previousChannelEnabledChanged();
emit nextChannelEnabledChanged();
}
}
int PatternView::firstChannel() const {
return m_firstChannel;
}
void PatternView::setFirstChannel(int value) {
if(value < 0) {
value = 0;
}
if(m_firstChannel != value) {
m_firstChannel = value;
emit firstChannelChanged();
createPatternView();
emit previousChannelEnabledChanged();
emit nextChannelEnabledChanged();
}
}
bool PatternView::previousChannelEnabled() const {
return m_song != NULL &&
m_song->songLoaded() &&
m_song->isTrackerSong() &&
m_firstChannel > 0 &&
m_song->channels() > 0;
}
bool PatternView::nextChannelEnabled() const {
return m_song != NULL &&
m_song->songLoaded() &&
m_song->isTrackerSong() &&
m_firstChannel < m_song->channels() - visibleChannels();
}