@@ -251,7 +251,7 @@ ThresholdSelectorCustomComponent::~ThresholdSelectorCustomComponent()
251251
252252void ThresholdSelectorCustomComponent::mouseDown (const MouseEvent& event)
253253{
254- if (channel == nullptr )
254+ if (channel == nullptr || ! channel-> isValid () )
255255 return ;
256256
257257 auto * popupComponent = new PopupThresholdComponent (table,
@@ -334,7 +334,9 @@ void ThresholdSelectorCustomComponent::paint (Graphics& g)
334334
335335 thresholdString = thresholdString.substring (0 , thresholdString.length () - 1 );
336336
337- g.setColour (findColour (ThemeColours::defaultText));
337+ float alpha = getParentComponent ()->isEnabled () ? 1 .0f : 0 .5f ;
338+
339+ g.setColour (findColour (ThemeColours::defaultText).withAlpha (alpha));
338340 g.setFont (FontOptions (" Inter" , " Regular" , 14 .0f ));
339341 g.drawFittedText (thresholdString, 4 , 0 , getWidth () - 8 , getHeight (), Justification::centredLeft, 1 , 0 .75f );
340342}
@@ -380,7 +382,7 @@ void ChannelSelectorCustomComponent::showAsPopup()
380382
381383void ChannelSelectorCustomComponent::mouseDown (const juce::MouseEvent& event)
382384{
383- if (acquisitionIsActive)
385+ if (acquisitionIsActive || ! getParentComponent ()-> isEnabled () )
384386 return ;
385387
386388 showAsPopup ();
@@ -449,7 +451,7 @@ void WaveformSelectorCustomComponent::setRowAndColumn (const int newRow, const i
449451
450452void DeleteButtonCustomComponent::mouseDown (const juce::MouseEvent& event)
451453{
452- if (acquisitionIsActive)
454+ if (acquisitionIsActive || ! getParentComponent ()-> isEnabled () )
453455 return ;
454456
455457 table->deleteSelectedRows (row);
@@ -460,7 +462,7 @@ void DeleteButtonCustomComponent::paint (Graphics& g)
460462 int width = getWidth ();
461463 int height = getHeight ();
462464
463- if (acquisitionIsActive)
465+ if (acquisitionIsActive || ! getParentComponent ()-> isEnabled () )
464466 {
465467 g.setColour (Colours::grey);
466468 }
@@ -471,7 +473,7 @@ void DeleteButtonCustomComponent::paint (Graphics& g)
471473
472474 g.fillEllipse (7 , 7 , width - 14 , height - 14 );
473475 g.setColour (Colours::white);
474- g.fillRect (9 , (height / 2 ) - 2 , width - 19 , 3 );
476+ g.fillRect (9 , (height / 2 ) - 1 , width - 19 , 2 );
475477}
476478
477479void DeleteButtonCustomComponent::setRowAndColumn (const int newRow, const int newColumn)
@@ -758,6 +760,15 @@ void SpikeDetectorTableModel::update (Array<SpikeChannel*> spikeChannels_)
758760
759761 table->updateContent ();
760762
763+ if (spikeChannels.size () > 0 && ! spikeChannels[0 ]->isValid ())
764+ {
765+ table->setEnabled (false );
766+ }
767+ else
768+ {
769+ table->setEnabled (true );
770+ }
771+
761772 waveformComponents.clear ();
762773 thresholdComponents.clear ();
763774
@@ -781,33 +792,23 @@ void SpikeDetectorTableModel::paintRowBackground (Graphics& g, int rowNumber, in
781792 if (rowNumber >= spikeChannels.size ())
782793 return ;
783794
784- if (rowIsSelected)
785- {
786- if (rowNumber % 2 == 0 )
787- g.fillAll (owner->findColour (ThemeColours::componentBackground));
788- else
789- g.fillAll (owner->findColour (ThemeColours::componentBackground).darker (0 .25f ));
790-
791- g.setColour (owner->findColour (ThemeColours::highlightedFill));
792- g.drawRoundedRectangle (2 , 2 , width - 4 , height - 4 , 5 , 2 );
793-
794- return ;
795- }
795+ Colour rowColour;
796796
797797 if (spikeChannels[rowNumber]->isValid ())
798- {
799- if (rowNumber % 2 == 0 )
800- g.fillAll (owner->findColour (ThemeColours::componentBackground));
801- else
802- g.fillAll (owner->findColour (ThemeColours::componentBackground).darker (0 .25f ));
803-
804- return ;
805- }
798+ rowColour = owner->findColour (ThemeColours::componentBackground);
799+ else
800+ rowColour = Colour (90 , 50 , 50 );
806801
807802 if (rowNumber % 2 == 0 )
808- g.fillAll (Colour ( 90 , 50 , 50 ) );
803+ g.fillAll (rowColour );
809804 else
810- g.fillAll (Colour (60 , 30 , 30 ));
805+ g.fillAll (rowColour.darker (0 .25f ));
806+
807+ if (rowIsSelected)
808+ {
809+ g.setColour (owner->findColour (ThemeColours::highlightedFill));
810+ g.drawRoundedRectangle (2 , 2 , width - 4 , height - 4 , 5 , 2 );
811+ }
811812}
812813
813814void SpikeDetectorTableModel::paintCell (Graphics& g, int rowNumber, int columnId, int width, int height, bool rowIsSelected)
@@ -1055,8 +1056,14 @@ PopupConfigurationWindow::PopupConfigurationWindow (SpikeDetectorEditor* editor_
10551056 addAndMakeVisible (viewport.get ());
10561057 update (spikeChannels);
10571058
1058- auto stream = editor->getProcessor ()->getDataStream (editor->getCurrentStream ());
1059- popupTitle = String (stream->getSourceNodeId ()) + " " + stream->getSourceNodeName () + " - " + stream->getName ();
1059+ if (auto stream = editor->getProcessor ()->getDataStream (editor->getCurrentStream ()))
1060+ {
1061+ popupTitle = String (stream->getSourceNodeId ()) + " " + stream->getSourceNodeName () + " - " + stream->getName ();
1062+ }
1063+ else
1064+ {
1065+ popupTitle = " No streams available" ;
1066+ }
10601067}
10611068
10621069void PopupConfigurationWindow::scrollBarMoved (ScrollBar* scrollBar, double newRangeStart)
@@ -1128,12 +1135,13 @@ void PopupConfigurationWindow::paint (Graphics& g)
11281135bool PopupConfigurationWindow::keyPressed (const KeyPress& key)
11291136{
11301137 // Popup component handles globally reserved undo/redo keys
1131- PopupComponent::keyPressed (key);
1132-
1133- // Pressing 'a' key adds a new spike channel
1134- if (key.getTextCharacter () == ' a' )
1138+ if (! PopupComponent::keyPressed (key))
11351139 {
1136- editor->addSpikeChannels (this , spikeChannelGenerator->getSelectedType (), 1 );
1140+ // Pressing 'a' key adds a new spike channel
1141+ if (key.getTextCharacter () == ' a' )
1142+ {
1143+ editor->addSpikeChannels (this , spikeChannelGenerator->getSelectedType (), 1 );
1144+ }
11371145 }
11381146
11391147 return true ;
0 commit comments