Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed DRO colors to have more contrast making them easier to read #2369

Merged
merged 1 commit into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 22 additions & 7 deletions ugs-core/src/com/willwinder/universalgcodesender/Utils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2012-2018 Will Winder
Copyright 2012-2023 Will Winder

This file is part of Universal Gcode Sender (UGS).

Expand Down Expand Up @@ -28,7 +28,8 @@ This file is part of Universal Gcode Sender (UGS).
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.Color;
import java.awt.EventQueue;
import java.text.DecimalFormat;
import java.text.NumberFormat;

Expand All @@ -39,17 +40,17 @@ This file is part of Universal Gcode Sender (UGS).
*/
public class Utils {

public static NumberFormat formatter = new DecimalFormat("#.###", Localization.dfs);
public static final NumberFormat formatter = new DecimalFormat("#.###", Localization.dfs);

public static String formattedMillis(long millis) {
String format = String.format("%%0%dd", 2);
long elapsedTime = millis / 1000;
String format = String.format("%%0%dd", 2);
long elapsedTime = millis / 1000;
String hours = String.format(format, elapsedTime / 3600);
elapsedTime %= 3600;

String minutes = String.format(format, elapsedTime / 60);
elapsedTime %= 60;

String seconds = String.format(format, elapsedTime);


Expand Down Expand Up @@ -107,6 +108,20 @@ public static Color getControllerStateBackgroundColor(ControllerState state) {
return ThemeColors.GREY;
}

/**
* Returns a foreground color suited for a specific state
*
* @param state the state
* @return a background color
*/
public static Color getControllerStateForegroundColor(ControllerState state) {
if (state == ControllerState.ALARM) {
return Color.WHITE;
}

return ThemeColors.VERY_DARK_GREY;
}


public static void checkNightlyBuild(Settings settings) {
if (settings.isShowNightlyWarning() && Version.isNightlyBuild()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2016-2017 Will Winder
Copyright 2016-2023 Will Winder

This file is part of Universal Gcode Sender (UGS).

Expand All @@ -26,7 +26,8 @@ public class ThemeColors {
public static final Color VERY_DARK_GREY = new Color(42, 44, 45);
public static final Color DARK_GREY = new Color(60, 63, 65);
public static final Color GREY = new Color(128, 128, 128);
public static final Color LIGHT_GREY = new Color(201, 201, 201);;
public static final Color LIGHT_GREY = new Color(201, 201, 201);

public static final Color ORANGE = new Color(255, 151, 11);
public static final Color GREEN = new Color(0, 201, 0);
public static final Color LIGHT_GREEN = new Color(106, 194, 89);
Expand All @@ -35,7 +36,7 @@ public class ThemeColors {

public static final Color DARK_BLUE_GREY = new Color(44, 65, 70);
public static final Color MED_BLUE_GREY = new Color(47, 93, 103);
public static final Color LIGHT_BLUE_GREY = new Color(65, 129, 143);
public static final Color LIGHT_BLUE_GREY = new Color(79, 158, 176);

public static final Color RED = new Color(240, 0, 0);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
Copyright 2023 Will Winder

This file is part of Universal Gcode Sender (UGS).

UGS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

UGS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with UGS. If not, see <http://www.gnu.org/licenses/>.
*/
package com.willwinder.ugs.nbp.dro.panels;

import com.willwinder.universalgcodesender.uielements.helpers.ThemeColors;
Expand Down Expand Up @@ -52,7 +70,7 @@ private void updateColor() {
Color color = isEnabled ? ThemeColors.LIGHT_BLUE : ThemeColors.LIGHT_BLUE_GREY;

if (highlighted) {
color = ThemeColors.RED;
color = ThemeColors.GREEN;
}

setForeground(color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,9 @@ private void updatePinStates(ControllerStatus status) {

private void updateStatePanel(ControllerState state) {
String text = Utils.getControllerStateText(state);
Color background = Utils.getControllerStateBackgroundColor(state);

this.activeStatePanel.setBackground(background);
this.activeStateValueLabel.setText(text.toUpperCase());
activeStatePanel.setBackground(Utils.getControllerStateBackgroundColor(state));
activeStateValueLabel.setForeground(Utils.getControllerStateForegroundColor(state));
activeStateValueLabel.setText(text.toUpperCase());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright 2021 Will Winder
Copyright 2021-2023 Will Winder

This file is part of Universal Gcode Sender (UGS).

Expand All @@ -25,7 +25,6 @@ This file is part of Universal Gcode Sender (UGS).
import com.willwinder.universalgcodesender.model.UGSEvent;
import com.willwinder.universalgcodesender.model.events.ControllerStateEvent;
import com.willwinder.universalgcodesender.uielements.components.RoundedBorder;
import com.willwinder.universalgcodesender.uielements.helpers.ThemeColors;
import org.openide.awt.StatusLineElementProvider;
import org.openide.util.lookup.ServiceProvider;

Expand Down Expand Up @@ -64,7 +63,7 @@ public void UGSEvent(UGSEvent ugsEvent) {

private void updateLabel() {
label.setText(Utils.getControllerStateText(backend.getControllerState()));
label.setForeground(ThemeColors.VERY_DARK_GREY);
label.setForeground(Utils.getControllerStateForegroundColor(backend.getControllerState()));
label.setBackground(Utils.getControllerStateBackgroundColor(backend.getControllerState()));
}
}