Skip to content

Commit a36e2ca

Browse files
committed
Update track zooming to minimize redrawing updates
1 parent 5109c09 commit a36e2ca

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ void LfpDisplayOptions::setRangeSelection(float range, bool canvasMustUpdate)
13241324

13251325
}
13261326

1327-
void LfpDisplayOptions::setSpreadSelection(int spread, bool canvasMustUpdate)
1327+
void LfpDisplayOptions::setSpreadSelection(int spread, bool canvasMustUpdate, bool deferDisplayRefresh)
13281328
{
13291329

13301330
if (canvasMustUpdate)
@@ -1337,8 +1337,11 @@ void LfpDisplayOptions::setSpreadSelection(int spread, bool canvasMustUpdate)
13371337
selectedSpread = spreadSelection->getSelectedId();
13381338
selectedSpreadValue = spreadSelection->getText();
13391339

1340-
canvas->repaint();
1341-
canvas->refresh();
1340+
if (!deferDisplayRefresh)
1341+
{
1342+
canvas->repaint();
1343+
canvas->refresh();
1344+
}
13421345
}
13431346
}
13441347

@@ -3573,6 +3576,7 @@ void LfpChannelDisplayInfo::mouseDrag(const MouseEvent &e)
35733576
{
35743577
if (e.mods.isCommandDown() && !display->getSingleChannelState()) // CTRL + drag -> change channel spacing
35753578
{
3579+
35763580
// init state in our track zooming info struct
35773581
if (!display->trackZoomInfo.isScrollingY)
35783582
{
@@ -3615,19 +3619,24 @@ void LfpChannelDisplayInfo::mouseDrag(const MouseEvent &e)
36153619
}
36163620

36173621
// set channel heights for all channel
3618-
display->setChannelHeight(newHeight);
3619-
display->setBounds(0,0,display->getWidth()-0, display->getChannelHeight()*display->drawableChannels.size()); // update height so that the scrollbar is correct
3622+
// display->setChannelHeight(newHeight);
3623+
for (int i = 0; i < display->getNumChannels(); ++i)
3624+
{
3625+
display->channels[i]->setChannelHeight(newHeight);
3626+
display->channelInfo[i]->setChannelHeight(newHeight);
3627+
}
3628+
3629+
options->setSpreadSelection(newHeight, false, true); // update combobox
36203630

3621-
canvas->viewport->setViewPositionProportionately(display->trackZoomInfo.zoomPivotRatioX, display->trackZoomInfo.zoomPivotRatioY);
3631+
canvas->fullredraw = true;//issue full redraw - scrolling without modifier doesnt require a full redraw
3632+
3633+
display->setBounds(0,0,display->getWidth()-0, display->getChannelHeight()*display->drawableChannels.size()); // update height so that the scrollbar is correct
36223634

36233635
int newViewportY = display->trackZoomInfo.zoomPivotRatioY * display->getHeight() - display->trackZoomInfo.zoomPivotViewportOffset.getY();
36243636
if (newViewportY < 0) newViewportY = 0; // make sure we don't adjust beyond the edge of the actual view
36253637

3626-
canvas->viewport->setViewPosition(display->trackZoomInfo.zoomPivotRatioX, newViewportY);
3627-
3628-
options->setSpreadSelection(newHeight); // update combobox
3638+
canvas->viewport->setViewPosition(0, newViewportY);
36293639

3630-
canvas->fullredraw = true;//issue full redraw - scrolling without modifier doesnt require a full redraw
36313640
}
36323641
}
36333642
}

Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class LfpDisplayOptions : public Component,
251251
void resized();
252252

253253
void setRangeSelection(float range, bool canvasMustUpdate = false); // set range selection combo box to correct value if it has been changed by scolling etc.
254-
void setSpreadSelection(int spread, bool canvasMustUpdate = false); // set spread selection combo box to correct value if it has been changed by scolling etc.
254+
void setSpreadSelection(int spread, bool canvasMustUpdate = false, bool deferDisplayRefresh = false); // set spread selection combo box to correct value if it has been changed by scolling etc.
255255

256256
void comboBoxChanged(ComboBox* cb);
257257
void buttonClicked(Button* button);

0 commit comments

Comments
 (0)