Skip to content
Open
9 changes: 9 additions & 0 deletions OpenBCI_GUI/AuditoryNeurofeedback.pde
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,14 @@ class AuditoryNeurofeedback {
});
modeButton.setDescription("Change Auditory Feedback mode. Use the Metric to control all notes at once, or use Band Powers to control certain notes of the chord.");
}

public void updateColors() {
color btnBg = style.isDarkMode() ? style.getButtonColor() : colorNotPressed;
color btnText = style.isDarkMode() ? style.getButtonTextColor() : OPENBCI_DARKBLUE;
startStopButton.setColorBackground(btnBg);
startStopButton.getCaptionLabel().setColor(btnText);
modeButton.setColorBackground(btnBg);
modeButton.getCaptionLabel().setColor(btnText);
}

}
4 changes: 2 additions & 2 deletions OpenBCI_GUI/BoardCyton.pde
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ implements ImpedanceSettingsBoard, AccelerometerCapableBoard, AnalogCapableBoard

currentADS1299Settings.values.gain[channel] = Gain.X1;
currentADS1299Settings.values.inputType[channel] = InputType.NORMAL;
currentADS1299Settings.values.bias[channel] = Bias.INCLUDE;
currentADS1299Settings.values.srb2[channel] = Srb2.DISCONNECT;
currentADS1299Settings.values.bias[channel] = Bias.NO_INCLUDE;
currentADS1299Settings.values.srb2[channel] = Srb2.CONNECT;
currentADS1299Settings.values.srb1[channel] = Srb1.DISCONNECT;

