From 2a0cc111cfcd06d2e3463134157bf4949bc69dc3 Mon Sep 17 00:00:00 2001 From: Joacim Breiler Date: Sun, 19 Nov 2023 12:24:59 +0100 Subject: [PATCH] Changed DRO colors to have more contrast making them easier to read (#2369) --- .../universalgcodesender/Utils.java | 29 ++++++++++++++----- .../uielements/helpers/ThemeColors.java | 7 +++-- .../ugs/nbp/dro/panels/CoordinateLabel.java | 20 ++++++++++++- .../nbp/dro/panels/MachineStatusPanel.java | 7 ++--- .../ControllerStatusLineService.java | 5 ++-- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/ugs-core/src/com/willwinder/universalgcodesender/Utils.java b/ugs-core/src/com/willwinder/universalgcodesender/Utils.java index 55a0770891..fbc4ca07bf 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/Utils.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/Utils.java @@ -1,5 +1,5 @@ /* - Copyright 2012-2018 Will Winder + Copyright 2012-2023 Will Winder This file is part of Universal Gcode Sender (UGS). @@ -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; @@ -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); @@ -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()) { diff --git a/ugs-core/src/com/willwinder/universalgcodesender/uielements/helpers/ThemeColors.java b/ugs-core/src/com/willwinder/universalgcodesender/uielements/helpers/ThemeColors.java index 0b89807c87..be67e0d734 100644 --- a/ugs-core/src/com/willwinder/universalgcodesender/uielements/helpers/ThemeColors.java +++ b/ugs-core/src/com/willwinder/universalgcodesender/uielements/helpers/ThemeColors.java @@ -1,5 +1,5 @@ /* - Copyright 2016-2017 Will Winder + Copyright 2016-2023 Will Winder This file is part of Universal Gcode Sender (UGS). @@ -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); @@ -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); diff --git a/ugs-platform/ugs-platform-plugin-dro/src/main/java/com/willwinder/ugs/nbp/dro/panels/CoordinateLabel.java b/ugs-platform/ugs-platform-plugin-dro/src/main/java/com/willwinder/ugs/nbp/dro/panels/CoordinateLabel.java index f503f94aab..95b0272603 100644 --- a/ugs-platform/ugs-platform-plugin-dro/src/main/java/com/willwinder/ugs/nbp/dro/panels/CoordinateLabel.java +++ b/ugs-platform/ugs-platform-plugin-dro/src/main/java/com/willwinder/ugs/nbp/dro/panels/CoordinateLabel.java @@ -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 . + */ package com.willwinder.ugs.nbp.dro.panels; import com.willwinder.universalgcodesender.uielements.helpers.ThemeColors; @@ -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); diff --git a/ugs-platform/ugs-platform-plugin-dro/src/main/java/com/willwinder/ugs/nbp/dro/panels/MachineStatusPanel.java b/ugs-platform/ugs-platform-plugin-dro/src/main/java/com/willwinder/ugs/nbp/dro/panels/MachineStatusPanel.java index c9026b92d5..ce7130ef60 100644 --- a/ugs-platform/ugs-platform-plugin-dro/src/main/java/com/willwinder/ugs/nbp/dro/panels/MachineStatusPanel.java +++ b/ugs-platform/ugs-platform-plugin-dro/src/main/java/com/willwinder/ugs/nbp/dro/panels/MachineStatusPanel.java @@ -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 diff --git a/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/statusline/ControllerStatusLineService.java b/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/statusline/ControllerStatusLineService.java index 4485c41e91..7a4ae3ea2b 100644 --- a/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/statusline/ControllerStatusLineService.java +++ b/ugs-platform/ugs-platform-ugscore/src/main/java/com/willwinder/ugs/nbp/core/statusline/ControllerStatusLineService.java @@ -1,5 +1,5 @@ /* - Copyright 2021 Will Winder + Copyright 2021-2023 Will Winder This file is part of Universal Gcode Sender (UGS). @@ -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; @@ -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())); } }