mirror of
https://github.com/miek/inspectrum.git
synced 2026-03-07 00:37:05 +01:00
plotview: Add vertical scrolling
This commit is contained in:
13
plotview.cpp
13
plotview.cpp
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user