This is an automated email from the ASF dual-hosted git repository. neilcsmith pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push: new d6dcd69e07 Alter FlatLaf tab colouring to address focus / selected visibility issues. new 99af5936a5 Merge pull request #4286 from neilcsmith-net/flatlaf-colours d6dcd69e07 is described below commit d6dcd69e07206d76d9f8f452a7ec5b02e2f89d0a Author: Neil C Smith <neilcsm...@apache.org> AuthorDate: Mon Jun 27 13:22:01 2022 +0100 Alter FlatLaf tab colouring to address focus / selected visibility issues. Improve colour contrast between tabs and background. Move accent colour (underline) to top of tabs and extend border up tab sides. Make view tabs active / selected behaviour same as editor tabs. Don't paint view tab separators around selected tab when different selected background colour set. --- .../swing/laf/flatlaf/FlatDarkLaf.properties | 42 +++++++++++----------- .../netbeans/swing/laf/flatlaf/FlatLFCustoms.java | 2 +- .../netbeans/swing/laf/flatlaf/FlatLaf.properties | 6 ++-- .../swing/laf/flatlaf/FlatLightLaf.properties | 36 +++++++++---------- .../laf/flatlaf/ui/FlatEditorTabCellRenderer.java | 17 ++++++--- .../laf/flatlaf/ui/FlatEditorTabDisplayerUI.java | 8 +++-- .../laf/flatlaf/ui/FlatViewTabDisplayerUI.java | 13 +++++-- 7 files changed, 72 insertions(+), 52 deletions(-) diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatDarkLaf.properties b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatDarkLaf.properties index 918f5209f0..42d2af0991 100644 --- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatDarkLaf.properties +++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatDarkLaf.properties @@ -25,40 +25,40 @@ nb.warningForeground=@foreground #---- EditorView ---- -Nb.EmptyEditorArea.background=darken(@background,5%) +Nb.EmptyEditorArea.background=darken(@background,8%) #---- EditorTab ---- -EditorTab.background=@background -#EditorTab.foreground=#f00 -EditorTab.activeBackground=#3B4754 -#EditorTab.activeForeground=#f00 -EditorTab.selectedBackground=#5c6164 -EditorTab.selectedForeground=lighten(@foreground,10%) -EditorTab.hoverBackground=$TabbedPane.hoverColor -#EditorTab.hoverForeground=#f00 +EditorTab.background=$Nb.EmptyEditorArea.background +EditorTab.foreground=darken(@foreground,10%) +EditorTab.activeBackground=shade($TabbedPane.underlineColor,75%) +EditorTab.activeForeground=darken(@foreground,10%) +EditorTab.selectedBackground=@background +EditorTab.selectedForeground=@foreground +EditorTab.hoverBackground=lighten(@componentBackground,5%) +EditorTab.hoverForeground=@foreground EditorTab.attentionBackground=#E6C840 EditorTab.attentionForeground=#000 EditorTab.underlineColor=$TabbedPane.underlineColor -EditorTab.inactiveUnderlineColor=lighten($TabbedPane.disabledUnderlineColor,5%) - +EditorTab.inactiveUnderlineColor=darken(@foreground,40%) +EditorTab.tabSeparatorColor=darken($Component.borderColor,15%) #---- ViewTab ---- -ViewTab.background=@background -#ViewTab.foreground=#f00 -ViewTab.activeBackground=#3B4754 -#ViewTab.activeForeground=#f00 -#ViewTab.selectedBackground=#f00 -#ViewTab.selectedForeground=#0f0 -ViewTab.hoverBackground=$TabbedPane.hoverColor -#ViewTab.hoverForeground=#f00 +ViewTab.background=$EditorTab.background +ViewTab.foreground=$EditorTab.foreground +ViewTab.activeBackground=$EditorTab.activeBackground +ViewTab.activeForeground=$EditorTab.activeForeground +ViewTab.selectedBackground=$EditorTab.selectedBackground +ViewTab.selectedForeground=$EditorTab.selectedForeground +ViewTab.hoverBackground=$EditorTab.hoverBackground +ViewTab.hoverForeground=$EditorTab.hoverForeground ViewTab.attentionBackground=$EditorTab.attentionBackground ViewTab.attentionForeground=$EditorTab.attentionForeground -ViewTab.underlineColor=$TabbedPane.underlineColor +ViewTab.underlineColor=$EditorTab.underlineColor ViewTab.inactiveUnderlineColor=$EditorTab.inactiveUnderlineColor - +ViewTab.tabSeparatorColor=$EditorTab.tabSeparatorColor #---- SlidingButton ---- diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java index 7a31f97062..ab8ca653d3 100644 --- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java +++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java @@ -73,7 +73,7 @@ public class FlatLFCustoms extends LFCustoms { VIEW_TAB_DISPLAYER_UI, "org.netbeans.swing.laf.flatlaf.ui.FlatViewTabDisplayerUI", // NOI18N SLIDING_BUTTON_UI, "org.netbeans.swing.laf.flatlaf.ui.FlatSlidingButtonUI", // NOI18N - EDITOR_TABSCOMPONENT_BORDER, DPISafeBorder.matte(1, 1, 1, 1, editorContentBorderColor), + EDITOR_TABSCOMPONENT_BORDER, DPISafeBorder.matte(0, 1, 1, 1, editorContentBorderColor), EDITOR_TOOLBAR_BORDER, DPISafeBorder.matte(0, 0, 1, 0, editorContentBorderColor), EDITOR_TAB_CONTENT_BORDER, DPISafeBorder.matte(0, 1, 1, 1, editorContentBorderColor), VIEW_TAB_CONTENT_BORDER, DPISafeBorder.matte(0, 1, 1, 1, UIManager.getColor("TabbedContainer.view.contentBorderColor")), // NOI18N diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties index 4d1dbb762b..362ba95368 100644 --- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties +++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLaf.properties @@ -39,20 +39,18 @@ TabbedContainer.view.contentBorderColor=$Component.borderColor EditorTab.tabInsets=5,6,7,8 EditorTab.underlineHeight=3 -#EditorTab.underlineAtTop=true +EditorTab.underlineAtTop=true EditorTab.tabSeparatorColor=$Component.borderColor EditorTab.showTabSeparators=true - #---- ViewTab ---- ViewTab.tabInsets=5,6,7,2 ViewTab.underlineHeight=3 -#ViewTab.underlineAtTop=true +ViewTab.underlineAtTop=true ViewTab.tabSeparatorColor=$Component.borderColor ViewTab.showTabSeparators=true - #---- Multi-tabs ---- nb.multitabs.tabInsets=5,2,7,2 diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLightLaf.properties b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLightLaf.properties index 1717aef692..51a7791da4 100644 --- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLightLaf.properties +++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLightLaf.properties @@ -19,38 +19,38 @@ nb.preferred.color.profile=FlatLaf Light #---- EditorView ---- -Nb.EmptyEditorArea.background=darken(@background,10%) +Nb.EmptyEditorArea.background=darken(@background,12%) #---- EditorTab ---- -EditorTab.background=@background -#EditorTab.foreground=#f00 -EditorTab.activeBackground=#E2E6EC -#EditorTab.activeForeground=#f00 -EditorTab.selectedBackground=#FFF +EditorTab.background=$Nb.EmptyEditorArea.background +EditorTab.foreground=lighten(@foreground,25%) +EditorTab.activeBackground=mix($EditorTab.background, $TabbedPane.underlineColor, 85%) +EditorTab.activeForeground=lighten(@foreground,25%) +EditorTab.selectedBackground=@background EditorTab.selectedForeground=@foreground -EditorTab.hoverBackground=$TabbedPane.hoverColor -#EditorTab.hoverForeground=#f00 +EditorTab.hoverBackground=@componentBackground +EditorTab.hoverForeground=@foreground EditorTab.attentionBackground=#E6C840 EditorTab.attentionForeground=#000 EditorTab.underlineColor=$TabbedPane.underlineColor -EditorTab.inactiveUnderlineColor=#9CA7B8 +EditorTab.inactiveUnderlineColor=lighten(@foreground,60%) #---- ViewTab ---- -ViewTab.background=@background -#ViewTab.foreground=#f00 -ViewTab.activeBackground=#E2E6EC -#ViewTab.activeForeground=#f00 -#ViewTab.selectedBackground=#f00 -#ViewTab.selectedForeground=#0f0 -ViewTab.hoverBackground=$TabbedPane.hoverColor -#ViewTab.hoverForeground=#f00 +ViewTab.background=$EditorTab.background +ViewTab.foreground=$EditorTab.foreground +ViewTab.activeBackground=$EditorTab.activeBackground +ViewTab.activeForeground=$EditorTab.activeForeground +ViewTab.selectedBackground=$EditorTab.selectedBackground +ViewTab.selectedForeground=$EditorTab.selectedForeground +ViewTab.hoverBackground=$EditorTab.hoverBackground +ViewTab.hoverForeground=$EditorTab.hoverForeground ViewTab.attentionBackground=$EditorTab.attentionBackground ViewTab.attentionForeground=$EditorTab.attentionForeground -ViewTab.underlineColor=$TabbedPane.underlineColor +ViewTab.underlineColor=$EditorTab.underlineColor ViewTab.inactiveUnderlineColor=$EditorTab.inactiveUnderlineColor diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatEditorTabCellRenderer.java b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatEditorTabCellRenderer.java index 49882f6326..3676ab1d24 100644 --- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatEditorTabCellRenderer.java +++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatEditorTabCellRenderer.java @@ -68,6 +68,8 @@ public class FlatEditorTabCellRenderer extends AbstractTabCellRenderer { private static final FlatTabPainter painter = new FlatTabPainter(); + boolean firstTab; + boolean lastTab; boolean nextTabSelected; public FlatEditorTabCellRenderer() { @@ -207,7 +209,8 @@ public class FlatEditorTabCellRenderer extends AbstractTabCellRenderer { background, activeBackground, selectedBackground, hoverBackground, attentionBackground); - boolean showSeparator = showTabSeparators && !selected && !ren.nextTabSelected; + boolean showSeparator = showTabSeparators && !selected && !ren.nextTabSelected + && !ren.lastTab; // do not round tab separator width to get nice small lines at 125%, 150% and 175% int tabSeparatorWidth = showSeparator ? (int) (1 * scale) : 0; @@ -219,11 +222,17 @@ public class FlatEditorTabCellRenderer extends AbstractTabCellRenderer { if (selected && underlineHeight > 0) { // paint underline if tab is selected int underlineHeight = (int) Math.round(FlatEditorTabCellRenderer.underlineHeight * scale); - g.setColor(ren.isActive() ? underlineColor : inactiveUnderlineColor); - if (underlineAtTop) + if (underlineAtTop) { + g.setColor(contentBorderColor); + int borderWidth = (int) (1 * scale); + g.fillRect(0, 0, borderWidth, height); + g.fillRect(width - tabSeparatorWidth - borderWidth, 0, borderWidth, height); + g.setColor(ren.isActive() ? underlineColor : inactiveUnderlineColor); g.fillRect(0, 0, width - tabSeparatorWidth, underlineHeight); - else + } else { + g.setColor(ren.isActive() ? underlineColor : inactiveUnderlineColor); g.fillRect(0, height - underlineHeight, width - tabSeparatorWidth, underlineHeight); + } } else { // paint bottom border int contentBorderWidth = HiDPIUtils.deviceBorderWidth(scale, 1); diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatEditorTabDisplayerUI.java b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatEditorTabDisplayerUI.java index c20c68b188..d4219aea5b 100644 --- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatEditorTabDisplayerUI.java +++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatEditorTabDisplayerUI.java @@ -80,8 +80,12 @@ public class FlatEditorTabDisplayerUI extends BasicScrollingTabDisplayerUI { @Override public TabCellRenderer getTabCellRenderer(int tab) { TabCellRenderer ren = super.getTabCellRenderer(tab); - if (ren instanceof FlatEditorTabCellRenderer && tab + 1 < displayer.getModel().size()) { - ((FlatEditorTabCellRenderer)ren).nextTabSelected = (tabState.getState(tab + 1) & TabState.SELECTED) != 0; + if (ren instanceof FlatEditorTabCellRenderer) { + FlatEditorTabCellRenderer fren = (FlatEditorTabCellRenderer) ren; + int N = displayer.getModel().size(); + fren.firstTab = (tab == 0); + fren.lastTab = (tab == N - 1); + fren.nextTabSelected = tab + 1 < N && (tabState.getState(tab + 1) & TabState.SELECTED) != 0; } return ren; } diff --git a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatViewTabDisplayerUI.java b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatViewTabDisplayerUI.java index d3409262c8..a24a5ad552 100644 --- a/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatViewTabDisplayerUI.java +++ b/platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/ui/FlatViewTabDisplayerUI.java @@ -221,8 +221,14 @@ public class FlatViewTabDisplayerUI extends AbstractViewTabDisplayerUI { int underlineHeight = (int) Math.round(this.underlineHeight * scale); g.setColor(isActive() ? underlineColor : inactiveUnderlineColor); if (underlineAtTop) { + g.setColor(contentBorderColor); + int borderWidth = (int) (1 * scale); + g.fillRect(0, 0, borderWidth, height); + g.fillRect(width - tabSeparatorWidth - borderWidth, 0, borderWidth, height); + g.setColor(isActive() ? underlineColor : inactiveUnderlineColor); g.fillRect(0, 0, width - tabSeparatorWidth, underlineHeight); } else { + g.setColor(isActive() ? underlineColor : inactiveUnderlineColor); g.fillRect(0, height - underlineHeight, width - tabSeparatorWidth, underlineHeight); } } else { @@ -232,7 +238,9 @@ public class FlatViewTabDisplayerUI extends AbstractViewTabDisplayerUI { g.fillRect(0, height - contentBorderWidth, width, contentBorderWidth); } - if (showTabSeparators && index >= 0) { + if (showTabSeparators && index >= 0 && + ((!isSelected(index) && index < getDataModel().size() - 1 && !isSelected(index + 1)) + || selectedBackground.equals(activeBackground))) { int offset = (int) (4 * scale); g.setColor(tabSeparatorColor); g.fillRect(width - tabSeparatorWidth, offset, tabSeparatorWidth, height - (offset * 2) - 1); @@ -251,7 +259,8 @@ public class FlatViewTabDisplayerUI extends AbstractViewTabDisplayerUI { private Color colorForState(int index, Color normal, Color active, Color selected, Color hover, Color attention) { return isAttention(index) ? attention : isMouseOver(index) ? hover - : isActive() ? (isSelected(index) ? selected : active) + : isSelected(index) ? selected + : isActive() ? active : normal; } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org For additional commands, e-mail: commits-h...@netbeans.apache.org For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists