@@ -198,7 +198,6 @@ void PopupThresholdComponent::sliderValueChanged(Slider* slider)
198198 lockButton->getToggleState (), // isLocked
199199 slider->getValue ()); // value
200200
201- owner->repaint ();
202201}
203202
204203void PopupThresholdComponent::buttonClicked (Button* button)
@@ -222,8 +221,7 @@ void PopupThresholdComponent::buttonClicked(Button* button)
222221 thresholdType); // threshold type
223222
224223 createSliders ();
225-
226- owner->repaint ();
224+
227225}
228226
229227ThresholdSelectorCustomComponent::ThresholdSelectorCustomComponent (SpikeChannel* channel_, bool acquisitionIsActive_)
@@ -303,7 +301,7 @@ void ThresholdSelectorCustomComponent::paint(Graphics& g)
303301
304302 if (channel == nullptr )
305303 return ;
306-
304+
307305 thresholdString = " " ;
308306
309307 switch (thresholder_type->getSelectedIndex ())
@@ -578,6 +576,8 @@ void SpikeDetectorTableModel::broadcastThresholdTypeToSelectedRows(int rowThatWa
578576 }
579577
580578 table->updateContent ();
579+
580+ table->repaint ();
581581}
582582
583583void SpikeDetectorTableModel::broadcastThresholdToSelectedRows (int rowThatWasClicked,
@@ -588,7 +588,7 @@ void SpikeDetectorTableModel::broadcastThresholdToSelectedRows(int rowThatWasCli
588588{
589589 SparseSet<int > selectedRows = table->getSelectedRows ();
590590
591- // std::cout << "Broadcasting value." << std::endl;
591+ // std::cout << "Broadcasting value for " << rowThatWasClicked << ", " << channelIndex << std::endl;
592592
593593 float actualValue;
594594
@@ -639,12 +639,18 @@ void SpikeDetectorTableModel::broadcastThresholdToSelectedRows(int rowThatWasCli
639639 Component* c = table->getCellComponent (SpikeDetectorTableModel::Columns::THRESHOLD, i);
640640
641641 if (c != nullptr )
642+ {
643+ // std::cout << "Repainting" << std::endl;
642644 c->repaint ();
645+ }
646+
643647
644648 }
645649 }
646650
647651 table->updateContent ();
652+
653+ table->repaint ();
648654}
649655
650656Component* SpikeDetectorTableModel::refreshComponentForCell (int rowNumber,
@@ -949,7 +955,7 @@ void SpikeChannelGenerator::buttonClicked(Button* button)
949955 int numSpikeChannelsToAdd = spikeChannelCountLabel->getText ().getIntValue ();
950956 SpikeChannel::Type channelType = (SpikeChannel::Type) spikeChannelTypeSelector->getSelectedId ();
951957
952- std::cout << " Button clicked! Sending " << startChannels.size () << " start channels " << std::endl;
958+ // std::cout << "Button clicked! Sending " << startChannels.size() << " start channels " << std::endl;
953959
954960 if (startChannels.size () == 0 )
955961 editor->addSpikeChannels (window, channelType, numSpikeChannelsToAdd);
@@ -1008,7 +1014,7 @@ void SpikeChannelGenerator::channelStateChanged(Array<int> selectedChannels)
10081014{
10091015 startChannels = selectedChannels;
10101016
1011- std::cout << " Size of start channels: " << startChannels.size () << std::endl;
1017+ // std::cout << "Size of start channels: " << startChannels.size() << std::endl;
10121018}
10131019
10141020void SpikeChannelGenerator::paint (Graphics& g)
@@ -1054,46 +1060,66 @@ PopupConfigurationWindow::PopupConfigurationWindow(SpikeDetectorEditor* editor_,
10541060 electrodeTable->setHeaderHeight (30 );
10551061 electrodeTable->setRowHeight (30 );
10561062 electrodeTable->setMultipleSelectionEnabled (true );
1063+
1064+ viewport = std::make_unique<Viewport>();
10571065
1058- addChildComponent (electrodeTable.get ());
1066+ viewport->setViewedComponent (electrodeTable.get (), false );
1067+ viewport->setScrollBarsShown (true , false );
1068+ viewport->getVerticalScrollBar ().addListener (this );
10591069
1070+ addAndMakeVisible (viewport.get ());
10601071 update (spikeChannels);
10611072
10621073
10631074}
10641075
1076+ void PopupConfigurationWindow::scrollBarMoved (ScrollBar* scrollBar, double newRangeStart)
1077+ {
1078+
1079+ if (!updating)
1080+ {
1081+ scrollDistance = viewport->getViewPositionY ();
1082+ }
1083+
1084+ }
1085+
10651086
10661087void PopupConfigurationWindow::update (Array<SpikeChannel*> spikeChannels)
10671088{
10681089
10691090 if (spikeChannels.size () > 0 )
10701091 {
10711092
1093+ updating = true ;
1094+
10721095 tableModel->update (spikeChannels);
10731096
10741097 int maxRows = 16 ;
10751098
1076- int numRows = spikeChannels.size () <= maxRows ? spikeChannels.size () : maxRows;
1099+ int numRowsVisible = spikeChannels.size () <= maxRows ? spikeChannels.size () : maxRows;
10771100
10781101 int scrollBarWidth = 0 ;
10791102
1080- electrodeTable->getHorizontalScrollBar ().setVisible (false );
1081-
10821103 if (spikeChannels.size () > maxRows)
10831104 {
1084- electrodeTable ->getVerticalScrollBar ().setVisible (true );
1105+ viewport ->getVerticalScrollBar ().setVisible (true );
10851106 scrollBarWidth += 20 ;
10861107 }
10871108 else {
1088- electrodeTable ->getVerticalScrollBar ().setVisible (false );
1109+ viewport ->getVerticalScrollBar ().setVisible (false );
10891110 }
1090-
1091- setSize (530 + scrollBarWidth, (numRows + 1 ) * 30 + 10 + 40 );
1092- electrodeTable->setBounds (5 , 5 , 520 + scrollBarWidth, (numRows + 1 ) * 30 );
1111+
1112+ setSize (530 + scrollBarWidth, (numRowsVisible + 1 ) * 30 + 10 + 40 );
1113+ viewport->setBounds (5 , 5 , 520 + scrollBarWidth, (numRowsVisible + 1 ) * 30 );
1114+ electrodeTable->setBounds (0 , 0 , 520 + scrollBarWidth, (spikeChannels.size () + 1 ) * 30 );
1115+
1116+ viewport->setViewPosition (0 , scrollDistance);
10931117
10941118 electrodeTable->setVisible (true );
10951119
1096- spikeChannelGenerator->setBounds (60 , electrodeTable->getBottom () + 8 , 420 , 30 );
1120+ spikeChannelGenerator->setBounds (60 , viewport->getBottom () + 8 , 420 , 30 );
1121+
1122+ updating = false ;
10971123
10981124 }
10991125 else {
0 commit comments