@@ -1345,9 +1345,9 @@ void LfpDisplayOptions::setSpreadSelection(int spread, bool canvasMustUpdate, bo
13451345 }
13461346}
13471347
1348- void LfpDisplayOptions::togglePauseButton ()
1348+ void LfpDisplayOptions::togglePauseButton (bool sendUpdate )
13491349{
1350- pauseButton->setToggleState (!pauseButton->getToggleState (), sendNotification);
1350+ pauseButton->setToggleState (!pauseButton->getToggleState (), sendUpdate ? sendNotification : dontSendNotification );
13511351}
13521352
13531353void LfpDisplayOptions::buttonClicked (Button* b)
@@ -2108,7 +2108,7 @@ LfpDisplay::LfpDisplay(LfpDisplayCanvas* c, Viewport* v)
21082108
21092109LfpDisplay::~LfpDisplay ()
21102110{
2111- deleteAllChildren ();
2111+ // deleteAllChildren();
21122112}
21132113
21142114
@@ -2143,7 +2143,8 @@ void LfpDisplay::setNumChannels(int numChannels)
21432143 numChans = numChannels;
21442144
21452145
2146- deleteAllChildren ();
2146+ // deleteAllChildren();
2147+ removeAllChildren ();
21472148
21482149 channels.clear ();
21492150 channelInfo.clear ();
@@ -2299,6 +2300,7 @@ void LfpDisplay::paint(Graphics& g)
22992300
23002301void LfpDisplay::refresh ()
23012302{
2303+
23022304 // X-bounds of this update
23032305 int fillfrom = canvas->lastScreenBufferIndex [0 ];
23042306 int fillto = (canvas->screenBufferIndex [0 ]);
@@ -2700,26 +2702,34 @@ void LfpDisplay::toggleSingleChannel(int chan)
27002702 LfpChannelTrack lfpChannelTrack{drawableChannels[chan].channel , drawableChannels[chan].channelInfo };
27012703 lfpChannelTrack.channelInfo ->setEnabledState (true );
27022704 lfpChannelTrack.channelInfo ->setSingleChannelState (true );
2703- setChannelHeight (newHeight, false );
2704- setSize (getWidth (), numChans*getChannelHeight ());
27052705
2706- viewport->setScrollBarsShown (false , false );
2707- viewport->setViewPosition (Point<int >(0 , chan*newHeight));
2706+ removeAllChildren ();
27082707
27092708 // disable unused channels
2710- for (int i = 0 ; i < drawableChannels. size (); i++)
2709+ for (int i = 0 ; i < getNumChannels (); i++)
27112710 {
2712- if (i != chan) drawableChannels[i].channel ->setEnabledState (false );
2711+ if (i != chan)
2712+ {
2713+ drawableChannels[i].channel ->setEnabledState (false );
2714+ }
27132715 }
27142716
27152717 // update drawableChannels, give only the single channel to focus on
27162718 Array<LfpChannelTrack> channelsToDraw{lfpChannelTrack};
27172719 drawableChannels = channelsToDraw;
27182720
2719- // remove all other children and show this one channel
2720- removeAllChildren ();
27212721 addAndMakeVisible (lfpChannelTrack.channel );
27222722 addAndMakeVisible (lfpChannelTrack.channelInfo );
2723+
2724+ // set channel height and position (so that we allocate the smallest
2725+ // necessary image size for drawing)
2726+ setChannelHeight (newHeight, false );
2727+
2728+ lfpChannelTrack.channel ->setTopLeftPosition (canvas->leftmargin , 0 );
2729+ lfpChannelTrack.channelInfo ->setTopLeftPosition (0 , 0 );
2730+ setSize (getWidth (), getChannelHeight ());
2731+
2732+ viewport->setViewPosition (0 , 0 );
27232733
27242734 }
27252735// else if (chan == singleChan || chan == -2)
@@ -2882,9 +2892,7 @@ void LfpDisplay::mouseDown(const MouseEvent& event)
28822892 {
28832893// if (singleChan != -1)
28842894 if (event.getNumberOfClicks () == 2 ) {
2885- std::cout << " singleChan = " << singleChan << std::endl;
28862895 toggleSingleChannel (closest);
2887- std::cout << " singleChan = " << singleChan << std::endl;
28882896 }
28892897
28902898 if (getSingleChannelState ())
@@ -2899,21 +2907,9 @@ void LfpDisplay::mouseDown(const MouseEvent& event)
28992907 }
29002908 }
29012909
2902- // if (event.getNumberOfClicks() == 2) {
2903- // toggleSingleChannel(closest);
2904- // return;
2905- // }
2906-
2907- // if (event.mods.isRightButtonDown())
2908- // {
2909- // PopupMenu channelMenu = channels[closest]->getOptions();
2910- // const int result = channelMenu.show();
2911- // drawableChannels[closest].channel->changeParameter(result);
2912- // }
2910+ // canvas->fullredraw = true;//issue full redraw
29132911
2914- canvas->fullredraw = true ;// issue full redraw
2915-
2916- refresh ();
2912+ // refresh();
29172913
29182914}
29192915
@@ -3580,12 +3576,16 @@ void LfpChannelDisplayInfo::mouseDrag(const MouseEvent &e)
35803576 // init state in our track zooming info struct
35813577 if (!display->trackZoomInfo .isScrollingY )
35823578 {
3583- display->trackZoomInfo .isScrollingY = true ;
3584- display->trackZoomInfo .componentStartHeight = getChannelHeight ();
3585- display->trackZoomInfo .zoomPivotRatioY = (getY () + e.getMouseDownY ())/(float )display->getHeight ();
3586- display->trackZoomInfo .zoomPivotRatioX = (getX () + e.getMouseDownX ())/(float )display->getWidth ();
3587- display->trackZoomInfo .zoomPivotViewportOffset = getPosition () + e.getMouseDownPosition () - canvas->viewport ->getViewPosition ();
3579+ auto & zoomInfo = display->trackZoomInfo ;
3580+
3581+ zoomInfo.isScrollingY = true ;
3582+ zoomInfo.componentStartHeight = getChannelHeight ();
3583+ zoomInfo.zoomPivotRatioY = (getY () + e.getMouseDownY ())/(float )display->getHeight ();
3584+ zoomInfo.zoomPivotRatioX = (getX () + e.getMouseDownX ())/(float )display->getWidth ();
3585+ zoomInfo.zoomPivotViewportOffset = getPosition () + e.getMouseDownPosition () - canvas->viewport ->getViewPosition ();
35883586
3587+ zoomInfo.unpauseOnScrollEnd = !display->isPaused ;
3588+ if (!display->isPaused ) display->options ->togglePauseButton (true );
35893589 }
35903590
35913591 int h = display->trackZoomInfo .componentStartHeight ;
@@ -3618,6 +3618,12 @@ void LfpChannelDisplayInfo::mouseDrag(const MouseEvent &e)
36183618 newHeight = display->trackZoomInfo .maxZoomHeight ;
36193619 }
36203620
3621+ // return early if the
3622+ if (newHeight == getChannelHeight ())
3623+ {
3624+ return ;
3625+ }
3626+
36213627 // set channel heights for all channel
36223628// display->setChannelHeight(newHeight);
36233629 for (int i = 0 ; i < display->getNumChannels (); ++i)
@@ -3636,16 +3642,20 @@ void LfpChannelDisplayInfo::mouseDrag(const MouseEvent &e)
36363642 if (newViewportY < 0 ) newViewportY = 0 ; // make sure we don't adjust beyond the edge of the actual view
36373643
36383644 canvas->viewport ->setViewPosition (0 , newViewportY);
3639-
36403645 }
36413646 }
36423647}
36433648
36443649void LfpChannelDisplayInfo::mouseUp (const MouseEvent &e)
36453650{
3646- if (e.mods .isLeftButtonDown ())
3651+ if (e.mods .isLeftButtonDown () && display-> trackZoomInfo . isScrollingY )
36473652 {
36483653 display->trackZoomInfo .isScrollingY = false ;
3654+ if (display->trackZoomInfo .unpauseOnScrollEnd )
3655+ {
3656+ display->isPaused = false ;
3657+ display->options ->togglePauseButton (false );
3658+ }
36493659 }
36503660}
36513661
0 commit comments