fullCommand.append(currentADS1299Settings.getValuesString(channel, currentADS1299Settings.values));
Expand Down
4 changes: 2 additions & 2 deletions OpenBCI_GUI/ChannelSelect.pde
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ChannelSelect {
if (channelSelectHover) {
fill(OPENBCI_BLUE);
} else {
fill(OPENBCI_DARKBLUE);
fill(style.isDarkMode() ? style.getTextColor() : OPENBCI_DARKBLUE);
}
textFont(p5, 12);

Expand Down Expand Up @@ -100,7 +100,7 @@ class ChannelSelect {

public void drawGrayBackground(int _x, int _y, int _w, int _h) {
pushStyle();
fill(200);
fill(style.isDarkMode() ? style.getBoxColor() : 200);
rect(_x, _y, _w, _h);
popStyle();
}
Expand Down
6 changes: 3 additions & 3 deletions OpenBCI_GUI/ControlPanel.pde
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ class ControlPanel {
//draw the box that tells you to stop the system in order to edit control settings
if (drawStopInstructions) {
pushStyle();
fill(boxColor);
fill(style.getBoxColor());
strokeWeight(1);
stroke(boxStrokeColor);
stroke(style.getBoxStrokeColor());
rect(x, y, w, dataSourceBox.h); //draw background of box
String stopInstructions = "Press the \"STOP SESSION\" button to change your data source or edit system settings.";
textAlign(CENTER, TOP);
textFont(p4, 14);
fill(OPENBCI_DARKBLUE);
fill(style.getTextColor());
text(stopInstructions, x + globalPadding*2, y + globalPadding*3, w - globalPadding*4, dataSourceBox.h - globalPadding*4);
popStyle();
}
Expand Down
78 changes: 35 additions & 43 deletions OpenBCI_GUI/Debugging.pde
Original file line number Diff line number Diff line change
Expand Up @@ -75,56 +75,48 @@ class HelpWidget {

pushStyle();

if (colorScheme == COLOR_SCHEME_DEFAULT) {
// draw background of widget
stroke(OPENBCI_DARKBLUE);
fill(255);
rect(-1, height-h, width+2, h);
noStroke();

//draw bg of text field of widget
strokeWeight(1);
stroke(color(0, 5, 11));
fill(color(0, 5, 11));
rect(x + padding, height-h + padding, width - padding*2, h - padding *2);

textFont(p4);
textSize(14);
fill(255);
textAlign(LEFT, TOP);
text(currentOutput, padding*2, height - h + padding);
} else if (colorScheme == COLOR_SCHEME_ALTERNATIVE_A){
// draw background of widget
stroke(OPENBCI_DARKBLUE);
fill(OPENBCI_BLUE);
rect(-1, height-h, width+2, h);
noStroke();

//draw bg of text field of widget
strokeWeight(1);
int saturationFadeValue = 0;
if (outputWasTriggered) {
int timeDelta = millis() - colorFadeCounter;
saturationFadeValue = (int)map(timeDelta, 0, colorFadeTimeMillis, 100, 0);
if (timeDelta > colorFadeTimeMillis) {
outputWasTriggered = false;
}
// Use the global style manager for theme-aware colors
color helpBg = style.getHelpWidgetBackground();
color helpTextBg = style.getHelpWidgetTextBackground();
color helpStroke = style.getBoxStrokeColor();

// draw background of widget
stroke(helpStroke);
fill(helpBg);
rect(-1, height-h, width+2, h);
noStroke();

//draw bg of text field of widget
strokeWeight(1);
int saturationFadeValue = 0;
if (outputWasTriggered) {
int timeDelta = millis() - colorFadeCounter;
saturationFadeValue = (int)map(timeDelta, 0, colorFadeTimeMillis, 100, 0);
if (timeDelta > colorFadeTimeMillis) {
outputWasTriggered = false;
}
}

// For dark mode, use solid colors; for other modes, use HSB fade effect
if (style.isDarkMode()) {
stroke(helpTextBg);
fill(helpTextBg);
} else {
//Colors in this method are calculated using Hue, Saturation, Brightness
colorMode(HSB, 360, 100, 100);
color c = getBackgroundColor(saturationFadeValue);
stroke(c);
fill(c);
rect(x + padding, height-h + padding, width - padding*2, h - padding *2);

// Revert color mode back to standard RGB here
colorMode(RGB, 255, 255, 255);
textFont(p4);
textSize(14);
fill(getTextColor());
textAlign(LEFT, TOP);
text(currentOutput, padding*2, height - h + padding);
}
rect(x + padding, height-h + padding, width - padding*2, h - padding *2);

// Revert color mode back to standard RGB here
colorMode(RGB, 255, 255, 255);
textFont(p4);
textSize(14);
fill(style.isDarkMode() ? style.getTextColor() : getTextColor());
textAlign(LEFT, TOP);
text(currentOutput, padding*2, height - h + padding);

popStyle();
}
Expand Down
17 changes: 16 additions & 1 deletion OpenBCI_GUI/FilterUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class FilterUIPopup extends PApplet implements Runnable {

private color headerColor = OPENBCI_BLUE;
private color buttonColor = OPENBCI_BLUE;
// backgroundColor will be set dynamically based on theme
private color backgroundColor = GREY_235;
private color textLabelColor = color(102);

private ControlP5 cp5;

Expand Down Expand Up @@ -137,12 +139,25 @@ class FilterUIPopup extends PApplet implements Runnable {
frame.toFront();
frame.requestFocus();

// Set theme-aware colors
updateThemeColors();

cp5 = new ControlP5(this);
cp5.setGraphics(this, 0, 0);
cp5.setAutoDraw(false);

createAllCp5Objects();
}

private void updateThemeColors() {
if (style.isDarkMode()) {
backgroundColor = style.getBoxColor();
textLabelColor = style.getTextColor();
} else {
backgroundColor = GREY_235;
textLabelColor = color(102);
}
}

@Override
void draw() {
Expand Down Expand Up @@ -220,7 +235,7 @@ class FilterUIPopup extends PApplet implements Runnable {
text("Notch", headerObjX[2], HEADER_OBJ_Y, HEADER_OBJ_WIDTH, uiObjectHeight);
// Column labels
textAlign(CENTER, TOP);
fill(102);
fill(textLabelColor);
text("Channel", columnObjX[0], HEADER_HEIGHT + SM_SPACER, TEXTFIELD_WIDTH, HEADER_HEIGHT);
String firstColumnHeader = "";
String secondColumnHeader = "";
Expand Down
11 changes: 8 additions & 3 deletions OpenBCI_GUI/Grid.pde
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ class Grid {
strings = new String[numRows][numCols];
textColors = new color[numRows][numCols];

color defaultTextColor = OPENBCI_DARKBLUE;
updateDefaultTextColor();
}

// Update default text color based on theme
public void updateDefaultTextColor() {
color defaultTextColor = style.isDarkMode() ? style.getTextColor() : OPENBCI_DARKBLUE;
for (color[] row: textColors) {
Arrays.fill(row, defaultTextColor);
}
Expand All @@ -41,7 +46,7 @@ class Grid {
public void draw() {
pushStyle();
textAlign(LEFT);
stroke(OPENBCI_DARKBLUE);
stroke(style.isDarkMode() ? style.getGraphGridColor() : OPENBCI_DARKBLUE);
textFont(tableFont, tableFontSize);

if (drawTableInnerLines) {
Expand Down Expand Up @@ -69,7 +74,7 @@ class Grid {

if (drawTableBorder) {
noFill();
stroke(OPENBCI_DARKBLUE);
stroke(style.isDarkMode() ? style.getGraphGridColor() : OPENBCI_DARKBLUE);
rect(x, y, w, rowOffset[numRows - 1]);
}

Expand Down
25 changes: 25 additions & 0 deletions OpenBCI_GUI/GuiSettings.pde
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public class GuiSettingsValues {
public boolean autoStartDataStream = false;
public boolean autoStartNetworkStream = false;
public boolean autoLoadSessionSettings = false;
public ThemeType themeType = ThemeType.DEFAULT;

public GuiSettingsValues() {
}
Expand Down Expand Up @@ -87,6 +88,8 @@ class GuiSettings {
saveToFile();
}

// Apply persisted theme
applyThemeFromSettings();
return true;

} catch (IOException e) {
Expand Down Expand Up @@ -168,6 +171,7 @@ class GuiSettings {
topNav.configSelector.toggleAutoStartDataStreamFrontEnd(getAutoStartDataStream());
topNav.configSelector.toggleAutoStartNetworkStreamFrontEnd(getAutoStartNetworkStream());
topNav.configSelector.toggleAutoLoadSessionSettingsFrontEnd(getAutoLoadSessionSettings());
applyThemeFromSettings();
}

public void setExpertMode(ExpertModeEnum val) {
Expand Down Expand Up @@ -241,4 +245,25 @@ class GuiSettings {
values.autoLoadSessionSettings = b;
saveToFile();
}

public void setThemeType(ThemeType themeType) {
values.themeType = themeType;
saveToFile();
println("OpenBCI_GUI::Settings: Theme saved as " + themeType.getString());
}

public ThemeType getThemeType() {
return values.themeType;
}

private void applyThemeFromSettings() {
if (style != null && values.themeType != null) {
style.setTheme(values.themeType);
// If widgets are initialized, notify them of the theme
if (widgetManager != null) {
style.notifyThemeChange();
}
println("OpenBCI_GUI::Settings: Applied persisted theme: " + values.themeType.getString());
}
}
}
12 changes: 3 additions & 9 deletions OpenBCI_GUI/Interactivity.pde
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,9 @@ void parseKey(char val) {
drawContainers = !drawContainers;
return;
case '{':
/*
if(colorScheme == COLOR_SCHEME_DEFAULT){
colorScheme = COLOR_SCHEME_ALTERNATIVE_A;
} else if(colorScheme == COLOR_SCHEME_ALTERNATIVE_A) {
colorScheme = COLOR_SCHEME_DEFAULT;
}
*/
//topNav.updateNavButtonsBasedOnColorScheme();
output("New Dark color scheme coming soon!");
// Cycle through themes: Default -> Dark -> Light -> Default...
style.cycleTheme();
output("Theme changed to: " + style.getThemeName());
return;

//deactivate channels 1-4
Expand Down
5 changes: 5 additions & 0 deletions OpenBCI_GUI/OpenBCI_GUI.pde
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,11 @@ void setup() {

directoryManager = new DirectoryManager();

// Initialize the global style/theme manager
// This must be done early so all UI components can access theme colors
style = new Style();
println("Style: Initialized with " + style.getThemeName() + " theme");

// redirect all output to a custom stream that will intercept all prints
// write them to file and display them in the GUI's console window
outputStream = new CustomOutputStream(System.out);
Expand Down
Loading