Skip to content

Commit 3dcb9ff

Browse files
committed
Dismiss PopupChannelSelector if channel count changes
1 parent 38c80ac commit 3dcb9ff

8 files changed

Lines changed: 47 additions & 4 deletions

File tree

Plugins/SpikeDetector/PopupConfigurationWindow.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ class ChannelSelectorCustomComponent : public PopupChannelSelector::Listener,
103103
channels->setNextValue (newArray);
104104
}
105105

106+
/** Get the number of channels */
107+
int getChannelCount() override
108+
{
109+
return channels->getChannelCount();
110+
}
111+
106112
/** Sets row and column */
107113
void setRowAndColumn (const int newRow, const int newColumn);
108114

@@ -409,6 +415,9 @@ class SpikeChannelGenerator : public Component,
409415
/** Responds to changes in the PopupChannelSelector*/
410416
void channelStateChanged (Array<int> selectedChannels);
411417

418+
/** Get the number of channels */
419+
int getChannelCount() { return channelCount; }
420+
412421
/** Responds to button clicks*/
413422
void buttonClicked (Button* button);
414423

Source/Processors/Editors/PopupChannelSelector.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ void PopupChannelSelector::paint (Graphics& g)
268268

269269
void PopupChannelSelector::updatePopup()
270270
{
271+
if (nChannels != listener->getChannelCount())
272+
{
273+
findParentComponentOfClass<CallOutBox>()->exitModalState (0);
274+
return;
275+
}
276+
271277
Array<int> selectedChannels = listener->getSelectedChannels();
272278
for (auto* btn : channelButtons)
273279
{

Source/Processors/Editors/PopupChannelSelector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class PLUGIN_API PopupChannelSelector : public PopupComponent,
127127
virtual ~Listener() {}
128128
virtual Array<int> getSelectedChannels() = 0;
129129
virtual void channelStateChanged (Array<int> selectedChannels) = 0;
130+
virtual int getChannelCount() = 0;
130131
};
131132

132133
/** Constructor */

Source/Processors/Parameter/Parameter.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,9 @@ class PLUGIN_API SelectedChannelsParameter : public Parameter
736736
/** Sets the total number of available channels in this stream*/
737737
void setChannelCount (int count);
738738

739+
/** Returns the total number of available channels in this stream*/
740+
int getChannelCount() { return channelCount; }
741+
739742
/** Saves the parameter to an XML Element*/
740743
virtual void toXml (XmlElement*) override;
741744

@@ -787,6 +790,9 @@ class PLUGIN_API MaskChannelsParameter : public Parameter
787790
/** Gets the value change description */
788791
virtual String getChangeDescription() override;
789792

793+
/** Returns the total number of available channels in this stream*/
794+
int getChannelCount() { return channelCount; }
795+
790796
/** Sets the total number of available channels in this stream*/
791797
void setChannelCount (int count);
792798

Source/Processors/Parameter/ParameterEditor.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,11 @@ Array<int> SelectedChannelsParameterEditor::getSelectedChannels()
586586
return ((SelectedChannelsParameter*) param)->getArrayValue();
587587
}
588588

589+
int SelectedChannelsParameterEditor::getChannelCount()
590+
{
591+
return ((SelectedChannelsParameter*) param)->getChannelCount();
592+
}
593+
589594
void SelectedChannelsParameterEditor::channelStateChanged (Array<int> newChannels)
590595
{
591596
Array<var> newArray;
@@ -691,6 +696,11 @@ Array<int> MaskChannelsParameterEditor::getSelectedChannels()
691696
return ((MaskChannelsParameter*) param)->getArrayValue();
692697
}
693698

699+
int MaskChannelsParameterEditor::getChannelCount()
700+
{
701+
return ((MaskChannelsParameter*) param)->getChannelCount();
702+
}
703+
694704
void MaskChannelsParameterEditor::channelStateChanged (Array<int> newChannels)
695705
{
696706
Array<var> newArray;

Source/Processors/Parameter/ParameterEditor.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,9 @@ class PLUGIN_API SelectedChannelsParameterEditor : public ParameterEditor,
399399
/** Responds to changes in the PopupChannelSelector*/
400400
void channelStateChanged (Array<int> selectedChannels) override;
401401

402+
/** Get the number of channels */
403+
int getChannelCount() override;
404+
402405
/** Sets sub-component locations */
403406
virtual void resized() override;
404407

@@ -459,6 +462,9 @@ class PLUGIN_API MaskChannelsParameterEditor : public ParameterEditor,
459462
/** Responds to changes in the PopupChannelSelector*/
460463
void channelStateChanged (Array<int> selectedChannels) override;
461464

465+
/** Get the number of channels */
466+
int getChannelCount() override;
467+
462468
/** Sets sub-component locations */
463469
virtual void resized() override;
464470

Source/Processors/RecordNode/RecordNodeEditor.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ void RecordChannelsParameterEditor::channelStateChanged (Array<int> newChannels)
257257
updateView();
258258
}
259259

260+
int RecordChannelsParameterEditor::getChannelCount()
261+
{
262+
return ((MaskChannelsParameter*) param)->getChannelCount();
263+
}
264+
260265
Array<int> RecordChannelsParameterEditor::getSelectedChannels()
261266
{
262267
MaskChannelsParameter* p = (MaskChannelsParameter*) param;

Source/Processors/RecordNode/RecordNodeEditor.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,6 @@ class SyncStartTimeMonitor : public SyncMonitor
118118
void paint (Graphics& g);
119119
};
120120

121-
122-
123121
class StreamMonitor : public LevelMonitor
124122
{
125123
public:
@@ -144,7 +142,6 @@ class StreamMonitor : public LevelMonitor
144142
int totalChannels;
145143
};
146144

147-
148145
class DiskMonitor : public LevelMonitor, public DiskSpaceListener
149146
{
150147
public:
@@ -197,6 +194,9 @@ class RecordChannelsParameterEditor : public ParameterEditor,
197194
/** Responds to changes in the PopupChannelSelector*/
198195
void channelStateChanged (Array<int> selectedChannels) override;
199196

197+
/** Get the number of channels */
198+
int getChannelCount() override;
199+
200200
/** Sets sub-component locations */
201201
virtual void resized() override;
202202

@@ -314,7 +314,7 @@ class RecordNodeEditor : public GenericEditor,
314314
/** Set the time of latest sync pulse */
315315
void setLastSyncEvent (uint16 streamId, bool isSynchronized, float syncTimeSeconds);
316316

317-
/** Set the synchronization accuracy metric for a particular stream */
317+
/** Set the synchronization accuracy metric for a particular stream */
318318
void setSyncAccuracy (uint16 streamId, bool isSynchronized, float expectedMinusActual);
319319

320320
std::unique_ptr<FifoDrawerButton> fifoDrawerButton;

0 commit comments

Comments
 (0)