@@ -1355,9 +1355,9 @@ void LfpDisplayOptions::setSpreadSelection(int spread, bool canvasMustUpdate, bo
13551355 }
13561356}
13571357
1358- void LfpDisplayOptions::togglePauseButton ()
1358+ void LfpDisplayOptions::togglePauseButton (bool sendUpdate )
13591359{
1360- pauseButton->setToggleState (!pauseButton->getToggleState (), sendNotification);
1360+ pauseButton->setToggleState (!pauseButton->getToggleState (), sendUpdate ? sendNotification : dontSendNotification );
13611361}
13621362
13631363void LfpDisplayOptions::buttonClicked (Button* b)
@@ -2119,7 +2119,7 @@ LfpDisplay::LfpDisplay(LfpDisplayCanvas* c, Viewport* v)
21192119
21202120LfpDisplay::~LfpDisplay ()
21212121{
2122- deleteAllChildren ();
2122+ // deleteAllChildren();
21232123}
21242124
21252125
@@ -2154,7 +2154,8 @@ void LfpDisplay::setNumChannels(int numChannels)
21542154 numChans = numChannels;
21552155
21562156
2157- deleteAllChildren ();
2157+ // deleteAllChildren();
2158+ removeAllChildren ();
21582159
21592160 channels.clear ();
21602161 channelInfo.clear ();
@@ -2310,6 +2311,7 @@ void LfpDisplay::paint(Graphics& g)
23102311
23112312void LfpDisplay::refresh ()
23122313{
2314+
23132315 // X-bounds of this update
23142316 int fillfrom = canvas->lastScreenBufferIndex [0 ];
23152317 int fillto = (canvas->screenBufferIndex [0 ]);
@@ -2711,26 +2713,34 @@ void LfpDisplay::toggleSingleChannel(int chan)
27112713 LfpChannelTrack lfpChannelTrack{drawableChannels[chan].channel , drawableChannels[chan].channelInfo };
27122714 lfpChannelTrack.channelInfo ->setEnabledState (true );
27132715 lfpChannelTrack.channelInfo ->setSingleChannelState (true );
2714- setChannelHeight (newHeight, false );
2715- setSize (getWidth (), numChans*getChannelHeight ());
27162716
2717- viewport->setScrollBarsShown (false , false );
2718- viewport->setViewPosition (Point<int >(0 , chan*newHeight));
2717+ removeAllChildren ();
27192718
27202719 // disable unused channels
2721- for (int i = 0 ; i < drawableChannels. size (); i++)
2720+ for (int i = 0 ; i < getNumChannels (); i++)
27222721 {
2723- if (i != chan) drawableChannels[i].channel ->setEnabledState (false );
2722+ if (i != chan)
2723+ {
2724+ drawableChannels[i].channel ->setEnabledState (false );
2725+ }
27242726 }
27252727
27262728 // update drawableChannels, give only the single channel to focus on
27272729 Array<LfpChannelTrack> channelsToDraw{lfpChannelTrack};
27282730 drawableChannels = channelsToDraw;
27292731
2730- // remove all other children and show this one channel
2731- removeAllChildren ();
27322732 addAndMakeVisible (lfpChannelTrack.channel );
27332733 addAndMakeVisible (lfpChannelTrack.channelInfo );
2734+
2735+ // set channel height and position (so that we allocate the smallest
2736+ // necessary image size for drawing)
2737+ setChannelHeight (newHeight, false );
2738+
2739+ lfpChannelTrack.channel ->setTopLeftPosition (canvas->leftmargin , 0 );
2740+ lfpChannelTrack.channelInfo ->setTopLeftPosition (0 , 0 );
2741+ setSize (getWidth (), getChannelHeight ());
2742+
2743+ viewport->setViewPosition (0 , 0 );
27342744
27352745 }
27362746// else if (chan == singleChan || chan == -2)
@@ -2893,9 +2903,7 @@ void LfpDisplay::mouseDown(const MouseEvent& event)
28932903 {
28942904// if (singleChan != -1)
28952905 if (event.getNumberOfClicks () == 2 ) {
2896- std::cout << " singleChan = " << singleChan << std::endl;
28972906 toggleSingleChannel (closest);
2898- std::cout << " singleChan = " << singleChan << std::endl;
28992907 }
29002908
29012909 if (getSingleChannelState ())
@@ -2910,21 +2918,9 @@ void LfpDisplay::mouseDown(const MouseEvent& event)
29102918 }
29112919 }
29122920
2913- // if (event.getNumberOfClicks() == 2) {
2914- // toggleSingleChannel(closest);
2915- // return;
2916- // }
2917-
2918- // if (event.mods.isRightButtonDown())
2919- // {
2920- // PopupMenu channelMenu = channels[closest]->getOptions();
2921- // const int result = channelMenu.show();
2922- // drawableChannels[closest].channel->changeParameter(result);
2923- // }
2921+ // canvas->fullredraw = true;//issue full redraw
29242922
2925- canvas->fullredraw = true ;// issue full redraw
2926-
2927- refresh ();
2923+ // refresh();
29282924
29292925}
29302926
@@ -3599,12 +3595,16 @@ void LfpChannelDisplayInfo::mouseDrag(const MouseEvent &e)
35993595 // init state in our track zooming info struct
36003596 if (!display->trackZoomInfo .isScrollingY )
36013597 {
3602- display->trackZoomInfo .isScrollingY = true ;
3603- display->trackZoomInfo .componentStartHeight = getChannelHeight ();
3604- display->trackZoomInfo .zoomPivotRatioY = (getY () + e.getMouseDownY ())/(float )display->getHeight ();
3605- display->trackZoomInfo .zoomPivotRatioX = (getX () + e.getMouseDownX ())/(float )display->getWidth ();
3606- display->trackZoomInfo .zoomPivotViewportOffset = getPosition () + e.getMouseDownPosition () - canvas->viewport ->getViewPosition ();
3598+ auto & zoomInfo = display->trackZoomInfo ;
3599+
3600+ zoomInfo.isScrollingY = true ;
3601+ zoomInfo.componentStartHeight = getChannelHeight ();
3602+ zoomInfo.zoomPivotRatioY = (getY () + e.getMouseDownY ())/(float )display->getHeight ();
3603+ zoomInfo.zoomPivotRatioX = (getX () + e.getMouseDownX ())/(float )display->getWidth ();
3604+ zoomInfo.zoomPivotViewportOffset = getPosition () + e.getMouseDownPosition () - canvas->viewport ->getViewPosition ();
36073605
3606+ zoomInfo.unpauseOnScrollEnd = !display->isPaused ;
3607+ if (!display->isPaused ) display->options ->togglePauseButton (true );
36083608 }
36093609
36103610 int h = display->trackZoomInfo .componentStartHeight ;
@@ -3637,6 +3637,12 @@ void LfpChannelDisplayInfo::mouseDrag(const MouseEvent &e)
36373637 newHeight = display->trackZoomInfo .maxZoomHeight ;
36383638 }
36393639
3640+ // return early if the
3641+ if (newHeight == getChannelHeight ())
3642+ {
3643+ return ;
3644+ }
3645+
36403646 // set channel heights for all channel
36413647// display->setChannelHeight(newHeight);
36423648 for (int i = 0 ; i < display->getNumChannels (); ++i)
@@ -3655,16 +3661,20 @@ void LfpChannelDisplayInfo::mouseDrag(const MouseEvent &e)
36553661 if (newViewportY < 0 ) newViewportY = 0 ; // make sure we don't adjust beyond the edge of the actual view
36563662
36573663 canvas->viewport ->setViewPosition (0 , newViewportY);
3658-
36593664 }
36603665 }
36613666}
36623667
36633668void LfpChannelDisplayInfo::mouseUp (const MouseEvent &e)
36643669{
3665- if (e.mods .isLeftButtonDown ())
3670+ if (e.mods .isLeftButtonDown () && display-> trackZoomInfo . isScrollingY )
36663671 {
36673672 display->trackZoomInfo .isScrollingY = false ;
3673+ if (display->trackZoomInfo .unpauseOnScrollEnd )
3674+ {
3675+ display->isPaused = false ;
3676+ display->options ->togglePauseButton (false );
3677+ }
36683678 }
36693679}
36703680
0 commit comments