Skip to content

Commit b34599d

Browse files
committed
Update RecordNode editor enabled states during recording
1 parent 8f8b7c5 commit b34599d

File tree

7 files changed

+68
-11
lines changed

7 files changed

+68
-11
lines changed

Source/Processors/Editors/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,4 @@ add_sources(open-ephys
2020
PopupChannelSelector.h
2121
)
2222

23-
#add nested directories
24-
25-
23+
#add nested directories

Source/Processors/Editors/PopupChannelSelector.cpp

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void ChannelButton::paintButton(Graphics &g, bool isMouseOver, bool isButtonDown
6060
g.setColour(Colour(0,0,0));
6161
g.fillRoundedRectangle(0.0f, 0.0f, getWidth(), getHeight(), 0.001*getWidth());
6262

63-
if (isMouseOver)
63+
if (isMouseOver && parent->isEditable())
6464
{
6565
if (getToggleState())
6666
g.setColour(parent->buttonColour.brighter());
@@ -130,12 +130,12 @@ PopupChannelSelector::PopupChannelSelector(PopupChannelSelector::Listener* liste
130130
maxSelectable(-1)
131131
{
132132

133-
int width = 368; //can use any multiples of 16 here for dynamic resizing
133+
width = 368; //can use any multiples of 16 here for dynamic resizing
134134

135-
int nColumns = 16;
136-
int nRows = nChannels / nColumns + (int)(!(nChannels % nColumns == 0));
137-
int buttonSize = width / 16;
138-
int height = buttonSize * nRows;
135+
nColumns = 16;
136+
nRows = nChannels / nColumns + (int)(!(nChannels % nColumns == 0));
137+
buttonSize = width / 16;
138+
height = buttonSize * nRows;
139139

140140
maxSelectable = (maxSelectable == -1) ? nChannels : maxSelectable;
141141
maxSelectable = (maxSelectable > nChannels) ? nChannels : maxSelectable;
@@ -209,6 +209,35 @@ PopupChannelSelector::PopupChannelSelector(PopupChannelSelector::Listener* liste
209209

210210
}
211211

212+
void PopupChannelSelector::setEditable(bool editable)
213+
{
214+
this->editable = editable;
215+
216+
if (editable)
217+
{
218+
for (auto* btn : selectButtons)
219+
btn->setVisible(true);
220+
221+
if (nChannels > 8)
222+
rangeEditor->setVisible(true);
223+
}
224+
else
225+
{
226+
for (auto* btn : selectButtons)
227+
btn->setVisible(false);
228+
229+
if (nChannels > 8)
230+
rangeEditor->setVisible(false);
231+
}
232+
233+
//Resize window
234+
if (editable)
235+
setSize (width, buttonSize * nRows + buttonSize);
236+
else
237+
setSize(width, height);
238+
239+
}
240+
212241
void PopupChannelSelector::setMaximumSelectableChannels(int num)
213242
{
214243
maxSelectable = num;

Source/Processors/Editors/PopupChannelSelector.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ class PLUGIN_API PopupChannelSelector :
165165

166166
OwnedArray<ChannelButton> channelButtons;
167167

168+
void setEditable(bool editable);
169+
170+
bool isEditable() { return editable; }
171+
168172
private:
169173
Listener* listener;
170174

@@ -194,6 +198,12 @@ class PLUGIN_API PopupChannelSelector :
194198
Array<int> channelStates;
195199
Array<int> selectedButtons;
196200
Array<int> activeChannels;
201+
202+
int buttonSize;
203+
int width;
204+
int height;
205+
int nRows;
206+
int nColumns;
197207
};
198208

199209

Source/Processors/RecordNode/RecordNodeEditor.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ void FifoMonitor::mouseDown(const MouseEvent &event)
504504
bool editable = !recordNode->recordThread->isThreadRunning();
505505
auto* channelSelector = new PopupChannelSelector(this, channelStates);
506506
channelSelector->setChannelButtonColour(Colours::red);
507+
channelSelector->setEditable(!recordNode->getRecordingStatus());
507508

508509
CallOutBox& myBox
509510
= CallOutBox::launchAsynchronously (std::unique_ptr<Component>(channelSelector), getScreenBounds(), nullptr);

Source/Processors/RecordNode/SyncChannelSelector.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ SyncChannelSelector::SyncChannelSelector(int nChans, int selectedIdx, bool isPri
9898
nChannels(nChans),
9999
selectedId(selectedIdx),
100100
isPrimary(isPrimary_),
101-
detectedChange(false)
101+
detectedChange(false),
102+
editable(true)
102103
{
103104

104105
width = 368; //can use any multiples of 16 here for dynamic resizing
@@ -145,6 +146,16 @@ SyncChannelSelector::SyncChannelSelector(int nChans, int selectedIdx, bool isPri
145146

146147
}
147148

149+
void SyncChannelSelector::setEditable(bool editable)
150+
{
151+
this->editable = editable;
152+
153+
for (int i = 0; i < buttons.size(); i++)
154+
buttons[i]->setEnabled(editable);
155+
156+
setSize(width, buttonSize + buttonSize * (editable && !isPrimary));
157+
}
158+
148159
SyncChannelSelector::~SyncChannelSelector() {}
149160

150161
void SyncChannelSelector::mouseMove(const MouseEvent &event) {}

Source/Processors/RecordNode/SyncChannelSelector.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,14 @@ class SyncChannelSelector : public Component, public Button::Listener
104104

105105
OwnedArray<SyncChannelButton> buttons;
106106

107+
void setEditable(bool editable);
108+
109+
bool isEditable() { return editable; }
110+
107111
private:
108112

113+
bool editable;
114+
109115
ScopedPointer<SetButton> setPrimaryStreamButton;
110116

111117
};

Source/Processors/RecordNode/SyncControlButton.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,15 @@ void SyncControlButton::componentBeingDeleted(Component &component)
8686
void SyncControlButton::mouseUp(const MouseEvent &event)
8787
{
8888

89-
if (!CoreServices::getRecordingStatus() && event.mods.isLeftButtonDown())
89+
if (event.mods.isLeftButtonDown())
9090
{
9191

9292
int syncLine = node->getSyncLine(streamId);
9393

9494
SyncChannelSelector* channelSelector = new SyncChannelSelector (ttlLineCount, syncLine, node->isMainDataStream(streamId));
9595

96+
channelSelector->setEditable(!CoreServices::getRecordingStatus());
97+
9698
CallOutBox& myBox
9799
= CallOutBox::launchAsynchronously (std::unique_ptr<Component>(channelSelector), getScreenBounds(), nullptr);
98100

0 commit comments

Comments
 (0)