mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-17 11:07:35 -05:00
#2559 User Preference setting to use complementary alias colors when dark mode causes the default alias color (black) to have no contrast on background (#2565)
Co-authored-by: denny <dennis.sheirer@gmail.com>
This commit is contained in:
@@ -74,6 +74,7 @@ public class ThemeManager
|
||||
private volatile UserPreferences mUserPreferences;
|
||||
private volatile Theme mCurrentTheme = Theme.LIGHT;
|
||||
private volatile double mCurrentGuiScale = 1.0d;
|
||||
private volatile boolean mComplementaryAliasColors = false;
|
||||
/** Data URL of the currently-active per-theme accent stylesheet, or null. */
|
||||
private volatile String mAccentStylesheetUrl;
|
||||
|
||||
@@ -109,6 +110,7 @@ public class ThemeManager
|
||||
mUserPreferences = userPreferences;
|
||||
mCurrentTheme = userPreferences.getApplicationPreference().getTheme();
|
||||
mCurrentGuiScale = userPreferences.getApplicationPreference().getGuiScale();
|
||||
mComplementaryAliasColors = userPreferences.getApplicationPreference().isComplementaryAliasColors();
|
||||
|
||||
if(firstBind)
|
||||
{
|
||||
@@ -225,12 +227,12 @@ public class ThemeManager
|
||||
* Provides the color to render user-selected content (e.g. an alias) against a background in the current theme.
|
||||
* @param color selected by the user.
|
||||
* @param background that the color is rendered against.
|
||||
* @return the color, or a readable alternative when dark mode is active and the color lacks contrast with the
|
||||
* background.
|
||||
* @return the color, or a readable alternative when the user enabled complementary alias colors, dark mode is
|
||||
* active and the color lacks contrast with the background.
|
||||
*/
|
||||
public Color getReadableColor(Color color, Color background)
|
||||
{
|
||||
return isDarkMode() ? ColorContrast.getReadable(color, background) : color;
|
||||
return mComplementaryAliasColors && isDarkMode() ? ColorContrast.getReadable(color, background) : color;
|
||||
}
|
||||
|
||||
public void register(Scene scene)
|
||||
@@ -288,6 +290,20 @@ public class ThemeManager
|
||||
|
||||
Theme updated = mUserPreferences.getApplicationPreference().getTheme();
|
||||
double updatedScale = mUserPreferences.getApplicationPreference().getGuiScale();
|
||||
boolean updatedComplementary = mUserPreferences.getApplicationPreference().isComplementaryAliasColors();
|
||||
|
||||
if(updatedComplementary != mComplementaryAliasColors)
|
||||
{
|
||||
mComplementaryAliasColors = updatedComplementary;
|
||||
|
||||
//The Swing table renderers look up the alias color each time they paint.
|
||||
EventQueue.invokeLater(() -> {
|
||||
for(Window window: Window.getWindows())
|
||||
{
|
||||
window.repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if(updated == mCurrentTheme && Math.abs(updatedScale - mCurrentGuiScale) < 1e-6)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user