Skip to content

Commit 1649690

Browse files
authored
Merge pull request #1056 from OpenBCI/simpler-overlap-check
Simpler and more comprehensive Cp5 Overlap Checks
2 parents 124ca35 + e840c49 commit 1649690

13 files changed

Lines changed: 75 additions & 25 deletions

OpenBCI_GUI/ControlPanel.pde

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ class ControlPanel {
142142
public void open(){
143143
isOpen = true;
144144
topNav.controlPanelCollapser.setOn();
145+
topNav.setDropdownMenuIsOpen(true);
145146
}
146147

147148
public void close(){
148149
isOpen = false;
149150
topNav.controlPanelCollapser.setOff();
151+
topNav.setDropdownMenuIsOpen(false);
150152
}
151153

152154
public String getWifiSearchStyle() {

OpenBCI_GUI/Interactivity.pde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ synchronized void mousePressed() {
286286
//if clicked out of panel
287287
else {
288288
println("OpenBCI_GUI: mousePressed: outside of CP clicked");
289-
controlPanel.isOpen = false;
289+
controlPanel.close();
290290
topNav.controlPanelCollapser.setOff();
291291
}
292292
}

OpenBCI_GUI/OpenBCI_GUI.pde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ void introAnimation() {
10071007
if ((millis() >= settings.introAnimationInit + settings.introAnimationDuration)
10081008
&& controlPanel != null) {
10091009
systemMode = SYSTEMMODE_PREINIT;
1010-
controlPanel.isOpen = true;
1010+
controlPanel.open();
10111011
}
10121012
popStyle();
10131013
}

OpenBCI_GUI/TopNav.pde

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class TopNav {
5252
private final int SUBNAV_BUT_H = 26;
5353
private final int TOPNAV_BUT_H = SUBNAV_BUT_H;
5454

55+
private boolean topNavDropdownMenuIsOpen = false;
56+
5557
TopNav() {
5658
int controlPanel_W = 256;
5759

@@ -469,7 +471,7 @@ class TopNav {
469471
//make Help button and Settings button mutually exclusive
470472
if (!tutorialSelector.isVisible) {
471473
configSelector.toggleVisibility();
472-
}
474+
}
473475
}
474476
});
475477
settingsButton.setDescription("Save and Load GUI Settings! Click Default to revert to factory settings.");
@@ -528,6 +530,14 @@ class TopNav {
528530
toggleDataStreamingButton.setLock(_b);
529531
filtersButton.setLock(_b);
530532
}
533+
534+
public boolean getDropdownMenuIsOpen() {
535+
return topNavDropdownMenuIsOpen;
536+
}
537+
538+
public void setDropdownMenuIsOpen(boolean b) {
539+
topNavDropdownMenuIsOpen = b;
540+
}
531541
}
532542

