Skip to content

Commit 798505a

Browse files
committed
Implement Color Pop/Fade for HelpWidget at the bottom of the GUI
1 parent b65552a commit 798505a

2 files changed

Lines changed: 45 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* Minor UI/UX improvements to Spectrogram widget to increase clarity for all users
2121
* Add slower options for FFT data smoothing
2222
* Fix certain Textfield and TextArea fonts not drawing correctly on some Macs
23+
* Update and enforce style guide throughout the GUI in preparation for multiple themes
24+
* Improve UI/UX for HelpWidget at the bottom of the GUI to make it more noticeable
2325

2426
# v5.0.9
2527

OpenBCI_GUI/Debugging.pde

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ void verbosePrint(String _string) {
4747

4848
//this class is used to create the help widget that provides system feedback in response to interactivity
4949
//it is intended to serve as a pseudo-console, allowing us to print useful information to the interface as opposed to an IDE console
50-
5150
class HelpWidget {
5251

5352
public float x, y, w, h;
@@ -56,6 +55,9 @@ class HelpWidget {
5655
//current text shown in help widget, based on most recent command
5756
String currentOutput = "Learn how to use this application and more at docs.openbci.com";
5857
OutputLevel curOutputLevel = OutputLevel.INFO;
58+
private int colorFadeCounter;
59+
private int colorFadeTimeMillis = 1000;
60+
private boolean outputWasTriggered = false;
5961

6062
HelpWidget(float _xPos, float _yPos, float _width, float _height) {
6163
x = _xPos;
@@ -99,19 +101,25 @@ class HelpWidget {
99101

100102
//draw bg of text field of widget
101103
strokeWeight(1);
102-
stroke(getBackgroundColor());
103-
// fill(200);
104-
// fill(255);
105-
fill(getBackgroundColor());
106-
// fill(57,128,204);
104+
int saturationFadeValue = 0;
105+
if (outputWasTriggered) {
106+
int timeDelta = millis() - colorFadeCounter;
107+
saturationFadeValue = (int)map(timeDelta, 0, colorFadeTimeMillis, 100, 0);
108+
if (timeDelta > colorFadeTimeMillis) {
109+
outputWasTriggered = false;
110+
}
111+
}
112+
// Color mode is switched to Hue, Saturation, Brightness in the next line
113+
color c = getBackgroundColor(saturationFadeValue);
114+
stroke(c);
115+
fill(c);
107116
rect(x + padding, height-h + padding, width - padding*2, h - padding *2);
108117

118+
// Revert color mode back to standard RGB here
119+
colorMode(RGB, 255, 255, 255);
109120
textFont(p4);
110121
textSize(14);
111-
// fill(OPENBCI_DARKBLUE);
112122
fill(getTextColor());
113-
// fill(57,128,204);
114-
// fill(OPENBCI_BLUE);
115123
textAlign(LEFT, TOP);
116124
text(currentOutput, padding*2, height - h + padding);
117125
}
@@ -135,19 +143,37 @@ class HelpWidget {
135143
}
136144
}
137145

138-
private color getBackgroundColor() {
146+
private color getBackgroundColor(int fadeVal) {
147+
//Colors in this method are calculated using Hue, Saturation, Brightness
148+
colorMode(HSB, 360, 100, 100);
149+
int sat = 0;
150+
int maxSat = 75;
139151
switch (curOutputLevel) {
140152
case INFO:
141-
return #BDE5F8;
153+
//base color - #BDE5F8;
154+
sat = 25;
155+
sat = (int)map(fadeVal, 0, 100, sat, maxSat);
156+
return color(199, sat, 97);
142157
case SUCCESS:
143-
return #DFF2BF;
158+
//base color - #DFF2BF;
159+
sat = 25;
160+
sat = (int)map(fadeVal, 0, 100, sat, maxSat);
161+
return color(106, sat, 95);
144162
case WARN:
145-
return #FEEFB3;
163+
//base color - #FEEFB3;
164+
sat = 30;
165+
sat = (int)map(fadeVal, 0, 100, sat, maxSat);
166+
return color(48, sat, 100);
146167
case ERROR:
147-
return #FFD2D2;
168+
//base color - #FFD2D2;
169+
sat = 18;
170+
sat = (int)map(fadeVal, 0, 100, sat, maxSat);
171+
println("ERROR");
172+
return color(0, sat, 100);
148173
case DEFAULT:
149174
default:
150-
return color(255);
175+
colorMode(RGB, 255, 255, 255);
176+
return WHITE;
151177
}
152178
}
153179

@@ -157,6 +183,8 @@ class HelpWidget {
157183

158184
String outputWithPrefix = "[" + level.name() + "]: " + _output;
159185
println(outputWithPrefix); // add this output to the console log
186+
outputWasTriggered = true;
187+
colorFadeCounter = millis();
160188
}
161189
};
162190

0 commit comments

Comments
 (0)