Skip to content

Commit b499a54

Browse files
committed
Adjust all subnav rectangular buttons to be pixel perfect
- also fix topnav dropdownMenuIsOpen check
1 parent 24bd916 commit b499a54

9 files changed

Lines changed: 29 additions & 24 deletions

OpenBCI_GUI/TopNav.pde

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ class TopNav {
132132
configSelector.update();
133133
previousSystemMode = systemMode;
134134
}
135+
136+
boolean topNavSubClassIsOpen = layoutSelector.isVisible || configSelector.isVisible || tutorialSelector.isVisible;
137+
setDropdownMenuIsOpen(topNavSubClassIsOpen);
135138
}
136139

137140
void draw() {
@@ -631,7 +634,6 @@ class LayoutSelector {
631634

632635
void toggleVisibility() {
633636
isVisible = !isVisible;
634-
topNav.setDropdownMenuIsOpen(isVisible);
635637
if (isVisible) {
636638
//the very convoluted way of locking all controllers of a single controlP5 instance...
637639
for (int i = 0; i < wm.widgets.size(); i++) {
@@ -815,7 +817,6 @@ class ConfigSelector {
815817

816818
void toggleVisibility() {
817819
isVisible = !isVisible;
818-
topNav.setDropdownMenuIsOpen(isVisible);
819820
if (systemMode >= SYSTEMMODE_POSTINIT) {
820821
if (isVisible) {
821822
//the very convoluted way of locking all controllers of a single controlP5 instance...
@@ -1061,7 +1062,6 @@ class TutorialSelector {
10611062

10621063
void toggleVisibility() {
10631064
isVisible = !isVisible;
1064-
topNav.setDropdownMenuIsOpen(isVisible);
10651065
if (systemMode >= SYSTEMMODE_POSTINIT) {
10661066
if (isVisible) {
10671067
//the very convoluted way of locking all controllers of a single controlP5 instance...

OpenBCI_GUI/W_Accelerometer.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class W_Accelerometer extends Widget {
7272
accelerometerBar.adjustTimeAxis(xLimOptions[settings.accHorizScaleSave]);
7373
accelerometerBar.adjustVertScale(yLimOptions[settings.accVertScaleSave]);
7474

75-
createAccelModeButton("accelModeButton", "Turn Accel. Off", (int)(x + 3), (int)(y + 3 - navHeight), 120, navHeight - 6, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
75+
createAccelModeButton("accelModeButton", "Turn Accel. Off", (int)(x + 1), (int)(y0 + navHeight + 1), 120, navHeight - 3, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
7676
}
7777

7878
float adjustYMaxMinBasedOnSource() {
@@ -175,7 +175,7 @@ class W_Accelerometer extends Widget {
175175
//resize the accelerometer line graph
176176
accelerometerBar.screenResized(accelGraphX, accelGraphY, accelGraphWidth-accPadding*2, accelGraphHeight); //bar x, bar y, bar w, bar h
177177
//update the position of the accel mode button
178-
accelModeButton.setPosition((int)(x + 3), (int)(y + 3 - navHeight));
178+
accelModeButton.setPosition((int)(x0 + 1), (int)(y0 + navHeight + 1));
179179
}
180180

181181
void mousePressed() {

OpenBCI_GUI/W_AnalogRead.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class W_AnalogRead extends Widget {
8484
analogReadBars[i].adjustTimeAxis(w_timeSeries.getTSHorizScale().getValue());
8585
}
8686

87-
createAnalogModeButton("analogModeButton", "Turn Analog Read On", (int)(x + 3), (int)(y + 3 - navHeight), 128, navHeight - 6, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
87+
createAnalogModeButton("analogModeButton", "Turn Analog Read On", (int)(x0 + 1), (int)(y0 + navHeight + 1), 128, navHeight - 3, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
8888
}
8989

9090
public int getNumAnalogReads() {
@@ -145,7 +145,7 @@ class W_AnalogRead extends Widget {
145145
analogReadBars[i].screenResized(int(ar_x), analogReadBarY, int(ar_w), analogReadBarHeight); //bar x, bar y, bar w, bar h
146146
}
147147

148-
analogModeButton.setPosition(x + 3, y + 3 - navHeight);
148+
analogModeButton.setPosition((int)(x0 + 1), (int)(y0 + navHeight + 1));
149149
}
150150

151151
void mousePressed() {

OpenBCI_GUI/W_CytonImpedance.pde

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class W_CytonImpedance extends Widget {
9999
//Init the electrode map and fill and create signal check buttons
100100
initCytonImpedanceMap();
101101

102-
cytonResetAllChannels = createCytonResetChannelsButton("cytonResetAllChannels", "Reset Channels", (int)(x + padding_3), (int)(y + padding_3 - navHeight), 90, navHeight - 6, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
103-
cytonImpedanceMasterCheck = createCytonImpMasterCheckButton("cytonImpedanceMasterCheck", "Check All Channels", (int)(x + padding_3*2 + 90), (int)(y + padding_3 - navHeight), 120, navHeight - 6, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
102+
cytonResetAllChannels = createCytonResetChannelsButton("cytonResetAllChannels", "Reset Channels", (int)(x0 + 1), (int)(y0 + navHeight + 1), 90, navHeight - 3, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
103+
cytonImpedanceMasterCheck = createCytonImpMasterCheckButton("cytonImpedanceMasterCheck", "Check All Channels", (int)(x0 + 1 + padding_3 + 90), (int)(y0 + navHeight + 1), 120, navHeight - 3, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
104104
errorThreshold = new SignalCheckThresholdUI(threshold_ui_cp5, "errorThreshold", x + tableWidth + padding, y + h - navH, thresholdTFWidth, thresholdTFHeight, SIGNAL_CHECK_RED, signalCheckMode);
105105
warningThreshold = new SignalCheckThresholdUI(threshold_ui_cp5, "warningThreshold", x + tableWidth + padding, y + h - navH/2, thresholdTFWidth, thresholdTFHeight, SIGNAL_CHECK_YELLOW, signalCheckMode);
106106
}
@@ -192,8 +192,8 @@ class W_CytonImpedance extends Widget {
192192
imp_buttons_cp5.setGraphics(pApplet, 0, 0);
193193
threshold_ui_cp5.setGraphics(pApplet, 0, 0);
194194

195-
cytonResetAllChannels.setPosition((int)(x + padding_3), (int)(y + padding_3 - navHeight));
196-
cytonImpedanceMasterCheck.setPosition((int)(x + padding_3*2 + 90), (int)(y + padding_3 - navHeight));
195+
cytonResetAllChannels.setPosition((int)(x0 + 1), (int)(y0 + navHeight + 1));
196+
cytonImpedanceMasterCheck.setPosition((int)(x0 + 1 + padding_3 + 90), (int)(y0 + navHeight + 1));
197197

198198
resizeTable();
199199

@@ -431,6 +431,7 @@ class W_CytonImpedance extends Widget {
431431
private Button createCytonImpMasterCheckButton(String name, String text, int _x, int _y, int _w, int _h, PFont _font, int _fontSize, color _bg, color _textColor) {
432432
final Button myButton = createButton(cp5_widget, name, text, _x, _y, _w, _h, _font, _fontSize, _bg, _textColor);
433433
myButton.setSwitch(true);
434+
myButton.setBorderColor(OBJECT_BORDER_GREY);
434435
myButton.setVisible(signalCheckMode == CytonSignalCheckMode.IMPEDANCE);
435436
myButton.onRelease(new CallbackListener() {
436437
public void controlEvent(CallbackEvent theEvent) {
@@ -462,6 +463,7 @@ class W_CytonImpedance extends Widget {
462463
final Button myButton = createButton(cp5_widget, name, text, _x, _y, _w, _h, _font, _fontSize, _bg, _textColor);
463464
//myButton.setSwitch(true);
464465
myButton.setVisible(signalCheckMode == CytonSignalCheckMode.IMPEDANCE);
466+
myButton.setBorderColor(OBJECT_BORDER_GREY);
465467
myButton.onRelease(new CallbackListener() {
466468
public void controlEvent(CallbackEvent theEvent) {
467469
println("Cyton Impedance Check: User clicked reset all channel settings.");

OpenBCI_GUI/W_DigitalRead.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class W_DigitalRead extends Widget {
7474
digitalReadDots[i] = tempDot;
7575
}
7676

77-
createDigitalModeButton("digitalModeButton", "Turn Digital Read On", (int)(x + 3), (int)(y + 3 - navHeight), 128, navHeight - 6, p5, 12, buttonsLightBlue, WHITE);
77+
createDigitalModeButton("digitalModeButton", "Turn Digital Read On", (int)(x0 + 1), (int)(y0 + navHeight + 1), 128, navHeight - 3, p5, 12, buttonsLightBlue, WHITE);
7878
}
7979

8080
public int getNumDigitalReads() {
@@ -144,7 +144,7 @@ class W_DigitalRead extends Widget {
144144

145145
}
146146

147-
digitalModeButton.setPosition((int)(x + 3), (int)(y + 3 - navHeight));
147+
digitalModeButton.setPosition((int)(x0 + 1), (int)(y0 + navHeight + 1));
148148
}
149149

150150
public void mousePressed() {

OpenBCI_GUI/W_Networking.pde

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ class W_Networking extends Widget {
572572
}
573573

574574
void createGuideButton() {
575-
guideButton = createButton(cp5_networking, "networkingGuideButton", "Networking Guide", x0 + 2, y0 + navH + 2, 125, navH - 6, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
575+
guideButton = createButton(cp5_networking, "networkingGuideButton", "Networking Guide", (int)(x0 + 1), (int)(y0 + navH + 1), 125, navH - 3, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
576576
guideButton.setBorderColor(OBJECT_BORDER_GREY);
577577
guideButton.onRelease(new CallbackListener() {
578578
public void controlEvent(CallbackEvent theEvent) {
@@ -584,7 +584,7 @@ class W_Networking extends Widget {
584584
}
585585

586586
void createDataOutputsButton() {
587-
dataOutputsButton = createButton(cp5_networking, "dataOutputsButton", "Data Outputs", x0 + 2*2 + guideButton.getWidth(), y0 + navH + 2, 100, navH - 6, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
587+
dataOutputsButton = createButton(cp5_networking, "dataOutputsButton", "Data Outputs", x0 + 1 + 3 + guideButton.getWidth(), y0 + navH + 1, 100, navH - 3, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
588588
dataOutputsButton.setBorderColor(OBJECT_BORDER_GREY);
589589
dataOutputsButton.onRelease(new CallbackListener() {
590590
public void controlEvent(CallbackEvent theEvent) {
@@ -776,8 +776,8 @@ class W_Networking extends Widget {
776776

777777
//reset the button positions using new x and y
778778
startButton.setPosition(x + w/2 - 70, y + h - 40 );
779-
guideButton.setPosition(x0 + 2, y0 + navH + 2);
780-
dataOutputsButton.setPosition(x0 + 2*2 + guideButton.getWidth() , y0 + navH + 2);
779+
guideButton.setPosition(x0 + 1, y0 + navH + 1);
780+
dataOutputsButton.setPosition(x0 + 1 + 2 + guideButton.getWidth() , y0 + navH + 1);
781781

782782
int dropdownsItemsToShow = int((this.h0 * datatypeDropdownScaling) / (this.navH - 4));
783783
int dropdownHeight = (dropdownsItemsToShow) * (this.navH - 4);

OpenBCI_GUI/W_Playback.pde

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class W_playback extends Widget {
1717
MenuList playbackMenuList;
1818
//Used for spacing
1919
int padding = 10;
20+
List<controlP5.Controller> cp5ElementsToCheck = new ArrayList<controlP5.Controller>();
2021

2122
private boolean menuHasUpdated = false;
2223

@@ -39,7 +40,7 @@ class W_playback extends Widget {
3940
menuHasUpdated = true;
4041
}
4142
//Lock the MenuList if Widget selector is open, otherwise update
42-
if (cp5_widget.get(ScrollableList.class, "WidgetSelector").isOpen()) {
43+
if (cp5_widget.get(ScrollableList.class, "WidgetSelector").isOpen() || topNav.getDropdownMenuIsOpen()) {
4344
if (!playbackMenuList.isLock()) {
4445
playbackMenuList.lock();
4546
playbackMenuList.setUpdate(false);
@@ -51,6 +52,7 @@ class W_playback extends Widget {
5152
}
5253
playbackMenuList.updateMenu();
5354
}
55+
lockElementsOnOverlapCheck(cp5ElementsToCheck);
5456
}
5557

5658
void draw() {
@@ -61,7 +63,7 @@ class W_playback extends Widget {
6163
fill(boxColor);
6264
stroke(boxStrokeColor);
6365
strokeWeight(1);
64-
rect(x, y, w, h);
66+
rect(x-1, y, w+1, h);
6567
//Add text if needed
6668
/*
6769
fill(OPENBCI_DARKBLUE);
@@ -82,7 +84,7 @@ class W_playback extends Widget {
8284
cp5_playback.setGraphics(pApplet, 0, 0);
8385

8486
//Resize and position cp5 objects within this widget
85-
selectPlaybackFileButton.setPosition(x + w - selectPlaybackFileButton.getWidth() - padding, y - navHeight + 2);
87+
selectPlaybackFileButton.setPosition(x + w - selectPlaybackFileButton.getWidth() - 2, y - navHeight + 2);
8688

8789
playbackMenuList.setPosition(x + padding/2, y + 2);
8890
playbackMenuList.setSize(w - padding*2, h - padding*2);
@@ -131,6 +133,7 @@ class W_playback extends Widget {
131133
}
132134
});
133135
selectPlaybackFileButton.setDescription("Click to open a dialog box to select an OpenBCI playback file (.txt or .csv).");
136+
cp5ElementsToCheck.add((controlP5.Controller)selectPlaybackFileButton);
134137
}
135138

136139
private void createPlaybackMenuList(ControlP5 _cp5, String name, int _x, int _y, int _w, int _h, PFont font) {

OpenBCI_GUI/W_PulseSensor.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class W_PulseSensor extends Widget {
8585
setPulseWidgetVariables();
8686
initializePulseFinderVariables();
8787

88-
createAnalogModeButton("pulseSensorAnalogModeButton", "Turn Analog Read On", (int)(x + 3), (int)(y + 3 - navHeight), 128, navHeight - 6, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
88+
createAnalogModeButton("pulseSensorAnalogModeButton", "Turn Analog Read On", (int)(x0 + 1), (int)(y0 + navHeight + 1), 128, navHeight - 3, p5, 12, colorNotPressed, OPENBCI_DARKBLUE);
8989
}
9090

9191
void update(){
@@ -169,7 +169,7 @@ class W_PulseSensor extends Widget {
169169
super.screenResized(); //calls the parent screenResized() method of Widget (DON'T REMOVE)
170170

171171
setPulseWidgetVariables();
172-
analogModeButton.setPosition((int)(x + 3), (int)(y + 3 - navHeight));
172+
analogModeButton.setPosition((int)(x0 + 1), (int)(y0 + navHeight + 1));
173173
}
174174

175175
void mousePressed(){

OpenBCI_GUI/W_TimeSeries.pde

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class W_timeSeries extends Widget {
205205
int h_hsc = channelBarHeight * numChannelBars;
206206

207207
if (currentBoard instanceof ADS1299SettingsBoard) {
208-
hwSettingsButton = createHSCButton("HardwareSettings", "Hardware Settings", (int)(x0 + 80), (int)(y + navHeight + 3), 120, navHeight - 6);
208+
hwSettingsButton = createHSCButton("HardwareSettings", "Hardware Settings", (int)(x0 + 80), (int)(y0 + navHeight + 1), 120, navHeight - 3);
209209
cp5ElementsToCheck.add((controlP5.Controller)hwSettingsButton);
210210
adsSettingsController = new ADS1299SettingsController(_parent, tsChanSelect.activeChan, x_hsc, y_hsc, w_hsc, h_hsc, channelBarHeight);
211211
}
@@ -331,7 +331,7 @@ class W_timeSeries extends Widget {
331331
}
332332

333333
if (currentBoard instanceof ADS1299SettingsBoard) {
334-
hwSettingsButton.setPosition(x0 + 80, (int)(y0 + navHeight + 3));
334+
hwSettingsButton.setPosition(x0 + 80, (int)(y0 + navHeight + 1));
335335
}
336336

337337
}

0 commit comments

Comments
 (0)