Skip to content

Commit 8b64f40

Browse files
committed
Fix vertical alignment of pop-up text and buttons #1157
1 parent ecd6985 commit 8b64f40

2 files changed

Lines changed: 15 additions & 36 deletions

File tree

OpenBCI_GUI/EmgSettingsUI.pde

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
////////////////////////////////////////////////////////////
2-
// EmgSettingsUI.pde //
2+
// EmgSettingsUI.pde //
33
// Display the Emg Settings UI as a popup //
4+
// Note: This window is never resized. //
45
// //
56
////////////////////////////////////////////////////////////
67

@@ -14,7 +15,7 @@ class EmgSettingsUI extends PApplet implements Runnable {
1415
private ControlP5 emgCp5;
1516
private int x, y, w, h;
1617
private final int HEADER_HEIGHT = 55;
17-
private final int FOOTER_PADDING = 80;
18+
private final int FOOTER_PADDING = 90;
1819
private final int PADDING_3 = 3;
1920
private final int PADDING_12 = 12;
2021
private final int NUM_CONTROL_BUTTONS = 3;
@@ -29,7 +30,7 @@ class EmgSettingsUI extends PApplet implements Runnable {
2930
private final int NUM_FOOTER_OBJECTS = 3;
3031
private final int FOOTER_OBJECT_WIDTH = 45;
3132
private final int FOOTER_OBJECT_HEIGHT = 26;
32-
private int footerObjY = 0;
33+
private int footerObjY;
3334
private int[] footerObjX = new int[NUM_FOOTER_OBJECTS];
3435

3536
private final color HEADER_COLOR = OPENBCI_BLUE;
@@ -142,28 +143,6 @@ class EmgSettingsUI extends PApplet implements Runnable {
142143
emgCp5.draw();
143144
}
144145

145-
private void screenResized() {
146-
x = 0;
147-
y = 0;
148-
w = width;
149-
h = height;
150-
151-
emgCp5.setGraphics(ourApplet, 0, 0);
152-
153-
int colWidth = (width / NUM_COLUMNS);
154-
int colOffset = colWidth / 2;
155-
int labelY = y + HEADER_HEIGHT / 2;
156-
channelColumnLabel.setPosition(x + colOffset, labelY);
157-
windowLabel.setPosition(x + colOffset + colWidth, labelY);
158-
uvLimitLabel.setPosition(x + colOffset + colWidth*2, labelY);
159-
creepIncLabel.setPosition(x + colOffset + colWidth*3, labelY);
160-
creepDecLabel.setPosition(x + colOffset + colWidth*4, labelY);
161-
minDeltaUvLabel.setPosition(x + colOffset + colWidth*5, labelY);
162-
lowLimitLabel.setPosition(x + colOffset + colWidth*6, labelY);
163-
164-
resizeDropdowns();
165-
}
166-
167146
private void scene() {
168147
// Draw background
169148
background(BACKGROUND_COLOR);
@@ -229,15 +208,15 @@ class EmgSettingsUI extends PApplet implements Runnable {
229208

230209
for (int i = 0; i < channelCount; i++) {
231210
String channelLabel = channelCount > channelLabels.length ? "Channel " + Integer.toString(i + 1) : channelLabels[i];
232-
text(channelLabel, x + colOffset, dropdownYPositions[i] + (DROPDOWN_HEIGHT / 2));
211+
text(channelLabel, x + colOffset, dropdownYPositions[i] + (DROPDOWN_HEIGHT / 2) - 2);
233212
}
234213

235214
popStyle();
236215
}
237216

238217
private void resizeDropdowns() {
239218
dropdownWidth = int((w - (DROPDOWN_SPACER * (NUM_COLUMNS + 1))) / NUM_COLUMNS);
240-
final int MAX_HEIGHT_ITEMS = channelCount == 4 ? 8 : 5;
219+
final int MAX_HEIGHT_ITEMS = 6;
241220

242221
for (int i = 0; i < channelCount; i++) {
243222
int dropdownX = x + DROPDOWN_SPACER * 2 + dropdownWidth;
@@ -270,7 +249,7 @@ class EmgSettingsUI extends PApplet implements Runnable {
270249
}
271250

272251
private void createAllUIObjects() {
273-
footerObjY = y + h - FOOTER_PADDING + PADDING_3;
252+
footerObjY = y + h - FOOTER_PADDING/2 - FOOTER_OBJECT_HEIGHT/2;
274253
int middle = x + w / 2;
275254
int halfObjWidth = FOOTER_OBJECT_WIDTH / 2;
276255
footerObjX[0] = middle - halfObjWidth - PADDING_12 - FOOTER_OBJECT_WIDTH;
@@ -291,13 +270,13 @@ class EmgSettingsUI extends PApplet implements Runnable {
291270
int colWidth = (w / NUM_COLUMNS);
292271
int colOffset = colWidth / 2;
293272
int labelY = y + HEADER_HEIGHT / 2;
294-
channelColumnLabel = new TextBox("Channel", x + colOffset, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
295-
windowLabel = new TextBox("Window", x + colOffset + colWidth, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
296-
uvLimitLabel = new TextBox("uV Limit", x + colOffset + colWidth*2, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
297-
creepIncLabel = new TextBox("Creep +", x + colOffset + colWidth*3, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
298-
creepDecLabel = new TextBox("Creep -", x + colOffset + colWidth*4, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
299-
minDeltaUvLabel = new TextBox("Min \u0394uV", x + colOffset + colWidth*5, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
300-
lowLimitLabel = new TextBox("Low Limit", x + colOffset + colWidth*6, labelY, labelTxt, labelBG, 12, h3, CENTER, TOP);
273+
channelColumnLabel = new TextBox("Channel", x + colOffset, labelY, labelTxt, labelBG, 12, h3, CENTER, CENTER);
274+
windowLabel = new TextBox("Window", x + colOffset + colWidth, labelY, labelTxt, labelBG, 12, h3, CENTER, CENTER);
275+
uvLimitLabel = new TextBox("uV Limit", x + colOffset + colWidth*2, labelY, labelTxt, labelBG, 12, h3, CENTER, CENTER);
276+
creepIncLabel = new TextBox("Creep +", x + colOffset + colWidth*3, labelY, labelTxt, labelBG, 12, h3, CENTER, CENTER);
277+
creepDecLabel = new TextBox("Creep -", x + colOffset + colWidth*4, labelY, labelTxt, labelBG, 12, h3, CENTER, CENTER);
278+
minDeltaUvLabel = new TextBox("Min \u0394uV", x + colOffset + colWidth*5, labelY, labelTxt, labelBG, 12, h3, CENTER, CENTER);
279+
lowLimitLabel = new TextBox("Low Limit", x + colOffset + colWidth*6, labelY, labelTxt, labelBG, 12, h3, CENTER, CENTER);
301280

302281
createAllDropdowns();
303282
}

OpenBCI_GUI/PopupMessage.pde

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class PopupMessage extends PApplet implements Runnable {
106106
textFont(p0, 24);
107107
fill(WHITE);
108108
textAlign(LEFT, CENTER);
109-
text(headerMessage, (width - w)/2 + padding, (height - h)/2, w, headerHeight);
109+
text(headerMessage, (width - w)/2 + padding, headerHeight/2);
110110

111111
//draw message
112112
textFont(p3, 16);

0 commit comments

Comments
 (0)