-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatterneditorview.cpp
51 lines (41 loc) · 1.5 KB
/
patterneditorview.cpp
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
#include "patterneditorview.h"
#include "SNFX.h"
#include <QScrollBar>
#include <QDebug>
#include <QString>
#include <QSizePolicy>
CPatternEditorView::CPatternEditorView(QWidget *parent) : QAbstractScrollArea(parent)
{
tst = new QWidget(this);
tst->setStyleSheet("background: lightslategray;");
tst->move(50,0);
tst->show();
pianoWidget = new CPianoWidget(this);
pianoWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
pianoWidget->setChannel(0);
pianoWidget->show();
connect(pianoWidget, &CPianoWidget::noteOn, dynamic_cast<SNFX*>(parent), &SNFX::playNote);
connect(pianoWidget, &CPianoWidget::noteOff, dynamic_cast<SNFX*>(parent), &SNFX::stopNote);
}
void CPatternEditorView::resizeEvent(QResizeEvent *event)
{
QSize areaSize = viewport()->size();
QSize widgetSize(2000,pianoWidget->height());
verticalScrollBar()->setPageStep(areaSize.height());
horizontalScrollBar()->setPageStep(areaSize.width());
verticalScrollBar()->setRange(0, widgetSize.height() - areaSize.height());
horizontalScrollBar()->setRange(0, widgetSize.width() - areaSize.width());
// verticalScrollBar()->setValue(pianoWidget->height()/2);
}
QSize CPatternEditorView::sizeHint() const
{
return QSize(200, pianoWidget->height());
}
void CPatternEditorView::scrollContentsBy(int dx, int dy)
{
int xvalue = tst->pos().x() + dx;
int yvalue = pianoWidget->pos().y() + dy;
tst->move(xvalue, yvalue);
pianoWidget->move(0, yvalue);
viewport()->update();
}