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

8271923: [macos] the text color on the selected disabled tabbed pane button remains white making text unreadable #5217

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public Object createValue(UIDefaults defaultsTable) {
// Contrast tab UI colors

final ColorUIResource selectedTabTitlePressedColor = new ColorUIResource(240, 240, 240);
final ColorUIResource selectedTabTitleDisabledColor = new ColorUIResource(new Color(1, 1, 1, 0.55f));
final ColorUIResource selectedTabTitleDisabledColor = black;
final ColorUIResource selectedTabTitleNormalColor = white;
final Color selectedControlTextColor = AquaImageFactory.getSelectedControlColorUIResource();
final ColorUIResource selectedTabTitleShadowDisabledColor = new ColorUIResource(new Color(0, 0, 0, 0.25f));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -38,9 +38,12 @@

import sun.swing.SwingUtilities2;

import apple.laf.JRSUIUtils;
import apple.laf.JRSUIConstants.*;

public class AquaTabbedPaneContrastUI extends AquaTabbedPaneUI {
private static boolean isFrameActive = false;

public static ComponentUI createUI(final JComponent c) {
return new AquaTabbedPaneContrastUI();
}
Expand Down Expand Up @@ -77,7 +80,7 @@ protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetri
protected static Color getSelectedTabTitleColor(boolean enabled, boolean pressed) {
if (enabled && pressed) {
return UIManager.getColor("TabbedPane.selectedTabTitlePressedColor");
} else if (!enabled) {
} else if (!enabled || (!JRSUIUtils.isMacOSXBigSurOrAbove() && !isFrameActive)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we enter this condition in BigSur when SwingSet2 is not focused?

If yes, Will we not see difference in color between "new ColorUIResource(new Color(1, 1, 1, 0.55f))" and updated "black" color ?

If no, In BigSur from where black color is picked for selectedTabTitleDisabledColor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In BigSur, there is no difference between if frame is focused or non-focused. It is always black on white (BigSur tabbedpane text design is different than Catalina).......it's not selectedTabTitleDisabledColor which governs this but selectedTabTitleNormalColor...There the text is governed by selectedControlTextColor via this code...

"TabbedPane.selectedTabTitleNormalColor", JRSUIUtils.isMacOSXBigSurOrAbove() ? selectedControlTextColor : selectedTabTitleNormalColor,

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does inactive frame lead to "enabled" having "false" value? What is the difference between "enabled" flag and "frameActive" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

inactive frame is non-focused frame...
enabled false is tabbedpane is not enabled...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me elaborate my question, it is still not clear to me.

If i click on tabbedpane(enabled -> true), then move focus out of this Frame(SwingSet2) will that make enabled-> false? Is there any hierarchical relation between enabled & frameActive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it will not. To make enabled false, you need to call tabPane.setEnabled(false);
frameActive is to decide if frame is focused or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification

return UIManager.getColor("TabbedPane.selectedTabTitleDisabledColor");
} else {
return UIManager.getColor("TabbedPane.selectedTabTitleNormalColor");
Expand All @@ -101,6 +104,7 @@ protected boolean shouldRepaintSelectedTabOnMouseDown() {
}

protected State getState(final int index, final boolean frameActive, final boolean isSelected) {
isFrameActive = frameActive;;
if (!frameActive) return State.INACTIVE;
if (!tabPane.isEnabled()) return State.DISABLED;
if (pressedTab == index) return State.PRESSED;
Expand Down