533543
class LayoutSelector {
@@ -621,6 +631,7 @@ class LayoutSelector {
621631

622632
void toggleVisibility() {
623633
isVisible = !isVisible;
634+
topNav.setDropdownMenuIsOpen(isVisible);
624635
if (isVisible) {
625636
//the very convoluted way of locking all controllers of a single controlP5 instance...
626637
for (int i = 0; i < wm.widgets.size(); i++) {
@@ -804,6 +815,7 @@ class ConfigSelector {
804815

805816
void toggleVisibility() {
806817
isVisible = !isVisible;
818+
topNav.setDropdownMenuIsOpen(isVisible);
807819
if (systemMode >= SYSTEMMODE_POSTINIT) {
808820
if (isVisible) {
809821
//the very convoluted way of locking all controllers of a single controlP5 instance...
@@ -1049,6 +1061,7 @@ class TutorialSelector {
10491061

10501062
void toggleVisibility() {
10511063
isVisible = !isVisible;
1064+
topNav.setDropdownMenuIsOpen(isVisible);
10521065
if (systemMode >= SYSTEMMODE_POSTINIT) {
10531066
if (isVisible) {
10541067
//the very convoluted way of locking all controllers of a single controlP5 instance...

OpenBCI_GUI/W_Accelerometer.pde

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ class W_Accelerometer extends Widget {
104104
}
105105

106106
//ignore top left button interaction when widgetSelector dropdown is active
107-
lockElementOnOverlapCheck(accelModeButton);
107+
List<controlP5.Controller> cp5ElementsToCheck = new ArrayList<controlP5.Controller>();
108+
cp5ElementsToCheck.add((controlP5.Controller)accelModeButton);
109+
lockElementsOnOverlapCheck(cp5ElementsToCheck);
108110

109111
if(!accelBoard.canDeactivateAccelerometer() && !(currentBoard instanceof BoardCyton)) {
110112
accelModeButton.getCaptionLabel().setText("Accel. On");

OpenBCI_GUI/W_AnalogRead.pde

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ class W_AnalogRead extends Widget {
104104
}
105105

106106
//ignore top left button interaction when widgetSelector dropdown is active
107-
lockElementOnOverlapCheck(analogModeButton);
107+
List<controlP5.Controller> cp5ElementsToCheck = new ArrayList<controlP5.Controller>();
108+
cp5ElementsToCheck.add((controlP5.Controller)analogModeButton);
109+
lockElementsOnOverlapCheck(cp5ElementsToCheck);
108110

109111
if (!analogBoard.canDeactivateAnalog()) {
110112
analogModeButton.setLock(true);

OpenBCI_GUI/W_BandPower.pde

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ class W_BandPower extends Widget {
3232
public ChannelSelect bpChanSelect;
3333
boolean prevChanSelectIsVisible = false;
3434

35+
List<controlP5.Controller> cp5ElementsToCheck = new ArrayList<controlP5.Controller>();
36+
3537
W_BandPower(PApplet _parent) {
3638
super(_parent); //calls the parent CONSTRUCTOR method of Widget (DON'T REMOVE)
3739

3840
//Add channel select dropdown to this widget
3941
bpChanSelect = new ChannelSelect(pApplet, this, x, y, w, navH, "BP_Channels");
4042
bpChanSelect.activateAllButtons();
43+
cp5ElementsToCheck.addAll(bpChanSelect.getCp5ElementsForOverlapCheck());
4144

4245
//Add settings dropdowns
4346
addDropdown("Smoothing", "Smooth", Arrays.asList(settings.fftSmoothingArray), smoothFac_ind); //smoothFac_ind is a global variable at the top of W_HeadPlot.pde
@@ -116,6 +119,10 @@ class W_BandPower extends Widget {
116119
bp_points.add(BETA + 0.5, activePower[BETA], "BETA\n13-32Hz");
117120
bp_points.add(GAMMA + 0.5, activePower[GAMMA], "GAMMA\n32-100Hz");
118121
bp_plot.setPoints(bp_points);
122+
123+
if (bpChanSelect.isVisible()) {
124+
lockElementsOnOverlapCheck(cp5ElementsToCheck);
125+
}
119126
} //end of update
120127

121128
void draw() {

OpenBCI_GUI/W_DigitalRead.pde

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ class W_DigitalRead extends Widget {
9393
}
9494

9595
//ignore top left button interaction when widgetSelector dropdown is active
96-
lockElementOnOverlapCheck(digitalModeButton);
96+
List<controlP5.Controller> cp5ElementsToCheck = new ArrayList<controlP5.Controller>();
97+
cp5ElementsToCheck.add((controlP5.Controller)digitalModeButton);
98+
lockElementsOnOverlapCheck(cp5ElementsToCheck);
9799

98100
if (!digitalBoard.canDeactivateDigital()) {
99101
digitalModeButton.setLock(true);

OpenBCI_GUI/W_FFT.pde

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,15 @@ class W_fft extends Widget {
4646
int FFT_indexLim = int(1.0*xMax*(getNfftSafe()/currentBoard.getSampleRate())); // maxim value of FFT index
4747
int yLim = yLimOptions[2]; //maximum value of y axis ... 100 uV
4848

49+
List<controlP5.Controller> cp5ElementsToCheck = new ArrayList<controlP5.Controller>();
50+
4951
W_fft(PApplet _parent){
5052
super(_parent); //calls the parent CONSTRUCTOR method of Widget (DON'T REMOVE)
5153

5254
//Add channel select dropdown to this widget
5355
fftChanSelect = new ChannelSelect(pApplet, this, x, y, w, navH, "BP_Channels");
5456
fftChanSelect.activateAllButtons();
57+
cp5ElementsToCheck.addAll(fftChanSelect.getCp5ElementsForOverlapCheck());
5558

5659
//Default FFT plot settings
5760
settings.fftMaxFrqSave = 2;
@@ -131,6 +134,10 @@ class W_fft extends Widget {
131134
flexGPlotSizeAndPosition();
132135
prevChanSelectIsVisible = fftChanSelect.isVisible();
133136
}
137+
138+
if (fftChanSelect.isVisible()) {
139+
lockElementsOnOverlapCheck(cp5ElementsToCheck);
140+
}
134141
}
135142

136143
void draw(){

OpenBCI_GUI/W_Focus.pde

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,19 @@ class W_Focus extends Widget {
6666
private int graphPadding = 30;
6767
private color cBack, cDark, cMark, cFocus, cWave, cPanel;
6868

69+
List<controlP5.Controller> cp5ElementsToCheck = new ArrayList<controlP5.Controller>();
70+
6971
W_Focus(PApplet _parent) {
7072
super(_parent); //calls the parent CONSTRUCTOR method of Widget (DON'T REMOVE)
7173

7274
//Add channel select dropdown to this widget
7375
focusChanSelect = new ChannelSelect(pApplet, this, x, y, w, navH, "FocusChannelSelect");
7476
focusChanSelect.activateAllButtons();
77+
cp5ElementsToCheck.addAll(focusChanSelect.getCp5ElementsForOverlapCheck());
7578

7679
auditoryNeurofeedback = new AuditoryNeurofeedback(x + PAD_FIVE, y + PAD_FIVE, w/2 - PAD_FIVE*2, navBarHeight/2);
80+
cp5ElementsToCheck.add((controlP5.Controller)auditoryNeurofeedback.startStopButton);
81+
cp5ElementsToCheck.add((controlP5.Controller)auditoryNeurofeedback.modeButton);
7782

7883
exgChannels = currentBoard.getEXGChannels();
7984
channelCount = currentBoard.getNumEXGChannels();
@@ -132,10 +137,7 @@ class W_Focus extends Widget {
132137
predictionExceedsThreshold = metricPrediction > focusThreshold.getValue();
133138
}
134139

135-
//ignore top left button interaction when widgetSelector dropdown is active
136-
lockElementOnOverlapCheck(auditoryNeurofeedback.startStopButton);
137-
138-
//put your code here...
140+
lockElementsOnOverlapCheck(cp5ElementsToCheck);
139141
}
140142

141143
public void draw() {

0 commit comments

Comments
 (0)