plotview: Add vertical scrolling

This commit is contained in:
Mike Walters
2016-03-06 23:47:45 +00:00
parent 74a5307b58
commit e1dd912d72
2 changed files with 13 additions and 1 deletions

View File

@@ -168,7 +168,7 @@ void PlotView::paintEvent(QPaintEvent *event)
#define PLOT_LAYER(paintFunc) \
{ \
int y = 0; \
int y = -verticalScrollBar()->value(); \
for (auto&& plot : plots) { \
QRect rect = QRect(0, y, width(), plot->height()); \
plot->paintFunc(painter, rect, {viewRange.first, viewRange.second});\
@@ -185,6 +185,15 @@ void PlotView::paintEvent(QPaintEvent *event)
#undef PLOT_LAYER
}
int PlotView::plotsHeight()
{
int height = 0;
for (auto&& plot : plots) {
height += plot->height();
}
return height;
}
void PlotView::resizeEvent(QResizeEvent * event)
{
updateView();
@@ -209,6 +218,8 @@ void PlotView::updateView()
};
horizontalScrollBar()->setMaximum(mainSampleSource->count() - ((width() - 1) * samplesPerLine()));
verticalScrollBar()->setMaximum(std::max(0, plotsHeight() - viewport()->height()));
// Update cursors
QRect rect = viewport()->rect();
range_t<int> newSelection = {